White Textures

Started by
17 comments, last by UponTheEnd 20 years, 11 months ago
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.

Advertisement
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
"What we do in life, echos in eternity" -- Gladiator
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.
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
"What we do in life, echos in eternity" -- Gladiator
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.
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..
"What we do in life, echos in eternity" -- Gladiator
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
---------------------------------------
---------------------------------------There are 10 type of people:those who knows binary codeand those who doesn't---------------------------------------
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.
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

"What we do in life, echos in eternity" -- Gladiator

This topic is closed to new replies.

Advertisement