资源简介
OpenGLTexture

代码片段和文件信息
#include “cgl.h“
CGL::CGL()
{
//ctor
}
CGL::CGL(int _width int _height)
{
this->width = _width;
this->height = _height;
// model = mat4(0.5f);
prog = ShaderProgram();
}
CGL::~CGL()
{
//dtor
}
bool CGL::initGL()
{
/* Enable smooth shading */
glShadeModel( GL_SMOOTH );
/* Set the background black */
glClearColor( 0.0f 0.0f 0.0f 0.0f );
/* Depth buffer setup */
glClearDepth( 1.0f );
/* Enables Depth Testing */
glEnable( GL_DEPTH_TEST );
/* The Type Of Depth Test To Do */
glDepthFunc( GL_LEQUAL );
/* Really Nice Perspective Calculations */
glHint( GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST );
model = mat4(1.0f);
view = glm::lookAt(vec3(-2.0f5.0f1.0f) vec3(0.0f1.0f0.0f) vec3(0.0f1.0f0.0f));
bunny = Objobject(“assets/model/cubic.obj“);
return( true );
}
bool CGL::resizeGL(int widthint height)
{
if ( height == 0 )
{
height = 1;
}
//Reset View
glViewport( 0 0 (GLint)width (GLint)height );
//Choose the Matrix mode
glMatrixMode( GL_PROJECTION );
//reset projection
glLoadIdentity();
//set perspection
gluPerspective( 45.0 (GLfloat)width/(GLfloat)height 0.1 100.0 );
//choose Matrix mode
glMatrixMode( GL_MODELVIEW );
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
}
bool CGL::renderGL()
{
/* These are to calculate our fps */
static GLint T0 = 0;
static GLint frames = 0;
// Clear the color and depth buffers.
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// We don‘t want to modify the projection matrix. */
glMatrixMode( GL_MODELVIEW );
glDrawArrays(GL_TRIANGLES 0 bunny.vertices.size() );
SDL_GL_SwapBuffers( );
//this->changeMatrics();
/* Gather our frames per second */
frames++;
{
GLint t = SDL_GetTicks();
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = frames / seconds;
printf(“%d frames in %g seconds = %g FPS\n“ frames seconds fps);
T0 = t;
frames = 0;
}
}
}
void CGL::compileShader()
{
glGenVertexArrays(1 &VertexArrayID);
glBindVertexArray(VertexArrayID);
glGenBuffers(1 &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER vertexbuffer);
glBufferData(GL_ARRAY_BUFFER bunny.vertices.size() * sizeof(glm::vec3) &bunny.vertices[0] GL_STATIC_DRAW);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER vertexbuffer);
glVertexAttribPointer(
0 // attribute
3 // size
GL_FLOAT // type
GL_FALSE // normalized?
0 // stride
(void*)0 // array buffer offset
);
// 2rd attribute buffer : normals
GLuint normalbuffer;
glGenBuffers(1 &normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER normalbuffer);
glBufferData(GL_ARRAY_BUFFER bunny.normals
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-11-24 10:57 OpenGLPro16_Texturing\
文件 207 2013-08-07 16:35 OpenGLPro16_Texturing\README.txt
文件 194 2013-08-07 16:35 OpenGLPro16_Texturing\README.txt~
文件 1555 2013-08-27 22:38 OpenGLPro16_Texturing\SDLTest.cbp
文件 1437 2013-08-07 16:04 OpenGLPro16_Texturing\SDLTest.cbp~
文件 7746 2013-11-24 10:43 OpenGLPro16_Texturing\SDLTest.depend
文件 1280 2013-11-24 10:57 OpenGLPro16_Texturing\SDLTest.layout
文件 1279 2013-11-24 10:57 OpenGLPro16_Texturing\SDLTest.layout.cbTemp
目录 0 2013-11-22 16:13 OpenGLPro16_Texturing\assets\
目录 0 2013-11-23 22:45 OpenGLPro16_Texturing\assets\model\
文件 57404 2013-08-16 20:33 OpenGLPro16_Texturing\assets\model\ball.obj
文件 43662 2013-08-17 10:25 OpenGLPro16_Texturing\assets\model\ball2.obj
文件 4862151 2013-08-16 20:29 OpenGLPro16_Texturing\assets\model\bunny.obj
文件 944 2013-11-23 22:40 OpenGLPro16_Texturing\assets\model\cubic.obj
文件 7037230 2013-08-16 23:18 OpenGLPro16_Texturing\assets\model\dragon.obj
文件 58002 2013-08-01 14:59 OpenGLPro16_Texturing\assets\model\monkey.obj
文件 194614 2013-08-21 21:39 OpenGLPro16_Texturing\assets\model\scene.obj
目录 0 2013-11-24 09:53 OpenGLPro16_Texturing\assets\textures\
文件 210980 2012-06-15 10:39 OpenGLPro16_Texturing\assets\textures\brick.jpg
文件 196662 2001-06-16 10:29 OpenGLPro16_Texturing\assets\textures\crate.bmp
文件 196662 2013-11-24 09:53 OpenGLPro16_Texturing\assets\textures\crate_normal.bmp
文件 2193338 2012-06-15 10:39 OpenGLPro16_Texturing\assets\textures\moss.png
文件 11159 2013-08-05 19:56 OpenGLPro16_Texturing\assets\textures\smile.png
目录 0 2013-11-22 16:13 OpenGLPro16_Texturing\bin\
目录 0 2013-11-24 10:55 OpenGLPro16_Texturing\bin\Debug\
文件 457598 2013-11-24 10:55 OpenGLPro16_Texturing\bin\Debug\SDLTest
文件 10098 2013-11-24 10:54 OpenGLPro16_Texturing\cgl.cpp
文件 739 2013-11-24 10:43 OpenGLPro16_Texturing\cgl.h
文件 3143 2013-08-21 10:42 OpenGLPro16_Texturing\csdl.cpp
文件 766 2013-08-20 23:13 OpenGLPro16_Texturing\csdl.h
文件 704 2013-11-24 09:15 OpenGLPro16_Texturing\main.cpp
............此处省略28个文件信息
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
- OpenGL实现飘动效果
- opengl室内场景的绘制,包括碰撞检测
评论
共有 条评论