全屏在openGL [英] Full screen in openGL

查看:303
本文介绍了全屏在openGL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在全屏幕渲染一个openGL窗口,我使用NeHe教程来学习如何做到这一点。然而,我已经达到一个点,我使用完全相同的代码在示例代码和我自己的代码,但当它达到这一行:

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)

在我的代码中不评估为true,即使它在示例代码中给出。这更加令人困惑,因为解除所有的东西在这一点上是完全一样的。

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教程我使用的是:
http://nehe.gamedev.net/tutorial/creating_an_opengl_window_%28win32%29/13001/

NeHe tutorial I am using: http://nehe.gamedev.net/tutorial/creating_an_opengl_window_%28win32%29/13001/

推荐答案

如果你只是在学习,你可以尝试使用GLUT。你可以创建一个窗口,它有几行,你可以只是搞砸你的OpenGL代码,直到你感到足够实际尝试平台特定的API,如WinAPI。

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.

您需要安装Freeglut(实现过时的GLUT)和GLEW(为了方便使用OpenGL 1.1+的功能,因为Microsoft的 gl.h 尚未更新)

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)

最低限额:

#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;
}

这篇关于全屏在openGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