PDA

View Full Version : updating a texture at every frame



franz1999
04-17-2003, 02:41 PM
I am trying to make a top view of a maze in a corner of the screen to let the player know where he is in the maze.
I though about updating each frame a global GLubyte array and associate it to a texture. I keep seeing a white rectangle instead of the map although (I have debugged it carefully) I am positively sure that the array contains the right RGB information.

this is the function that I call each frame:

void UpdateMap() {
// this gets the info from my data structure and updates the array "maskTex"
map->updateTextures();

int maskTexWidth = myWorld->getWidth() * MAP_CELL_SIZE;
int maskTexHeight = myWorld->getHeight() * MAP_CELL_SIZE;

glBindTexture(GL_TEXTURE_2D, mapMaskTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maskTexWidth, maskTexHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, maskTex);
}

What is wrong with this approach?
HELP!

F.

[This message has been edited by franz1999 (edited 04-17-2003).]

shinpaughp
04-17-2003, 06:17 PM
Originally posted by franz1999:
I am trying to make a top view of a maze in a corner of the screen to let the player know where he is in the maze.
I though about updating each frame a global GLubyte array and associate it to a texture. I keep seeing a white rectangle instead of the map although (I have debugged it carefully) I am positively sure that the array contains the right RGB information.

this is the function that I call each frame:

void UpdateMap() {
// this gets the info from my data structure and updates the array "maskTex"
map->updateTextures();

int maskTexWidth = myWorld->getWidth() * MAP_CELL_SIZE;
int maskTexHeight = myWorld->getHeight() * MAP_CELL_SIZE;

glBindTexture(GL_TEXTURE_2D, mapMaskTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, maskTexWidth, maskTexHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, maskTex);
}

What is wrong with this approach?
HELP!

F.

[This message has been edited by franz1999 (edited 04-17-2003).]

Are your width and height a power of 2? If not, make them so. If so, call glGetError after glTexImage2D and see what error it gives you.

franz1999
04-18-2003, 06:05 AM
Originally posted by shinpaughp:
Are your width and height a power of 2? If not, make them so. If so, call glGetError after glTexImage2D and see what error it gives you.

I didn't know that I HAD to make them power of 2.. thanks!