summaryrefslogtreecommitdiff
path: root/ball.c
blob: 7d60903a5c24d4205adeb16490b4a6d41a27d383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
}