OVH Cloud OVH Cloud

c++ avec mingw probleme avec sdl

1 réponse
Avatar
giovanni
j'arrive pas a faire tourer un programme que voici

#include "Tunnel.h"

// SDL Stuff
SDL_Surface *screen;
SDL_Surface *bBuffer;
SDL_Surface *Image;
SDL_Rect rScreen;
SDL_Rect rBuffer;

#ifdef WIN32
// Timer maison... cuz GetTickCount ca SUXX !
:) ----------------------------------
static __int64 timerstart;
static __int64 timerfrq;

static void Tunnel_Timer() {
QueryPerformanceCounter((LARGE_INTEGER *)&timerstart);
QueryPerformanceFrequency((LARGE_INTEGER *)&timerfrq);
}

static double Tunnel_GetTime() {
__int64 a;
QueryPerformanceCounter((LARGE_INTEGER *)&a);

return (double)(a - timerstart)/(double)(timerfrq);
}
#else

void Tunnel_Timer(){}
double Tunnel_GetTime()
{
return SDL_GetTicks()*1.0/1000;
}

#endif
// ---------------------------------------------------------------------------------

int main (int argc, char **argv)
{

// on init SDL
int flag = SDL_SWSURFACE;
#ifdef WIN32
int fullscreen = MessageBox(NULL, "Un jolie tunnel en plein ecran ? :)",
"Screen Setting", MB_YESNO);

if (fullscreen==IDYES)
{
flag |= SDL_FULLSCREEN;
}
#endif

// Init du Timer
Tunnel_Timer();

SDL_Init( SDL_INIT_VIDEO );

// on set la resolution
screen = SDL_SetVideoMode( 320, 240, 32, flag);

bBuffer = SDL_CreateRGBSurface( SDL_HWSURFACE, screen->w,
screen->h,
screen->format->BitsPerPixel,
screen->format->Rmask,
screen->format->Gmask,
screen->format->Bmask,
screen->format->Amask);
Image = SDL_LoadBMP( "tunnel_map.bmp" );

if (!bBuffer || !Image)
{
printf("Error: I can't load or create bmp !!!\n\n");
return -1;
}

Image = SDL_ConvertSurface(Image, screen->format, SDL_HWSURFACE);

rBuffer.x = 0;
rBuffer.y = 0;
rBuffer.w = bBuffer->w;
rBuffer.h = bBuffer->h;

SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);

SDL_ShowCursor( SDL_DISABLE );

Tunnel.Set( 320, 240 ); // Dimension du tunnel
Tunnel.Precalc( 16 ); // Diametre du tunnel

while (SDL_PollEvent(NULL)==0)
{
float fTime = Tunnel_GetTime();

SDL_LockSurface(bBuffer);
SDL_LockSurface(Image);

// et on le dessine normalement !
// Tunnel.Draw(bBuffer, Image, fTime*100, fTime*100);

// ou un peu plus delire
Tunnel.Draw(bBuffer, Image, 180*sin(fTime), fTime*100);

SDL_UnlockSurface(bBuffer);
SDL_UnlockSurface(Image);

SDL_BlitSurface( bBuffer, NULL, screen, &rBuffer );
SDL_UpdateRect( screen, 0, 0, 0, 0 );

}

Tunnel.Free();

return 0;
}


compile me fais 0 error et 2 warning que voici

--------------------Configuration: test - Debug--------------------
Compiling...
main.cpp
..\Documents and Settings\paolo\Bureau\parallax-4\2d_tunnel\main.cpp: In
function `int SDL_main(int, char**)':
..\Documents and Settings\paolo\Bureau\parallax-4\2d_tunnel\main.cpp:100:
warning: passing `double' for converting 3 of `void
CTunnel::Draw(SDL_Surface*, SDL_Surface*, int, int)'
..\Documents and Settings\paolo\Bureau\parallax-4\2d_tunnel\main.cpp:100:
warning: passing `float' for converting 4 of `void
CTunnel::Draw(SDL_Surface*, SDL_Surface*, int, int)'

main.o - 0 error(s), 2 warning(s)
et en build et execute me fais ca

Deleting intermediate files and output files for project 'test - Debug'
--------------------Configuration: test - Debug--------------------
Compiling source file(s)...
main.cpp
..\Documents and Settings\paolo\Bureau\parallax-4\2d_tunnel\main.cpp: In
function `int SDL_main(int, char**)':
..\Documents and Settings\paolo\Bureau\parallax-4\2d_tunnel\main.cpp:100:
warning: passing `double' for converting 3 of `void
CTunnel::Draw(SDL_Surface*, SDL_Surface*, int, int)'
..\Documents and Settings\paolo\Bureau\parallax-4\2d_tunnel\main.cpp:100:
warning: passing `float' for converting 4 of `void
CTunnel::Draw(SDL_Surface*, SDL_Surface*, int, int)'
Linking...
g++.exe: C:\test\Debug\main.o: No such file or directory
g++.exe: no input files

test.exe - 2 error(s), 2 warning(s) cest un prog deja qui marche vous pouvez
le chargez ici

http://www.ouhlavache.com/stv/tunnel2d.tar.bz2

j'ai installer dans include cree un repertoire avec la library sdl....

1 réponse

Avatar
Arnaud Meurgues
giovanni wrote:
j'arrive pas a faire tourer un programme que voici



// ou un peu plus delire
Tunnel.Draw(bBuffer, Image, 180*sin(fTime), fTime*100);

--------------------Configuration: test - Debug--------------------
Compiling...
main.cpp
..Documents and SettingspaoloBureauparallax-42d_tunnelmain.cpp: In
function `int SDL_main(int, char**)':
..Documents and SettingspaoloBureauparallax-42d_tunnelmain.cpp:100:
warning: passing `double' for converting 3 of `void
CTunnel::Draw(SDL_Surface*, SDL_Surface*, int, int)'
..Documents and SettingspaoloBureauparallax-42d_tunnelmain.cpp:100:
warning: passing `float' for converting 4 of `void
CTunnel::Draw(SDL_Surface*, SDL_Surface*, int, int)'

main.o - 0 error(s), 2 warning(s)


vous passez des flottants (180*sin(fTime) et fTime*100) là où un int est
attendu. C'est ce que dit le warning.

et en build et execute me fais ca

Deleting intermediate files and output files for project 'test - Debug'
--------------------Configuration: test - Debug--------------------
[...]

Linking...
g++.exe: C:testDebugmain.o: No such file or directory
g++.exe: no input files


Là, c'est un problème de chemin, certainement. Il ne trouve pas main.o,
ce qui doit vouloir dire qu'il ne sait pas où le chercher.

--
Arnaud