Discussion:
OpenGL glTexImage2D sometimes creates an opaque white texture ?
(too old to reply)
R.Wieser
2022-03-18 16:57:39 UTC
Permalink
Hello all,

I've been using OpenGL to show some scenery, and am adding textures (while
loading the models) using the glTexImage2D call (which takes raw pixels).

The problem is that just a few textures of the 80 I add turn out to be a
fully opaque white*. However, when I pre-load such a texture it turns out
fine.

* in the loaded model as well as in a debugging model in which I display all
loaded textures as squares in a grid (read: its not a problem just of the
model).

an glGetError call just after the glTexImage2D one always shows Zero (no
error)

And oh yeah, the effect seems to be static. I've ran the program a number
of times and even on different days (rebooting the 'puter) in between, but
its always the same textures that go wrong.

I've also tried to change the raw pixel data for all textures to fully
transparent just before calling glTexImage2D, but the opaque white textures
stayed - which seems to indicate that its really related to the glTexImage2D
call.

The question is, what can be causing it ?

Regards,
Rudy Wieser
R.Wieser
2022-03-20 10:29:49 UTC
Permalink
Post by R.Wieser
The problem is that just a few textures of the 80 I add turn out to be
a fully opaque white*. However, when I pre-load such a texture it turns
out fine.
Trying to isolate what circumstances cause it I found that putting just the
glTexImage2D inside a glNewlist, glEndlist pair causes the effect to happen.

Which is rather odd as I load all other, looking OK, images the exact same
way.

Also, glGetError keeps returning an OK status before and after calling each
of the above three functions.

I also checked if its actually the glTexImage2D function, by directly after
it using glGetTexImage. On most textures I get back what I offered to
glTexImage2D, but on the problematic ones the targtet "pixel" buffer doesn't
get touched - but still the glGetError call after the glGetTexImage one
returns an OK status ...

I have /no/ idea what is going on here. Help ?

Regards,
Rudy Wieser
R.Wieser
2022-03-21 11:16:26 UTC
Permalink
Post by R.Wieser
I have /no/ idea what is going on here. Help ?
After a few days of testing, trying to make sense of seemingly inconsistent
results, I found in which circumstances it happened and from there the why
of it. A quick succesfull "that means if I do {this} (a hack) my problem
should disappear" test seemed to confirm it. With that in hand looking at
the involved functions gave me lead on what to change to fix it.

Bottom line : creating textures within a displaylist (glNewList) and sharing
those textures with other displaylists comes with a few gotyas - none of
them described in the MSDN pages to the involved functions.

And ofcourse, looking back the problem and its solution do seem to be quite
obvious.

Regards,
Rudy Wieser

Loading...