diff options
Diffstat (limited to 'ball.c')
-rw-r--r-- | ball.c | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -0,0 +1,54 @@ +#include "SDL.h" +#include "SDL_opengl.h" + +#include "ball.h" + +void +GLPong_BallDraw(const Ball_t * ball) { + glLoadIdentity(); + glBindTexture(GL_TEXTURE_2D, ball_texture); + glEnable(GL_TEXTURE_2D); + glColor3f(GLPong.Ball.r, GLPong.Ball.g, GLPong.Ball.b); + glTranslatef(GLPong.Ball.coord.x, GLPong.Ball.coord.y, GLPong.Ball.coord.z); + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 1.0f); glVertex2f(GLPong.Ball.w, GLPong.Ball.h); /* Lower Left */ + glTexCoord2f(1.0f, 1.0f); glVertex2f(0.0f, GLPong.Ball.h); /* Lower Right */ + glTexCoord2f(1.0f, 0.0f); glVertex2f(0.0f, 0.0f); /* Upper Right */ + glTexCoord2f(0.0f, 0.0f); glVertex2f(GLPong.Ball.w, 0.0f); /* Upper Left */ + glEnd(); + glDisable(GL_TEXTURE_2D); + +#ifdef DEBUG + /* Lower Left */ + glLoadIdentity(); + glColor3f(1.0f, 0.0f, 0.0f); + glTranslatef(GLPong.Ball.coord.x, GLPong.Ball.coord.y, GLPong.Ball.coord.z); + glBegin(GL_POINTS); + glVertex3f(0.0f, 0.0f, 0.0f); + glEnd(); + + /* Lower Right */ + glLoadIdentity(); + glTranslatef(GLPong.Ball.coord.x + GLPong.Ball.w, GLPong.Ball.coord.y, GLPong.Ball.coord.z); + glBegin(GL_POINTS); + glVertex3f(0.0f, 0.0f, 0.0f); + glEnd(); + + /* Top Right */ + glLoadIdentity(); + glTranslatef(GLPong.Ball.coord.x + GLPong.Ball.w, GLPong.Ball.coord.y + GLPong.Ball.h, GLPong.Ball.coord.z); + glBegin(GL_POINTS); + glVertex3f(0.0f, 0.0f, 0.0f); + glEnd(); + /* Top Left */ + glLoadIdentity(); + glTranslatef(GLPong.Ball.coord.x, GLPong.Ball.coord.y + GLPong.Ball.h, GLPong.Ball.coord.z); + glBegin(GL_POINTS); + glVertex3f(0.0f, 0.0f, 0.0f); + glEnd(); +#endif + + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, GLPong.Ball.coord.z); + glCallList(box); +} |