jplev
03-07-2006, 05:22 PM
Hi
i work on an myst-like game engine with opengl and delphi 7
i try to do transition between two texture but i dont know how in OpenGl
anyone can help me?
i want to blend two texture into one.
Thanks
JP
Nitrogen
03-07-2006, 06:41 PM
The simplest way is like this:
(initalisation)
Set Orthographic Projection mode.
Load Texture into Tex1
Load Texture into Tex2
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
(drawing)
Fade := (a number ranging from 0.0 to 1.0 where 0 means Tex1 is visible, 1 = Tex2 visible.)
glBindTexture2D(GL_TEXTURE_2D, Tex1);
glColor4f(1,1,1, Fade);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2f(0,0);
glTexCoord2f(1, 1); glVertex2f(Width,0);
glTexCoord2f(1, 0); glVertex2f(Width,Height);
glTexCoord2f(0, 0); glVertex2f(0,Height);
glEnd;
glBindTexture2D(GL_TEXTURE_2D, Tex2);
glColor4f(1,1,1, 1-Fade);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2f(0,0);
glTexCoord2f(1, 1); glVertex2f(Width,0);
glTexCoord2f(1, 0); glVertex2f(Width,Height);
glTexCoord2f(0, 0); glVertex2f(0,Height);
glEnd;
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.