GLuint *OpenGL_Texture = (GLuint*)malloc( font_rows * font_width * 4 );
// 4 for the number of bytes (rgba)
i then run a loop like this( taking this out solves my problem!!! so error is prob here lol):
Uint32 Count = 0;
for( Sint32 y = font_rows-1; y > -1; y-- ) //read backwards for texture layout
{
for( Sint32 x = 0; x < font_width; x++ )
{
OpenGL_Texture[Count] = 255; // or other number up2 255
Count++;
OpenGL_Texture[Count] = 255; // or other number up2 255
Count++;
OpenGL_Texture[Count] = 255; // or other number up2 255
Count++;
OpenGL_Texture[Count] = 255; // or other number up2 255
Count++;
}
}
Help, malloc and textures
I've recently hit a snag in my coding. I read fonts from 8-bit bitmap info in memory and place into a malloc'd array in 32-bit rgba format. However, i constantly receive memory errors, if i use free(OpenGL_Texture) and also if i dont, the next malloc returns and error.
to do this i use:
any idea where im overstepping my bounds here?
[Edited by - phantom on August 17, 2005 9:04:48 PM]
Your array is declared as a gluint, i.e. a 32-bit int. You are requesting enough memory for rows*width*4 *bytes*. In your loop, you are writing rows*width*4 *integers*. There's the problem. Just declare your OpenGL_Texture as GLubyte*.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement