vs 2012 +opengl

news2023/12/12 2:29:12

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

I was recently helping a friend get set up running OpenGL and I realized that most of the instructions available online for this are fairly outdated. So, here’s a quick run through to set the record straight. This guide is meant for beginners who just want to get a simple OpenGL desktop app going on a Windows machine.

This guide assume you have the following installed:

1.       Windows 7 or 8

2.       Visual Studio 2008, 2010, or 2012

By convention, we assume the OS is installed to the C drive and VS is installed to a folder such as “C:\Program Files (x86)\Microsoft Visual Studio 10.0″ (for 2010, 2008 maps to 9.0 and 2012 to 11.0).

The first step is to download GLUT (the OpenGl Utility Toolkit). This library provides a slew of helper functions for working with OpenGL, including setting up a window. Grab the latest binaries from here. Unzip this and copy the binaries out into the following directories. Be aware that these are 32-bit binaries. You will need to create the “gl” folder in “\Microsoft Visual Studio 10.0\VC\include\”, as it doesn’t already exist.

File

Location

glut32.dll

C:\Windows\SysWOW64\

glut.h

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\gl\

glut32.lib

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\

Windows 64-bit


File

Location

glut32.dll

C:\Windows\System32\

glut.h

C:\Program Files\Microsoft Visual Studio 10.0\VC\include\gl\

glut32.lib

C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\

Windows 32-bit

Now boot up Visual Studio. You’ll want to create a simple Win32 console application. In VS 2010, open the New Project dialog and look at the list of templates. Select Visual C++\Win32\Win32 Console Application. Click through the Wizard that appears, leaving the defaults in place.

At this point you should get a solution with a couple of default files and a “_tmain” entry function. Right-click the project you created, go to Properties, then open Configuration Properties\Linker\Advanced

Choose the NO.

 

Close the settings and modify your main .cpp file to look like this:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

#include "stdafx.h"

#include <gl/glut.h>

 

// One-time initializtion logic

void init( void )

{

    printf( "OpenGL version: %s\n", (char*)glGetString(GL_VERSION));

    printf( "OpenGL renderer: %s\n", (char*)glGetString(GL_RENDERER));

 

    //Configure basic OpenGL settings

    glClearColor(0.0, 0.0, 0.0, 1.0);

    glShadeModel(GL_SMOOTH);

    glEnable(GL_BLEND);

    glEnable(GL_TEXTURE_2D);

}

 

// Main drawing routine. Called repeatedly by GLUT's main loop

void display( void )

{

    //Clear the screen and set our initial view matrix

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();

 

    //TODO: Perform drawing here

 

    //We just drew to the back buffer. Now we need to swap that with the

    //front buffer to show it on screen.

    glutSwapBuffers();

}

 

// Entry point - GLUT setup and initialization

int main( int argc, char** argv )

{

 

   glutInit( &argc, argv );

   glutInitDisplayMode (GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);

   glutInitWindowSize (800, 600);

   glutInitWindowPosition (100, 100);

   glutCreateWindow( "OpenGL Test" );

   glutDisplayFunc( display );

 

   init();

 

   glutMainLoop();

 

   return 0;

}

Hit F5 to build and run. You should get a window with a black screen. Pat yourself on the back. You’re now ready to start coding with OpenGL.

Graphics

 

转载于:https://my.oschina.net/gujianhan/blog/161534

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.dtcms.cn/news/show-830753.html

如若内容造成侵权/违法违规/事实不符,请联系七分地网进行投诉反馈,一经查实,立即删除!

相关文章

Linux压缩那些事

简介 本文主要介绍互联网上最主流的两种压缩格式&#xff08;rar和zip&#xff09;文件在Linux系统上的压缩和解压操作&#xff0c;包括分卷压缩。本文不展开过多详细的命令选项的讲解&#xff0c;只列举实际使用Linux系统最常用的一些命令。 ZIP 压缩 将多个文件压缩为一个…

手机当电脑音响_hifi迷你组合音响怎么样 hifi迷你组合音响优势简介【详解】

迷你音响简单的讲就是便于携带的产品&#xff0c;在近年来受到人们的青睐&#xff0c;户外的时候&#xff0c;hifi迷你组合音响会给人们增添很多乐趣。这种类型产品虽然个头小巧&#xff0c;但是不影响音质播放。那么&#xff0c;hifi迷你组合音响有什么特点吗?大家请看介绍。…

android之SharedPreferences

2019独角兽企业重金招聘Python工程师标准>>> 一、SharedPreferences应用场景 SharedPreferences 用于保存参数&#xff1b; 内部是以XML文件进行保存的&#xff0c;位于/data/data/package/shared_prefs目录中&#xff1b; 二、SharedPreferences核心代码 1.保存 Sh…

牛客多校9 - Groundhog Chasing Death(质因子分解+思维)

题目链接&#xff1a;点击查看 题目大意&#xff1a;给出 a , b , c , d , x , y &#xff0c;求 题目分析&#xff1a;因为涉及到了 gcd 的乘积运算&#xff0c;那么易知不同质因子的贡献是相互独立的&#xff0c;首先我们就可以先将 x 和 y 进行质因子分解&#xff0c;那么…

用WPF山寨折线图,抄?是狠狠的抄

对于没有美术细胞的我来说&#xff0c;抄袭人家的设计或是创意是再平常不过的事&#xff0c;我承认这很无耻&#xff0c;如果在伟大“天朝”的教育体系下还可能升级为道德上的沦丧&#xff0c;毕竟人家搞个东西也不容易&#xff0c;可任务在身&#xff0c;只好下策&#xff0c;…

PyCharm编写shell脚本无法运行

