That wouldn’t alter the point size but should not prevent anything from being rendered. If the projection and viewport are correctly initialized it should at least render a single white pixel. What’s important, if you got a double-buffered context, you have to swap the buffers after rendering, or in your case flushing. Otherwise you’ll never see the contents of the back-buffer. If swapping is handled automatically by whatever widget toolkit you’re using then that’s not necessary. But I like to turn off automatic swapping and add it myself for clarity.
can anyone help me how to make the projection and viewport work correctly
The viewport is simple. I think you’ll want to render to the whole buffer so you setup the viewport with
glViewport(0, 0, 600, 600);
Since you already use legacy stuff you can check out gluPerspective(). Note that the viewport should be resized to the new window size after a resize and the aspect ratio for gluPerspective is the quotient width / height.
So in conclusion something like this:
void resize(int width, int height)
{
}
// in main add
glutReshapeFunc(&resize);
can anyone help me how to make the projection and viewport work correctly
The viewport is simple. I think you’ll want to render to the whole buffer so you setup the viewport with
glViewport(0, 0, 600, 600);
Since you already use legacy stuff you can check out gluPerspective(). Note that the viewport should be resized to the new window size after a resize and the aspect ratio for gluPerspective is the quotient width / height.
So in conclusion something like this:
void resize(int width, int height)
{
glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// choose your FOV accordingly, 75.0 is simply an example, so are near and far
gluPerspective(75.0, static_cast<GLdouble>(width) / static_cast<GLdouble>(height), 1.0, 100);
// don't forget to go back to the model-view matrix-stack
glMatrixMode(GL_MODELVIEW);
}
// in main add
glutReshapeFunc(&resize);
void resize(int width, int height)
{
glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// choose your FOV accordingly, 75.0 is simply an example, so are near and far
gluPerspective(75.0, static_cast<GLdouble>(width) / static_cast<GLdouble>(height), 1.0, 100);
// don't forget to go back to the model-view matrix-stack
glMatrixMode(GL_MODELVIEW);