看《OpenGL超级宝典(第四版)》的4.5.2节时遇到了一系列问题,经过不懈努力终于解决,现将过程记录在下,以便查找追思。

看《OpenGL超级宝典(第四版)》的4.5.2节时遇到了一系列问题,经过不懈努力终于解决,现将过程记录在下,以便查找追思。


在第4.5.2节之前,自己写的的代码都没有使用作者的gltools.h文件,而是直接使用的glut.h文件,且从未出现过问题。

看到4.5.2节时,本来想先看看运行效果,于是复制运行了作者的代码,结果遇到了问题:

11>LINK : fatal error LNK1104: 无法打开文件“freeglut.lib”

解决方法:

(1)下载freeglut-2.8.1.tar.gz压缩包并解压。

(2)将freeglut-2.8.1\freeglut-2.8.1\include\GL文件夹下的freeglut.h、freeglut_ext.h、freeglut_std.h、glut.h文件复制到C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl文件夹下。(初次配置OpenGL环境后,C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl文件夹下会有一个glut.h文件,将它改个名字屏蔽掉,防止覆盖,例如“glut.h-”)

(3)将freeglut-2.8.1\freeglut-2.8.1\lib\x86文件夹下的freeglut.dll文件复制到C:\Windows\System32文件夹下。

(4)将freeglut-2.8.1\freeglut-2.8.1\lib\x86文件夹下的freeglut.lib、freeglut_static.lib文件复制到C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib文件夹下。

按F7生成后出现另外的问题:

21>MainOfTempCode.obj : error LNK2001: 无法解析的外部符号 "void __cdecl m3dRotationMatrix44(float * const,float,float,float,float)" (?m3dRotationMatrix44@@YAXQAMMMMM@Z)

1>D:\WLSCode\TempCode\Debug\TempCode.exe : fatal error LNK1120: 1 个无法解析的外部命令

解决方法:

添加shared文件夹下的math3d.cpp到工程中。

再次F7生成后又出现一个问题:

31>Link:
1>  freeglut_static.lib(freeglut_display.obj) : 找到 MSIL .netmodule 或使用 /GL 编译的模块;正在使用 /LTCG 重新启动链接;将 /LTCG 添加到链接命令行以改进链接器性能
1>LINK : warning LNK4075: 忽略“/INCREMENTAL”(由于“/LTCG”规范)
1>libcmt.lib(crt0dat.obj) : error LNK2005: __initterm_e 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(crt0dat.obj) : error LNK2005: _exit 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(crt0dat.obj) : error LNK2005: __exit 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(crt0dat.obj) : error LNK2005: __cexit 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(crt0dat.obj) : error LNK2005: __amsg_exit 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(invarg.obj) : error LNK2005: __invoke_watson 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xi_a 已经在 MSVCRTD.lib(cinitexe.obj) 中定义
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xi_z 已经在 MSVCRTD.lib(cinitexe.obj) 中定义
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xc_a 已经在 MSVCRTD.lib(cinitexe.obj) 中定义
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xc_z 已经在 MSVCRTD.lib(cinitexe.obj) 中定义
1>libcmt.lib(crt0.obj) : error LNK2005: _mainCRTStartup 已经在 MSVCRTD.lib(crtexe.obj) 中定义
1>libcmt.lib(errmode.obj) : error LNK2005: ___set_app_type 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(mlock.obj) : error LNK2005: __unlock 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(mlock.obj) : error LNK2005: __lock 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(winxfltr.obj) : error LNK2005: __XcptFilter 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>libcmt.lib(setlocal.obj) : error LNK2005: __configthreadlocale 已经在 MSVCRTD.lib(MSVCR100D.dll) 中定义
1>LINK : warning LNK4098: 默认库“MSVCRTD”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: 默认库“libcmt.lib”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
1>D:\WLSCode\TempCode\Debug\TempCode.exe : fatal error LNK1169: 找到一个或多个多重定义的符号
1>
1>生成失败。

解决方法:

屏蔽gltools.h文件夹下的“#define FREEGLUT_STATIC”一行。

最后F7生成成功,运行正常。


-----------------------------------------------------------------

至此,本着“看效果”的目的,运行作者代码成功。

