From 4dad8cc6605fc7e01386ae2a0bb4dc061b64fd5f Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 4 Aug 2006 21:23:58 +0000 Subject: Added new SkyOS paddle. Paddle should move with mouse as expected. git-svn-id: svn://mattst88.com/svn/glpong3d/trunk@8 4dd1920e-271a-0410-bca0-81b404a81564 --- glpong3d.c | 51 +++++++++++++++++++++++++-------------------------- glpong3d.h | 2 +- paddle-skyos.png | Bin 11998 -> 57023 bytes 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/glpong3d.c b/glpong3d.c index fe040a3..9fb1d42 100644 --- a/glpong3d.c +++ b/glpong3d.c @@ -51,6 +51,12 @@ void GLPong_Init() { GLPong.Front.y = -(GLPong.Front.h / 2); GLPong.Front.z = -3.0f; + GLPong.Back.w = 0.66f; + GLPong.Back.h = 0.5f; + GLPong.Back.x = -(GLPong.Front.w / 2); + GLPong.Back.y = -(GLPong.Front.h / 2); + GLPong.Back.z = -9.0f; + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); atexit(SDL_Quit); @@ -74,15 +80,15 @@ void GLPong_Init() { glLoadIdentity(); gluPerspective(45.0f, GLPong.w / GLPong.h, 0.1f, 50.0f); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glShadeModel(GL_SMOOTH); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glShadeModel(GL_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthFunc(GL_LEQUAL); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glDepthFunc(GL_LEQUAL); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); GLPong.Event.type = SDL_NOEVENT; @@ -204,9 +210,21 @@ void GLPong_Draw() { glEnd(); glLoadIdentity(); - glBindTexture(GL_TEXTURE_2D, ball_texture); + glBindTexture(GL_TEXTURE_2D, paddle_texture); glEnable(GL_TEXTURE_2D); glColor3f(1.0f, 1.0f, 1.0f); + glTranslatef(0.0f, 0.0f, GLPong.Back.z); + glBegin(GL_QUADS); + glTexCoord2f(0.168f, 1.0f); glVertex2f(GLPong.Back.w / 2, GLPong.Back.h / 2); /* Upper Right */ + glTexCoord2f(0.832f, 1.0f); glVertex2f(-GLPong.Back.w / 2, GLPong.Back.h / 2); /* Upper Left */ + glTexCoord2f(0.832f, 0.0f); glVertex2f(-GLPong.Back.w / 2, -GLPong.Back.h / 2); /* Lower Left */ + glTexCoord2f(0.168f, 0.0f); glVertex2f(GLPong.Back.w / 2, -GLPong.Back.h / 2); /* Lower Right */ + glEnd(); + glDisable(GL_TEXTURE_2D); + + glLoadIdentity(); + glBindTexture(GL_TEXTURE_2D, ball_texture); + glEnable(GL_TEXTURE_2D); glTranslatef(GLPong.Ball.x, GLPong.Ball.y, GLPong.Ball.z); /*glRotatef(GLPong.Ball.rotate, 0.0f, 0.0f, 1.0f);*/ glBegin(GL_QUADS); @@ -317,22 +335,3 @@ GLuint SDL_GL_SurfaceToTexture(SDL_Surface * surface) { return texture; } - -/* -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; - } - if (hratio) { - *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); - SDL_FreeSurface(surface); - - return SDL_GL_SurfaceToTexture(pow2); -}*/ diff --git a/glpong3d.h b/glpong3d.h index 76fb8e5..27122ab 100644 --- a/glpong3d.h +++ b/glpong3d.h @@ -16,6 +16,7 @@ struct { SDL_Surface * Surface; Ball_t Ball; Paddle_t Front; + Paddle_t Back; Mouse_t Mouse; GLfloat w; GLfloat h; @@ -29,7 +30,6 @@ void GLPong_CleanUp(); void GLPong_Move(); GLuint SDL_GL_SurfaceToTexture(SDL_Surface * surface); -/*GLuint SDL_GL_NPOTSurfaceToTexture(SDL_Surface * surface, GLfloat * wratio, GLfloat * hratio);*/ __inline__ unsigned int NextPow2(unsigned int value); #endif diff --git a/paddle-skyos.png b/paddle-skyos.png index 2bb6972..4af354c 100644 Binary files a/paddle-skyos.png and b/paddle-skyos.png differ -- cgit v1.2.3