-
大小: 4.27MB文件類型: .zip金幣: 2下載: 0 次發布日期: 2023-10-01
- 語言: 其他
- 標簽: OpenGLPro12??
資源簡介
OpenGLPro12 代碼

代碼片段和文件信息
#include?“cgl.h“
CGL::CGL()
{
????//ctor
}
CGL::CGL(int?_width?int?_height)
{
????this->width?=?_width;
????this->height?=?_height;
????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?);
????bunny?=?Objobject(“dragon.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);
????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?);
????//prog.printActiveUniforms();
????//prog.printActiveAttribs();
???//?glDrawArrays(GL_QUADS04);
????glDrawArrays(GL_TRIANGLES?0?bunny.vertices.size()?);
??? SDL_GL_SwapBuffers(?);
????/*?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);
//glBufferData(GL_ARRAY_BUFFER?12?*?sizeof(GLfloat)?positionData?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
);
????GLuint?normalbuffer;
glGenBuffers(1?&normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER?normalbuffer);
glBufferData(GL_ARRAY_BUFFER?bunny.normals.size()?*?sizeof(glm::vec3)?&bunny.normals[0]?GL_STATIC_DRAW);
//?3rd?attribute?buffer?:?normals
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????25924??2013-08-16?13:42??OpenGLPro12\obj\Debug\main.o
?????文件??????215868??2013-08-17?03:06??OpenGLPro12\obj\Debug\cgl.o
?????文件???????21460??2013-08-01?14:17??OpenGLPro12\obj\Debug\sdl.o
?????文件???????42448??2013-08-16?13:34??OpenGLPro12\obj\Debug\csdl.o
?????文件??????204768??2013-08-13?14:01??OpenGLPro12\obj\Debug\util.o
?????文件???????80884??2013-08-07?08:04??OpenGLPro12\obj\Debug\shader.o
?????文件???????82232??2013-08-16?13:34??OpenGLPro12\obj\Debug\shaderprogram.o
?????文件???????72780??2013-08-13?14:01??OpenGLPro12\obj\Debug\teapot.o
?????文件???????72856??2013-08-16?13:28??OpenGLPro12\obj\Debug\objob
?????文件??????374070??2013-08-17?03:06??OpenGLPro12\bin\Debug\SDLTest
?????文件?????????511??2013-08-15?01:59??OpenGLPro12\shader\basic.frag
?????文件?????????159??2013-08-14?15:22??OpenGLPro12\shader\basic.vert~
?????文件?????????172??2013-08-17?03:06??OpenGLPro12\shader\basic1.frag
?????文件????????1285??2013-08-17?03:04??OpenGLPro12\shader\basic1.vert~
?????文件?????????216??2013-08-15?01:59??OpenGLPro12\shader\basic.vert
?????文件????????1290??2013-08-17?03:06??OpenGLPro12\shader\basic1.vert
?????文件?????????511??2013-08-15?01:59??OpenGLPro12\shader\basic.frag~
?????文件?????????167??2013-08-17?03:04??OpenGLPro12\shader\basic1.frag~
?????文件?????????552??2013-08-13?13:58??OpenGLPro12\util.h
?????文件????????4134??2013-08-13?13:21??OpenGLPro12\util.cpp
?????文件????????1273??2013-08-17?03:19??OpenGLPro12\SDLTest.layout
?????文件????????2098??2013-08-17?03:06??OpenGLPro12\SDLTest.depend
?????文件????????1437??2013-08-07?08:04??OpenGLPro12\SDLTest.cbp~
?????文件?????????631??2013-08-16?13:42??OpenGLPro12\main.cpp
?????文件?????????758??2013-08-02?01:45??OpenGLPro12\csdl.h
?????文件????????3011??2013-08-15?06:04??OpenGLPro12\csdl.cpp
?????文件?????????590??2013-08-16?13:34??OpenGLPro12\cgl.h
?????文件????????5136??2013-08-17?03:06??OpenGLPro12\cgl.cpp
?????文件????????1767??2013-08-16?13:31??OpenGLPro12\shaderprogram.h
?????文件???????58002??2013-08-01?06:59??OpenGLPro12\monkey.obj
?????文件????????8489??2013-08-16?13:33??OpenGLPro12\shaderprogram.cpp
............此處省略16個文件信息
- 上一篇:glm-0.9.4.4
- 下一篇:g77_pack g77_pack
評論
共有 條評論