added crude orb, drawing in incorrect order

git-svn-id: svn://anubis/dwscr/trunk@106 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
josh 2008-11-14 00:28:45 +00:00
parent 9ba9ac64cb
commit cfa5c5dd1b
2 changed files with 27 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include <GL/glu.h>
#include "LightBounce.h"
#include "math.h"
#include <iostream>
#include <vector>
#include <algorithm>
@ -15,6 +16,7 @@ using namespace std;
#define SIZE 5
#define STRIDE_MULTIPLIER 1.0;
#define ZOOM 12.0
#define ORB_RADIUS 1.5
LightBounceBox::LightBounceBox(LogoBox * lb,
float x, float y, float z,
@ -119,7 +121,25 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
y += box_stride;
}
/* Set up the orb */
m_orb_pos[0] = m_orb_pos[1] = m_orb_pos[2] = 0.0f;
double theta = M_2_PI * ((double)rand() / (double)RAND_MAX);
double gamma = M_PI * ((double)rand() / (double)RAND_MAX);
m_orb_dir[0] = cos(theta) * sin(gamma);
m_orb_dir[1] = sin(theta) * sin(gamma);
m_orb_dir[2] = cos(gamma);
m_orb_dl = glGenLists(1);
glNewList(m_orb_dl, GL_COMPILE);
GLfloat mat[] = {1, 1, 0.2, 0.8};
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat);
GLUquadric * quad = gluNewQuadric();
gluQuadricNormals(quad, GL_TRUE);
gluSphere(quad, ORB_RADIUS, 16, 8);
glEndList();
glPushAttrib(GL_POLYGON_BIT); /* store CULL_FACE settings */
glPushAttrib(GL_ENABLE_BIT); /* store current GL_BLEND setting */
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -139,7 +159,8 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
LightBounce::~LightBounce()
{
glPopAttrib();
glPopAttrib(); /* restore old GL_BLEND setting */
glPopAttrib(); /* restore old CULL_FACE settings */
int sz = m_boxes.size();
for (int i = 0; i < sz; i++)
delete m_boxes[i];
@ -176,6 +197,8 @@ void LightBounce::update()
{
m_boxes[i]->draw();
}
glTranslatef(m_orb_pos[0], m_orb_pos[1], m_orb_pos[2]);
glCallList(m_orb_dl);
}
SDL_GL_SwapBuffers();
}

View File

@ -51,6 +51,9 @@ protected:
LightBounceBoxComparator m_comparator;
vector<LightBounceBox *> m_boxes;
LogoBox m_logoBox;
GLfloat m_orb_pos[3];
GLfloat m_orb_dir[3];
GLuint m_orb_dl;
};
#endif