How do I use ''
glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels);
''? Everytime I try to use it, my program crashes.
I use ''
glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params);
'' to get the dimensions of my texture. It says ''256x256x4'', so I know that it''s binded and that everything is A-Okay. I can even see it on the screen.
I make a buffer,
unsigned char buf[256*256*4];
, and everything is happy. But, I type:
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
and my program crashes. I type:
unsigned char *buf = NULL;
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buf);
Thinking that maybe it allocates the right amount of memory on it''s own. But again it crashes. I type:
unsigned char buf[256*256*256];
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
Thinking that maybe the data was aligned on some boundry and needed more memory, but again it crashed. Finially, getting really angry, I type:
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
Just to see if it wouldn''t just do nothing. It still crashed.
What am I doing wrong? Sure, I wouldn''t need to do this if I kept the original copy, but I don''t want to have several copies of the texture in memory if I don''t need to. Or maybe that
is the problem, and I shouldn''t free the texture data after I call
glTexImage2D
? It never caused a problem before, though; I assumed OpenGL made it''s own copy. If I''m supposed to be in control of the data though, I wouldn''t need
glGetTexImage
in the first place, so I don''t think that''s the problem.
Help, please?
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.