Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Water

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Paddeh   Members   

122
Like
Likes
Like

Posted 24 October 2001 - 09:44 AM

I''ve recently been pondering the best way to go about making a water effect, im a total novice at opengl, and I was just wondering if anyone had any thoughts on how to go about coding such a thing. Think of the water in quake1, It doesnt flow, it just seems to morph the texture around. Any ideas would be greatly apreciated.

#2 BlackHwk4   Members   

122
Like
Likes
Like

Posted 24 October 2001 - 07:07 PM

It''s been a little while since I did something like this, so I might have forgot something. Here is an example of what you will do:

float angle;
float rotate;

init()
{
loadMyTextures();
}

drawStuff()
{
/* Draw stuff in the scene and do whatever else you''re gonna do here */

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotatef(angle, 1.0f, 1.0f, 0.0f);
glRotatef(rotate, 0.0f, 0.0f, 1.0f);
glTranslatef(0.0f, 0.0f, -280.0f);
glMatrixMode(GL_MODELVIEW);

// we want the water to be a little transparent
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);

glBlendFunc(GL_SRC_ALPHA, GL_ONE);

glColor4f(0.3f, 0.3f, 0.8f, 0.8f);

glPushMatrix();
glBindTexture(GL_TEXTURE_2D, textureID);
drawCube(); // this will be the cube with a water texture on it
glPopMatrix();

// disable blending stuff
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);

// reset the texture matrix or stuff will be screwed up
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);

angle += 0.0005f;
rotate += 0.01f;
}

Now the texture on the cube will look like it''s flowing to the southeast and will be going slowly counter clockwise. Basically what you''re doing when you set the matrix stack to GL_TEXTURE, is telling OpenGL to do these things to all the textures. So, if you don''t reset the texture matrix then it will do the stuff you told it to do to all the other textures. Like I said, I''m a bit rusty on this subject but that''s what I think is happening. Try looking for tutorials on the matrix stack if you want a better explanation. Hope this helped.

#3 Paddeh   Members   

122
Like
Likes
Like

Posted 25 October 2001 - 01:49 AM

That helped a hell of a lot, thanks man. muchly apreciated :]




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.