• Advertisement


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

How do I store my texture in a dynamic array?

This topic is 6072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was reading the redbook and for those who read it, you know that they always use the checkboard texture that they generate proceduraly. Well it was all fine and good but I wanted my own texture (wonders of wonders). So, after writting the loading code etc I tried to store it in an array like the checkboard but I ran in a problem, I couldnt declare an array this way : int *Image; Image = new int[Width][Height][3]; I can only do it when it''s not a pointer, so I thought : hey no biggies, I''ll do a one dimension array. So, I toyed around with the checkboard example and did the following : < #define checkImageWidth 64 #define checkImageHeight 64 //GLubyte checkImage[checkImageHeight][checkImageWidth][3]; GLubyte checkImage[checkImageHeight * checkImageWidth * 3]; void makeCheckImage(void) { int i, j, c; for (i = 0; i < checkImageHeight; i++) { for (j = 0; j < checkImageWidth; j++) { c = ((((i&0x8)==0)^((j&0x8))==0))*255; checkImage[(i * checkImageWidth) + 0] = (GLubyte) c; checkImage[(i * checkImageWidth) + 1] = (GLubyte) c; checkImage[(i * checkImageWidth) + 2] = (GLubyte) c; } } } Of course since I''m writting this, it doesnt work at all. So, what did I miss, how do ppl store the textures usualy, before they load them into vram?

Share this post

Link to post
Share on other sites

  • Advertisement