int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[10]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit
if ((TextureImage[0]=LoadBMP("images/tiles01b.bmp")) &&
(TextureImage[1]=LoadBMP("images/tiles02b.bmp")) &&
(TextureImage[2]=LoadBMP("images/tiles03b.bmp")) &&
(TextureImage[3]=LoadBMP("images/tiles04b.bmp")) &&
(TextureImage[4]=LoadBMP("images/tiles05b.bmp")) &&
(TextureImage[5]=LoadBMP("images/tiles07b.bmp")) &&
(TextureImage[6]=LoadBMP("images/tiles08b.bmp")) &&
(TextureImage[7]=LoadBMP("images/tiles09b.bmp")) &&
(TextureImage[8]=LoadBMP("images/tiles10b.bmp")) &&
(TextureImage[9]=LoadBMP("images/tiles11b.bmp")))
{
Status=TRUE; // Set The Status To TRUE
for (int index = 0; index <=9; index++) // loop for all textures
{
glGenTextures(1, &texture[index]); // Create one Texture at given texture[]
// Create Non Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[index]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
// glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[index]->sizeX, TextureImage[index]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[index]->data);
}
}
for (int index = 0; index <=9; index++) // loop for all textures
{
if (TextureImage[index]) // If Texture Exists
{
if (TextureImage[index]->data) // If Texture Image Exists
{
free(TextureImage[index]->data); // Free The Texture Image Memory
}
free(TextureImage[index]); // Free The Image Structure
}
}
return Status; // Return The Status
}
For some reason, it seems that because I am using textures the way I am using them, the text just doesn''t display. I have commented out that one line and the text shows, when I already comment out my DrawGLScene. If either that line or my drawglscene function is uncommented, the text will not show. It just seems like I can''t use this method of drawing text and use textures for drawing at the same time, is this true?
Tutorial #13 related problem(text)
I am making a tile based game. I am trying to test out some text output using the methods in tutorial #13, but it won''t work. I have isolated one line of code in my program that when removed allows the text to display. It is a line in my LoadGLTextures() function:
The line is shown commented out, but I should mention, the line I comment out is:
I have also tried
And it still doesn't print unless I comment out that line. Any ideas?
[edited by - john dowis on September 8, 2003 12:24:28 AM]
[edited by - john dowis on September 8, 2003 12:51:58 AM]
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[index]->sizeX, TextureImage[index]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[index]->data);
I have also tried
glDisable(GL_TEXTURE_2D); glRasterPos2f(0,0);glPrint("Here is some text"); // Print GL Text To The ScreenglEnable(GL_TEXTURE_2D);
And it still doesn't print unless I comment out that line. Any ideas?
[edited by - john dowis on September 8, 2003 12:24:28 AM]
[edited by - john dowis on September 8, 2003 12:51:58 AM]
Are the textures in the power of 2? (128, 256, 512, etc)
Maybe you should try gluBuild2DMipmaps(*), it will resize the texture for you. If the textures are not to the power of 2, glTexImage2D(*) will not work.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
Maybe you should try gluBuild2DMipmaps(*), it will resize the texture for you. If the textures are not to the power of 2, glTexImage2D(*) will not work.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
They are 512x512. This is a fully functional map editor, everything in it works great, but now I am trying to add the text and things just don't seem to work together or something. The textures have been loading and displaying perfectly. If I don't comment anything out, everything looks fine, I just don't see the text I am trying to draw.
[edited by - john dowis on September 9, 2003 1:35:54 AM]
[edited by - john dowis on September 9, 2003 1:35:54 AM]
This line, I think that it means to allocate the memory for one texture. Right ?
So, shouldn't be : (?)
Another question. How do you do for insterting CPP file into a topic ? Wich param is it ?
========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
[edited by - Leyder Dylan on September 9, 2003 5:40:06 AM]
memset(TextureImage,0,sizeof(void *)*1);
So, shouldn't be : (?)
memset(TextureImage,0,sizeof(void *)*10);
Another question. How do you do for insterting CPP file into a topic ? Wich param is it ?
========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
[edited by - Leyder Dylan on September 9, 2003 5:40:06 AM]
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
If you mean the little code windows, just type it or copy-paste, and type [*source][*/source] tags around it, without the *.
[edited by - john dowis on September 9, 2003 11:06:52 AM]
[edited by - john dowis on September 9, 2003 11:06:52 AM]
For those interested, I fixed it. I had to clear the depth buffer before drawing. So it was like this:
clear screen and depth buffer
draw my scene
clear depth buffer
disable textures
draw text
enable textures
[edited by - john dowis on September 9, 2003 12:47:11 PM]
clear screen and depth buffer
draw my scene
clear depth buffer
disable textures
draw text
enable textures
[edited by - john dowis on September 9, 2003 12:47:11 PM]
Yea...
memset(TextureImage,0,sizeof(void *)*1);
should be:
memset(TextureImage,0,sizeof(void *)*10);
Edit: it worked without changing this?
[edited by - durran21 on September 9, 2003 12:48:15 PM]
memset(TextureImage,0,sizeof(void *)*1);
should be:
memset(TextureImage,0,sizeof(void *)*10);
Edit: it worked without changing this?
[edited by - durran21 on September 9, 2003 12:48:15 PM]
I changed it just now for good measure, having read some things. Plus, there is more to this than just clearing the depth buffer. Something wierd.
I am not sure exactly what I did, but at one point the text started printing with that one texture line NOT commented out, and this was after I had changed some things. The problem is, I am not sure exactly what was changed, although I did change the line that was suggested (memset line), but I changed it back before I ran the program for the run that worked.
Ok, I am not really sure what that means, or how that is possible, but maybe changing that memset for one execution, even though the text didn''t print, changed something in memory for the next time I ran it.
Kinda like how I ran it once with the texture line commented out and got the text, then the next time I ran it, with the lines that draw the text commented out, but accidently forgot to clear the screen each loop. The text was still in the video memory from the last time I ran the program, even though my screen was flashing funny, the text was still visible on the screen, despite the fact that nowhere in my code was anything being drawn, including the text!
All I know is it works now, and I can''t be 100% sure why. Kinda makes me nervous. But I am tesing out NeHe''s tutorial 17 method now anyway, so maybe it won''t matter
I am not sure exactly what I did, but at one point the text started printing with that one texture line NOT commented out, and this was after I had changed some things. The problem is, I am not sure exactly what was changed, although I did change the line that was suggested (memset line), but I changed it back before I ran the program for the run that worked.
Ok, I am not really sure what that means, or how that is possible, but maybe changing that memset for one execution, even though the text didn''t print, changed something in memory for the next time I ran it.
Kinda like how I ran it once with the texture line commented out and got the text, then the next time I ran it, with the lines that draw the text commented out, but accidently forgot to clear the screen each loop. The text was still in the video memory from the last time I ran the program, even though my screen was flashing funny, the text was still visible on the screen, despite the fact that nowhere in my code was anything being drawn, including the text!
All I know is it works now, and I can''t be 100% sure why. Kinda makes me nervous. But I am tesing out NeHe''s tutorial 17 method now anyway, so maybe it won''t matter

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement