Hey ich habe ein programm geschrieben um Texturen zu laden (also nix besinderes) nun habe ich das problem das die textur die ich ausgewählt habe nicht angezeigt wird(irgendwie ironisch
) jedenfals hab ich nix im internet gefunden und wollte deshalb euch fragen .
ich bedanke mich für alle Antworten im voraus
.
|
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include "SDL.h"
#include <stdio.h>
bool init();
bool loadMedia();
void close();
SDL_Window* window = NULL;
SDL_Surface* screen = NULL;
SDL_Surface* loadingPicture = NULL;
bool init()
{
bool success = true;
//initialisiert SDl
if (SDL_Init (SDL_INIT_VIDEO) < 0)
{
printf("SDL konnte nicht initialisiert werden ! SDL_Error: %s\n", SDL_GetError());
success = false;
}
else
{
//create Window
window = SDL_CreateWindow("A Resume Game : Astroman", 300,300,400,700,SDL_WINDOW_SHOWN);
if (window = NULL)
{
printf("Fenster konnte nicht erstellt werden ! SDL_Error: s%\n", SDL_GetError());
success = false;
}
else
{
//Get Window Surface
screen = SDL_GetWindowSurface ( window );
}
}
return success;
}
bool loadMedia()
{
bool success = true;
loadingPicture = SDL_LoadBMP("02_getting_an_image_on_the_screen/Back.bmp");
if (loadingPicture = NULL)
{
printf("Textur konnte nicht geladen werden %s! SDL_Error: %s\n","02_getting_an_image_on_the_screen/Back.bmp",SDL_GetError());
success = false;
}
return success;
}
void close()
{
//close screen
SDL_FreeSurface( loadingPicture );
loadingPicture = NULL;
//Destroys window
SDL_DestroyWindow( window );
window = NULL;
// Quit SDl
SDL_Quit();
}
int main(int argc, char* args[]) {
if(!init())
{
printf("Initialisierung fehlgeschlagen !\n");
}
else
{
if(!loadMedia())
{
printf("Laden der Textur gescheitert\n");
}
else
{
//Textur Öffnen
SDL_BlitSurface ( loadingPicture, NULL, screen, NULL);
SDL_UpdateWindowSurface( window );
SDL_Delay (60000); // Zeitspanne des geöffneteten Fensters
}
}
close();
return 0;
}
|