glClear(GL_COLOR_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, ids[colorbuffer]);
glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, ids[normalbuffer]);
glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, ids[depthbuffer]);
SubSys_EnableShaderStage(shader_deferred);
// do the matrix stuff
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
glUniformMatrix4fv(si->loc[mvmatrix_loc], 1, GL_FALSE, modelview);
glGetFloatv(GL_PROJECTION_MATRIX, projection);
glUniformMatrix4fv(si->loc[pjmatrix_loc], 1, GL_FALSE, projection);
glPushMatrix();
glTranslatef(0.0f, 0.0f,0.0f);
// draw the spere at (0,0,0)
DisplaySphere();
glPopMatrix();
SubSys_DisableShaderStage();
glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0);
// and the code to render the sphere (ugly as crap :()
void DisplaySphere(vec3f32_t* pos) {
int r = 145; // TODO: variable
int lats = 30; // TODO: static
int longs = 30;// TODO: static
int16 i, j;
for(i = 0; i <= lats; i++) {
float32 lat0 = MATH_PI * (-0.5 + (float32) (i - 1) / lats);
float32 z0 = r * M_fsin(lat0);
float32 zr0 = r * M_fcos(lat0);
float32 lat1 = MATH_PI * (-0.5 + (float32) i / lats);
float32 z1 = r * M_fsin(lat1);
float32 zr1 = r * M_fcos(lat1);
// TODO: VBO
glBegin(GL_QUAD_STRIP);
for(j = 0; j <= longs; j++) {
float32 lng = 2 * MATH_PI * (float32) (j - 1) / longs;
float32 x = M_fcos(lng);
float32 y = M_fsin(lng);
glVertex3f(x * zr0 + pos->x, y * zr0 + pos->y, z0 + pos->z);
glVertex3f(x * zr1 + pos->x, y * zr1 + pos->y, z1 + pos->z);
}
glEnd();
}