I want to generate a texture in code and then apply that to objects in my scene. Can someone point me to a code fragment that illustrates how in Irrlicht I can:
- use an arbitrary sized block of system memory as a texture
and
- apply a texture scale (in OpenGL terms) so that non-power of two textures appear to fill the texel space correctly.
I thought the render-to-texture example might help but that appears to be not quite what I need.
--Callum
Rendering dynamic textures
I could be mistaken but I don't think OpenGL lets you use textures that aren't powers of two. You just need to use a texture that's as big as or bigger than the texture you're trying to display and adjust the texture coordinates of the polygon so it only renders the portion of the texture that you're using.
-
- Posts: 277
- Joined: Thu Dec 15, 2005 6:11 pm
Actually, for some time now OGL has support for non power of two textures. Depending on the video card, it may be slower though. Some older cards don't support it though. It's still better to use the PO2 textures because they are better supported and quicker.bigfish wrote:I could be mistaken but I don't think OpenGL lets you use textures that aren't powers of two. You just need to use a texture that's as big as or bigger than the texture you're trying to display and adjust the texture coordinates of the polygon so it only renders the portion of the texture that you're using.
OP: Why can't you just use a correctly sized texture from the start instead of trying to resize it later??
If the graphics card supports non-power-of2 then you can use it in opengl.
Check for GL_ARB_texture_non_power_of_two.
To scale - you could always just adjust the texture coords - 200.0f/256.0f
As for dynamic uploading - I'm not sure how to do it in Irrlicht.
In plain OpenGL, after you've created your texture with glGenTextures(...) and glTexImage2D(...)
you can update part / all of that texture by using glTexSubImage2D
Check for GL_ARB_texture_non_power_of_two.
To scale - you could always just adjust the texture coords - 200.0f/256.0f
As for dynamic uploading - I'm not sure how to do it in Irrlicht.
In plain OpenGL, after you've created your texture with glGenTextures(...) and glTexImage2D(...)
you can update part / all of that texture by using glTexSubImage2D
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
In order to create a texture from some memory block you create an IImage from that area and create the texture from the image. If you just want to access the memory later on you can skip this part and directly lock() and unlock() the texture. This gives you the raw memory pointer. Upon unlocking the texture update occurs.
Texture scaling is possible via the texture matrix. Just set the texture matrix to a scale matrix with the required scales.
NPOT textures are supported by Irrlicht, but there's no automatic fall-back. So you have to query the driver for NPOT capability and pass the correctly sized texture depending on the return value.
Texture scaling is possible via the texture matrix. Just set the texture matrix to a scale matrix with the required scales.
NPOT textures are supported by Irrlicht, but there's no automatic fall-back. So you have to query the driver for NPOT capability and pass the correctly sized texture depending on the return value.