Advertisement

modifying textures @ runtime?

Started by September 25, 2003 03:39 PM
4 comments, last by NeViL tHe dEVil 21 years, 5 months ago
is there a simple, memory-saving way to modify a texture at runtime or do I have to keep a copy and load it every time ??? ------------------------------------------------------ Regret Nothing - Learn Everything
------------------------------------------------------ Regret Nothing - Learn Everything
Use glTexSubImage2D if you''re loading your texture with glTexImage2D (mostly the case) or use glCopyTexSubImage2D if you''re loading you texture with glCopyTexImage2D (rarely, but may happen).
Advertisement
Thx, but can you explain the parameters:
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels

I assume {xoffset, yoffset} is the top left coner of the area to change, width and height the size of that area and pixels the data. Am I right? And the rest?

------------------------------------------------------
Regret Nothing - Learn Everything
------------------------------------------------------ Regret Nothing - Learn Everything
void glTexSubImage2D(
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid *pixels
);

target must be GL_TEXTURE_2D (since this is a 2d texture)
level is the mip-map level you wish to change
You are correct about the offset, and width/height parameters.
format specifies the color format of the pixels you are sending, such as GL_RGBA, or GL_RGB.
type specifies the type of data you are sending, such as GL_FLOAT or GL_UNSIGNED_BYTE.
pixels is simply a pointer to the new image data.

J.W.
A thread about modifying textures in real time simply needs the obvious reference to pbuffers and render-texture functionalities

Previously "Krohm"

Well, you''re right but anyway I wouldn''t recommend pbuffers unless really required because they are not supported on all hardware, whereas glTexSubImage2D is supported on all OpenGL 1.1 compatible hardware.

This topic is closed to new replies.

Advertisement