- [... Variablendefintion, etc. ...]
- if SDL_Init(SDL_INIT_VIDEO) <> 0 then
- begin
- raise Exception.Create('Could not initialize SDL Video Mode!');
- Finalize; // In der Finalize; steckt das ganze drin wie SDL_FreeSurface(FSDLSurface); SDL_Quit; Halt(0);
- end;
- VideoInfo := SDL_GetVideoInfo;
- if VideoInfo = nil then
- begin
- raise Exception.Create('Could not collect system info. Application terminated.');
- Finalize;
- end;
- Flags := SDL_OPENGL or SDL_DOUBLEBUF or SDL_HWPALETTE;
- if VideoInfo.hw_available <> 0 then Flags := Flags or SDL_HWSURFACE
- else Flags := Flags or SDL_SWSURFACE;
- if VideoInfo.blit_hw <> 0 then Flags := Flags or SDL_HWACCEL;
- if Fullscreen then Flags := Flags or SDL_FULLSCREEN;
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_WM_SetCaption(ApplicationTitle, ApplicationIcon);
- FSDLSurface := SDL_SetVideoMode(Width, Height, ColorBits, Flags);
- if not Assigned(FSDLSurface) then
- begin
- raise Exception.Create('Could not initialize SDL!');
- Finalize;
- end;
- if not InitOpenGL then InitOpenGL;
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_ALWAYS);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- while not Done do
- begin
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity;
- glViewport(0, 0, FWidth, FHeight);
- glOrtho(0, FWidth, FHeight, 0, 0, 128);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity;
- glTranslatef(0, 0, 0);
- glColor3f(0.2, 0.2, 0.6);
- glcolor3f(0,1,0);
- glBegin( GL_QUADS );
- glVertex3f( -1.0, 1.0, 0.0 );
- glVertex3f( 1.0, 1.0, 0.0 );
- glVertex3f( 1.0, -1.0, 0.0 );
- glVertex3f( -1.0, -1.0, 0.0 );
- glEnd;
- SDL_GL_SwapBuffers;
- end;