Procedural Noise and OpenGL Help!
I'm wondering if a kind soul, has the source-code to this tutorial.? http://www.gamedev.net/reference/art...rticle2085.asp
I'm getting a few errors, (something about C99 standards), when compiling in CodeBlocks, when i copied the text from the page. (In the ForLoop mainly)
I'm fairly much a newbie and have limited C and OGL skills. I do however understand most of what is happening, but i was hoping to compile this example and simplify.... I'm looking for C Source and not C++ which is all i seem to find when looking for similar examples.
Technically unlike that Tutorial, i just want to render a 32x32 map of noise. No smoothing or octaves or mipmapping is needed. I just need to see something, before i go back and read up on every line of the code.
The example tutorial is actually a little more advanced than what I'm trying to do. Eventually i would like to do my own terrain displacement, but for now the following would suffice.
I'm trying to simply:
1)Make a texture array,
2)Generate procedural noise
3)Fill Map array with a random procedural noise,
4)Display the array via OGL.
Any help on getting this a step further would be appreciated:
Basically below i believe i have done steps 1 & 2.
by declaring a MAP32, and generating a Noise function.
I would like to now i guess fill the array with the data from noise function. But the pseudo-code gave me compiler errors, so anyone help me add this function....
Code:
#include <GL/gl.h> //include the gl header file
#include <GL/glut.h> //include the glut header file
float map32[32 * 32]; //Texture Array
float Noise(int x, int y, int random) // Generate Noise
{
int n = x + y * 57 + random * 131;
n = (n<<13) ^ n;
return (1.0f - ( (n * (n * n * 15731 + 789221) +
1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);
}
void
int main (int argc, char **argv) {
glutInit (&argc, argv); //initialize the program.
glutInitDisplayMode (GLUT_SINGLE); //set up a basic display buffer (only singular for now)
glutInitWindowSize (512, 512); //set whe width and height of the window
glutInitWindowPosition (100, 100); //set the position of the window
glutCreateWindow ("A basic OpenGL Window"); //set the caption for the window
glutDisplayFunc (Noise); //call the display function to draw our world
glutMainLoop (); //initialize the OpenGL loop cycle
return 0;
}
PS No I'm not a student! (They generally have a much better grasp of what they are doing!) :)