GL4Dummies
GL4Dummies copied to clipboard
Resizing window with AnimeManager (demo helper) should resize textures
Hi!
Currently, if we use the demo helper with the flag SDL_RESIZABLE and then resize the window, the animation in not well drawn.
This seems to be because the function gl4dhInit() takes two arguments w and h used two creates two textures (for colors and depth). There should be a way to resize those textures when resizing the window.
Thus, I would suggest to add the following function to gl4dhAnimeManager.c:
void gl4dhResize(int w, int h) {
_w = w; _h = h;
// Resize color texture
glBindTexture(GL_TEXTURE_2D, _wTexId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// Resize depth texture
glBindTexture(GL_TEXTURE_2D, _wdTexId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, w, h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
}
that could then be called the following way:
int main(int argc, char* argv[]) {
// init...
gl4duwResizeFunc(resize);
}
void resize(int w, int h) {
glViewport(0, 0, w, h);
// stuffs...
gl4dhResize(w, h);
}
The textures should then be properly resized and fit the window.
Would you allow me to add this feature? Would there be things to add before? (Like allowing the user to specify a resize function for each animation?) Should we make sure the textures actually exist before trying to resize them?
Hi Gothor,
sorry for my late reply,
your proposal sounds good, and I'm happy with the way it's set up. Go for it. Thanks a lot!