Hi, i'm pretty new to this open GL business but i'm trying to map some .raw textures onto some geometry.
Both the height and normal texture files are using both width and height of 1024.
I've managed to load the normal texture on using the pixel depth of 4 but when i load the height texture using the same format of 4, it appears tiled even when using "glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);"
for both T and S.
I can't seem to use any other number for pixel depth since it gives me a memory error and my code breaks.
Heres my loading code:
And my building code:
and this is what i'm using to call it:
If anyone knows why it is tiling instead of appearing correctly mapped (like the normal one does) can you please help.
Thanks in advance.
Both the height and normal texture files are using both width and height of 1024.
I've managed to load the normal texture on using the pixel depth of 4 but when i load the height texture using the same format of 4, it appears tiled even when using "glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);"
for both T and S.
I can't seem to use any other number for pixel depth since it gives me a memory error and my code breaks.
Heres my loading code:
Code:
int LoadRAWTexture ( char *filename, pImageTexture input)
{
FILE *file;
int i,j,k,done=0;
int stride = input->width * input->pixel_depth; // Size Of A Row (Width * Bytes Per Pixel)
unsigned char *p = NULL;
file = fopen(filename, "rb"); // Open "filename" For Reading Bytes
if( file != NULL )
{//if the file is not empty-or does exist-
for( i = input->height-1; i >= 0 ; i-- )
{//image loads from bottom up in GLSL so flip
p = input->data + (i * stride );
for ( j = 0; j < input->width ; j++ )
{
for ( k = 0 ; k < input->pixel_depth-1 ; k++, p++, done++ )
{
*p = fgetc(file);
}
*p = 255; p++;
}
}
fclose(file);
}
else
{
MessageBox(NULL,"Error loading Colour Textures!","Colour Texture Issue",MB_OK | MB_ICONINFORMATION);
}
return done;
}
And my building code:
Code:
void LoadTexture (pImageTexture tex,int slot)
{
if (slot == 1)
{//then its height
glBindTexture(GL_TEXTURE_2D, texture[slot]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex->width, tex->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex->data);
}
}
and this is what i'm using to call it:
Code:
height = AllocateTextureBuffer( 1024,1024,4 );//load colour texture
if (LoadRAWTexture("HEIGHT.raw",height)==0)
{
MessageBox(NULL,"Height.RAW could not load for some reason","Height map issue",MB_OK | MB_ICONINFORMATION);
return FALSE;
}
If anyone knows why it is tiling instead of appearing correctly mapped (like the normal one does) can you please help.
Thanks in advance.