資源簡介
這是一個用opengl實現的人物模型讀取以及地面,以及光照,貼圖,shader。
代碼片段和文件信息
//?Include?standard?headers
#include?
#include?
#include?
//?Include?GLEW
#include?
//?Include?GLFW
#include?
GLFWwindow*?window;
#??include?
#??include?
//?Include?GLM
#include?
#include?
using?namespace?glm;
#include?
#include?
#include?
#include?
int?main(?void?)
{
//?初始化?GLFW
if(?!glfwInit()?)
{
fprintf(?stderr?“Failed?to?initialize?GLFW\n“?);
getchar();
return?-1;
}
//配置glfw
glfwWindowHint(GLFW_SAMPLES?4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR?3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR?3);
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT?GL_TRUE);?//?Mac系統需要加這行代碼
glfwWindowHint(GLFW_OPENGL_PROFILE?GLFW_OPENGL_CORE_PROFILE);
//?創建窗口對象
int?width?=?1024;
int?height?=?768;
window?=?glfwCreateWindow(?width?height?“Model?Loading“?NULL?NULL);
if(?window?==?NULL?){
fprintf(?stderr?“Failed?to?open?GLFW?window.?If?you?have?an?Intel?GPU?they?are?not?3.3?compatible.?Try?the?2.1?version?of?the?tutorials.\n“?);
getchar();
glfwTerminate();
return?-1;
}
glfwMakeContextCurrent(window);
//?初始化GLEW
glewExperimental?=?true;?//?Needed?for?core?profile
if?(glewInit()?!=?GLEW_OK)?{
fprintf(stderr?“Failed?to?initialize?GLEW\n“);
getchar();
glfwTerminate();
return?-1;
}
//?按鍵
glfwSetInputMode(window?GLFW_STICKY_KEYS?GL_TRUE);
????//?鼠標
????glfwSetInputMode(window?GLFW_CURSOR?GLFW_CURSOR_DISABLED);
????
????//?設置鼠標
????glfwPollEvents();
????glfwSetCursorPos(window?width/2?height/2);
//?深度測試
glEnable(GL_DEPTH_TEST);
//?靠近時重新繪制幀緩存中對應像素的顏色值
glDepthFunc(GL_LESS);?
//?加載著色器
GLuint?programID?=?LoadShaders(?“ObjVertexShader.vertexshader“?“ObjFragmentShader.fragmentshader“?);
GLuint?programID2?=?LoadShaders(?“ObjVertexShader.vertexshader“?“ObjFragmentShader.fragmentshader“?);
GLuint?programID3?=?LoadShaders(“ObjVertexShader.vertexshader“?“ObjFragmentShader.fragmentshader“);
GLuint?programID4?=?LoadShaders(“ObjVertexShader.vertexshader“?“ObjFragmentShader.fragmentshader“);
GLuint?group?=?LoadShaders(“GroupShader.vertexshader“?“GroupShader.fragmentshader“);
//?加載紋理
GLuint?Texture?=?loadBMP_custom(“wall.bmp“);
GLuint?Texture2?=?loadBMP_custom(“cat.bmp“);
GLuint?Texture3?=?loadBMP_custom(“boy.bmp“);
GLuint?Texture4?=?loadBMP_custom(“wood.bmp“);
//給著色器傳遞常量uniform
GLuint?MatrixID?=?glGetUniformLocation(programID?“MVP“);//模視變換矩陣?傳給頂點著色器
GLuint?TextureID??=?glGetUniformLocation(programID?“myTextureSampler“);//紋理?傳給片元著色器
GLuint?LightColorID??=?glGetUniformLocation(programID?“lightColor“);//光源顏色?傳給片元著色器
GLuint?modelID??=?glGetUniformLocation(programID?“model“);//模變換矩陣?傳給頂點著色器
GLuint?lightPositionID??=?glGetUniformLocation(programID?“lightPos“);//光源位置?傳給片元著色器
????GLuint?viewID??=?glGetUniformLocation(programID
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-02-28?22:54??Opengl_lab1\
?????目錄???????????0??2018-02-28?22:56??Opengl_lab1\Opengl_lab1\
?????目錄???????????0??2017-12-04?17:59??Opengl_lab1\Opengl_lab1\.vs\
?????目錄???????????0??2017-12-04?17:59??Opengl_lab1\Opengl_lab1\.vs\Opengl_lab1\
?????目錄???????????0??2017-12-04?17:59??Opengl_lab1\Opengl_lab1\.vs\Opengl_lab1\v14\
?????文件???????64000??2017-12-05?00:26??Opengl_lab1\Opengl_lab1\.vs\Opengl_lab1\v14\.suo
?????目錄???????????0??2017-12-07?15:37??Opengl_lab1\Opengl_lab1\Debug\
?????文件??????424448??2017-12-07?15:37??Opengl_lab1\Opengl_lab1\Debug\Opengl_lab1.exe
?????文件?????1307564??2017-12-07?15:37??Opengl_lab1\Opengl_lab1\Debug\Opengl_lab1.ilk
?????文件?????2731008??2017-12-07?15:37??Opengl_lab1\Opengl_lab1\Debug\Opengl_lab1.pdb
?????目錄???????????0??2017-12-07?15:39??Opengl_lab1\Opengl_lab1\Opengl_lab1\
?????文件????42860544??2018-02-28?22:56??Opengl_lab1\Opengl_lab1\Opengl_lab1.sdf
?????文件?????????900??2017-10-25?09:53??Opengl_lab1\Opengl_lab1\Opengl_lab1.sln
?????文件???????46080??2017-11-17?11:30??Opengl_lab1\Opengl_lab1\Opengl_lab1.v11.suo
?????文件???????61440??2018-02-28?22:56??Opengl_lab1\Opengl_lab1\Opengl_lab1.v12.suo
?????文件????42598400??2017-12-05?00:26??Opengl_lab1\Opengl_lab1\Opengl_lab1.VC.db
?????文件?????3145784??2017-12-04?23:38??Opengl_lab1\Opengl_lab1\Opengl_lab1\111.bmp
?????文件?????1389218??2017-11-15?16:14??Opengl_lab1\Opengl_lab1\Opengl_lab1\23.obj
?????文件??????786488??2017-12-04?23:45??Opengl_lab1\Opengl_lab1\Opengl_lab1\boy.bmp
?????文件??????158945??2017-12-04?21:09??Opengl_lab1\Opengl_lab1\Opengl_lab1\boy.obj
?????文件?????3145784??2017-12-04?23:45??Opengl_lab1\Opengl_lab1\Opengl_lab1\cat.bmp
?????文件??????137448??2017-12-04?21:09??Opengl_lab1\Opengl_lab1\Opengl_lab1\cat.obj
?????文件???????16887??2017-12-07?08:41??Opengl_lab1\Opengl_lab1\Opengl_lab1\chair.obj
?????目錄???????????0??2017-12-04?22:00??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\
?????文件????????3269??2017-12-04?22:00??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\controls.cpp
?????文件?????????151??2017-07-17?01:25??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\controls.hpp
?????文件????????5757??2017-11-15?17:13??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\objloader.cpp
?????文件?????????406??2017-07-17?01:25??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\objloader.hpp
?????文件????????4247??2017-10-25?14:25??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\quaternion_utils.cpp
?????文件?????????248??2017-07-17?01:25??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\quaternion_utils.hpp
?????文件????????3441??2017-07-17?01:25??Opengl_lab1\Opengl_lab1\Opengl_lab1\common\shader.cpp
............此處省略343個文件信息
評論
共有 條評論