diff options
| author | Steven Fuller <relnev@icculus.org> | 2001-08-08 06:14:20 +0000 |
|---|---|---|
| committer | Patryk Obara <dreamer.tan@gmail.com> | 2019-08-20 02:22:36 +0200 |
| commit | 9e5b7f430d3c5f30042c1fa380ed6b4be13c884d (patch) | |
| tree | 46010c2b8d4509ec43bc559f8e4d45d194aa6bfe /src/main.c | |
| parent | 665f33b0f9014d8501106f74cb629d3d5d1877be (diff) | |
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.)
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 71 |
1 files changed, 68 insertions, 3 deletions
@@ -2,6 +2,9 @@ #include <stdlib.h> #include <string.h> +#include <SDL/SDL.h> +#include <GL/gl.h> + #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; |
