From 9e5b7f430d3c5f30042c1fa380ed6b4be13c884d Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Wed, 8 Aug 2001 06:14:20 +0000 Subject: Moved inline assembly to a separate file for debugging. Implemented GetTickCount/timeGetTime. Added basic SDL/OpenGL support. Draws something with no optimizations, but draws nothing with -O2. (What is drawn looks like garbage.) --- src/main.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 26ecc90..117477a 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,9 @@ #include #include +#include +#include + #include "fixer.h" #include "3dc.h" @@ -32,11 +35,75 @@ int InitialiseWindowsSystem() { ScanDrawMode = ScanDrawD3DHardwareRGB; + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError()); + exit(EXIT_FAILURE); + } + + 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); + + if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) { + fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError()); + SDL_Quit(); + exit(EXIT_FAILURE); + } + + glViewport(0, 0, 640, 480); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 1, 1000); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + return 0; } +void CheckForWindowsMessages() +{ + SDL_Event event; + + if (SDL_PollEvent(&event)) { + do { + switch(event.type) { + case SDL_KEYDOWN: + break; + case SDL_KEYUP: + break; + case SDL_QUIT: + SDL_Quit(); + exit(17); /* TODO tempy! */ + break; + } + } while (SDL_PollEvent(&event)); + } +} + +void InGameFlipBuffers() +{ + SDL_GL_SwapBuffers(); +} + +void ThisFramesRenderingHasBegun() +{ + fprintf(stderr, "ThisFramesRenderingHasBegun()\n"); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + +void ThisFramesRenderingHasFinished() +{ + fprintf(stderr, "ThisFramesRenderingHasFinished()\n"); +} + int ExitWindowsSystem() { + SDL_Quit(); + return 0; } @@ -176,9 +243,7 @@ int main(int argc, char *argv[]) ThisFramesRenderingHasFinished(); -/* NOT YET InGameFlipBuffers(); -*/ FrameCounterHandler(); { @@ -209,7 +274,7 @@ int main(int argc, char *argv[]) RestartLevel(); } - break; /* TODO -- remove when loop works */ +// break; /* TODO -- remove when loop works */ } AvP.LevelCompleted = thisLevelHasBeenCompleted; -- cgit v1.3