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:
parent
9ba9ac64cb
commit
cfa5c5dd1b
@ -7,6 +7,7 @@
|
|||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include "LightBounce.h"
|
#include "LightBounce.h"
|
||||||
|
|
||||||
|
#include "math.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -15,6 +16,7 @@ using namespace std;
|
|||||||
#define SIZE 5
|
#define SIZE 5
|
||||||
#define STRIDE_MULTIPLIER 1.0;
|
#define STRIDE_MULTIPLIER 1.0;
|
||||||
#define ZOOM 12.0
|
#define ZOOM 12.0
|
||||||
|
#define ORB_RADIUS 1.5
|
||||||
|
|
||||||
LightBounceBox::LightBounceBox(LogoBox * lb,
|
LightBounceBox::LightBounceBox(LogoBox * lb,
|
||||||
float x, float y, float z,
|
float x, float y, float z,
|
||||||
@ -119,7 +121,25 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
|||||||
y += box_stride;
|
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_POLYGON_BIT); /* store CULL_FACE settings */
|
||||||
|
glPushAttrib(GL_ENABLE_BIT); /* store current GL_BLEND setting */
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
@ -139,7 +159,8 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
|||||||
|
|
||||||
LightBounce::~LightBounce()
|
LightBounce::~LightBounce()
|
||||||
{
|
{
|
||||||
glPopAttrib();
|
glPopAttrib(); /* restore old GL_BLEND setting */
|
||||||
|
glPopAttrib(); /* restore old CULL_FACE settings */
|
||||||
int sz = m_boxes.size();
|
int sz = m_boxes.size();
|
||||||
for (int i = 0; i < sz; i++)
|
for (int i = 0; i < sz; i++)
|
||||||
delete m_boxes[i];
|
delete m_boxes[i];
|
||||||
@ -176,6 +197,8 @@ void LightBounce::update()
|
|||||||
{
|
{
|
||||||
m_boxes[i]->draw();
|
m_boxes[i]->draw();
|
||||||
}
|
}
|
||||||
|
glTranslatef(m_orb_pos[0], m_orb_pos[1], m_orb_pos[2]);
|
||||||
|
glCallList(m_orb_dl);
|
||||||
}
|
}
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,9 @@ protected:
|
|||||||
LightBounceBoxComparator m_comparator;
|
LightBounceBoxComparator m_comparator;
|
||||||
vector<LightBounceBox *> m_boxes;
|
vector<LightBounceBox *> m_boxes;
|
||||||
LogoBox m_logoBox;
|
LogoBox m_logoBox;
|
||||||
|
GLfloat m_orb_pos[3];
|
||||||
|
GLfloat m_orb_dir[3];
|
||||||
|
GLuint m_orb_dl;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user