Archived

This topic is now archived and is closed to further replies.

UponTheEnd

White Textures

Recommended Posts

I have a engine i am working on and it has a pretty advance texturing loading system in it. I have been testing it lately and after i debugged most of the run-time errors, i was left with a white texture I have gl-texture-2d enabled, i have all the data from the bitmap so i know i am loading the right file and i am actually loading it. I regiestered it with opengl and did all that no problem. and i even used the gltexcoord stuff. everything i need is there i belive. appearantly it isnt beacuse it isnt working I was wandering if anyone could throw out some guesses why this is, it just a white quad right now..... I would post the code but it is very large. if you really need it. post and i will send it to you. thanks alot

Share this post


Link to post
Share on other sites
Hello.

Thanks for the replys.

I checked to make sure and i am not using mipmaps for the texturing.

Any other ideas of what it could be?

Thanks

Share this post


Link to post
Share on other sites
What do you mean by enabling texturing?

Is there something else besides glEnable(GL_TEXTURE_2D);?

Also my texture is 128 by 128..

Share this post


Link to post
Share on other sites
I am desperate.

It is probley going to be something very simple that i missed..

Ok.. when you open the project, the relevant code is in image.h and texture.h and engine.h

the rest is just for planning....

ok here is the link:

http://www.geocities.com/cscoding/Engine.zip

if it doesnt work or it says you dont have access or something, just post a reply. and i will change to a different server.

thanks for the replys

Share this post


Link to post
Share on other sites
Use "glGetError()" (or something like that ?) after each glXXX call until you get a fail. Then you know which call failed. You will probably get "invalid parameter" or something as equally useful, but at least you know what line is stuffing up.
White texture = gl error.

Share this post


Link to post
Share on other sites
Hi,

I think the error is in your loading function LoadBMPData().
using this (image.h, line 169):
Data = Image[0]->data;
you copy a pointer, not the entire data. And after you free that data. That''s why you get a blank image. You should use memcopy instead or don''t free the data.

Share this post


Link to post
Share on other sites
Thanks for the reply.

That is more than likely an error also. But i am not calling that function when i am loading the image. i am just calling LoadBMP(); from Image.h

I dont think the error is in the loading code. Something about drawing it. Because when i look at the data structure for the file, everything seems to be find including the data. So can you check the opengl stuff to make sure i am not missing anything crucial, like maybe i am not enabling a state that needs to be enabled for texturing. That stuff would be in Engine.h at the top


Thanks

Share this post


Link to post
Share on other sites
You are generating textures in a wrong way. Check second parameter to glGenTexture. It should not be just some number but memory adress of loaded texture.

Share this post


Link to post
Share on other sites
I looked at what you said Plega,i didnt see anything wrong with that.

Can you go further on what you meant?

Wouldnt this work though?

unsigned int ID;

glGenTextures(1, &Id);

?

Thanks for the reply

Share this post


Link to post
Share on other sites
Sorry for not going thoroughly trough your code. Here is easier example:

Define space for texture and then generate it:
GLuint texture[1];
.
.
.
glGenTextures(1, &texture[0]);

Ok, now if you debug trough this code you would find that texture[0] has value 1 just like your ID but in your code you are just creating new variable ID and later give it value 1. You are not using array where you actually loaded texture. Then when you pass that to glGenTexture you actually don''t pass texture in memory but just some variable.
So find in your code array where you loaded texture and pass it to glGenT. like in example above.

Pretty confusing, I know . I''ll try to explain it some more if you have any more questions.
Hope I was helpful.

Share this post


Link to post
Share on other sites
I understood what you said in the example but why is that?

Also i did what you said and nothing changed.. I am probley doing something wrong because you probley tried to compile it and it worked for you..

Here is the link to the stuff i changed.

http://www.geocities.com/cscoding/RevisedEngine.zip

Thanks alot for sticking with me..

Share this post


Link to post
Share on other sites
I had the same problem, the routine worked on the examples I studied but not on my own images...

Are you sure that your images have power of 2 dimensions and 16M colors??

THAT was my problem...

---------------------------------------
There are 10 type of people:
those who knows binary code
and those who doesn''t
---------------------------------------

Share this post


Link to post
Share on other sites
I have been studying your problem for a while now and think I have found a solution. I believe you have serious scoping issues with all the pointers you are returning from your static get functions and such. The code that is supposed to initialize Sky at line 115 of Engine.h appears to be the immediate problem.

Sky = CTexture::Get()->LoadTexture("Data/Sky.bmp");

This is fine; Sky get''s what it is supposed to...for this function. But what happens when the function ends? I''m pretty sure that the anonymous object you send back to initialize Sky is going out of scope at the end of the function. When this happens, it''s destructor is called and the texture you just loaded is gone. Doesn''t matter if Sky still has the ID -- glDeleteTextures was called.

In playing with your code, I got rid of the destructor for CFileInfo and I saw the image just fine, so it''s a pretty good bet that is your problem.

btw, although I don''t think this is your immediate problem, you should look into overloading operators and making deep (rather than shallow) copies of objects as soon as possible.

Share this post


Link to post
Share on other sites
I am at school right now and cant try what you said about the destructor but i am sure it works. it makes perfect sense

Thanks alot

You talked about operator overloading, why would i need this for depth?

argg. dumb mistake on my part and it costed me about 4 days of nothing. errr

usually with singletons i pass in the object as a reference and just fill it in so there is no return value. But i thought the functions were getting too clutered and it just wasnt working with the pointer issues, so i changed it to a return value and looked what it got me! Heheh

Oh well, another lesson learned. Thanks very much

Share this post


Link to post
Share on other sites