中文名: openGL超级宝典第四版)及代码 英文名: OpenGL SuperBible (4th Edition) 版本: [PDF] 发行日期: 2007年06月28日 地区: 美国 对白语言: 英语 简介: 原名:OpenGL SuperBible (4th Edition) 作者:Richard S. Wright, Jr. 出版社:Addison Wesley 页码: 1262 版次:4 丛名: OpenGL SuperBible 出版日期: 2007-6-28 官方网站:http://www.starstonesoftware.com/OpenGL/ 本OpenGL编程指南,涵盖了使用新版本的OpenGL进行编程所需要的主要知识。 全分3个部分,共23章,另有3个附录。第一部介绍经典OpenGL绘图的所有基础知识,包括3D图形和OpenGL简介, OpenGL空间绘图,几何转换,颜色、材料和光照,纹理贴图,曲线和表面,管线,交互式图形等内容。第二部分是着重介绍OpenGL的一些高级功能。第三部分别介绍了不同操作系统平台上的OpenGL功能特性和编程细节。 本适合于希望精通OpenGL以便对他们的图形编程和3D图形知识进行扩展的程序员,也可以帮助那些经验丰富的OpenGL程序员学习如何移植自己的应用程序。本既可以作为学习OpenGL的教材,也可以作为随时查阅的参考手册。 第二个文件是里面代码 Editorial Reviews Product Description OpenGL ® SuperBible, Fourth Edition, begins by illuminating the core techniques of “classic” OpenGL graphics programming, from drawing in space to geometric transformations, from lighting to texture mapping. The authors cover newer OpenGL capabilities, including OpenGL 2.1’s powerful programmable pipeline, vertex and fragment shaders, and advanced buffers. They also present thorough, up-to-date introductions to OpenGL implementations on multiple platforms, including Windows, Mac OS X, GNU/Linux, UNIX, and embedded systems. Coverage includes · An entirely new chapter on OpenGL ES programming for handhelds · Completely rewritten chapters on OpenGL for Mac OS X and GNU/Linux · Up-to-the-minute coverage of OpenGL on Windows Vista · New material on floating-point color buffers and off-screen rendering · In-depth introductions to 3D modeling and object composition · Expert techniques for utilizing OpenGL’s programmable shading language · Thorough coverage of curves, surfaces, interactive graphics, textures, shadows, and much more · A fully updated API reference, and an all-new section of full-color images You’ll rely on this book constantly–whether you’re learning OpenGL for the first time, deepening your graphics programming expertise, upgrading from older versions of OpenGL, or porting applications from other environments. Now part of the OpenGL Technical Library–The official knowledge resource for OpenGL developers The OpenGL Technical Library provides tutorial and reference books for OpenGL. The Library enables programmers to gain a practical understanding of OpenGL and shows them how to unlock its full potential. Originally developed by SGI, the Library continues to evolve under the auspices of the OpenGL Architecture Review Board (ARB) Steering Group (now part of the Khronos Group), an industry consortium responsible for guiding the evolution of OpenGL and related technologies. Contents Preface xxvii About the Authors xxxv Introduction 1 Part I: The Old Testament Chapter 1 Introduction to 3D Graphics and OpenGL 9 Chapter 2 Using OpenGL 33 Chapter 3 Drawing in Space: Geometric Primitives and Buffers 73 Chapter 4 Geometric Transformations: The Pipeline 127 Chapter 5 Color, Materials, and Lighting: The Basics 173 Chapter 6 More on Colors and Materials 229 Chapter 7 Imaging with OpenGL 251 Chapter 8 Texture Mapping: The Basics 303 Chapter 9 Texture Mapping: Beyond the Basics 341 Chapter 10 Curves and Surfaces 377 Chapter 11 It’s All About the Pipeline: Faster Geometry Throughput 421 Chapter 12 Interactive Graphics 457 Chapter 13 Occlusion Queries: Why Do More Work Than You Need To? 481 Chapter 14 Depth Textures and Shadows 495 Part II: The New Testament Chapter 15 Programmable Pipeline: This Isn’t Your Father’s OpenGL 515 Chapter 16 Vertex Shading: Do-It-Yourself Transform, Lighting, and Texgen 547 Chapter 17 Fragment Shading: Empower Your Pixel Processing 567 Chapter 18 Advanced Buffers 601 Part III: The Apocrypha Chapter 19 Wiggle: OpenGL on Windows 641 Chapter 20 OpenGL on Mac OS X 685 Chapter 21 OpenGL on Linux 713 Chapter 22 OpenGL ES — OpenGL on the Small 735 Appendix A Further Reading/References 773 Appendix B Glossary 777 Appendix C API Reference 783 Index 1141 About the Author Richard S. Wright, Jr.has been using OpenGL for more than 12 years, since it first became available on the Windows platform, and teaches OpenGL programming in the game design degree program at Full Sail in Orlando, Florida. Currently, Richard is the president of Starstone Software Systems, Inc., where he develops third-party multimedia simulation software for the PC and Macintosh platforms using OpenGL. Previously with Real 3D/Lockheed Martin, Richard was a regular OpenGL ARB attendee and contributed to the OpenGL 1.2 specification and conformance tests. Since then, Richard has worked in multidimensional database visualization, game development, medical diagnostic visualization, and astronomical space simulation. Richard first learned to program in the eighth grade in 1978 on a paper terminal. At age 16, his parents let him buy a computer with his grass-cutting money instead of a car, and he sold his first computer program less than a year later (and it was a graphics program!). When he graduated from high school, his first job was teaching programming and computer literacy for a local consumer education company. He studied electrical engineering and computer science at the University of Louisville’s Speed Scientific School and made it half way through his senior year before his career got the best of him and took him to Florida. A native of Louisville, Kentucky, he now lives with his wife and three children in Lake Mary, Florida. When not programming or dodging hurricanes, Richard is an avid amateur astronomer and an Adult Sunday School teacher. Benjamin Lipchak graduated from Worcester Polytechnic Institute with a double major in technical writing and computer science. “Why would anyone with a CS degree want to become a writer?” That was the question asked of him one fateful morning when Benj was interviewing for a tech writing job at Digital Equipment Corporation. Benj’s interview took longer than scheduled, and he left that day with job offer in hand to work on the software team responsible for DEC’s AlphaStation OpenGL drivers. Benj’s participation in the OpenGL Architecture Review Board began when he chaired the working group that generated the GL_ARB_fragment_program extension spec. While chairing the Khronos OpenGL Ecosystem Technical SubGroup, he established the OpenGL SDK and created the OpenGL Pipeline newsletter, of which he remains editor. Benj will now participate in the Khronos OpenGL ES Working Group. After 12 years of OpenGL driver development and driver team management at DEC, Compaq, and ATI, he is headed for smaller pastures. Benj recently became manager of AMD’s handheld software team. Although the API is familiar, the new challenges of size and power consumption make for a great change of scenery. In his fleeting spare time, Benj tries to get outdoors for some hiking or kayaking. He also operates an independent record label, Wachusett Records, specializing in solo piano music. Nicholas Haemel, developer at AMD in the Graphics Products Group, was technical reviewer for OpenGL SuperBible, Third Edition, and contributed the chapters on GLX and OpenGL ES
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值