Archived

This topic is now archived and is closed to further replies.

Zeblar Nagrim

Question

Recommended Posts

I have problem with getting Perlins function to work. I don´t really know how to use it. I want the function to generate a pattern and store the values in a buffer witch I can use to create a directdraw surface. The function store the values in a unsigned int 16 buffer but I want the buffer to be unsigned char.

If somebody can explain how to use Perlins noise function, what all parameters do etc.

And how to control the parameters to create diffrent patterns.

If the image buffer is 256x256 how many elements is it in the palette?

Here is the funcion:
void Perlins(long u, long v, long du, long dv, long ddu, long ddv, unsigned _int16 Num_Pix, unsigned _int16* palette, unsigned _int16* screen_buffer)

Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
I show you exactly my problem:

                            

// Pointer to surface

unsigned _int16* shortDestPtr =
(unsigned _int16 *)ddsd.lpSurface;

for (int i = 0; i < height*width; i++)
{
*(shortDestPtr) = (unsigned short)
(((0>>3)<<11) + ((0>>2)<<5) + ((255>>3)) );
shortDestPtr++;
}

unsigned _int16 *pal = new unsigned _int16[256*256*3];

memset(pal, 0, sizeof(unsigned _int16)*(256*256*3));

C_Noise(0,0,1,1,0,0,256*256,pal,shortDestPtr);

delete[] pal;


The C_Noise function do nothing with the pixel buffer. The surface is still blue!

Zeblar Nagrim, Lord of Chaos


Edited by - Zeblar Nagrim on July 19, 2000 12:37:58 PM

Share this post


Link to post
Share on other sites
I finaly get the function to work! You want to know what the problem was? It was in fact a parameter type that my compiler couldn´t identify but not give a error on.

void Perlins(long, long, long, long, long, long, unsigned _int16 Num_Pix, unsigned _int16*, unsigned _int16*)

If I changed Num_Pix data type from unsigned _int16 to int, then the function works! Why? I don´t know

Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites