Hallo zusammen,
In den letzten Wochen habe ich mit der Programmierung von grafischen Oberflächen mittels SDL beschäftigt. Das ganze hat nun soweit auch ganz gut geklappt nur bräuchte ich nun Text. Daher habe ich die Bibliothek SDL_ttf heruntergeladen und folgendermasen installiert:
Header-File SDL_ttf.h in .../.../CodeBlocks/SDL/include kopiert
SDL_ttf.lib in .../.../CodeBlocks/SDL/lib kopiert
Die DLL's (x86/32Bit) habe ich in C:/Windows/system32 sowie in C/Windows/SysWOW64 kopiert (sicher is sicher ;-) )
Danach habe ich dann in Code::Blocks unter Setting->Compiler and Debugger -> Linker Settings bei Lnkk librarys die SDL_ttf.lib gesucht und angegeben.
Den Sourcecode habe ich aus einem Tutorial übernommen(
http://www.aaroncox.net/tutorials/2dtutorials/sdltext.html), habe jedoch auch andere ausprobiert.
Das Problem ist nun, dass jedes mal wenn ich den Compiler starte das Fenster erscheint und dann rechts unten (im Windows da wo die Uhr is) ein kleines gelbes Fenster erchein in welchem steht:
"SIGNAL RESIVED
rogram resived signal SIGSEGV, Signal fault"
Das Programm läuft daraufhin zwar weiter aber das gesamte Fenster bleibt schwarz.
Ein kleiner gelber Pfeil zeigt auf folgende Zeile:
|
C-/C++-Quelltext
|
1
|
SDL_Surface* textSurface = TTF_RenderText_Shaded(font, "This is my text.",foregroundColor, backgroundColor);
|
Der Debugger gibt folgendes aus:
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: D:\Programmieren\projekte\SDL_TTF3\
Adding source dir: D:\Programmieren\projekte\SDL_TTF3\
Adding file: bin\Debug\SDL_TTF3.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Child process PID: 6892
Program received signal SIGSEGV, Segmentation fault.
In TTF_SizeUNICODE () (C:\Windows\SysWOW64\SDL_ttf.dll)
At D:\Programmieren\projekte\SDL_TTF3\main.cpp:22
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
72
73
74
75
76
77
78
79
80
81
|
#include
#include
const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char* WINDOW_TITLE = "SDL Start";
int main(int argc, char **argv)
{
SDL_Init( SDL_INIT_VIDEO );
TTF_Init();
SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0,SDL_HWSURFACE | SDL_DOUBLEBUF );
SDL_WM_SetCaption( WINDOW_TITLE, 0 );
TTF_Font* font = TTF_OpenFont("ARIAL.TTF", 12);
SDL_Color foregroundColor = { 255, 255, 255 };
SDL_Color backgroundColor = { 0, 0, 255 };
SDL_Surface* textSurface = TTF_RenderText_Shaded(font, "This is my text.",foregroundColor, backgroundColor); // Pass zero for width and height to draw the whole surface
SDL_Rect textLocation = { 100, 100, 0, 0 };
SDL_Event event;
bool gameRunning = true;
while (gameRunning)
{
if (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
gameRunning = false;
}
}
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
SDL_BlitSurface(textSurface, NULL, screen, &textLocation);
SDL_Flip(screen);
}
SDL_FreeSurface(textSurface);
TTF_CloseFont(font);
TTF_Quit();
SDL_Quit();
return 0;
}
|
Ich hoffe irgendjemand hat mir eine Idee bin schon am verzweifeln!!
MfG Pat711
Edit: noch einige Ergänzungen:
Code::Blocks 10.05
Windows 7 x64