背景 我们常常选择使用PyCharm在本地&#xff08;Windows&#xff09;进行开发&#xff0c;然后将文件远程同步到远程服务器&#xff08;Linux&#xff09;运行程序&#xff0c;但是这样编写的shell脚本常常无法运行&#xff0c;出现语法错误&#xff0c;因为好几个朋友和我提…

返回局部变量或临时变量的地址_值传递和地址返回两者在堆区(Heap)应用的三种易错点...

1、指针变量作为参数进行值传递给函数的形参&#xff0c;并在堆区(Heap)进行内存分配和赋值程序源码&#xff1a;1 结果&#xff1a;Segmentation fault (core dumped)分析&#xff1a;如上图&#xff0c;指针变量ptr进行值传递给函数allocation()的形参tmp并赋值为NULL&#x…

微服务通信带来的问题

有了远程通信以后&#xff0c;我们势必会考虑几个问题 1. 目标服务肯定会做扩容&#xff0c;扩容以后&#xff0c;客户端会带来一些变化 2. 客户端对于目标服务如何进行负载均衡 3. 客户端如何维护目标服务的地址信息 4. 服务端的服务状态变化&#xff0c;如何让客户端尽心…

牛客多校10 - Tournament(找规律)

题目链接&#xff1a;点击查看 题目大意&#xff1a;现在有 n 个队伍参加比赛&#xff0c;任意两个队伍之间都要进行一次比赛&#xff0c;也就是共需要进行 n * ( n - 1 ) / 2 次比赛&#xff0c;对于每个队伍来说&#xff0c;必须要在第一场比赛的时候到达赛场&#xff0c;在…

Zend API: array_init

为什么80%的码农都做不了架构师&#xff1f;>>> array_init 和array_init_size 这2个看起来像是个函数其实这2个都是宏&#xff0c;具体定义在文件&#xff1a;zend_API.h 中。 #define array_init(arg) _array_init((arg), 0 ZEND_FILE_LINE_CC) #define array…

pvbrowser安装教程(Linux)

简介 pvbrowser是一款基于QT的开源组态软件开发框架&#xff0c;它为客户端计算机提供了一个专门的浏览器&#xff0c;并为创建实现可视化的服务器提供了一个集成开发环境。不过&#xff0c;官方文档对于pvbrowser开发环境的配置写的略微有点草率&#xff0c;本文给出Ubuntu下…

tensorflow官方文档_Tensorflow 2.0 Preview 官方文档

TensorFlow 2.0目前放出了Preview版本。目前想了解TensorFlow 2.0最快的方式就是查看官方API中的变化。本文列举一些从TF官方API中看出的TF 2.0的改进。TensorFlow 2.0 Preview可以通过pip下载了:CPU: https://pypi.org/project/tf-nightly-2.0-preview/GPU: https://pypi.org/…

Android ---- Context

Context字面意思上下文&#xff0c;位于framework package的android.content.Context中&#xff0c;很多方法需要通过  Context才能识别调用者的实例&#xff0c;比如说Toast的第一个参数就是Context&#xff0c;一般在Activity中我们直接用this代替&#xff0c;代表调用者的 …

Linux进程详细信息查看

我们通过ps及top系列命令查看进程信息时&#xff0c;只能看到命令执行的相对路径&#xff0c;查不到的进程的详细信息&#xff08;如绝对路径&#xff09;&#xff0c;那么这些信息到底如何查找呢&#xff1f; 其实&#xff0c;在Linux中&#xff0c;一切皆文本&#xff0c;那…

python操作json_如何使用Python处理JSON数据

如何使用Python处理JSON数据&#xff1f;本篇文章就给大家介绍使用Python处理JSON数据的基本方法。有一定的参考价值&#xff0c;有需要的朋友可以参考一下&#xff0c;希望对你们有所帮助。 在介绍使用Python处理JSON数据的基本方法之前&#xff0c;我们首先要了解一下什么是J…

面试题——interleave

2019独角兽企业重金招聘Python工程师标准>>> <!-- lang: cpp --> /** *3个字符串a&#xff0c;b&#xff0c;c。判断c是否是a和b的interleave&#xff0c;也就是c中应该有a&#xff0c;b中所有字符&#xff0c; *并且c中字符顺序和a&#xff0c;b中一样。 *比…

corosync/openais+pacemaker+drbd+web实现高可用群集

拓扑图:配置前提&#xff1a; 1.节点的名字必须跟uname -n的名字相同&#xff0c;而且两个主机必须能通过主机名来访问。尽量不通过DNS来访问。时钟时间保持一样。 2.双方的通信要必须通过SSL的无障碍通信机制 3.双节点之间可以通过某个IP来提供连接&#xff0c;但是这只是通信…

0459-Repeated Substring Pattern(重复的子字符串)

这个系列算是出于个人兴趣开的一个新坑吧&#xff0c;最近看到同学刷LeetCode算法题&#xff0c;就想写写那些可以一行Python代码写出来的题目&#xff0c;因此本专栏的文章的解题方式效率不做保证&#xff0c;只为追求“一行的浪漫”。 题目 题解 简单解释一下题目&#xff0…

golang 反射_golang原理篇- nil:接口类型和值类型的区别

interface接口类型是golang的最重要的数据结构&#xff0c;底层是value和type组成&#xff0c;实现interface的struct的实例都能赋值给接口类型的变量&#xff0c;实现动态value的能力。type记录value的类型。int 3 的接口表示是(int, 3)&#xff0c;接口的零值是 (nil, nil)&a…

分布式一致性问题

什么是分布式一致性问题呢&#xff1f;简单来说&#xff0c;就是在一个分布式系统中&#xff0c;有多个节点&#xff0c;每个节点都会提出一个请求&#xff0c;但是在所有节点中只能确定一个请求被通过。而这个通过是需要所有节点达成一致的结果&#xff0c;所以所谓的一致性就…