//
// cocos2d (incomplete) GLU implementation
//
// gluLookAt and gluPerspective from:
// http://jet.ro/creations (San Angeles Observation)
//
//
#import <OpenGLES/ES1/gl.h>
#import <math.h>
#import "OpenGL_Internal.h"
#include "glu.h"
void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar)
{
GLfloat xmin, xmax, ymin, ymax;
ymax = zNear * (GLfloat)tanf(fovy * (float)M_PI / 360);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustumf(xmin, xmax,
ymin, ymax,
zNear, zFar);
}
void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
GLfloat centerx, GLfloat centery, GLfloat centerz,
GLfloat upx, GLfloat upy, GLfloat upz)
{
GLfloat m[16];
GLfloat x[3], y[3], z[3];
GLfloat mag;
/* Make rotation matrix */
/* Z vector */
z[0] = eyex - centerx;
z[1] = eyey - centery;
z[2] = eyez - centerz;
mag = (float)sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
if (mag) {
z[0] /= mag;
z[1] /= mag;
z[2] /= mag;
}
/* Y vector */
y[0] = upx;
y[1] = upy;
y[2] = upz;
/* X vector = Y cross Z */
x[0] = y[1] * z[2] - y[2] * z[1];
x[1] = -y[0] * z[2] + y[2] * z[0];
x[2] = y[0] * z[1] - y[1] * z[0];
/* Recompute Y = Z cross X */
y[0] = z[1] * x[2] - z[2] * x[1];
y[1] = -z[0] * x[2] + z[2] * x[0];
y[2] = z[0] * x[1] - z[1] * x[0];
/* cross product gives area of parallelogram, which is < 1.0 for
* non-perpendicular unit-length vectors; so normalize x, y here
*/
mag = (float)sqrtf(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
if (mag) {
x[0] /= mag;
x[1] /= mag;
x[2] /= mag;
}
mag = (float)sqrtf(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
if (mag) {
y[0] /= mag;
y[1] /= mag;
y[2] /= mag;
}
#define M(row,col) m[col*4+row]
M(0, 0) = x[0];
M(0, 1) = x[1];
M(0, 2) = x[2];
M(0, 3) = 0.0f;
M(1, 0) = y[0];
M(1, 1) = y[1];
M(1, 2) = y[2];
M(1, 3) = 0.0f;
M(2, 0) = z[0];
M(2, 1) = z[1];
M(2, 2) = z[2];
M(2, 3) = 0.0f;
M(3, 0) = 0.0f;
M(3, 1) = 0.0f;
M(3, 2) = 0.0f;
M(3, 3) = 1.0f;
#undef M
glMultMatrixf(m);
/* Translate Eye to Origin */
glTranslatef(-eyex, -eyey, -eyez);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
水果对对碰APP IOS 源码 (233个子文件)
glu.c 2KB
base64.c 2KB
LICENSE.cocos2d 890B
LICENSE.cocosdenshion 1KB
.DS_Store 6KB
CCCompatibility.h 15KB
CCDirector.h 13KB
CCNode.h 13KB
CCIntervalAction.h 12KB
ccArray.h 12KB
CDOpenALSupport.h 11KB
CCSprite.h 10KB
CCTexture2D.h 9KB
CDAudioManager.h 9KB
CCMenuItem.h 8KB
CocosDenshion.h 8KB
CCParticleSystem.h 8KB
CGPointExtension.h 8KB
CCTransition.h 7KB
EAGLView.h 6KB
CCTiledGridAction.h 6KB
CCGrid3DAction.h 6KB
CCTMXLayer.h 5KB
CCEaseAction.h 5KB
ccTypes.h 5KB
ccHashSet.h 4KB
CCTMXXMLParser.h 4KB
CCGridAction.h 4KB
CCTextureAtlas.h 4KB
OpenGL_Internal.h 4KB
CCTMXTiledMap.h 4KB
CCLayer.h 4KB
CCBitmapFontAtlas.h 4KB
CCSpriteSheet.h 4KB
CCProtocols.h 4KB
FontLabelStringDrawing.h 4KB
CCTextureCache.h 4KB
ccConfig.h 4KB
CCAction.h 4KB
CCSpriteFrame.h 4KB
CLScoreServerRequest.h 3KB
CLScoreServerPost.h 3KB
FontManager.h 3KB
CCSpriteFrameCache.h 3KB
CCPVRTexture.h 3KB
CCTouchDispatcher.h 3KB
CCRibbon.h 3KB
ZAttributedString.h 3KB
CCActionManager.h 3KB
CCGrid.h 3KB
SimpleAudioEngine.h 3KB
CCScheduler.h 3KB
cocos2d.h 3KB
ccMacros.h 3KB
CCInstantAction.h 3KB
CDConfig.h 3KB
CDataScanner.h 2KB
CCAtlasNode.h 2KB
CCTouchHandler.h 2KB
CCTileMapAtlas.h 2KB
CCCamera.h 2KB
CCMotionStreak.h 2KB
CCDrawingPrimitives.h 2KB
CCProgressTimer.h 2KB
CCMenu.h 2KB
CCTouchDelegateProtocol.h 2KB
CJSONDeserializer.h 2KB
CCRenderTexture.h 2KB
CJSONScanner.h 2KB
FontLabel.h 2KB
CCLabel.h 2KB
CCCameraAction.h 2KB
CJSONSerializer.h 2KB
ZFont.h 2KB
CCLabelAtlas.h 2KB
NSScanner_Extensions.h 2KB
CCTMXObjectGroup.h 1KB
CCPageTurnTransition.h 1KB
CDataScanner_Extensions.h 1KB
CCParticleExamples.h 1KB
NSDictionary_JSONExtensions.h 1KB
NSCharacterSet_Extensions.h 1KB
CCProgressTimerActions.h 1KB
CCQuadParticleSystem.h 1KB
TGAlib.h 1KB
CCConfiguration.h 1KB
CCParallaxNode.h 1KB
CCPointParticleSystem.h 915B
CCScene.h 854B
CCPageTurn3DAction.h 778B
ZAttributedStringPrivate.h 722B
CCGrabber.h 704B
ZipUtils.h 699B
CCRadialTransition.h 696B
cocoslive.h 655B
Box.h 595B
CCFileUtils.h 593B
base64.h 551B
TransformUtils.h 527B
glu.h 526B
共 233 条
- 1
- 2
- 3
资源评论
- 双枪老汉2014-03-13不是我想要的啊!不过还是谢谢啦!编译的时候出了点问题,百度一下也解决了。
- gaoyp2013-02-01iOS6下编译失败。
- cfager2013-05-20资源太旧,不能编译
- branil2015-04-29东西有点老,要改好多
凡沙
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python实现基于深度学习高性能中文车牌识别(源码+数据)
- 用于MATLAB的bossdevice API
- docker配置使用,很值得学习的笔记
- Python实现基于 opencv 和 tensorflow 的车牌识别项目(源码+数据).zip
- TM1629B SOP-32封装 LED驱动控制专用电路 深圳市可芯电子有限公司.pdf
- qt-everywhere-src-5.15.0
- Vue3+Element Plus+pinia+ts实现的后台管理系统
- python爬取北、上、广租房信息(高分课程设计)
- Flutter Widget魔法:构建绚丽界面的秘诀
- 基于SSM的学生智能选课系统(源代码+数据库+文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功