summaryrefslogtreecommitdiff
path: root/glpong3d.h
blob: 80d6cb01488f4e189a41a5da8c884280b1ff6da3 (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
55
56
57
58
59
60
61
62
63
#ifndef GLPONG3D_H
#define GLPONG3D_H

#include "SDL.h"
#include "SDL_opengl.h"

#define GLPONG_WIDTH	800.0f
#define GLPONG_HEIGHT	600.0f

#define GLPONG_NOACTION	0
#define GLPONG_EXIT	1

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define RMASK 0xff000000
#define GMASK 0x00ff0000
#define BMASK 0x0000ff00
#define AMASK 0x000000ff
#else
#define RMASK 0x000000ff
#define GMASK 0x0000ff00
#define BMASK 0x00ff0000
#define AMASK 0xff000000
#endif

GLuint background;

GLuint paddle_texture;
GLuint paddle_texture_hit;
GLuint ball_texture;

typedef struct {
	GLfloat w, h, x, y, z;
	GLfloat r, g, b;
} Paddle_t;

typedef struct {
	GLfloat w, h, x, y, z;
	GLfloat r, g, b;
	GLfloat xv, yv, zv;
	GLfloat rotate;
} Ball_t;

typedef struct {
	GLfloat x, y;
} Mouse_t;

typedef struct {
	SDL_Surface * Surface;
	Ball_t Ball;
	Paddle_t Front;
	Paddle_t Back;
	Mouse_t Mouse;
	GLfloat fps;
} GLPong_t;

GLPong_t GLPong;

void GLPong_Collide(Ball_t * ball, const Paddle_t * paddle);

GLuint SDL_GL_SurfaceToTexture(SDL_Surface * surface);
static __inline__ unsigned int NextPow2(unsigned int value);

#endif