博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Installing GLUT for MinGW [转]
阅读量:6215 次
发布时间:2019-06-21

本文共 3252 字,大约阅读时间需要 10 分钟。

[转] https://users.cs.jmu.edu/bernstdh/web/common/help/cpp_mingw-glut-setup.php

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.

  GLUT 3.7.6
  
3 Putting Files in the Right Place:
  You need to copy three files from the .ZIP file.
  
  Copy glut.h to the MinGW\include\GL  directory.
    
  Copy glut32.lib to your build directory (i.e., the directory
  that you compile into and link from).
    
  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 link-in glut32.lib (and not
  use the -lglut32).
 
  
  You may get some warnings like the following:

ignoring #pragma comment
warning: 'int glutCreateMenu_ATEXIT_HACK(void (*)(int))' defined but not used

  

  You can ignore them.

   
  Help resolving other problems is available at the MinGWiki.
    
5 Testing Your Installation:  You can use the following small program (named test.c) to test your installation:

1 #include 
2 #include "GL/glut.h" 3 4 5 6 void display() 7 {
8 glClear(GL_COLOR_BUFFER_BIT); 9 10 glBegin(GL_POLYGON); 11 glVertex2f(-0.5, -0.5); 12 glVertex2f(-0.5, 0.5); 13 glVertex2f(0.5, 0.5); 14 glVertex2f(0.5, -0.5); 15 glEnd(); 16 17 glFlush(); 18 } 19 20 void init() 21 {
22 glClearColor(0.000, 0.110, 0.392, 0.0); // JMU Gold 23 24 glColor3f(0.314, 0.314, 0.000); // JMU Purple 25 26 glMatrixMode(GL_PROJECTION); 27 glLoadIdentity(); 28 gluOrtho2D(-1.0, 1.0, -1.0, 1.0); 29 } 30 31 int main(int argc, char** argv) 32 {
33 glutInit(&argc, argv); 34 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 35 glutInitWindowSize(640, 480); 36 glutInitWindowPosition(0, 0); 37 glutCreateWindow("Test"); 38 glutDisplayFunc(display); 39 init(); 40 glutMainLoop(); 41 }

  

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

  

6 Using jGrasp:

  Some of you may have used MinGW under jGrasp in the past.
  You can do so with GLUT but you will have to change some settings
  in jGrasp.
  
  In jGrasp, choose Settings on the main menu,
  pull down to Compiler Settings, and then
  pull down to either Workspace or
  Project.
  Next, click on the Compiler tab and change the "Language"
  to C.
 
  
  From here, you can set the "FLAGS or ARGS" for "Make", the "Compiler",
  etc...  See, for example, the flags and arguments used in the
  example above.
 

 
  

  

 

转载地址:http://jwpja.baihongyu.com/

你可能感兴趣的文章
Go基础系列:struct和嵌套struct
查看>>
【nodejs】让nodejs像后端mvc框架(asp.net mvc )一样处理请求--路由限制及选择篇(2/8)【route】...
查看>>
WPFの阴影效果
查看>>
PostgreSQL 10.1 手册_部分 II. SQL 语言_第 14 章 性能提示_14.3. 用显式JOIN子句控制规划器...
查看>>
VS生成Cordova for Android应用之Gradle
查看>>
使用IB_DESIGNABLE与IBInspectable实现可在SB编辑border与corner的Button
查看>>
Android&Java面试题大全—金九银十面试必备
查看>>
普林斯顿大学算法公开课笔记——选择排序
查看>>
Hikyuu 1.1.2 发布,量化交易研究框架
查看>>
Android ADB命令的使用
查看>>
Python全栈 Web(Flask框架、CRUD、聚合分组)
查看>>
【最佳实践】使用BYOK密钥加密OSS中对象
查看>>
Scrapy实战-爬取豆瓣漫画
查看>>
[剑指offer] 矩阵中的路径
查看>>
log4j2配置
查看>>
07.Java基础(泛型)
查看>>
自制操作系统Antz day11——实现shell(下)命令响应
查看>>
MyBatis 笔记
查看>>
常见浏览器User-Agent大全
查看>>
第七章:Redis 位图bitmap&基数统计HyperLogLog
查看>>