سؤال

Is there a way to initialize or reset an OpenGL texture with a solid color? I can use functions up to OpenGL 4.0 since I'd like to support notebook's Intel HD Graphics 4000.

هل كانت مفيدة؟

المحلول 3

Maybe you can use a framebuffer. You can link it with a texture and draw what you want on the framebuffer. If the fallback is in action, you clear the framebuffer to a color you want.

And then you draw the framebuffer as texture.

نصائح أخرى

If you unbind a texture from its unit/sampler object, it texture accesses will come out all white. So I suggest you simply add a uniform for color modulation. If you need a solid color, unbind the texture and set that color uniform to whatever you want.

But quite frankly, it sounds to me, like you want to reimplement the OpenGL fixed function pipeline, where you had a large bunch of switches to get your desired effects. We finally got rid of that, and now you want to reincarnate this bane?

Although you say you can use up to GL 4.0 (and you got some answers for that), I'd still like to point out that beginning with GL 4.4, there is also glClearTexImage().

The relevant OpenGL extension for this is ARB_clear_texture. Intel HD 4000 is said to support GL4.0, but with newer drivers, lots of extensions implementing extensions for 4.1, 4.2 and 4.3 level feautres have been adeed. However, I have not yet found any source claiming that Intel had started implementing 4.4 level features. The latest source I found is this OpenGL feature matrix from february 2014 showing that Intel des not yet support that feature. But I find it quite likely that this extension might be supported in future driver versions.

You can do that by copying your color data into the already created texture using glTexSubImage2D, and giving it the full textures dimensions. The different is that this doesn't create a new buffer but only updates it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top