From ad0fe49b1a3f7c6b0d6d622811d82ca4d6cac47a Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 22 Jan 2010 16:15:53 -0500 Subject: Clean ups. Cut down GLPong_t more. Signed-off-by: Matt Turner --- glpong3d.c | 30 +++++++++++------------------- glpong3d.h | 1 - 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/glpong3d.c b/glpong3d.c index d64faf9..ff1d064 100644 --- a/glpong3d.c +++ b/glpong3d.c @@ -71,6 +71,7 @@ int main(int argc, char * argv[]) { static int GLPong_Init(GLPong_t * GLPong) { + SDL_Surface * Surface = NULL; SDL_Surface * temp = NULL; GLPong->Ball.w = 0.5f; @@ -139,12 +140,12 @@ GLPong_Init(GLPong_t * GLPong) { } atexit(SDLNet_Quit); - GLPong->Surface = SDL_SetVideoMode(GLPONG_WIDTH, GLPONG_HEIGHT, 32, SDL_OPENGL); + Surface = SDL_SetVideoMode(GLPONG_WIDTH, GLPONG_HEIGHT, 32, SDL_OPENGL); glViewport(0, 0, GLPONG_WIDTH, GLPONG_HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(45.0f, GLPONG_WIDTH / GLPONG_HEIGHT, 0.1f, 50.0f); + gluPerspective(45.0f, GLPONG_WIDTH / GLPONG_HEIGHT, 3.0f, 9.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -218,7 +219,8 @@ GLPong_HandleEvents(void) { return GLPONG_NOACTION; } -void GLPong_Move(void) { +static void +GLPong_Move(void) { GLPong.Ball.coord.x += GLPong.Ball.xv; if (GLPong.Ball.coord.x > 1.0f) { GLPong.Ball.coord.x = 1.0f; @@ -245,8 +247,11 @@ void GLPong_Move(void) { GLPong.Ball.coord.z = GLPONG_FRONT_Z; GLPong.Ball.zv = -GLPong.Ball.zv; } + +#ifdef DEBUG GLPong.Back.coord.x = GLPong.Ball.coord.x; GLPong.Back.coord.y = GLPong.Ball.coord.y; +#endif GLPong_Collide(&GLPong.Ball, &GLPong.Front); } @@ -256,7 +261,7 @@ void GLPong_Draw(void) { glColor3f(0.0f, 1.0f, 0.0f); for (count = GLPONG_FRONT_Z; count >= GLPONG_BACK_Z; count -= 1.0f) { glLoadIdentity(); - glTranslatef(0.0f, 0.0f, count); + glTranslatef(0.0f, 0.0f, count); /* XXX: optimize by moving glLoadIdentity out of loop? */ glCallList(box); } @@ -333,28 +338,15 @@ NextPow2(unsigned int value) { } GLuint SDL_GL_SurfaceToTexture(SDL_Surface * surface) { - Uint32 rmask, gmask, bmask, amask; GLuint texture; GLenum format = GL_RGB; -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; -#else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; -#endif - - if (surface->format->Rmask & rmask) { + if (surface->format->Rmask & RMASK) { format = GL_RGB; if (surface->format->BitsPerPixel == 32) { format = GL_RGBA; } - } else if (surface->format->Rmask & bmask) { + } else if (surface->format->Rmask & BMASK) { format = GL_BGR; if (surface->format->BitsPerPixel == 32) { format = GL_BGRA; diff --git a/glpong3d.h b/glpong3d.h index e032fc7..318dcf0 100644 --- a/glpong3d.h +++ b/glpong3d.h @@ -49,7 +49,6 @@ typedef struct { } Ball_t; typedef struct { - SDL_Surface * Surface; Ball_t Ball; Paddle_t Front; Paddle_t Back; -- cgit v1.2.3