注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Mr.Right

不顾一切的去想,于是我们有了梦想。脚踏实地的去做,于是梦想成了现实。

 
 
 

日志

 
 
关于我

人生一年又一年,只要每年都有所积累,有所成长,都有那么一次自己认为满意的花开时刻就好。即使一时不顺,也要敞开胸怀。生命的荣枯并不是简单的重复,一时的得失不是成败的尺度。花开不是荣耀,而是一个美丽的结束,花谢也不是耻辱,而是一个低调的开始。

网易考拉推荐

OpengGL Glut 在 MinGW中的安装和使用, 亲测可用  

2015-02-08 21:01:07|  分类: 编程 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
1 Introduction: OpenGL is independent of any windowing system. As a result, it contains no functions for opening windows or interacting with the user. Each windowing systems that supports OpenGL has its own library that procides the support.

GLUT, the OpenGL Utility Toolkit, is a simple windowing system that has been ported to several different operating systems. It is commonly used when teaching OpenGL.

This document describes the installation of GLUT for developing on MS-Windows using MinGW. It assumes that you have already installed MinGW.

2 Getting Started: The first thing you need to do is download the binaries for the Win32 port of GLUT.
3 Putting Files in the Right Place: You need to copy three files from the .ZIP file.
  1. Copy glut.h to the MinGW\include\GL directory.
  2. Copy glut32.lib to your build directory (i.e., the directory that you compile into and link from).
  3. Copy glut32.dll to the same directory where your executable will be created.
    (You can actually put glut32.dll in any directory in your path.)
4 Building an Executable: You need to be aware of the following:
  • You must #include <windows.h> before you #include <"GL/glut.h">
  • When you link, you must explicitly link-in glut32.lib (and not use the -lglut32 option).
  • You may get some warnings like the following:
      ignoring #pragma comment
      
      warning: 'int glutCreateMenu_ATEXIT_HACK(void (*)(int))' defined but not used
    5 Testing Your Installation: You can use the following small program (named test.c) to test your installation:
      #include <windows.h>
      #include "GL/glut.h"
    
    
    
      void display() 
      {
        glClear(GL_COLOR_BUFFER_BIT);
    
        glBegin(GL_POLYGON);
        glVertex2f(-0.5, -0.5);
        glVertex2f(-0.5,  0.5);
        glVertex2f(0.5,  0.5);
        glVertex2f(0.5, -0.5);
        glEnd();
    
        glFlush();
      }
    
      void init() 
      {
        glClearColor(0.000, 0.110, 0.392, 0.0); // JMU Gold
    
        glColor3f(0.314, 0.314, 0.000); // JMU Purple
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(-1.0, 1.0, -1.0, 1.0);
      }
    
      int main(int argc, char** argv) 
      {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize(640, 480);
        glutInitWindowPosition(0, 0);
        glutCreateWindow("Test");
        glutDisplayFunc(display);
        init();
        glutMainLoop();
      }
      

    You should be able to build this program from the command line as follows:

      g++ -o test -Wall test.c -mwindows glut32.lib -lopengl32 -lglu32
  评论这张
 
阅读(338)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016