欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > VisualStudio中配置OpenGL环境并制作模板

VisualStudio中配置OpenGL环境并制作模板

2025/1/23 14:10:16 来源:https://blog.csdn.net/weixin_48524215/article/details/145307403  浏览:    关键词:VisualStudio中配置OpenGL环境并制作模板

VisualStudio中配置OpenGL环境并制作模板

本教程来自:sumantaguha

Install Visual Studio

  1. Download Microsoft Visual Studio Community 2019 from https://my.
    visualstudio.com/Downloads?q=visual%20studio%202019&wt.mc_
    id=omsftvscom~older-downloads and follow the installation steps.
    On the tool bar of the MSVS page click Project → OpenGLPro
    jectTemplate Properties to bring up the Property Pages. Select All
    Configurations from the dropdown menu to the right of “Configura
    tion:”.

Install Helper Libraries

  1. Create a folder called OpenGLwrappers in the C: drive, so this folder is C:\OpenGLwrappers. This particular name and location is so that all our programs in ExperimenterSource run out of the box.
    The version numbers below of the libraries we ask you to download
    may not be the latest but they are the ones we have installed in
    our environment. There are sometimes little things that differ with
    versions. To be sure, we have not yet heard of a problem in upgrading to a newer version. Still, to avoid any issues at all while you are learning we suggest you install the exact versions below.

  2. FreeGLUT:Downloadandunzipthe file http://files.transmissionzero.
    co.uk/software/development/GLUT/older/freeglut-MSVC-2.8.1-1.
    mp.zip and save the folder freeglut-MSVC-2.8.1-1.mp in OpenGLwrappers.

  3. GLEW: Download and unzip the file https://sourceforge.net/
    projects/glew/files/glew/1.10.0/glew-1.10.0-win32.zip/ download
    and save the folder glew-1.10.0-win32 in OpenGLwrappers.

  4. GLM: Download and unzip the file https://github.com/g-truc/
    glm/releases/download/0.9.7.5/glm-0.9.7.5.zip and save the
    folder glm-0.9.7.5 in OpenGLwrappers.

  5. Copy freeglut.dll from C:\OpenGLwrappers
    freeglut-MSVC-2.8.1-1.mp\freeglut\bin to C:\Windows\SysWOW64.

  6. Copy glew32.dll from C:\OpenGLwrappers\glew-1.10.0-win32
    glew-1.10.0\bin\Release\Win32 to C:\Windows\SysWOW64.

  7. Check if glu32.dll is already in C:\Windows\SysWOW64. Normally,
    it should be. If not, search resources on the web to reinstall it there.

Create and Use an OpenGL Project Template

  1. Open Visual Studio 2019 from the Start Menu. Click “Create a new
    project” and in the next page search for “C++” in the templates search
    box and select C++ Console App. Click Next. In the “Configure
    your new project” page enter OpenGLProjectTemplate for Project
    name and for Location any convenient folder. Check the box “Place
    solution and project in the same directory”. Click Create.

  1. The MSVS page of OpenGLProjectTemplate comes up. On the tool
    bar click View → Solution Explorer to open the Solution Explorer pane.
    Under the Source Files item you will find OpenGLProjectTemplates.cpp.
    Double click it to open it in another pane.

3.On the tool bar of the MSVS page click Project → OpenGLPro
jectTemplate Properties to bring up the Property Pages. Select All
Configurations from the dropdown menu to the right of “Configura
tion:”.

4.Expand Configuration Properties and click Configuration Properties
→C/C++ →General → Additional Include Directories → ⟨Edit…⟩
(in the drop-down menu) to open the Additional Include Directories
dialog box. Click the New Line icon successively to create a new line
to add each of the following folders (order doesn’t matter; you can
click the box with “…” at the right of the empty new line to navigate
to the folder):
(1) C:\OpenGLwrappers\freeglut-MSVC-2.8.1-1.mp\freeglut
include
(2) C:\OpenGLwrappers\glew-1.10.0-win32\glew-1.10.0
include
(3) C:\OpenGLwrappers\glm-0.9.7.5\glm
Click OK to confirm.




添加包含目录

5.Click Configuration Properties → Linker → General → Additional
Library Directories → ⟨Edit…⟩ (in the drop-down menu) to open the
Additional Library Directories dialog box. Click the New Line icon
successively to create a new line to add each of the following folders
(order doesn’t matter; you can click the box with “…” at the right of
the empty new line to navigate to the folder):
(1) C:\OpenGLwrappers\freeglut-MSVC-2.8.1-1.mp\freeglut
lib
(2) C:\OpenGLwrappers\glew-1.10.0-win32\glew-1.10.0
lib\Release\Win32
Click OK to confirm.


6.Click Configuration Properties → Linker → Input → Additional
Dependencies → ⟨Edit…⟩ (in the drop-down menu) to open the
Additional Dependencies dialog box. Manually enter the following file
names one per line in the window at the top (order doesn’t matter):
(a) glew32.lib
(b) opengl32.lib
Click OK to confirm.



删除源文件后创建模板
7.On the MSVS toolbar click File → Save All. Next click Project
→ Export Template. In the Export Template Wizard choose the
Project template radio button and click Next. Name the template
OpenGLProjectTemplate and check the box “Automatically import
the template into Visual Studio” and uncheck the box “Display an
explorer window on the output files folder”. Click Finish. The
template OpenGLProjectTemplate has been created and you can, in
fact, now delete the project OpenGLProjectTemplate from the folder
you created it in.


)

)
)
To use the template, open Visual Studio 2019 from the Start Menu
to bring up the MSVS Start Page. Click Create a new project and
search for and select the template OpenGLProjectTemplate. Click
Next. Name the project and select an appropriate folder for its
location and click Create. The new project comes up. Right click on
Source Files in the Solution Explorer to add a New Item. Choose
C++ File for the type of this item, give a Name, and Add. A .cpp
file pops up in a pane in which you can now write C++/OpenGL
code.


以此为模板建立自己的源文件

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com