zoukankan      html  css  js  c++  java
  • Installing GLUT for MinGW [转]

    [转] 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 <windows.h>
    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.
     


     

      

      
     

  • 相关阅读:
    bzoj2751
    bzoj1483
    bzoj1011
    bzoj1412
    bzoj1820
    bzoj1295
    bzoj3444
    Java--Exchanger用于进行线程间的数据交换
    Java--Semaphore控制并发线程数量
    Java--Spring AOP 源码散点记录(最后整理成一篇博客)
  • 原文地址:https://www.cnblogs.com/longdouhzt/p/2384225.html
Copyright © 2011-2022 走看看