diff options
Diffstat (limited to 'glpong3d.c')
-rw-r--r-- | glpong3d.c | 51 |
1 files changed, 25 insertions, 26 deletions
@@ -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);
-}*/
|