From 3b3ab9f68f2624b538509e1af9b3cba76308e4ee Mon Sep 17 00:00:00 2001 From: stojce Date: Wed, 6 Mar 2013 08:08:18 +0100 Subject: [PATCH] set texture binding of first render call only --- interface/src/Head.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index eb5c294105..1a7dc9a2d2 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -33,10 +33,12 @@ const float DECAY = 0.1; char iris_texture_file[] = "interface.app/Contents/Resources/images/green_eye.png"; -static vector iris_texture; +vector iris_texture; unsigned int iris_texture_width = 512; unsigned int iris_texture_height = 256; +GLUquadric *sphere = gluNewQuadric(); + Head::Head() { position.x = position.y = position.z = 0; @@ -79,6 +81,7 @@ Head::Head() Head::~Head() { // all data is primitive, do nothing + gluDeleteQuadric(sphere); } Head* Head::clone() const { @@ -345,12 +348,14 @@ void Head::render(int faceToFace, float * myLocation) glPopMatrix(); // Right Pupil - GLUquadric *sphere = gluNewQuadric(); - gluQuadricTexture(sphere, GL_TRUE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gluQuadricOrientation(sphere, GLU_OUTSIDE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iris_texture_width, iris_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &iris_texture[0]); + if (!sphere) { + sphere = gluNewQuadric(); + gluQuadricTexture(sphere, GL_TRUE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gluQuadricOrientation(sphere, GLU_OUTSIDE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iris_texture_width, iris_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &iris_texture[0]); + } glPushMatrix(); { @@ -391,7 +396,6 @@ void Head::render(int faceToFace, float * myLocation) glDisable(GL_TEXTURE_2D); } - gluDeleteQuadric(sphere); glPopMatrix(); }