Added texture loading and displaying for 3D models

This commit is contained in:
trotFunky 2019-09-30 19:20:10 +02:00
parent 8275ae3109
commit 6dc94de9f8
4 changed files with 89 additions and 8 deletions

View file

@ -9,6 +9,7 @@
volatile unsigned long long int timer_ticks = 0;
static Texture tree_texture;
static Model3D raptor;
static Texture raptor_texture;
void display()
{
@ -22,7 +23,7 @@ void display()
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(10, 10, 10,
gluLookAt(7.5, 7.5, 7.5,
0, 0, 1,
0, 1, 0);
@ -33,7 +34,10 @@ void display()
display_tree(0,-5,0,3,5,tree_texture);
glPushMatrix();
glRotatef(angleY,0,-1,0);
raptor.draw_model();
glPopMatrix();
glutSwapBuffers();
}
@ -75,7 +79,16 @@ int main(int argc, char** argv)
glBindTexture(GL_TEXTURE_2D,tree_texture.opengl_id[0]);
gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,tree_texture.width,tree_texture.height,GL_RGBA,GL_UNSIGNED_BYTE,tree_texture.image_data);
// Load and generate raptor texture
raptor_texture.load_rgb_tga("resources/RAPTOR.tga");
glGenTextures(1, raptor_texture.opengl_id);
// TODO : Put in the Texture class
glBindTexture(GL_TEXTURE_2D, raptor_texture.opengl_id[0]);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB8, raptor_texture.width, raptor_texture.height, GL_RGB, GL_UNSIGNED_BYTE, raptor_texture.image_data);
raptor.load_ascii_off_file("resources/RAPTOR.off");
raptor.assign_texture(raptor_texture);
raptor.set_scaling(0.01,0.01,0.01);
raptor.set_rotation(-90,1,0,0);