资源简介
本程序提供给OpenGL初学者使用, 该程序中描述了如何实现透视投影。代码中如有疑问请指出,会为你一一解答。
代码片段和文件信息
#include
#include
#include
#include
#include
#ifdef __APPLE__
#include // OS X version of GLUT
#else
#define FREEGLUT_STATIC
#include // Windows FreeGlut equivalent
#endif
#include
using namespace std;
const float PI = 3.14159265358979323846;
/************************************************************************************/
void ChangeSize(int w int h)
{
glViewport(0 0 w h);
}
/************************************************************************************/
#include
#include
#define MAX_SHADER_LENGTH 8192
#define MAX_TARGET_NUM 10
GLchar shaderText[MAX_SHADER_LENGTH];
void gltLoadShaderSrc(const char *szShaderSrc GLuint shader)
{
GLchar *fsStringPtr[1];
fsStringPtr[0] = (GLchar *)szShaderSrc;
glShaderSource(shader 1 (const GLchar **)fsStringPtr NULL);
}
bool gltLoadShaderFile(const char *szFile GLuint shader)
{
GLint shaderLength = 0;
FILE *fp;
// Open the shader file
fp = fopen(szFile “r“);
if(fp != NULL)
{
// See how long the file is
while (fgetc(fp) != EOF)
shaderLength++;
// Allocate a block of memory to send in the shader
assert(shaderLength < MAX_SHADER_LENGTH); // make me bigger!
if(shaderLength > MAX_SHADER_LENGTH)
{
fclose(fp);
return false;
}
// Go back to beginning of file
rewind(fp);
// Read the whole file in
if (shaderText != NULL)
fread(shaderText 1 shaderLength fp);
// Make sure it is null terminated and close the file
shaderText[shaderLength] = ‘\0‘;
fclose(fp);
}
else
return false;
// Load the string
gltLoadShaderSrc((const char *)shaderText shader);
return true;
}
GLuint vao;
GLuint vertex_bufferindex_buffer;
GLuint vert_shader frag_shader;
GLuint program;
GLfloat vVerts[12] = { -500.0f -500.0f -800.0f
500.0f -500.0f -800.0f
0.0f 500.0f -800.0f
0.0f 0.0f -300.0f };
GLuint element_index[] = { 0 1 2
0 1 3
0 3 2
1 2 3 };
GLfloat modelMatrix[16] = {1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0};
GLfloat viewMatrix[16] = {1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0};
GLfloat projectionMat
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-14 13:16 SetPerspective\
文件 202 2016-09-23 10:56 SetPerspective\Identity.fp
文件 310 2016-09-23 14:11 SetPerspective\Identity.vp
文件 6878 2016-10-10 13:13 SetPerspective\main.cpp
文件 322 2016-10-09 15:52 SetPerspective\Triangle.pro
相关资源
- OpenGL纹理贴图.jpg格式图片小程序源码
- QT5.7+OPENGL画正方体
- OpenGL实现多边形扫描转换的扫描线算
- OpenGL鼠标点选平移物体
- 基于opengl es 的显示gif的
- OpenGL编程指南(第八版)中文高清晰
- OpenGL精美房屋,落雪其上
- OpenGL光照,多种情况下的建立
- vlc opengl播放视频
- Opengl写的3d人物模型
- OPENGL学习 3D小雪人
- opengl动态云彩的模拟
- nvidia-opengl-rdp 英伟达显卡 rdp 远程桌面
- OpenGL模型视图矩阵演示
- 基于VC_的OpenGL三维动画仿真及场景漫
- OpenGL仿微信视频聊天
- OpenGL预览摄像头
- OpenGl 会走路的机器人
- opengl 做的很漂亮的一棵树,用分形算
- 3ds模型导入opengl,实现旋转平移缩放
- opengl中点画圆法
- opengl编程指南第7版源代码
- 3D酷炫屏幕保护程序OpenGL
- OpenGL文件.zip
- 配置OpenGL以及glaux所需资源.h.dll
- luweiqi素材
- VS2017&OpenGL;环境搭建
- OpenGL 顶点数组+拾取
- openGL配置资源文件,含32/64位
- GLPrint_demo
评论
共有 条评论