if (ImportVTX(filename) == FALSE)
{
return FALSE;
}
glGenTextures(1, &Texture[NumTextures]);
glBindTexture(GL_TEXTURE_2D, Texture[NumTextures]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, tex.imgsizex, tex.imgsizey, 0, GL_RGB, GL_UNSIGNED_BYTE, imgdata); //Heh, Loaded
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
|
🔒 Locked
OGL: Odd Texture Problem
Advertisement
Original Post
In the intrest of speeding up texture loading, I developed my own file format/compileing tools for my current project. I am feeding the program Red, Green, Blue (RGB for short) componants.
However,
No matter what I do, I never get ANY colors other then Black and Red.
I am sure all the rest of my code is bug free. All except for the code below. Here is the code.
ImportVTX Loads the data into the "tex" structure.
imgdata a string of unsigned bytes (r, g, b, r, g, b, r, g, b.... and so on...)
I think it''s a error with glTexImage2D. This is not my area.
Thanks,
Steven
I'm only guessing, but is NumTextures a #define as the total number of textures you use in your program?
If so, then you need to swap NumTextures, in the code snippet you posted, for the texture id you want for the current texture you're binding.
e.g.
or something like that if you catch my drift...
..of course it's entirely possible that I've missed the point completely and this post if useless
Hope this helps. If not then post more code/flame me/wait for someone more knowledgeable to post*
Laters, Barry.
* delete as applicable
Edited by - poontardis on October 25, 2000 9:11:38 AM
If so, then you need to swap NumTextures, in the code snippet you posted, for the texture id you want for the current texture you're binding.
e.g.
|
or something like that if you catch my drift...
..of course it's entirely possible that I've missed the point completely and this post if useless
Hope this helps. If not then post more code/flame me/wait for someone more knowledgeable to post*
Laters, Barry.
* delete as applicable
Edited by - poontardis on October 25, 2000 9:11:38 AM
numtextures is a int used to define a texture array. So I can load all the textures at the beginning of a level instead of loading as I go.
The problem is my bitmaps come out looking like if you put GL_RED in instead of GL_RGB.
Does anyone know what the exact squence of pixels should be for a RGB texure? It should be R, G, B right?
If I give the program a texture that is totaly blue(00, 00, FF). I get Black. I give it white (00, 00, 00). I get light red. What makes things worse is if I change the border I get nothing BUT red.
It''s driveing me nuts!
The problem is my bitmaps come out looking like if you put GL_RED in instead of GL_RGB.
Does anyone know what the exact squence of pixels should be for a RGB texure? It should be R, G, B right?
If I give the program a texture that is totaly blue(00, 00, FF). I get Black. I give it white (00, 00, 00). I get light red. What makes things worse is if I change the border I get nothing BUT red.
It''s driveing me nuts!
Here is the more refined source.
I have gone from a red colored thing that looks sorta like my bitmap to a pure red screen. If I keep going at this rate my computer will explode before I fix this.
|
I have gone from a red colored thing that looks sorta like my bitmap to a pure red screen. If I keep going at this rate my computer will explode before I fix this.
Still No Good, I think I am going to rip out my Texture code and recode it. Maybe I have a small error no one sees.
Coding the bitmap loading yourself is a good exercise worth doing, but in the interests of your sanity (if you still can't get it working
):
PaulyG has code for loading targa images in and binding them to textures on his OpenGL webpage
Edited by - poontardis on October 27, 2000 5:07:18 AM
PaulyG has code for loading targa images in and binding them to textures on his OpenGL webpage
Edited by - poontardis on October 27, 2000 5:07:18 AM
Fixed it..
Had to do with glColor3f.
For some reason it''s was clashing with the texture.
Had to do with glColor3f.
For some reason it''s was clashing with the texture.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement