Search code examples
c++windowsopengl-escocos2d-x

How to create a fullscreen OpenGL-ES renderview in Windows?


I'm using cocos2d-x to develop an iPhone game and then it just came to my head why not release my game for PC too? The only problem is that setting the window to full screen mode is not implemented yet. Now I'm just stuck with how to create a full screen window? There are some window creation functions that are used but I'm not sure which one and how I should change.

There is the eglCreateWindowSurface function that cocos2d is calling to create a window. I'm not sure which option I should change so that it creates a full screen window. It would also be nice if I can implement a function that switches my game to full screen mode and back while running.


Solution

  • On Windows it's a bit more compilicated. Essentially you have to:

    • Create a proxy OpenGL context to get access to functionality above OpenGL-1.1 through extensions

    • Load the extensions required to create an OpenGL-ES compatible context

    • Create the higher version OpenGL context

    • Again Load the extensions, now for this context

    Luckily all this has been wrapped up in several easy to use libraries. I recomment GLFW for Window/Context creation (it deals with all that proxy context stuff, too), and GLee or GLEW to make the OpenGL extensions available to the code.

    http://www.glfw.org/

    http://elf-stone.com/glee.php

    http://glew.sourceforge.net/

    Those libraries are cross platform, so your application/game itself does not use OS dependent functions, it will compile not only for Windows but also Linux, BSD and MacOS X.