Problem with textures on Quads, Swapfile getting bigger and bigger
Hi all.
I have two problems which i hope u can help me with.
To make it simple i'll cut the whole code down a bit.
//we simply presume that texsez is a float with different info in each area and
//that locnum is 24, so it draws two quads,and respectivly needs two textures
//infochar is simply a filename (2 different ones) (infochar[0] and infochar[1])
GLuint texture[2];
int LoadGLTextures(int texnr)
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage[1];
memset(TextureImage,0,sizeof(void *)*1);
if (TextureImage[0]=LoadBMP(infochar[texnr]))
{
Status=TRUE;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture[texnr]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
if (TextureImage[0])
{
if (TextureImage[0]->data)
{
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
return Status;
}
int DrawGLScene(double i)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-0.0f,-2.0f,-20.0f);
for (int texzez=0,texz=0;texzez<locnum;texz++){
if (!LoadGLTextures(texz)){return FALSE;}
glBegin(GL_QUADS);
glVertex3f(infonum[texzez], infonum[texzez+1], infonum[texzez+2]);
glVertex3f(infonum[texzez+3], infonum[texzez+4], infonum[texzez+5]);
glVertex3f(infonum[texzez+6],infonum[texzez+7], infonum[texzez+8]);
glVertex3f(infonum[texzez+9],infonum[texzez+10], infonum[texzez+11]);
texzez=texzez+12;
glEnd();
}
here are my problems:
1) I was running my program and wanted to quit. It crashed on me, i started it again and noticed that my swap file is increasing at 3mb/sec with no end in sight. Why? I clear all of it when the loop runs through again right?
2) My textures arent displayed correctly, it just takes the "main" color of the bitmap, and the quad, related to the bitmap, is only of one color. But the program has recognised which textures belong to which quad, since they are differnt colors. (one only brown, one only blue). Why? Ive tried tweaking and adjusting, tried converting the bitmaps, but it doesnt work. The bitmaps are of the same sizes and settings as the tutorial told me. Sorry for being so noobish,ive tried about a long time on this problem alone and am getting really frustrated.
1. You only need to call LoadGLTextures once per program, i.e. don't call it every frame as you're uploading a texture to the graphics card every time you call it and when you run out of space it uses your main memory then your swap file and I think you have seen what that does. ;)
In other words, call LoadGLTextures once at the start of your program, usually after you initialize OpenGL, then when you want to use that texture again just call glBindTexture. Have a look at this thread, there's a link to "The Red Book" and "The Blue Book", they should help you no end.
2. I don't get what you're saying here, try taking a screenshot and posting a picture with some clarification. If you need hosting for the picture then check the thread I sent you too in the last answer.
Hope that helps!
In other words, call LoadGLTextures once at the start of your program, usually after you initialize OpenGL, then when you want to use that texture again just call glBindTexture. Have a look at this thread, there's a link to "The Red Book" and "The Blue Book", they should help you no end.
2. I don't get what you're saying here, try taking a screenshot and posting a picture with some clarification. If you need hosting for the picture then check the thread I sent you too in the last answer.
Hope that helps!
--
Cheers,
Darren Clark
Cheers,
Darren Clark
The Reason for the quads being 1 colour is that u havent given OpenGL Texture Coordinates to work with, Try adding glTexCoord2f like this
glTexCoord2f(0,0);
glVertex3f(infonum[texzez], infonum[texzez+1], infonum[texzez+2]);
glTexCoord2f(1,0);
glVertex3f(infonum[texzez+3], infonum[texzez+4], infonum[texzez+5]);
glTexCoord2f(1,1);
glVertex3f(infonum[texzez+6],infonum[texzez+7], infonum[texzez+8]);
glTexCoord2f(0,1);
glVertex3f(infonum[texzez+9],infonum[texzez+10], infonum[texzez+11]);
glTexCoord2f(0,0);
glVertex3f(infonum[texzez], infonum[texzez+1], infonum[texzez+2]);
glTexCoord2f(1,0);
glVertex3f(infonum[texzez+3], infonum[texzez+4], infonum[texzez+5]);
glTexCoord2f(1,1);
glVertex3f(infonum[texzez+6],infonum[texzez+7], infonum[texzez+8]);
glTexCoord2f(0,1);
glVertex3f(infonum[texzez+9],infonum[texzez+10], infonum[texzez+11]);
----------------------------http://djoubert.co.uk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement