Hi Folks,
Bare with me on this one, it’s a great source of frustration for myself.
I’ve spent some time searching for 'how-to’s on how to go about building an image using OpenGL and drawing it to memory. Just about everything I come across however uses Windows-based syntax, and/or other third party libraries (e.g. GLUT). What I’m trying to achieve is drawing an image to memory by using standard OpenGL, for the purpose of then displaying the image in a window via a bitmap. The software I’m writing is a plugin for a well-known animation package, which generally speaking, is in the form of a dialog window. The plugin is well underway.
Below is some example code of how I’m trying to go about this. It doesn’t work, but will at least show the general steps I’m trying. The displayed bitmap I get (which is ‘built’ inside the for loop line by line) is just filled with vertical lines (oddly enough always on the right-side half of the image). I’m not asking anyone to do the work for me, but if anyone in the know is able to point me in the right direction here, it would be very helpful.
void My_DrawClass::OpenGLDraw(void)
{
// Notes: Ww and Hh are class-level variables
GLuint MyGL;
glViewport((GLsizei)0,(GLsizei)0,(GLsizei)Ww,(GLsizei)Hh);
glClearColor(0.0,1.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
UChar *Viewport_Line = GeAllocType(UChar,Ww * 4); // SDK object
glDrawPixels(Ww,Hh,GL_RGBA,GL_FLOAT,Viewport_Line);
glReadBuffer(GL_BACK);
for(int h = 0; h <= Hh-1;)
{
glReadPixels(Xx,Yy,0,h,GL_RGBA,GL_FLOAT,Viewport_Line);
MyBitmap->SetPixelData(0,h,Ww,Viewport_Line,GL_RGBA);
h++;
}
FreeUChar(Viewport_Line);
}
I would seek support from the software company itself, but they won’t provide any. Will say no more on that. Any help appreciated. Cheers,
WP.