View Full Version : image over an opengl app?
11-02-2003, 12:35 PM
ok, here is my problem:
I have got to put the cover of a magazine over an OpenGL application. This app is implemented over a weird library named "acu". What did i figured out? I did a scan of the cover, transformed it in an RGBA TGA and tried to make a transparent texture. My idea was to put the texture over the app, so the text was displayed and the rest of the image (with alpha == 0) was transparent. Here started the troubles: my texture just won't be displayed. Why? It is 512x512 so it isn't the notorious 2^someting problem. TEXTURE_2D is enable and the same piece of code works in a normal opengl context. I tried to figure out what the heck this "acu" lib doed, but so far no good. Anyone has ANY idea of what to do? i have also the
stuff running. I just have no clues.
I tried also to write the image PIXEL per PIXEL (weird, i know) bou the bit table looks somehow screwed up (i have a y++ for-cicle, but my pixels aren't just near one to another. They look like the are 20 lines away one from the others). So what can I do? I am quite desparate, so any help is well appreciated.
Thanks my friends, the Gunslinger
11-02-2003, 10:18 PM
there are a lot of possible reasons for which a texture probably won't be displayed, some of them:
- texturing enabled at all? (glEnable(GL_TEXTURE_2D)
- all texture environment settings are correct?
- maybe the call to glTexImage2D is not correct?
- maybe the geometrive primitive in which the textue should be drawed on is not visible at all due to depth test reasons, or wrong matrix settings, etc.
and so on. What I would do, I would render a screen sized quad with orthographic projection (look for glOrtho2D and gluOrth2D) without a texture, but colored, and make sure that this is visible, and after that, put the texture on it.. should be rather easy. If you already do that and it doesn't work (the quad is shown but not the texture), post your texturing related code.
11-03-2003, 01:03 AM
i tried the gluortho2d thing and yes i CAN see the black QUAD over the opengl application, but still no texture on it. Here in my code, but for what i can see it is 100% standard:
glScalef(1.2, 1.2, 0.0);
i am quite sure that i have actually loaded the texture (even if i'd like to know if there is a safe way to check that without using just a bunch of sucking printf). The same loader with the same image (and the same opengl chunk i have displayed above) works fine on another opengl app that i have writed all by myself.
Anyway, just to be sure i put also the texture generation code so maybe u can find what's wrong with it...
glGenTextures(1, &texture.texID); // Generate OpenGL texture IDs
glBindTexture(GL_TEXTURE_2D, texture.texID); // Bind Our Texture
if (texture.bpp==24) // Was The TGA 24 Bits
type=GL_RGB; // If So Set The 'type' To GL_RGB
glTexImage2D(GL_TEXTURE_2D, 0, type, texture.width, texture.height, 0, type, GL_UNSIGNED_BYTE, texture.imageData);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtered
well what more can i say, but thanks 4 the attention? maybe just the promise to offer u a beer if u stop here anytime http://www.opengl.org/discussion_boards/ubb/wink.gif
Bye the Gunslinger
11-03-2003, 04:45 AM
Try add this somewhere in your setup:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
By default, the texture environment is set to GL_MODULATE, which causes the texture color to blend with the color of the polygon. In this case, you are setting your color to black, so your quad will be black. (0,0,0 * any other color = 0,0,0)
You could also try setting the color of your quad to full white.
[This message has been edited by Deiussum (edited 11-03-2003).]
11-03-2003, 05:37 AM
thank u pals,
i managed to solve that without textures (man i love brute force http://www.opengl.org/discussion_boards/ubb/smile.gif ).
thanks to everybody the Gunslinger
11-03-2003, 01:20 PM
So what exactly now did you do?
11-04-2003, 03:24 AM
well i used the pixel table of the image to draw it pixel per pixel over the second application..
for (image height)
for (image width)
if (pixel is black)
draw single pixel
just to keep perf impact low i put that in a display list and that's all, no texture at all. no really smooth, but as long as it works...
bye bye the Gunslinger
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.