Hi !
I need to draw a lot of textured cubes and spheres for a project (~3000).
I’m using glutSolidCube() and gluSphere() which let me draw all my primitives in 60 fps (VboMesh returns me 30 fps), but I can’t texture them…
I tried to bind an image with myImage.getTextureReference().bind(); but it doesn’t work.
Also, I’ve tried this solution :
But I get the same result, a black sphere/cube :
in setup :
ofImage myTexture;
myTexture.loadImage("texture.png");
in draw :
unsigned char* pixels = myTexture.getPixels();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0,GL_RGB, GL_UNSIGNED_BYTE, pixels);
glEnable(GL_TEXTURE_GEN_S); //enable texture coordinate generation
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, myTexture);
glutSolidCube(100);
glDisable(GL_TEXTURE_GEN_S); //enable texture coordinate generation
glDisable(GL_TEXTURE_GEN_T);
It get the same thing if I manually draw my cube like :
glBegin(GL_QUADS); /
// Top face (y = 100.0f)
glVertex3f( 100.0f, 100.0f, -100.0f);
glVertex3f(-100.0f, 100.0f, -100.0f);
glVertex3f(-100.0f, 100.0f, 100.0f);
glVertex3f( 100.0f, 100.0f, 100.0f);
// Bottom face (y = -100.0f)
glVertex3f( 100.0f, -100.0f, 100.0f);
glVertex3f(-100.0f, -100.0f, 100.0f);
glVertex3f(-100.0f, -100.0f, -100.0f);
glVertex3f( 100.0f, -100.0f, -100.0f);
// Front face (z = 100.0f)
glVertex3f( 100.0f, 100.0f, 100.0f);
glVertex3f(-100.0f, 100.0f, 100.0f);
glVertex3f(-100.0f, -100.0f, 100.0f);
glVertex3f( 100.0f, -100.0f, 100.0f);
// Back face (z = -100.0f)
glVertex3f( 100.0f, -100.0f, -100.0f);
glVertex3f(-100.0f, -100.0f, -100.0f);
glVertex3f(-100.0f, 100.0f, -100.0f);
glVertex3f( 100.0f, 100.0f, -100.0f);
// Left face (x = -100.0f)
glVertex3f(-100.0f, 100.0f, 100.0f);
glVertex3f(-100.0f, 100.0f, -100.0f);
glVertex3f(-100.0f, -100.0f, -100.0f);
glVertex3f(-100.0f, -100.0f, 100.0f);
// Right face (x = 100.0f)
glVertex3f(100.0f, 100.0f, -100.0f);
glVertex3f(100.0f, 100.0f, 100.0f);
glVertex3f(100.0f, -100.0f, 100.0f);
glVertex3f(100.0f, -100.0f, -100.0f);
glEnd();
Does anyone know how I could texture them ?
Thanks !