wxWidget - wxGLCanvas, GLUT and ofImage

Hi,
I have an application where I have a wxWidget GUI with a wxglcanvas. I connected this application to the OF and ‘render’ everything inside this wxglcanvas insted of in normal OF opengl window.
the only think which still doesnt work is ofImage. The code which use ofImage is correct for sure, as I use it in a normal OF application. But in my GUIenabled app there is only white rectangle /rectangle, where a command:

texColor.draw(scenePosX, scenePosY, sx2, sy2);

should draw a texture.
My question is, does anybody know what GLUT settings shoul I use? so far I have this:

void BasicGLPane::prepare2DViewport(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y)
{

/*
* Inits the OpenGL viewport for drawing in 2D
*/

glClearColor(1.0f, 0.0f, 0.0f, 1.0f); // Black Background
glEnable(GL_TEXTURE_2D); // textures
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

glViewport(topleft_x, topleft_y, bottomrigth_x-topleft_x, bottomrigth_y-topleft_y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluOrtho2D(topleft_x, bottomrigth_x, bottomrigth_y, topleft_y);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

Thanks a lot for any idea.

Hard to say, there’s nothing obviously wrong with that code you posted.

Are you absolutely sure you are properly loading the textures (i.e. right loading path)?
Try putting some error checking using this function:

  
void glError() {  
	GLenum err = glGetError();  
	while (err != GL_NO_ERROR) {  
		fprintf(stderr, "glError: %s caught at %s:%u\n", (char *)gluErrorString(err), __FILE__, __LINE__);  
		err = glGetError();  
	}  
}  

Call that after your texture loading to see if anything is going wrong.

You could also try drawing a straight openGL texture (try one of the nehe exampes http://nehe.gamedev.net/data/lessons/le-…-?lesson=06 ) and see if that turns up anything.

Hi,
actually I am not loading a file. I am doing this:

ofImage texColor;
unsigned char * colorPixels;
int colorIndex;

texColor.allocate(100, 100, OF_IMAGE_COLOR);
colorPixels = texColor.getPixels();

for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
colorIndex = (j*100+i)*3;
colorPixels[colorIndex + 0] = i; // r
colorPixels[colorIndex + 1] = j; // g
colorPixels[colorIndex + 2] = (unsigned char)(ofRandomuf() * 255); // b
}
}

texColor.update();
texColor.draw(0, 0, 100, 100);

so I think I have a proper texture. And also as I said, this code works in my regular OF app.
I also tried your error function and get this:
glError: invalid operation caught at D:\_openFrameworks\apps\examples\glCanvas1\BasicGLPane.cpp:308
but I do not know what that error means. you?

thx a lot!

The errors mean the OpenGL operation you carried out at line 308 of BasicGLPane.cpp is invalid. This could be for a number of different reasons.

What exactly is the line?