Here’s the code I use to plot the contents of my wee array (*m_image). I believe the “GLortho” part is the code I need to change in order to stop the image from being resized when the window is resized. I think what I want to do is ensure that the coordinate increments are always equal to 1 pixel, rather than a fraction of the height/width of the window.
Any suggestions would be greatly appreciated.
(in patronisingly plain english too)
void CChildView::OnGLDraw(CDC *pDC)
{
glClearColor(m_redbg, m_greenbg, m_bluebg, m_alphabg);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Puts origin in the centre of the drawing window
glOrtho((-512.0 + 5), // left: half horizontal screen resolution - 4 pixels for width of side bar
(512.0 - 5), // right:
(-384.0 + 33), // bottom
(384.0 - 33), // top
1.0, // near
-1.0); // far
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
for (int i = 0; i < (((m_width) * (m_height) * 3) - 1); i+=3)
{
glColor3d((m_image[i]/255.0), (m_image[i + 1]/255.0), (m_image[i + 2]/255.0));
// Colour of each pixel starting at top left corner
glBegin(GL_POINTS);
glVertex2d( (((i/3)%(m_width)) - (m_width / 2)), ( (((m_height / 2) - 1) - ((i/3)/(m_width)) )));
// Plots each pixel starting at top left corner, taking a new line when pixel-number is divisible by the width of the image
}
glEnd();
glFlush();
}