I am trying to render an openGL window in fullscreen and am using the NeHe tutorials to learn how to do this. however I have reached a point where I am using the exact same code in both the example code given and my own code, but when it reaches this line:
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
this doesn't evaluate to true in my code, even though it does in the example code given. this is even more confusing as while de-bugging everything was exactly the same up to this point.
Is there something simple I'm missing such as something in the project properties, or if not, could someone advise me on any other ways of creating a full screen window.
NeHe tutorial I am using: http://nehe.gamedev.net/tutorial/creating_an_opengl_window_%28win32%29/13001/
If you're just learning, you could try using GLUT. You can create a window with it in a few lines, and you can just mess with your OpenGL code, until you're comfortable with it enough to actually try out platform specific APIs for doing so such as WinAPI.
You'll need to install Freeglut (implementation of the outdated GLUT), and GLEW (for the ease of using OpenGL 1.1+ functions because Microsoft's gl.h
hasn't been updated since then)
Bare minimum code:
#define FREEGLUT_STATIC // defined so you can link to freeglut_static.lib when compiling
#define GLEW_STATIC // defined so you can link to glew's static .lib when compiling
#include <GL/glew.h> // has to be included before gl.h, or any header that includes gl.h
#include <GL/freeglut.h>
void draw()
{
// code for rendering here
glutSwapBuffers(); // swapping image buffer for double buffering
glutPostRedisplay(); // redrawing. Omit this line if you don't want constant redraw
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); // enabling double buffering and RGBA
glutInitWindowSize(600, 600);
glutCreateWindow("OpenGL"); // creating the window
glutFullScreen(); // making the window full screen
glutDisplayFunc(draw); // draw is your function for redrawing the screen
glutMainLoop();
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With