summaryrefslogtreecommitdiff
path: root/glpong3d.c
diff options
context:
space:
mode:
Diffstat (limited to 'glpong3d.c')
-rw-r--r--glpong3d.c110
1 files changed, 5 insertions, 105 deletions
diff --git a/glpong3d.c b/glpong3d.c
index 477988d..c4c4112 100644
--- a/glpong3d.c
+++ b/glpong3d.c
@@ -10,6 +10,8 @@
#include "glpong3d.h"
#include "text.h"
#include "fps.h"
+#include "paddle.h"
+#include "ball.h"
static int GLPong_Init(GLPong_t * GLPong);
static int GLPong_HandleEvents(void);
@@ -18,8 +20,6 @@ static void GLPong_CleanUp(void);
static void GLPong_Move(void);
static void SDL_GL_GetMouseState(Paddle_t * paddle);
-GLuint box;
-
int main(int argc, char * argv[]) {
unsigned int frames = 0;
int done = 0;
@@ -293,111 +293,11 @@ void GLPong_Draw(void) {
glVertex3f(-1.5f, 1.0f, GLPONG_BACK_Z);
glEnd();
- glLoadIdentity();
- glBindTexture(GL_TEXTURE_2D, paddle_texture);
- glEnable(GL_TEXTURE_2D);
- glColor3f(GLPong.Back.r, GLPong.Back.g, GLPong.Back.b);
- glTranslatef(GLPong.Back.coord.x, GLPong.Back.coord.y, GLPong.Back.coord.z);
- glBegin(GL_QUADS);
- glTexCoord2f(0.832f, 1.0f); glVertex2f(GLPong.Back.w / 2, GLPong.Back.h / 2); /* Upper Right */
- glTexCoord2f(0.168f, 1.0f); glVertex2f(-GLPong.Back.w / 2, GLPong.Back.h / 2); /* Upper Left */
- glTexCoord2f(0.168f, 0.0f); glVertex2f(-GLPong.Back.w / 2, -GLPong.Back.h / 2); /* Lower Left */
- glTexCoord2f(0.832f, 0.0f); glVertex2f(GLPong.Back.w / 2, -GLPong.Back.h / 2); /* Lower Right */
- glEnd();
- glDisable(GL_TEXTURE_2D);
-
- glLoadIdentity();
- glColor3f(1.0f, 0.0f, 0.0f);
- glTranslatef(GLPong.Back.coord.x, GLPong.Back.coord.y, GLPong.Back.coord.z);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
+ GLPong_PaddleDrawBack(&GLPong.Back);
- 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);
+ GLPong_BallDraw(&GLPong.Ball);
- /* 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();
-
- glLoadIdentity();
- glTranslatef(0.0f, 0.0f, GLPong.Ball.coord.z);
- glCallList(box);
-
- glLoadIdentity();
- glBindTexture(GL_TEXTURE_2D, paddle_texture);
- glEnable(GL_TEXTURE_2D);
- glColor3f(GLPong.Front.r, GLPong.Front.g, GLPong.Front.b);
- glTranslatef(GLPong.Front.coord.x + (GLPong.Front.w / 2), GLPong.Front.coord.y + (GLPong.Front.h / 2), GLPong.Front.coord.z);
- glBegin(GL_QUADS);
- glTexCoord2f(0.168f, 1.0f); glVertex2f(GLPong.Front.w / 2, GLPong.Front.h / 2); /* Upper Right */
- glTexCoord2f(0.832f, 1.0f); glVertex2f(-GLPong.Front.w / 2, GLPong.Front.h / 2); /* Upper Left */
- glTexCoord2f(0.832f, 0.0f); glVertex2f(-GLPong.Front.w / 2, -GLPong.Front.h / 2); /* Lower Left */
- glTexCoord2f(0.168f, 0.0f); glVertex2f(GLPong.Front.w / 2, -GLPong.Front.h / 2); /* Lower Right */
- glEnd();
- glDisable(GL_TEXTURE_2D);
-
- /* Lower Left */
- glLoadIdentity();
- glColor3f(1.0f, 0.0f, 0.0f);
- glTranslatef(GLPong.Front.coord.x, GLPong.Front.coord.y, GLPong.Front.coord.z);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
-
- /* Lower Right */
- glLoadIdentity();
- glTranslatef(GLPong.Front.coord.x + GLPong.Front.w, GLPong.Front.coord.y, GLPong.Front.coord.z);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
-
- /* Top Right */
- glLoadIdentity();
- glTranslatef(GLPong.Front.coord.x + GLPong.Front.w, GLPong.Front.coord.y + GLPong.Front.h, GLPong.Front.coord.z);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
- /* Top Left */
- glLoadIdentity();
- glTranslatef(GLPong.Front.coord.x, GLPong.Front.coord.y + GLPong.Front.h, GLPong.Front.coord.z);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
+ GLPong_PaddleDrawFront(&GLPong.Front);
}
void GLPong_Collide(Ball_t * ball, const Paddle_t * paddle) {