Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

The Flow

Frischling

  • »The Flow« ist der Autor dieses Themas

Beiträge: 31

Beruf: Student

  • Private Nachricht senden

11

07.10.2013, 13:41

Auch wenn ich das SDL_FreeSurface (display) hinter die while scleife schreibe kommt die fehlermeldung ?? ?(
if apple made a car would it have windows ?(

BlueCobold

Community-Fossil

Beiträge: 10 738

Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer

  • Private Nachricht senden

12

07.10.2013, 13:43

Den vierten Parameter hast du auf seine Gültigkeit (NULL) geprüft?
Teamleiter von Rickety Racquet (ehemals das "Foren-Projekt") und von Marble Theory

Willkommen auf SPPRO, auch dir wird man zu Unity oder zur Unreal-Engine raten, ganz bestimmt.[/Sarkasmus]

Architekt

Community-Fossil

Beiträge: 2 481

Wohnort: Hamburg

Beruf: Student

  • Private Nachricht senden

13

07.10.2013, 13:48

Am besten du machst mal was Blue sagt und legst zwei SDL_Rects mit irgendwelchen Größen an, um zu schauen, ob es tatsächlich daran liegt. Es würde mich zwar stark wundern aber wer weiß, die SDL 1.2er Version ist ja auch schon was älter. :)
Ansonsten prüf auch mal display auf Gültigkeit, sprich, dass es nicht NULL ist.
Der einfachste Weg eine Kopie zu entfernen ist sie zu löschen.
- Stephan Schmidt -

The Flow

Frischling

  • »The Flow« ist der Autor dieses Themas

Beiträge: 31

Beruf: Student

  • Private Nachricht senden

14

07.10.2013, 13:50

Auch wenn ich da ein Rect einbau "SDL_BlitSurface (text, NULL, display, &Rect);" bei Rect gleich
x = 20
y = 20
h = 600
w = 600

kommt immer noch die fehler meldung :cursing:
if apple made a car would it have windows ?(

The Flow

Frischling

  • »The Flow« ist der Autor dieses Themas

Beiträge: 31

Beruf: Student

  • Private Nachricht senden

15

07.10.2013, 14:14

display ist auch nicht NULL
und wenn ich bei beiden ein rect einfüge ist da immer noch der gleiche Fehler ;(
if apple made a car would it have windows ?(

Architekt

Community-Fossil

Beiträge: 2 481

Wohnort: Hamburg

Beruf: Student

  • Private Nachricht senden

16

07.10.2013, 14:26

Höchst seltsam. Zeig mal deinen aktuellen Stand.
Der einfachste Weg eine Kopie zu entfernen ist sie zu löschen.
- Stephan Schmidt -

The Flow

Frischling

  • »The Flow« ist der Autor dieses Themas

Beiträge: 31

Beruf: Student

  • Private Nachricht senden

17

07.10.2013, 15:03

#include <iostream>
#include <SDL.h>
#include <SDL_ttf.h>

using std::cerr;
using std::endl;

int main(int argc, char* args[])
{
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
cerr << "SDL_Init() Failed: " <<
SDL_GetError() << endl;
system ("pause");
exit(1);
}

SDL_Surface* display;
display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);

if (display == NULL)
{
cerr << "SDL_SetVideoMode() Failed: " <<
SDL_GetError() << endl;
system ("pause");
exit(1);
}

SDL_WM_SetCaption("SDL Tutorial", "SDL Tutorial");

if (TTF_Init() != 0)
{
cerr << "TTF_Init() Failed: " << TTF_GetError() << endl;
SDL_Quit();
system ("pause");
exit(1);
}

TTF_Font *font;
font = TTF_OpenFont("Data/arial.ttf", 24);
if (font == NULL)
{
cerr << "TTF_OpenFont() Failed: " << TTF_GetError() << endl;
TTF_Quit();
SDL_Quit();
system ("pause");
exit(1);
}

SDL_Rect Rect;
Rect.x = 20;
Rect.y = 20;
Rect.h = 600;
Rect.w = 600;

SDL_Rect eRect;
Rect.x = 20;
Rect.y = 20;
Rect.h = 600;
Rect.w = 600;

SDL_Surface *text;
SDL_Color text_color = {255, 255, 255};
text = TTF_RenderText_Solid(font,
"A journey of a thousand miles begins with a single step.",
text_color);

if (text == NULL)
{
cerr << "TTF_RenderText_Solid() Failed: " << TTF_GetError() << endl;
TTF_Quit();
SDL_Quit();
system ("pause");
exit(1);
}

while(1)
{
SDL_Event event;
if (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
break;
}
}

if (display == NULL)
{
cerr << "fehler in der matrix :D" << endl;
system ("pause");
}

if (SDL_BlitSurface(text, &eRect, display, &Rect) != 0)
{

cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl; //Diese Fehlermeldung wird immer ausgegeben
system ("pause");
break;

}

SDL_Flip(display);


}

SDL_FreeSurface (display);
TTF_Quit();

SDL_Quit();

return 0;
}
if apple made a car would it have windows ?(

The Flow

Frischling

  • »The Flow« ist der Autor dieses Themas

Beiträge: 31

Beruf: Student

  • Private Nachricht senden

18

07.10.2013, 15:54

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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <iostream>
#include <SDL.h>
#include <SDL_ttf.h>

using std::cerr;
using std::endl;

int DrawText(SDL_Surface* screen, TTF_Font* font, const char* text)
{
    if (screen == NULL)
    {
        cerr << "screen gleich NULL" << endl; 
    }

    SDL_Color color = {0,0,0};
    SDL_Surface *text_surface;

    text_surface = TTF_RenderText_Solid(font, text, color);
    if (text_surface != NULL)
    {
        SDL_BlitSurface(text_surface, NULL, screen, NULL);
        SDL_FreeSurface(text_surface);                          // An diesem Punkt bricht das Programm ab
        return 1;
    }
    else
    {
        // report error
        return 0;
    }
}

int main(int argc, char* args[])
{
   if (SDL_Init(SDL_INIT_VIDEO) != 0)
   {
      cerr << "SDL_Init() Failed: " <<
      SDL_GetError() << endl;
      system ("pause");
      exit(1);
   }

   SDL_Surface* display;
   display = SDL_SetVideoMode(800, 800, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);

   if (display == NULL)
   {
      cerr << "SDL_SetVideoMode() Failed: " <<        
      SDL_GetError() << endl;
      system ("pause");
      exit(1);
   }

   SDL_WM_SetCaption("SDL Tutorial", "SDL Tutorial");

   if (TTF_Init() != 0)
   {
      cerr << "TTF_Init() Failed: " << TTF_GetError() << endl;
      SDL_Quit();
      system ("pause");
      exit(1);
   }

   TTF_Font *font;
   font = TTF_OpenFont("Data/arial.ttf", 24);
   if (font == NULL)
   {
      cerr << "TTF_OpenFont() Failed: " << TTF_GetError() << endl;
      TTF_Quit();
      SDL_Quit();
      system ("pause");
      exit(1);
   }

   SDL_Rect Rect;
   Rect.x = 20;
   Rect.y = 20;
   Rect.h = 600;
   Rect.w = 600;

    SDL_Rect eRect;
   Rect.x = 20;
   Rect.y = 20;
   Rect.h = 600;
   Rect.w = 600;

   SDL_Surface *text = NULL;
   SDL_Color text_color = {255, 255, 255};

   if (text != NULL)
   {
      cerr << "TTF_RenderText_Solid() Failed: " << TTF_GetError() << endl;
      TTF_Quit();
      SDL_Quit();
      system ("pause");
      exit(1);
   }

   int a;

   while(1)
   {
       SDL_Event event;
      if (SDL_PollEvent(&event))
      {
         if (event.type == SDL_QUIT)
         {
            break;
         }
      }
      
      if (SDL_FillRect(display, 
                       NULL,
                       SDL_MapRGB( display->format, 255,0,255))
                       != 0)
      {
         cerr << "SDL_FillRect() Failed: " << SDL_GetError() << endl;
         system ("pause");
         break;
      }

      if (display == NULL)
      {
          cerr << "fehler in der matrix :D" << endl;
          system ("pause");
      }

      a = DrawText (display, font, "Ausgabe");

      if (a==0)
      {
          cerr << "fehler" << endl;
      }

      SDL_Flip(display);
     

   }

   SDL_FreeSurface (display);
   TTF_Quit();

   SDL_Quit();
    
   return 0;    
}
if apple made a car would it have windows ?(

The Flow

Frischling

  • »The Flow« ist der Autor dieses Themas

Beiträge: 31

Beruf: Student

  • Private Nachricht senden

19

07.10.2013, 15:55

bei dieser möglichkeit schmiert das programm immer bei SDL_FreeSurface (text_surface) ab :dash:
if apple made a car would it have windows ?(

Architekt

Community-Fossil

Beiträge: 2 481

Wohnort: Hamburg

Beruf: Student

  • Private Nachricht senden

20

07.10.2013, 16:09

Und was gibt SDL_GetError?
Sieht mir irgendwie so aus, als hättest du veraltete .dlls mit denen du arbeitest und die mit deiner derzeitigen SDL Version inkompatibel sind. Woher hast du sie?
Der einfachste Weg eine Kopie zu entfernen ist sie zu löschen.
- Stephan Schmidt -

Werbeanzeige