added wall,collision missing
This commit is contained in:
parent
2b2d58e904
commit
90f4b64af8
BIN
data/wall.tga
Normal file
BIN
data/wall.tga
Normal file
Binary file not shown.
130
src/main.cpp
130
src/main.cpp
@ -536,6 +536,134 @@ void explosion_callback(double x, double y, double z) {
|
||||
explosion.add(x, y, z);
|
||||
}
|
||||
|
||||
GLuint wallTex = 0;
|
||||
|
||||
void draw_box() {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, wallTex);
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
|
||||
if (wallTex == 0) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glfwLoadTexture2D("data/wall.tga", 0);
|
||||
}
|
||||
|
||||
GLfloat red[] = { 0.1f, 0.2f, 0.3f, 1.0f };
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
|
||||
// Enable/Disable features
|
||||
glPushAttrib( GL_ENABLE_BIT);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
//glDisable( GL_DEPTH_TEST);
|
||||
// glEnable( GL_LIGHTING);
|
||||
// glDisable( GL_BLEND);
|
||||
glMatrixMode( GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslated(2000.0, 0.0, 0.0);
|
||||
//glScaled(5000.0f, 5000.0f, 5000.0f);
|
||||
float s = 2500.0;
|
||||
// Just in case we set all vertices to white.
|
||||
glColor4f(1, 1, 1, 1);
|
||||
|
||||
// Render the front quad
|
||||
// glBindTexture(GL_TEXTURE_2D, _skybox[0]);
|
||||
glBegin( GL_QUADS);
|
||||
|
||||
glTexCoord2f(0, 0);
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
glVertex3f(s, -s, -s);
|
||||
|
||||
glTexCoord2f(0, 1);
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
glVertex3f(s, s, -s);
|
||||
glTexCoord2f(1, 1);
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
glVertex3f(-s, s, -s);
|
||||
|
||||
glTexCoord2f(1, 0);
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
glVertex3f(-s, -s, -s);
|
||||
|
||||
glEnd();
|
||||
|
||||
// Render the left quad
|
||||
// glBindTexture(GL_TEXTURE_2D, _skybox[1]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex3f(s, -s, s);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex3f(s, s, s);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex3f(s, s, -s);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex3f(s, -s, -s);
|
||||
glEnd();
|
||||
|
||||
// Render the back quad
|
||||
// glBindTexture(GL_TEXTURE_2D, _skybox[2]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex3f(-s, -s, s);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex3f(-s, s, s);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex3f(s, s, s);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex3f(s, -s, s);
|
||||
|
||||
glEnd();
|
||||
|
||||
// Render the right quad
|
||||
// glBindTexture(GL_TEXTURE_2D, _skybox[3]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex3f(-s, -s, -s);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex3f(-s, s, -s);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex3f(-s, s, s);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex3f(-s, -s, s);
|
||||
glEnd();
|
||||
|
||||
// Render the top quad
|
||||
//glBindTexture(GL_TEXTURE_2D, _skybox[4]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex3f(-s, s, -s);
|
||||
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex3f(s, s, -s);
|
||||
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex3f(s, s, s);
|
||||
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex3f(-s, s, s);
|
||||
|
||||
glEnd();
|
||||
|
||||
// Render the bottom quad
|
||||
//glBindTexture(GL_TEXTURE_2D, _skybox[5]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex3f(-s, -s, -s);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex3f(-s, -s, s);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex3f(s, -s, s);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex3f(s, -s, -s);
|
||||
glEnd();
|
||||
|
||||
// Restore enable bits and matrix
|
||||
glPopAttrib();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
class Application {
|
||||
public:
|
||||
void initialize(int argc, char ** argv);
|
||||
@ -728,6 +856,8 @@ void Application::update() {
|
||||
for (size_t i = 0; i < GAME_POINT_COUNT; i++)
|
||||
draw_point(&game.point[i]);
|
||||
|
||||
draw_box();
|
||||
|
||||
glDisable(GL_LIGHT0);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
Loading…
Reference in New Issue
Block a user