diff options
-rw-r--r-- | sdl/.gitignore | 5 | ||||
-rw-r--r-- | sdl/Makefile | 8 | ||||
-rw-r--r-- | sdl/gltools.c | 38 | ||||
-rw-r--r-- | sdl/gltools.h | 1 | ||||
-rw-r--r-- | sdl/math3d.c | 17 | ||||
-rw-r--r-- | sdl/math3d.h | 1 | ||||
-rw-r--r-- | sdl/mingw32 | 3 | ||||
-rw-r--r-- | sdl/platform.c | 104 | ||||
-rw-r--r-- | sdl/platform.h | 4 | ||||
-rw-r--r-- | sdl/pyramid.c | 64 | ||||
-rw-r--r-- | sdl/sdltools.c | 182 | ||||
-rw-r--r-- | sdl/sdltools.h | 15 | ||||
-rw-r--r-- | sdl/window.c | 5 |
13 files changed, 363 insertions, 84 deletions
diff --git a/sdl/.gitignore b/sdl/.gitignore new file mode 100644 index 0000000..f25d8b0 --- /dev/null +++ b/sdl/.gitignore @@ -0,0 +1,5 @@ +obj/ +*.dll +*.exe +stdout.txt +stderr.txt diff --git a/sdl/Makefile b/sdl/Makefile index e7dfefd..269c69e 100644 --- a/sdl/Makefile +++ b/sdl/Makefile @@ -1,5 +1,6 @@ BIN = pyramid -SRC = pyramid.c math3d.c gltools.c glframe.c shader.c platform.c window.c gldraw.c +SRC = pyramid.c math3d.c gltools.c glframe.c shader.c platform.c window.c \ + gldraw.c sdltools.c CC = gcc CFLAGS = -Wall -std=gnu99 DBGFLAGS = -g -O0 @@ -20,7 +21,7 @@ OBJ_FILES = $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(subst .c,,$(SRC)))) $(BIN): $(OBJ_DIR) $(OBJ_FILES) $(CC) $(LDFLAGS) $(SDL_LDFLAGS) $(SDL_image_LDFLAGS) $(OBJ_FILES) -o $@ -$(OBJ_DIR)/pyramid.o: $(OBJ_DIR)/%.o: %.c math3d.h gltools.h glframe.h platform.h +$(OBJ_DIR)/pyramid.o: $(OBJ_DIR)/%.o: %.c math3d.h gltools.h glframe.h platform.h sdltools.h $(CC) -c $(CFLAGS) $(SDL_CFLAGS) $(SDL_image_CFLAGS) $< -o $@ $(OBJ_DIR)/math3d.o: $(OBJ_DIR)/%.o: %.c %.h @@ -44,6 +45,9 @@ $(OBJ_DIR)/window.o: $(OBJ_DIR)/%.o: %.c %.h $(OBJ_DIR)/gldraw.o: $(OBJ_DIR)/%.o: %.c %.h math3d.h $(CC) -c $(CFLAGS) $< -o $@ +$(OBJ_DIR)/sdltools.o: $(OBJ_DIR)/%.o: %.c %.h math3d.h + $(CC) -c $(CFLAGS) $< -o $@ + $(OBJ_DIR): mkdir -p $(OBJ_DIR) diff --git a/sdl/gltools.c b/sdl/gltools.c index afb0777..2449cfc 100644 --- a/sdl/gltools.c +++ b/sdl/gltools.c @@ -11,6 +11,42 @@ #include <string.h> #include "gltools.h" +/* mipmapping enabled by default */ +GLuint gltLoadTGATexture(const char *fname) +{ + GLuint handle; + + /* variables used for texture loading */ + GLbyte *pBytes; + GLint iWidth, iHeight, iComponents; + GLenum eFormat; + + glGenTextures(1, &handle); + glBindTexture(GL_TEXTURE_2D, handle); + + /* load texture */ + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + pBytes = gltLoadTGA(fname, &iWidth, &iHeight, &iComponents, &eFormat); + if (!pBytes) + fprintf(stderr, "gltLoadTGA: failed to load texture!\n"); + + glTexImage2D(GL_TEXTURE_2D, 0, iComponents, iWidth, iHeight, 0, eFormat, + GL_UNSIGNED_BYTE, pBytes); + free(pBytes); + + /* seems like mipmapping only applies to MIN_FILTER since mipmapping divides + * current texture into smaller and smaller pieces + */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); /* GL_LINEAR to disable mipmapping */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + return handle; +} + void gltListExtensions(void) { const GLubyte *ext_str; @@ -145,7 +181,7 @@ GLint gltWriteTGA(const char *szFileName) return 1; } -GLbyte *gltLoadTGA(const char *szFileName, GLint *iWidth, GLint *iHeight, +GLbyte *gltLoadTGA(const char *szFileName, GLint *iWidth, GLint *iHeight, GLint *iComponents, GLenum *eFormat) { FILE *pFile; /* file pointer */ diff --git a/sdl/gltools.h b/sdl/gltools.h index 608b8aa..f7cc44d 100644 --- a/sdl/gltools.h +++ b/sdl/gltools.h @@ -22,6 +22,7 @@ typedef struct #pragma pack() /* function prototypes */ +GLuint gltLoadTGATexture(const char *); void gltListExtensions(void); void gltOpenGLInfo(void); GLboolean gltQueryExtension(const char *); diff --git a/sdl/math3d.c b/sdl/math3d.c index b22c530..a808e34 100644 --- a/sdl/math3d.c +++ b/sdl/math3d.c @@ -1,6 +1,7 @@ -/* @2010 Kamil Kaminski +/* math3d.c + * + * Math 3D Library * - * math3d.c * */ @@ -27,7 +28,6 @@ void m3dFindNormalf(M3DVector3f result, const M3DVector3f point1, m3dCrossProductf(result, v1, v2); } - void m3dLoadIdentity33f(M3DMatrix33f m) { /* don't be fooled, this is still column major */ @@ -38,7 +38,6 @@ void m3dLoadIdentity33f(M3DMatrix33f m) memcpy(m, identity, sizeof(M3DMatrix33f)); } - void m3dLoadIdentity44f(M3DMatrix44f m) /* 4x4 float */ { /* don't be fooled, this is still column major */ @@ -271,3 +270,13 @@ int m3dInvertMatrix44f(M3DMatrix44f dst, const M3DMatrix44f m) return 0; } +unsigned int m3dPowerOfTwo(unsigned int n) +{ + unsigned int ret = 1; + + while (ret < n) + ret <<= 1; + + return ret; +} + diff --git a/sdl/math3d.h b/sdl/math3d.h index d9d9117..b18d1d0 100644 --- a/sdl/math3d.h +++ b/sdl/math3d.h @@ -27,6 +27,7 @@ void m3dMakePlanarShadowMatrixf(M3DMatrix44f, const M3DVector4f, const M3DVector void m3dMatrixMultiply44f(M3DMatrix44f, const M3DMatrix44f, const M3DMatrix44f); void m3dPrintMatrix44f(const M3DMatrix44f); int m3dInvertMatrix44f(M3DMatrix44f, const M3DMatrix44f); +unsigned int m3dPowerOfTwo(unsigned int); static inline void m3dCrossProductf(M3DVector3f result, const M3DVector3f u, const M3DVector3f v) diff --git a/sdl/mingw32 b/sdl/mingw32 index 93d3bf3..591f975 100644 --- a/sdl/mingw32 +++ b/sdl/mingw32 @@ -1,5 +1,6 @@ BIN = pyramid -SRC = pyramid.c math3d.c gltools.c glframe.c shader.c platform.c window.c +SRC = pyramid.c math3d.c gltools.c glframe.c shader.c platform.c window.c \ + gldraw.c sdltools.c CC = gcc CFLAGS = -Wall -std=c99 -MD DBGFLAGS = -g -O0 diff --git a/sdl/platform.c b/sdl/platform.c index 69235bd..270a938 100644 --- a/sdl/platform.c +++ b/sdl/platform.c @@ -22,9 +22,10 @@ GLfloat sourceLight[] = { 0.75f, 0.75f, 0.75f, 1.0f }; GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f }; /* variables that should be already defined and declared for us by main program */ -extern const unsigned int xres; -extern const unsigned int yres; -extern const unsigned int bpp; +extern const unsigned int xres_w; +extern const unsigned int yres_w; +extern const unsigned int bpp_w; +extern const unsigned int sdl_video_flags; extern const char *window_caption; extern const char *window_icon_path; @@ -94,40 +95,105 @@ void setup_opengl(void) glClearColor(0.5f, 0.5f, 0.5f, 1.0f); } +SDL_Surface *setup_sdl_video(int w, int h, int bpp, unsigned int flags) +{ + SDL_Surface *srfc; + + if (!bpp) + { + const SDL_VideoInfo* info = NULL; + + /* get some video information. */ + info = SDL_GetVideoInfo(); + if (!info) + { + fprintf( stderr, "SDL: video query failed: %s\n", SDL_GetError()); + exit(-1); + } + + bpp = info->vfmt->BitsPerPixel; + printf("SDL: bpp was not specified, chose %d bits\n", bpp); + } + + if (!flags) + flags = SDL_OPENGL | SDL_RESIZABLE; + + if ((srfc = SDL_SetVideoMode(w, h, bpp, flags)) == NULL) + { + fprintf(stderr, "SDL: unable to set video mode: %s\n", SDL_GetError()); + exit(-1); + } + + return srfc; +} + void setup_sdl(void) { SDL_Surface *screen; + const SDL_VideoInfo* info = NULL; - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) == -1) { - fprintf(stderr, "unable to init SDL: %s\n", SDL_GetError()); + fprintf(stderr, "SDL: unable to init, %s\n", SDL_GetError()); exit(-1); } atexit(SDL_Quit); - SDL_WM_SetCaption(window_caption, NULL); - SDL_WM_SetIcon(IMG_Load(window_icon_path), NULL); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + + SDL_WM_SetCaption(window_caption, NULL); + SDL_WM_SetIcon(IMG_Load(window_icon_path), NULL); + + /* set video mode */ + screen = setup_sdl_video(xres_w, yres_w, bpp_w, sdl_video_flags); - if ((screen = SDL_SetVideoMode(xres, yres, bpp, SDL_OPENGL | SDL_RESIZABLE)) == NULL) + /* get some video information. */ + info = SDL_GetVideoInfo(); + if (!info) { - fprintf(stderr, "unable to set video mode: %s\n", SDL_GetError()); + fprintf( stderr, "SDL: video query failed: %s\n", SDL_GetError()); exit(-1); } + int bpp = info->vfmt->BitsPerPixel; + printf("SDL: applied %d bits per pixel\n", bpp); + + /* query opengl attributes after SetVideoMode call */ + int fb_red_comp; + int fb_green_comp; + int fb_blue_comp; + int fb_alpha_comp; + int double_buff; + int depth_sz; + + SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &fb_red_comp); + SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &fb_green_comp); + SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &fb_blue_comp); + SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &fb_alpha_comp); + SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &double_buff); + SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth_sz); + printf("SDL: framebuffer; size of components, red: %d bits, green: %d bits, " + "blue: %d bits, alpha: %d bits\n" + "SDL: double-buffering: %s, depth buffer size: %d bits\n", + fb_red_comp, fb_green_comp, fb_blue_comp, fb_alpha_comp, + double_buff ? "enabled" : "disabled", depth_sz); + SDL_EnableUNICODE(1); + /* SDL doesn't trigger off a ResizeEvent at startup, but as we need this * for OpenGL, we do this ourselves */ SDL_Event resizeEvent; resizeEvent.type = SDL_VIDEORESIZE; - resizeEvent.resize.w = xres; - resizeEvent.resize.h = yres; + resizeEvent.resize.w = xres_w; + resizeEvent.resize.h = yres_w; SDL_PushEvent(&resizeEvent); + + /* save the surf pointer in platform */ } void setup_glew(void) @@ -150,17 +216,3 @@ void setup_glew(void) fprintf(stdout, "GLEW: detected OpenGL %d.%d\n", major, minor); } -inline void fps_control(const unsigned int startclock) -{ - unsigned int deltaclock = SDL_GetTicks() - startclock; - if (deltaclock < 1000 / FRAMES_PER_SECOND) - SDL_Delay((1000 / FRAMES_PER_SECOND) - deltaclock); - -#ifdef STAT_FPS - char buffer[30] = { 0 }; - sprintf(buffer, "%s: %4d fps", window_caption, - 1000 / (SDL_GetTicks() - startclock)); - SDL_WM_SetCaption(buffer, NULL); -#endif -} - diff --git a/sdl/platform.h b/sdl/platform.h index 3428a90..8be6052 100644 --- a/sdl/platform.h +++ b/sdl/platform.h @@ -1,8 +1,6 @@ #ifndef _PLATFORM_H_ #define _PLATFORM_H_ -#define FRAMES_PER_SECOND 60 - extern GLfloat fNoLight[]; extern GLfloat fLowLight[]; extern GLfloat fBrightLight[]; @@ -13,9 +11,9 @@ extern GLfloat lightPos[]; /* function prototypes */ void setup_opengl(void); +SDL_Surface *setup_sdl_video(int, int, int, unsigned int); void setup_sdl(void); void setup_glew(void); -extern void fps_control(unsigned int); #endif diff --git a/sdl/pyramid.c b/sdl/pyramid.c index 566c976..4fb2b6a 100644 --- a/sdl/pyramid.c +++ b/sdl/pyramid.c @@ -26,6 +26,7 @@ #include "gltools.h" #include "math3d.h" #include "platform.h" +#include "sdltools.h" #include "window.h" /* function prototypes */ @@ -34,15 +35,16 @@ static void process_events(void); static void platform_init(void); static void platform_destroy(void); static void render(void); -GLuint gltLoadTGATexture(const char *); /* global */ int program_running = 1; -const unsigned int xres = 640; -const unsigned int yres = 480; -const unsigned int bpp = 32; +const int xres_w = 640; +const int yres_w = 480; +const int bpp_w = 32; const char *window_caption = "Textured Pyramid"; const char *window_icon_path = "tux.png"; +const unsigned int sdl_video_flags = SDL_OPENGL | SDL_RESIZABLE; + /* platform struct */ static struct @@ -58,6 +60,9 @@ static struct GLfloat xrot; GLfloat yrot; + + SDL_TimerID timer_id; + SDL_Cursor *my_cursor; } p; static void keys(SDL_keysym *keysym, const unsigned int *keys_held, const int flag) @@ -90,7 +95,7 @@ static void keys(SDL_keysym *keysym, const unsigned int *keys_held, const int fl p.yrot -= 5.0f; if (keys_held[SDLK_d]) p.yrot += 5.0f; - + if (keys_held[SDLK_UP]) glframe_move_forward(&p.camera, 0.05f); if (keys_held[SDLK_DOWN]) @@ -105,7 +110,7 @@ static void keys(SDL_keysym *keysym, const unsigned int *keys_held, const int fl if (keys_held[SDLK_m]) glframe_rotate_local_x(&p.camera, -0.02f); } - + p.xrot = (GLfloat) ((const int) p.xrot % 360); p.yrot = (GLfloat) ((const int) p.yrot % 360); } @@ -155,42 +160,6 @@ static void process_events(void) flag = !flag; } -/* mipmapping enabled by default */ -GLuint gltLoadTGATexture(const char *fname) -{ - GLuint handle; - - /* variables used for texture loading */ - GLbyte *pBytes; - GLint iWidth, iHeight, iComponents; - GLenum eFormat; - - glGenTextures(1, &handle); - glBindTexture(GL_TEXTURE_2D, handle); - - /* load texture */ - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - pBytes = gltLoadTGA(fname, &iWidth, &iHeight, &iComponents, &eFormat); - if (!pBytes) - fprintf(stderr, "gltLoadTGA: failed to load texture!\n"); - - glTexImage2D(GL_TEXTURE_2D, 0, iComponents, iWidth, iHeight, 0, eFormat, - GL_UNSIGNED_BYTE, pBytes); - free(pBytes); - - /* seems like mipmapping only applies to MIN_FILTER since mipmapping divides - * current texture into smaller and smaller pieces - */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); /* GL_LINEAR to disable mipmapping */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - return handle; -} - static void platform_init(void) { memset(&p, 0, sizeof(p)); @@ -217,6 +186,13 @@ static void platform_init(void) glColor3f(1.0f, 1.0f, 1.0f); glDrawTriangle(); glEndList(); + + /* add a simple timer / callback function */ + p.timer_id = SDL_AddTimer(5000, sdlTimerCallback, &(p.camera)); + + /* apply a custom cursor */ + p.my_cursor = sdlInitCursor(arrow); + SDL_SetCursor(p.my_cursor); } static void platform_destroy(void) @@ -274,9 +250,7 @@ int main(int argc, char **argv) process_events(); render(); - fps_control(startclock); - /* need some sort of a timer to trigger this */ - /* gl_frame_normalize(&p.camera); */ + sdlFrameControl(startclock); } platform_destroy(); diff --git a/sdl/sdltools.c b/sdl/sdltools.c new file mode 100644 index 0000000..c98a968 --- /dev/null +++ b/sdl/sdltools.c @@ -0,0 +1,182 @@ +/* sdltools.c + * + * SDL Tools + * + * + */ + +#include <SDL/SDL.h> +#include <SDL/SDL_image.h> +#include <GL/glew.h> +#include "sdltools.h" +#include "math3d.h" +#include "glframe.h" + +/* creates a new mouse cursor from an XPM */ +const char *arrow[] = { + /* width height num_colors chars_per_pixel */ + " 32 32 3 1", + /* colors */ + "X c #000000", + ". c #ffffff", + " c None", + /* pixels */ + "X ", + "XX ", + "X.X ", + "X..X ", + "X...X ", + "X....X ", + "X.....X ", + "X......X ", + "X.......X ", + "X........X ", + "X.....XXXXX ", + "X..X..X ", + "X.X X..X ", + "XX X..X ", + "X X..X ", + " X..X ", + " X..X ", + " X..X ", + " XX ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "0,0" +}; + +inline void sdlFrameControl(const unsigned int startclock) +{ + unsigned int deltaclock = SDL_GetTicks() - startclock; + if (deltaclock < 1000 / FRAMES_PER_SECOND) + SDL_Delay((1000 / FRAMES_PER_SECOND) - deltaclock); + +#ifdef STAT_FPS + char buffer[30] = { 0 }; + sprintf(buffer, "%s: %4d fps", window_caption, + 1000 / (SDL_GetTicks() - startclock)); + SDL_WM_SetCaption(buffer, NULL); +#endif +} + +SDL_Cursor *sdlInitCursor(const char *image[]) +{ + int i, row, col; + Uint8 data[4*32]; + Uint8 mask[4*32]; + int hot_x, hot_y; + + i = -1; + for (row = 0; row < 32; ++row) + { + for (col = 0; col < 32; ++col) + { + if (col % 8) + { + data[i] <<= 1; + mask[i] <<= 1; + } + else + { + ++i; + data[i] = mask[i] = 0; + } + + switch (image[4+row][col]) + { + case 'X': + data[i] |= 0x01; + break; + case '.': + mask[i] |= 0x01; + break; + case ' ': + break; + } + } + } + + sscanf(image[4+row], "%d,%d", &hot_x, &hot_y); + return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y); +} + +unsigned int sdlTimerCallback(unsigned int interval, void *params) +{ + GLFrame *p = (GLFrame *) params; + gl_frame_normalize(p); + + return interval; +} + +/* load an OpenGL texture from SDL surface */ +GLuint sdltLoadGLTexture(SDL_Surface *surface, GLfloat *texcoord) +{ + GLuint texture; + int w, h; + SDL_Surface *image; + SDL_Rect area; +#if 0 + Uint32 saved_flags; + Uint8 saved_alpha; +#endif + + /* use the surface width and height expanded to powers of 2 */ + w = m3dPowerOfTwo(surface->w); + h = m3dPowerOfTwo(surface->h); + texcoord[0] = 0.0f; /* min x */ + texcoord[1] = 0.0f; /* min y */ + texcoord[2] = (GLfloat) surface->w / w; /* max x */ + texcoord[3] = (GLfloat) surface->h / h; /* max y */ + + /* the mask in following line are not big endian aware */ + image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0x000000FF, 0x0000FF00, /* XXX */ + 0x00FF0000, 0xFF000000 /* OpenGL RGBA masks */ ); + + if (!image) + return 0; + +#if 0 + /* save the alpha blending attributes */ + saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); + SDL_GetSurfaceAlphaMod(surface, &saved_alpha); + if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) + SDL_SetAlpha(surface, 0, 0); +#endif + + /* copy the surface into the GL texture image */ + area.x = 0; + area.y = 0; + area.w = surface->w; + area.h = surface->h; + SDL_BlitSurface(surface, &area, image, &area); + +#if 0 + /* restore the alpha blending attributes */ + if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) + SDL_SetAlpha(surface, saved_flags, saved_alpha); +#endif + + /* create an OpenGL texture for the image */ + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); /* XXX */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); /* XXX */ + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, + image->pixels); + + SDL_FreeSurface(image); + + return texture; +} + diff --git a/sdl/sdltools.h b/sdl/sdltools.h new file mode 100644 index 0000000..63478ec --- /dev/null +++ b/sdl/sdltools.h @@ -0,0 +1,15 @@ +#ifndef _SDL_TOOLS_ +#define _SDL_TOOLS_ + +#define FRAMES_PER_SECOND 60 + +extern const char *arrow[]; + +/* function prototypes */ +extern void sdlFrameControl(unsigned int); +SDL_Cursor *sdlInitCursor(const char *image[]); +unsigned int sdlTimerCallback(unsigned int, void *); +GLuint sdltLoadGLTexture(SDL_Surface *, GLfloat *); + +#endif + diff --git a/sdl/window.c b/sdl/window.c index 3ecd99c..a96eef6 100644 --- a/sdl/window.c +++ b/sdl/window.c @@ -10,7 +10,8 @@ #include <GL/glew.h> #include "window.h" -extern const unsigned int bpp; +extern const unsigned int bpp_w; +extern const unsigned int sdl_video_flags; void window_resize(int w, int h) { @@ -32,6 +33,6 @@ void window_resize(int w, int h) glLoadIdentity(); /* this needs to be ran again, glut does it for you I suppose */ - SDL_SetVideoMode(w, h, bpp, SDL_OPENGL | SDL_RESIZABLE); + SDL_SetVideoMode(w, h, bpp_w, sdl_video_flags); } |