diff options
author | Matt Turner <mattst88@gmail.com> | 2007-12-04 21:58:06 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2007-12-04 21:58:06 +0000 |
commit | 01fad53a58f67c948fcf2b5617e9b557f264671c (patch) | |
tree | f8dc152a19d00847438b71231683f5a5fb8dabf2 /glpong.c | |
parent | 0e0bc15ac984dc5f5a96e346491c7e799d37baf1 (diff) |
Use a display list for ball rendering.
git-svn-id: svn://mattst88.com/svn/glpong/trunk@9 449aeecc-241a-0410-943f-e2f883e2d7a2
Diffstat (limited to 'glpong.c')
-rw-r--r-- | glpong.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -69,6 +69,8 @@ int main(int argc, char * argv[]) { /* clean up */ GLPong_BallDeleteAll(GLPong.balls); + GLPong_BallDeinit(); + return 0; } @@ -122,9 +124,11 @@ GLPong_Init(GLPong_t * GLPong) { printf("OpenGL Version: %s\n", glGetString(GL_VERSION)); printf("OpenGL Extensions: %s\n", glGetString(GL_EXTENSIONS)); - ball_texture = SDL_GL_SurfaceToTexture(temp); + ball_texture = SDL_GL_NPOTSurfaceToTexture(temp, NULL, NULL); SDL_FreeSurface(temp); + GLPong_BallInit(); + return 0; } @@ -214,8 +218,10 @@ SDL_GL_SurfaceToTexture(SDL_Surface * surface) { static GLuint SDL_GL_NPOTSurfaceToTexture(SDL_Surface * surface, GLfloat * wratio, GLfloat * hratio) { SDL_Surface * pow2 = NULL; + unsigned int w = NextPow2(surface->w); unsigned int h = NextPow2(surface->h); + if (wratio) { *wratio = (GLfloat)surface->w / (GLfloat)h; } @@ -223,9 +229,12 @@ SDL_GL_NPOTSurfaceToTexture(SDL_Surface * surface, GLfloat * wratio, GLfloat * h *hratio = (GLfloat)surface->h/(GLfloat)h; } - pow2 = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask); - SDL_BlitSurface(surface, NULL, pow2, NULL); - - return SDL_GL_SurfaceToTexture(pow2); + if ((w != surface->w) || (h != surface->h)) { + pow2 = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask); + SDL_BlitSurface(surface, NULL, pow2, NULL); + return SDL_GL_SurfaceToTexture(pow2); + } else { + return SDL_GL_SurfaceToTexture(surface); + } } |