PDA

View Full Version : Texture problem



Vlasko
07-27-2001, 02:18 AM
I have a problem with texture not showing on the cube

code:
void LoadGLTextures()
{ AUX_RGBImageRec *text;
if(!(text=auxDIBImageLoad("RedStar.bmp"))) printf("error");
glGenTextures(1,&texturename[1]);
glBindTexture(GL_TEXTURE_2D,texturename[0]);
glTexImage2D(GL_TEXTURE_2D,0,3,text->sizeX,text->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,text->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
}

part of display code

glBindTexture(GL_TEXTURE_2D,texturename[0]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f,1.0f);
//glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-0.5f,0.5f,0.5f);
glTexCoord2f(0.0f,0.0f);
glVertex3f(-0.5f,-0.5f,0.5f);
glTexCoord2f(1.0f,0.0f);
glVertex3f(0.5f,-0.5f,0.5f);
glTexCoord2f(1.0f,1.0f);
glVertex3f(0.5f,0.5f,0.5f);

and GL_TEXTURE_2D is enabled

T2k
07-27-2001, 02:45 AM
glGenTextures(1,&texturename[1]);

should be:
glGenTextures(1,texturename);
or:
glGenTextures(1,&texturename[0]);
because you use the [0]th element of the array, so get a valid textureobj for it, and not for the next element in the array ...

Vlasko
08-02-2001, 08:51 AM
i have fixed that but still the same - no texture on cube

T2k
08-02-2001, 11:53 PM
sorry, cant see any other errors, maybe the bmp is not loaded, or the dimensions of the texture are not n^2, or you call the binds between glBegin(); glEnd(); ...
try to use a 1d texture, and use as data some array like:
data[8]= { 0, 1, and so on
when it work, your bmp isnt loaded correct or in the correct dimensions

Vlasko
08-03-2001, 03:07 AM
bitmap is 128*128 I created it .
and there is testing for file load
but i will try it your way

ffish
08-03-2001, 05:59 AM
Send the app and texture to me (e-mail in profile, remove "nospam") if you like and I'll have a look on Sunday Australian time (day after tomorrow). It could be a number of things.

Hope that helps.

08-03-2001, 07:56 PM
you wouldnt be fred fish would you from the classic amiga collecion of PD discs?

ffish
08-04-2001, 06:36 AM
No, sorry http://www.opengl.org/discussion_boards/ubb/biggrin.gif

ffish
08-07-2001, 04:59 AM
Vlasko,

I tried to e-mail the code to you but it didn't work so here are my changes:

(i) You must put your init() function after all the GLUT initialisation code, in the line after glutCreateWindow. This is why the texture wasn't being bound properly.

(ii) The depth testing you are doing is making other problems with the display. Comment out the two lines in your init() function that enable depth testing and the depth func to use.

(iii) There are other problems with the program but making those two changes will get you started. If you have any other questions post them and someone will be glad to help.

E-mail me if you need any more help with this program or you don't understand my explanations.

Hope that helps.

Vlasko
08-13-2001, 10:23 AM
Thanks It works :-)but I get now problem with rotating the yellow part of texture disappears when I rotate cube . It's a problem with graphics card or something else (like VC++ 6.0 ... )I'm using CL 5446 as primary graphics card( crapy but I'll try Voodoo 2 (crapy too - but still works) later