simple clouds part 1 and trying to get it to work

anyone have any luck getting
http://www.gamedev.net/reference/articles/article2085.asp

to work on their computer? I used some basic opengl window setting up code from the nehe site and add the new functions and replaced DrawGlScene appropriately, however when I run it I get just a blank window.

I’m using the code from lesson2 of the nehe site and visual studio.net.

and the glinit function looks like

  int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
	Init();
	return TRUE;										// Initialization Went OK
}

and the draw scene code is:

int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	LoopForever();                   //Our cloud function  
	    
	char texture[256][256][3];       //Temporary array to hold texture RGB values 

	for(int i=0; i<256; i++)         //Set cloud color value to temporary array
	for(int j=0; j<256; j++) 
	{
		float color = map256[i*256+j]; 
		texture[i][j][0]=color;
		texture[i][j][1]=color;
		texture[i][j][2]=color;
	}

	unsigned int ID;                 //Generate an ID for texture binding                     
	glGenTextures(1, &ID);           //Texture binding 
	glBindTexture(GL_TEXTURE_2D, ID);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	   
	gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, texture);

	glMatrixMode(GL_TEXTURE);        //Let's move the clouds from left to right
	static float x;    
	x+=0.01f;
	glTranslatef(x,0,0);

	glEnable(GL_TEXTURE_2D);         //Render the cloud texture
	glBegin(GL_QUADS);
	glTexCoord2d(1,1); glVertex3f(0.5f, 0.5f, 0.);
	glTexCoord2d(0,1); glVertex3f(-0.5f, 0.5f, 0.);
	glTexCoord2d(0,0); glVertex3f(-0.5f, -0.5f, 0.);
	glTexCoord2d(1,0); glVertex3f(0.5f, -0.5f, 0.);
	glEnd(); 

	SwapBuffers(hDC);
	return TRUE;										// Keep Going
}  

If anyone has any suggestions let me know. I don’t get any complier errors so I know the syntax is good. But not sure why I don’t see anything on screen.

Noo noo… For me that’s BS… haha

Well not BS but there is actually a much better way for making clouds real-time. I think that the Perlin noise method is for non-real time rendering programs Please anyone correct me if I am wrong. (I asume you want to create real time).

For realistic real-time rendering clouds you should use a cloud layers. You use a plane that is curved in the form of the top of a sphere. You place that in your world. You then map the plane with a cloud texture with an alpha channel, so that the cloud looks transparent.

Next you tesselate the plane and add a tranparency effect so that the triangles farther away from the center of the plane are more transparent. This creates the effect that the clouds actually fade away instead of getting “eat” by the horizon.

Next you make a copy of the cloud plane and place two more cloud plane further away. You apply a different texture mapping scale (although same texture), and enable apha blending.

The effect: AWESOME realistic clouds! This is a technique used in the last games (I have read) like doom and unreal, etc.

It’s really difficult to find information about this. However I was lucky to find a full source code at the Advanced OpenGl Game Programming Book.
Dowload the full source code here.
http://glbook.gamedev.net/moglgp/code.asp

You can find it under the skybox and skydomes section. I think it’s chapter 8.

This may sound hard, but it’s actually very easy.

Good luck!

It isn’t that I want real time , it is more so that I am just trying to mess around with perlin noise functions and this looked like a good place to start.

By the way…You don’t see anything on the screen because you didnt switch back to the Model view matrix:

Add this line before SwapBuffers(hDC) and it should work fine :wink:
glMatrixMode(GL_MODEL_VIEW)

Your method is good, however there is one that is much better, I didn’t mean that it’s actual BS…
Sorry, I just got angry at the article cause I spent weeks trying to find info on what I just gave to you! :slight_smile:

Good night and good luck!

hmm tried that and didn’t work :frowning: