opengl白色视窗-Visual Studio 2010 [英] opengl white window - Visual Studio 2010

查看:116
本文介绍了opengl白色视窗-Visual Studio 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是opengl初学者. 我设置了DLL,库,标题,但是发生了错误. 我的开发环境是win7(64bit).

I am opengl beginner. I set the DLLs, Library, Header but, error occurred. My development environment is win7 ( 64bit ).

供参考- DLL:C:\ Windows \ System32,C:\ Windows \ SysWOW64//glu32.dll,glut.dll,glut32.dll,opengl32.dll

For reference - DLLs : C:\Windows\System32, C:\Windows\SysWOW64 // glu32.dll, glut.dll, glut32.dll, opengl32.dll

库:C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Lib,C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ lib//glut.lib,glut32.库

Libs : C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib, C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib // glut.lib, glut32.lib

标题:C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Include \ gl,C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ include \ gl//GL. H,GLAUX.H,GLU.H,glut.h

Header : C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl, C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\gl // GL.H, GLAUX.H, GLU.H, glut.h

#include <Windows.h>
#include <gl/glut.H>

void DoDisplay ( void )
{
    glClearColor ( 0.0f, 0.0f, 1.0f, 1.0f );
    glClear( GL_COLOR_BUFFER_BIT );

    glBegin ( GL_TRIANGLES );

    glVertex2f ( 0.0, 0.5 );
    glVertex2f ( -0.5, -0.5 );
    glVertex2f ( 0.5, -0.5 );

    glEnd ();
    glFlush ();
}

int main ( int argc, char ** argv )
{
    glutInit ( &argc, argv );
    glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
    glutInitWindowSize ( 300, 300 );
    glutInitWindowPosition ( 0, 0 );
    glutCreateWindow ( "OpenGL" );
    glutDisplayFunc ( DoDisplay );
    glutMainLoop ();

    return 0;
}

白色窗口: http://i.stack.imgur.com/9GJoN.jpg

此代码只是输出白色三角形.

This code is simply output the white triangle.

Win32项目->控制台项目.

Win32 Project -> Console Project.

问题没有解决..对不起.

Problem not solved.. sorry.

错误为 http://i.stack.imgur.com/9GJoN.jpg

推荐答案

  • 您正在使用即时模式.您有一个glEnd(),但没有glBegin()
  • 正如PeterT所指出的,您没有呼叫glutInit
  • 如果按照打印方式指定路径,则会遇到问题.您同时使用正斜杠和反斜杠,至少以我的经验,这会毁了这条路.
  • 您不会将屏幕清除为特定颜色,也不会将顶点设置为特定颜色.这可能是在暴风雪中绘制北极熊的情况.
    • You're using immediate mode. You have a glEnd() but no glBegin()
    • As PeterT also pointed out, you have no call to glutInit
    • If your paths are specified like the way you have printed, you'll run into a problem. You have both forward and backslashes, which at least in my experience ruins the path.
    • You're not clearing the screen to a specific color, nor are you setting your vertices to a specific color. This may be the case of drawing a polar bear in a snow storm.
    • 退房

      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      

      glClearColor(r, g, b, a);
      

      • 正如Drew McGowen所指出的,您未指定任何变换或投影矩阵.
      • 我会强烈建议在OpenGL上寻找教程,以很好地说明绘制三角形和为什么所需做的所有事情. Lighthouse3d,Swiftless,OGLDev-有很多应该向您展示的基础知识.
      • 还有一点:您正在尝试学习已被弃用约7年的代码.您应该学习新的可编程管线而不是固定功能管线,因为它更快并且可以为您提供更多控制.
        • As Drew McGowen pointed out, you're not specifying any transformation or projection matrices.
        • I would strongly recommend looking for a tutorial on OpenGL to get a good explanation of all the things you need to do to draw a triangle and why. Lighthouse3d, Swiftless, OGLDev - there are many that should show you the basics.
        • One more point: You're trying to learn code that has been deprecated for ~7 years. You should learn the new programmable pipeline instead of the fixed function pipeline because it is faster and gives you more control.
        • 这篇关于opengl白色视窗-Visual Studio 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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