一个头文件的问题,
头文件 GLTools.h 包含 math3d.h 。 在《opengl 超级宝典》的例程中GLTools.h 是可以正常运行的,可在我自己的程序里math3d.h 就会出现很多错误,少括号,少分号..... 等等。自己实在想不出为什么。帖子里不能同时容纳两个文件,下面是GLTools.h 。
----------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
// GLTools.h
// OpenGL SuperBible
/* Copyright 1998 - 2003 Richard S. Wright Jr.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither the name of Richard S. Wright Jr. nor the names of other contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GLTOOLS__LIBRARY
#define __GLTOOLS__LIBRARY
// There is a static block allocated for loading shaders to
// prevent heap fragmentation
#define MAX_SHADER_LENGTH 8192
// Bring in OpenGL
// Windows
#ifdef WIN32
#include <windows.h> // Must have for Windows platform builds
#ifndef GLEW_STATIC
#define GLEW_STATIC
#endif
#include <gl\glew.h> // OpenGL Extension "autoloader"
#include <gl\gl.h> // Microsoft OpenGL headers (version 1.1 by themselves)
#endif
// Mac OS X
#ifdef __APPLE__
#include <stdlib.h>
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE | TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#define OPENGL_ES
#else
#include <GL/glew.h>
#include <OpenGL/gl.h> // Apple OpenGL haders (version depends on OS X SDK version)
#endif
#endif
// Linux
#ifdef linux
#define GLEW_STATIC
#include <glew.h>
#endif
//////////////////////// TEMPORARY TEMPORARY TEMPORARY - On SnowLeopard this is suppored, but GLEW doens't hook up properly
//////////////////////// Fixed probably in 10.6.3
#ifdef __APPLE__
#define glGenVertexArrays glGenVertexArraysAPPLE
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE
#ifndef OPENGL_ES
#define glGenerateMipmap glGenerateMipmapEXT
#endif
#endif
// Universal includes
#include <stdio.h>
#include <math.h>
#include <math3d.h>
#include <GLBatch.h>
#include <GLTriangleBatch.h>
///////////////////////////////////////////////////////
// Macros for big/little endian happiness
// These are intentionally written to be easy to understand what they
// are doing... no flames please on the inefficiency of these.
#ifdef __BIG_ENDIAN__
///////////////////////////////////////////////////////////
// This function says, "this pointer is a little endian value"
// If the value must be changed it is... otherwise, this
// function is defined away below (on Intel systems for example)
inline void LITTLE_ENDIAN_WORD(void *pWord)
{
unsigned char *pBytes = (unsigned char *)pWord;
unsigned char temp;
temp = pBytes[0];
pBytes[0] = pBytes[1];
pBytes[1] = temp;
}
///////////////////////////////////////////////////////////
// This function says, "this pointer is a little endian value"
// If the value must be changed it is... otherwise, this
// function is defined away below (on Intel systems for example)
inline void LITTLE_ENDIAN_DWORD(void *pWord)
{
unsigned char *pBytes = (unsigned char *)pWord;
unsigned char temp;
// Swap outer bytes
temp = pBytes[3];
pBytes[3] = pBytes[0];
pBytes[0] = temp;
// Swap inner bytes
temp = pBytes[1];
pBytes[1] = pBytes[2];
pBytes[2] = temp;
}
#else
// Define them away on little endian systems
#define LITTLE_ENDIAN_WORD
#define LITTLE_ENDIAN_DWORD
#endif
///////////////////////////////////////////////////////////////////////////////
// THE LIBRARY....
///////////////////////////////////////////////////////////////////////////////
// Get the OpenGL version
void gltGetOpenGLVersion(GLint &nMajor, GLint &nMinor);
// Check to see if an exension is supported
int gltIsExtSupported(const char *szExtension);
// Set working directoyr to /Resources on the Mac
void gltSetWorkingDirectory(const char *szArgv);
///////////////////////////////////////////////////////////////////////////////
GLbyte* gltReadBMPBits(const char *szFileName, int *nWidth, int *nHeight);
/////////////////////////////////////////////////////////////////////////////////////
// Load a .TGA file
GLbyte *gltReadTGABits(const char *szFileName, GLint *iWidth, GLint *iHeight, GLint *iComponents, GLenum *eFormat);
// Capture the frame buffer and write it as a .tga
// Does not work on the iPhone
#ifndef OPENGL_ES
GLint gltGrabScreenTGA(const char *szFileName);
#endif
// Make Objects
void gltMakeTorus(GLTriangleBatch& torusBatch, GLfloat majorRadius, GLfloat minorRadius, GLint numMajor, GLint numMinor);
void gltMakeSphere(GLTriangleBatch& sphereBatch, GLfloat fRadius, GLint iSlices, GLint iStacks);
void gltMakeDisk(GLTriangleBatch& diskBatch, GLfloat innerRadius, GLfloat outerRadius, GLint nSlices, GLint nStacks);
void gltMakeCylinder(GLTriangleBatch& cylinderBatch, GLfloat baseRadius, GLfloat topRadius, GLfloat fLength, GLint numSlices, GLint numStacks);
void gltMakeCube(GLBatch& cubeBatch, GLfloat fRadius);
// Shader loading support
void gltLoadShaderSrc(const char *szShaderSrc, GLuint shader);
bool gltLoadShaderFile(const char *szFile, GLuint shader);
GLuint gltLoadShaderPair(const char *szVertexProg, const char *szFragmentProg);
GLuint gltLoadShaderPairWithAttributes(const char *szVertexProg, const char *szFragmentProg, ...);
GLuint gltLoadShaderPairSrc(const char *szVertexSrc, const char *szFragmentSrc);
GLuint gltLoadShaderPairSrcWithAttributes(const char *szVertexProg, const char *szFragmentProg, ...);
bool gltCheckErrors(GLuint progName = 0);
void gltGenerateOrtho2DMat(GLuint width, GLuint height, M3DMatrix44f &orthoMatrix, GLBatch &screenQuad);
#endif
//------------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------
...全文
相关推荐
C++的头文件互相包含的问题
C++的头文件互相包含的问题。比较有用的解决办法。
C++头文件包含问题的详细总结
不同头文件中的类的嵌套在实际编程中,不同的类一般是放在不同的相互独立的头文件中的,这样两个类在相互引用时又会有不一样的问题。重复编译是问题出现的根本原因。为了保证头文 件仅被编译一次,在C++中常用的办法是使用条件编译命令。。。
VScode编译C++ 头文件显示not found的问题
主要介绍了VScode编译C++ 头文件显示not found的问题,本文给大家分享问题解决方法,通过截图的形式给大家介绍的非常详细,需要的朋友可以参考下
浅谈iOS关于头文件的导入问题
本篇文章主要介绍了浅谈iOS关于头文件的导入问题,具有一定的参考价值,有兴趣的可以了解一下。
C头文件避免重复包含问题
C头文件的使用方法,避免头文件的重复包含


其它技术问题
