summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2010-10-15 01:02:52 -0500
committerKamil Kaminski <kamilkss@gmail.com>2010-10-15 01:02:52 -0500
commitbd79a6e0a38785f723f749608468b32e66e0f73b (patch)
tree46885841a1d21e3d21a5206c60ad050880c3d45f
parent9ac3e6642165d953cb376f3122f7aba69bce301f (diff)
downloadGLPyramid-bd79a6e0a38785f723f749608468b32e66e0f73b.tar.gz
GLPyramid-bd79a6e0a38785f723f749608468b32e66e0f73b.tar.bz2
GLPyramid-bd79a6e0a38785f723f749608468b32e66e0f73b.zip
Rename more
-rw-r--r--sdl/glframe.c12
-rw-r--r--sdl/glframe.h10
-rw-r--r--sdl/pyramid.c39
3 files changed, 30 insertions, 31 deletions
diff --git a/sdl/glframe.c b/sdl/glframe.c
index 668f8de..a86a393 100644
--- a/sdl/glframe.c
+++ b/sdl/glframe.c
@@ -10,7 +10,7 @@
#include "glframe.h"
#include "math3d.h"
-void reset_glframe(GLFrame *frame)
+void glframe_reset(GLFrame *frame)
{
frame->v_location[0] = 0.0f;
frame->v_location[1] = 0.0f;
@@ -26,7 +26,7 @@ void reset_glframe(GLFrame *frame)
}
/* get a 4x4 transformation matrix that describes the ccamera orientation */
-void get_camera_orientation(GLFrame *frame, M3DMatrix44f m)
+void glframe_get_camera_orientation(GLFrame *frame, M3DMatrix44f m)
{
M3DVector3f x, z;
@@ -61,13 +61,13 @@ void get_camera_orientation(GLFrame *frame, M3DMatrix44f m)
/* perform viewing or modeling transformations */
/* some of the code is unimplemented */
-void apply_camera_transform(GLFrame *frame)
+void glframe_apply_camera_transform(GLFrame *frame)
{
/* XXX: rotation only, should passed in as a parameter */
int rot_only = 0;
M3DMatrix44f m;
- get_camera_orientation(frame, m);
+ glframe_get_camera_orientation(frame, m);
glMultMatrixf(m);
/* if Rotation only, then do not do the translation */
@@ -83,7 +83,7 @@ void apply_camera_transform(GLFrame *frame)
#endif
}
-void move_forward(GLFrame *frame, float delta)
+void glframe_move_forward(GLFrame *frame, float delta)
{
// Move along direction of front direction
frame->v_location[0] += frame->v_forward[0] * delta;
@@ -91,7 +91,7 @@ void move_forward(GLFrame *frame, float delta)
frame->v_location[2] += frame->v_forward[2] * delta;
}
-void rotate_local_y(GLFrame *frame, float angle)
+void glframe_rotate_local_y(GLFrame *frame, float angle)
{
M3DMatrix44f rotMat;
diff --git a/sdl/glframe.h b/sdl/glframe.h
index d83f9e4..3842d7a 100644
--- a/sdl/glframe.h
+++ b/sdl/glframe.h
@@ -11,11 +11,11 @@ typedef struct
} GLFrame;
/* function prototypes */
-void reset_glframe(GLFrame *);
-void get_camera_orientation(GLFrame *, M3DMatrix44f);
-void apply_camera_transform(GLFrame *);
-void move_forward(GLFrame *, float);
-void rotate_local_y(GLFrame *, float);
+void glframe_reset(GLFrame *);
+void glframe_get_camera_orientation(GLFrame *, M3DMatrix44f);
+void glframe_apply_camera_transform(GLFrame *);
+void glframe_move_forward(GLFrame *, float);
+void glframe_rotate_local_y(GLFrame *, float);
#endif
diff --git a/sdl/pyramid.c b/sdl/pyramid.c
index 5959e02..689e9dd 100644
--- a/sdl/pyramid.c
+++ b/sdl/pyramid.c
@@ -67,23 +67,20 @@ static void setup_opengl(void)
GLenum eFormat;
/* light values and coordinates */
- GLfloat whiteLight[] = { 0.05f, 0.05f, 0.05f, 1.0f };
+ GLfloat whiteLight[] = { 0.05f, 0.05f, 0.05f, 1.0f };
GLfloat sourceLight[] = { 0.75f, 0.75f, 0.75f, 1.0f };
- GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f };
+ GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f };
/* setup fog */
glEnable(GL_FOG);
- glFogfv(GL_FOG_COLOR, fLowLight); /* set fog color to match background */
+ glFogfv(GL_FOG_COLOR, fLowLight); /* set fog color to match background */
glFogf(GL_FOG_START, 4.0f);
glFogf(GL_FOG_END, 20.0f);
- glFogi(GL_FOG_MODE, GL_LINEAR); /* fog equation */
+ glFogi(GL_FOG_MODE, GL_LINEAR); /* fog equation */
- glEnable(GL_DEPTH_TEST);/* hidden surface removal */
- glFrontFace(GL_CCW); /* counter clock-wise polygons face out */
- glEnable(GL_CULL_FACE); /* do not calculate inside of a pyramid */
-
- /* enable lighting */
- glEnable(GL_LIGHTING);
+ glEnable(GL_DEPTH_TEST); /* hidden surface removal */
+ glFrontFace(GL_CCW); /* counter clock-wise polygons face out */
+ glEnable(GL_CULL_FACE); /* do not calculate inside of a pyramid */
/* setup and enable light 0 */
/* ambient RGBA intensity of the entire scene */
@@ -92,6 +89,8 @@ static void setup_opengl(void)
glLightfv(GL_LIGHT0, GL_DIFFUSE, fBrightLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, fBrightLight);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
+
+ /* enable lighting */
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
@@ -142,7 +141,7 @@ static void setup_opengl(void)
glEnable(GL_TEXTURE_2D);
/* set the camera to <0,0,0> */
- reset_glframe(&camera);
+ glframe_reset(&camera);
/* multisampling for polygons, conflicts with anti-aliasing */
//glEnable(GL_MULTISAMPLE);
@@ -162,10 +161,10 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag)
case SDLK_s: xRot += 5.0f; break;
case SDLK_a: yRot -= 5.0f; break;
case SDLK_d: yRot += 5.0f; break;
- case SDLK_UP: move_forward(&camera, 0.5f); break;
- case SDLK_DOWN: move_forward(&camera, -0.5f); break;
- case SDLK_LEFT: rotate_local_y(&camera, 0.1f); break;
- case SDLK_RIGHT: rotate_local_y(&camera, -0.1f); break;
+ case SDLK_UP: glframe_move_forward(&camera, 0.5f); break;
+ case SDLK_DOWN: glframe_move_forward(&camera, -0.5f); break;
+ case SDLK_LEFT: glframe_rotate_local_y(&camera, 0.1f); break;
+ case SDLK_RIGHT: glframe_rotate_local_y(&camera, -0.1f); break;
default: break;
}
}
@@ -181,13 +180,13 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag)
yRot += 5.0f;
if (keys_held[SDLK_UP])
- move_forward(&camera, 0.05f);
+ glframe_move_forward(&camera, 0.05f);
if (keys_held[SDLK_DOWN])
- move_forward(&camera, -0.05f);
+ glframe_move_forward(&camera, -0.05f);
if (keys_held[SDLK_LEFT])
- rotate_local_y(&camera, 0.02f);
+ glframe_rotate_local_y(&camera, 0.02f);
if (keys_held[SDLK_RIGHT])
- rotate_local_y(&camera, -0.02f);
+ glframe_rotate_local_y(&camera, -0.02f);
}
xRot = (GLfloat) ((const int) xRot % 360);
@@ -246,7 +245,7 @@ static void render(void)
/* save the matrix state and do the rotations */
glPushMatrix();
/* apply camera transform, and draw the ground */
- apply_camera_transform(&camera);
+ glframe_apply_camera_transform(&camera);
glColor3ub(255, 0, 255);
gltDrawGround();