PDA

View Full Version : my texture 1D "don't want" to mapped, can you help me ?



airseb
01-16-2004, 04:02 AM
i just try to map a 1D texture and it display me a white triangle !i have a 16x1 texture
there is just a little bit of code :



#include <gl\GLAUX.h>
#include <gl\glut.h>
#include <gl\gl.h>
#include <gl\glext.h>
#include <iostream.h>

GLuint texname ;
float z=0 ;

#pragma comment(lib, "glaux.lib")

void init ()
{
AUX_RGBImageRec *texture1;
texture1 = auxDIBImageLoad("texture1D.bmp");//charge l'image

glGenTextures (1, &amp;texname) ;
glBindTexture (GL_TEXTURE_1D, texname) ;

//glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
/*glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);*/

glTexImage1D(GL_TEXTURE_1D, 0, 3, texture1->sizeX,
0, GL_RGB, GL_UNSIGNED_BYTE, texture1->data);//la texture n'a que une largeur pas d'hauteur

glEnable(GL_TEXTURE_1D) ;

}

void keyboard (unsigned char key, int x, int y)
{
switch (key)
{
case 'I' :
case 'i' :
z-=0.2 ;
glutPostRedisplay () ;
break ;
case 'O' :
case 'o' :
z+=0.2 ;
glutPostRedisplay () ;
break ;
}
}


void reshape (int w, int h)
{
glViewport (0, 0, w, h) ;
glMatrixMode (GL_PROJECTION) ;
glLoadIdentity () ;
glFrustum(-1.0 , 1.0, -1.0, 1.0, 5.0, 500.0); //perspective conique
glMatrixMode(GL_MODELVIEW); //la matrice active de modelisation/visualisation sera affectée
glLoadIdentity(); //charge la matrice identité

gluLookAt (0.0, 0.0, 15.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) ;
}

void display ()
{

//glPolygonMode (GL_FRONT_AND_BACK, GL_LINE) ;

glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
glBindTexture (GL_TEXTURE_1D, texname) ;
glPushMatrix ();
glTranslatef(0.0, 0.0, z) ;

glBegin (GL_TRIANGLES ) ;
glTexCoord1f(0.0) ; glVertex3f (-1.0, -1.0, 0.0) ;
glTexCoord1f(0.5) ; glVertex3f (0.5, 1.0, 0.0) ;
//glTexCoord2f(0.0, 1.0) ; glVertex3f (1.0, 1.0, 0.0) ;
glTexCoord1f(1.0) ; glVertex3f (1.0, -1.0, 0.0) ;
glEnd () ;

//glutSolidTeapot(0.8) ;
glPopMatrix ();

glutSwapBuffers() ;

}


void main (int argc, char** argv)
{
//char *version = (char*)glGetString(GL_VERSION);
//cout <<version<<endl ;
//cout<<"hello"<<endl ;
glutInit (&amp;argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;
glEnable( GL_DEPTH_TEST );
glClearColor (0.0, 0.7, 0.0, 0.0) ;

init () ;
glutReshapeFunc (reshape) ;
glutKeyboardFunc (keyboard) ;
glutDisplayFunc (display) ;
glutMainLoop () ;
}



[This message has been edited by airseb (edited 01-16-2004).]

Bob
01-16-2004, 04:21 AM
Default minification filter requires a full mipmap set for the texture to be valid. Change minification filter to a non-mipmapped filter, or generate a full mipmap set.

airseb
01-16-2004, 05:04 AM
thank you ! it works !