zoukankan      html  css  js  c++  java
  • VS上使用GLUT

    第一步 下载预编译的GLUT   GLUT下载地址

    第二步 安装GLUT

          文件             位置
    glut32.dll C:\WINDOWS\system\
    glut32.lib C:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Lib
    glut.h

    C:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Include\gl

    第三步 创建一个vs工程

    1. 新建win32工程文件 –> 新建 –> 项目 选择 “win32控制台应用程序” 选择 空项目,最后完成

    2. 加入源文件 main.cpp

    加入以下头文件

    #include <GL/glut.h>

    3.修改工程属性文件栏上的 项目->属性 在弹出对话框的左侧边栏 选择 连接器->输入,在右边的附加依赖项输入 opengl32.lib glu32.lib glut32.lib

    第四步 编写opengl的程序

    #include <GL/glut.h>
    
    
    void display(void)
    {
    /*  clear all pixels  */
        glClear (GL_COLOR_BUFFER_BIT);
    
    /*  draw white polygon (rectangle) with corners at
     *  (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)  
     */
        glColor3f (1.0, 1.0, 1.0);
        glBegin(GL_POLYGON);
            glVertex3f (0.25, 0.25, 0.0);
            glVertex3f (0.75, 0.25, 0.0);
            glVertex3f (0.75, 0.75, 0.0);
            glVertex3f (0.25, 0.75, 0.0);
        glEnd();
    
    /*  don't wait!  
     *  start processing buffered OpenGL routines 
     */
        glFlush ();
    }
    
    void init (void) 
    {
    /*  select clearing (background) color       */
        glClearColor (0.0, 0.0, 0.0, 0.0);
    
    /*  initialize viewing values  */
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    }
    
    /* 
     *  Declare initial window size, position, and display mode
     *  (single buffer and RGBA).  Open window with "hello"
     *  in its title bar.  Call initialization routines.
     *  Register callback function to display graphics.
     *  Enter main loop and process events.
     */
    int main(int argc, char** argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize (250, 250); 
        glutInitWindowPosition (100, 100);
        glutCreateWindow ("hello");
        init ();
        glutDisplayFunc(display); 
        glutMainLoop();
        return 0;   /* ISO C requires main to return int. */
    }
  • 相关阅读:
    sprin AOP
    springDI注解
    Spring学习
    cookie、session、token三者之间的关系
    解决报错:Cannot find module 'webpack-cli/bin/config-yargs'
    Vue全家桶-前端工程化
    Vue全家桶-前端路由
    Vue
    Git
    Ajax
  • 原文地址:https://www.cnblogs.com/yiya/p/2295791.html
Copyright © 2011-2022 走看看