Hi, ich bin grad dabei ein Bild in ein Fenster zu laden das problem ist ich bekomme es in das Fenster geladen aber es wird nicht angezeigt. Nun habe ich paar tutorial gefunden
diese benutzen aber die funktion SDL_Flip() abe diese ist von einer älteren version von SDL und ich kann sie daher nicht benutzen .
Also würde ich gerne fragen ob es eine neuere funktion gibt um Bilder sichtbar zu machen da ich nix im internet gefunden habe.
Ich bedanke mich für alle antworten im voraus
.
Der Code :
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include <SDL.h>
#include <stdio.h>
const int SCREEN_WIDTH = 640; // Window Parameter X
const int SCREEN_HEIGHT = 480; // Window Parameter Y
//_______________________________________________________________________________________________________
int main ( int argc, char* args[] )
{
SDL_Window* window = NULL; // The Window rendering
SDL_Surface* screensurface = NULL; // The screen in the Window
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf("SDL coiuld not be initialize! SDL_Error: %s\n", SDL_GetError() );
}
else
{
window = SDL_CreateWindow("A Resume Game : Astroman",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
if (window == NULL)
{
printf("Window could not be created ! SDL_Error: %s\n",SDL_GetError() );
}
else
{
screensurface = SDL_GetWindowSurface( window ); // Get Window Surface
SDL_FillRect(screensurface, NULL, SDL_MapRGB(screensurface->format, 0xB30, 0xB30, 0xB30)); // Background interface
SDL_UpdateWindowSurface( window );
}
}
SDL_Surface *image = SDL_LoadBMP("tux.bmp");
SDL_Event event;
int quit = 0;
while(!quit)
{
while(SDL_PollEvent(&event))
{
if(event.type == SDL_QUIT)
{
quit = 1;
}
if(event.type == SDL_MOUSEBUTTONDOWN)
{
if(event.button.button ==SDL_BUTTON_LEFT)
printf("Window was clicked%s\n");
}
}
}
SDL_BlitSurface(image , NULL, screensurface, NULL);
//Destroy window
SDL_Flip(screensurface); // SDL_Flip wird nicht erkannt
SDL_DestroyWindow( window );
// Quit SDL subsystems
SDL_Quit();
return 0;
}
|