Logo

¡Bienvenido a Stratos!

Acceder

Foros



[OpenGL + SDL] Multitextura o textura-color

Iniciado por kittie4man, 24 de Abril de 2008, 10:00:48 PM

« anterior - próximo »

kittie4man

Hola!!

Recien estoy empezando con opengl y leyendo los tutoriales de nehe no me quedo claro el tema de la multitextura.
Mi objetivo es hacer un cubo y solo en la cara frontal ponerle textura. En el resto de las caras iria solo un color.
Si alguien me puede explicar algo sobre multitextura o textura-color se lo voy a agradecer.

Salu2 y gracias
Juan Pablo

Prompt

Para lo que dices no es necesario la multi-texturización. Ya que dices 1 textura en la cara frontal.

Cuando haces glBegin(GL_TRIANGLES)... en la cara frontal cuando poner glVertex, glNormal y glTexCoord añade glBindTexture.


glBegin(GL_TRIANGLES)

...

// Cara frontal
glBindTexture( ... )
glVertex3f
glNormal3f
glTexCoord

...

// Cierras el bind y sigue con las demás caras



Mira a ver si funciona y ya nos cuentas :)

kittie4man

Cita de: PromptPara lo que dices no es necesario la multi-texturización. Ya que dices 1 textura en la cara frontal.

Cuando haces glBegin(GL_TRIANGLES)... en la cara frontal cuando poner glVertex, glNormal y glTexCoord añade glBindTexture.


glBegin(GL_TRIANGLES)

...

// Cara frontal
glBindTexture( ... )
glVertex3f
glNormal3f
glTexCoord

...

// Cierras el bind y sigue con las demás caras



Mira a ver si funciona y ya nos cuentas :)

Muchas gracias por la respuesta.
Me gustaría, si podes, que mires mi código y me digas que esta mal, ya que para el resto de las caras no eh podido sacar la textura.
Probé sacando el "glTexCoord2f" y directamente me desaparece la textura.
Creo que debo tener problemas en la inicialización de OpenGL; algún parámetro que me falta o algo así.

glBegin(GL_QUADS);
// Front Face
glBindTexture( GL_TEXTURE_2D, tCube );
glNormal3f( 0.0f, 0.0f, 0.0f );
glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f,  1.0f ); // Bottom Right Of The Texture and Quad
glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f,  1.0f ); // Bottom Left Of The Texture and Quad
glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f,  1.0f ); // Top Left Of The Texture and Quad
glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f,  1.0f ); // Top Right Of The Texture and Quad
glEnd();

glBegin(GL_QUADS);
glColor3f( 1.0f, 1.0f, 0.0f);
glNormal3f( 0.0f, 0.0f, 0.0f );
// Back Face
glVertex3f( 1.0f, -1.0f, -0.001f ); glTexCoord2f(0.0f, 0.0f); // Bottom Left Of The Texture and Quad
glVertex3f(-1.0f, -1.0f, -0.001f ); glTexCoord2f(1.0f, 0.0f); // Bottom Right Of The Texture and Quad
glVertex3f(-1.0f,  1.0f, -0.001f ); glTexCoord2f(1.0f, 1.0f); // Top Right Of The Texture and Quad
glVertex3f( 1.0f,  1.0f, -0.001f ); glTexCoord2f(0.0f, 1.0f); // Top Left Of The Texture and Quad
// Top Face
glVertex3f( -1.0f,  1.0f, -0.001f ); glTexCoord2f( 0.0f, 1.0f ); // Top Left Of The Texture and Quad
glVertex3f( -1.0f,  1.0f,  1.0f   ); glTexCoord2f( 0.0f, 0.0f ); // Bottom Left Of The Texture and Quad
glVertex3f(  1.0f,  1.0f,  1.0f   ); glTexCoord2f( 1.0f, 0.0f ); // Bottom Right Of The Texture and Quad
glVertex3f(  1.0f,  1.0f, -0.001f ); glTexCoord2f( 1.0f, 1.0f ); // Top Right Of The Texture and Quad
// Bottom Face
glVertex3f( -1.0f, -1.0f, -0.001f ); glTexCoord2f( 1.0f, 1.0f ); // Top Right Of The Texture and Quad
glVertex3f(  1.0f, -1.0f, -0.001f ); glTexCoord2f( 0.0f, 1.0f ); // Top Left Of The Texture and Quad
glVertex3f(  1.0f, -1.0f,  1.0f   ); glTexCoord2f( 0.0f, 0.0f ); // Bottom Left Of The Texture and Quad
glVertex3f( -1.0f, -1.0f,  1.0f   ); glTexCoord2f( 1.0f, 0.0f ); // Bottom Right Of The Texture and Quad
// Right face
glVertex3f( 1.0f, -1.0f, -0.001f ); glTexCoord2f( 1.0f, 0.0f ); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0f,  1.0f, -0.001f ); glTexCoord2f( 1.0f, 1.0f ); // Top Right Of The Texture and Quad
glVertex3f( 1.0f,  1.0f,  1.0f   ); glTexCoord2f( 0.0f, 1.0f ); // Top Left Of The Texture and Quad
glVertex3f( 1.0f, -1.0f,  1.0f   ); glTexCoord2f( 0.0f, 0.0f ); // Bottom Left Of The Texture and Quad
// Left Face
glVertex3f( -1.0f, -1.0f, -0.001f ); glTexCoord2f( 0.0f, 0.0f ); // Bottom Left Of The Texture and Quad
glVertex3f( -1.0f, -1.0f,  1.0f   ); glTexCoord2f( 1.0f, 0.0f ); // Bottom Right Of The Texture and Quad
glVertex3f( -1.0f,  1.0f,  1.0f   ); glTexCoord2f( 1.0f, 1.0f ); // Top Right Of The Texture and Quad
glVertex3f( -1.0f,  1.0f, -0.001f ); glTexCoord2f( 0.0f, 1.0f ); // Top Left Of The Texture and Quad
glEnd();


Por las dudas; el opengl lo inicio así:
void cEngine::init_gl(){
glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &maxTexelUnits );

glEnable( GL_TEXTURE_2D );
glShadeModel(GL_SMOOTH);
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f); //LIMPIAR CON FONDO NEGRO
// glClearColor( 255.0f, 255.0f, 255.0f, 255.0f); //LIMPIAR CON FONDO BLANCO
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

   glEnable( GL_COLOR_MATERIAL ); // Enable Material Coloring
}

void cEngine::resizeWindow(){
   GLfloat ratio;

   ratio = ( GLfloat )SCREEN_WIDTH / ( GLfloat )SCREEN_HEIGHT;
   glViewport( 0, 0, ( GLint )SCREEN_WIDTH, ( GLint )SCREEN_HEIGHT );
   glMatrixMode( GL_PROJECTION );
   glLoadIdentity( );
   gluPerspective( 45.0f, ratio, 0.1f, 100.0f );
   glMatrixMode( GL_MODELVIEW );
   glLoadIdentity( );
}


Alguna recomendación para que el aprendizaje de OpenGL sea mas rápido y fácil?? Algun manual que conozcas o hallas hecho? pagina? etc?

Salu2 y muchas gracias
Juan Pablo






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.
Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.