From e1d08a591e25787e17a2310aa0092c12d95695ac Mon Sep 17 00:00:00 2001 From: blobt Date: Mon, 22 Jun 2020 11:15:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=B0=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=A4=A7=E7=90=86=E7=9F=B3=E6=9D=90=E8=B4=A8=E7=90=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/shader2/v14/.suo | Bin 46592 -> 46592 bytes main.cpp | 26 +++++++------------------- shader2.vcxproj | 6 ++---- shader2.vcxproj.filters | 10 ++-------- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/.vs/shader2/v14/.suo b/.vs/shader2/v14/.suo index aa9fbd52fbfdf16f3f130de89f324db044cdfcc8..b099692f3449f0e485eaea96ed23c6cc030856e4 100644 GIT binary patch delta 479 zcmZp8!_@GGX+sVZtHZn>Gn_UTGOcEe6lGvwPy}LDAeIMWB_RF}1l&-X9Z1Up@jsxL zIFMEWVj&fcqV&tsH@09MHGOvG!TQ#6$4^^AO@+j1=5qJuv}n~0Wu~A&e+7IATU`$ zPMMbxB;yEGHF=_h%H$Hc^OFxV8BQ*d_vdA>0m?Wa$+9j4a=JJFlvZb&tRSU4`LGaB zp_D%>qa9Fua$>#k5Qn0y1s)uotngSQXLXc{Zvp^PZE|K$R z#AVaupN>}qyjxi#UE6Z>n`PH@NuN9Ua`Rm$WyVb=jBJ}3mHsnMKH$W@nce0mqa;Hq qLoS0JLk7e4bKSZhrXSPd5!-vJf0?@KW=WfujGLJpPBUROs~7;vjh#yX delta 450 zcmYk2J5NGE5QUk|E?mKjL`g(M*a&L0;9;->Lwpn%6Jl>+r-g+iSbKYIa2q@0qad*{ zcYlBdjSV3&(O*GnV*{Qsm@vtA&&=fP-jnqP!W)R!bD=K!$-P8tZEZ$^?>2p{$xV(F)sX79X2}FaS9U_^BwEEw2n=2VjDTe za0*a%v|A^KAB{8e-%M-2;Sx{(&&=DY4Olu7A5$uC+Cuq5J<)-%R2k82e%Ey8s@BVU QHq)$ diff --git a/main.cpp b/main.cpp index 68f1d79..4dee409 100644 --- a/main.cpp +++ b/main.cpp @@ -91,7 +91,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine glewInit(); /*创建program*/ - GLuint program = CreateGPUProgram("res/shader/PointSprite.vs", "res/shader/PointSprite.fs"); + GLuint program = CreateGPUProgram("res/shader/test.vs", "res/shader/test.fs"); GLuint posLocation, texcoordLocation, normalLocation, MLocation, VLocation, PLocation, NMLocation, textureLocation; posLocation = glGetAttribLocation(program, "pos"); @@ -109,16 +109,13 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine int vertexCount = 0, indexCount = 0; Timer t; t.Start(); - VertexData* vertexes = LoadObjModel("res/model/Quad.obj", &indexes, vertexCount, indexCount); + VertexData* vertexes = LoadObjModel("res/model/Sphere.obj", &indexes, vertexCount, indexCount); printf("load model cost %fs %d\n", t.GetPassedTime(), t.GetPassedTickers()); if (vertexes == nullptr) { printf("load obj model fail\n"); } - vertexes[0].position[0] = 0.0f; - vertexes[0].position[1] = 0.0f; - /*创建vbo*/ GLuint vbo = CreateBufferObject(GL_ARRAY_BUFFER, sizeof(VertexData) * vertexCount, GL_STATIC_DRAW, vertexes); @@ -127,14 +124,10 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine /*创建纹理*/ GLuint mainTexture = CreateTextureFromFile("res/image/stone.jpg"); - GLuint secondTexture = CreateTextureFromDds("res/image/camera.dds"); - glClearColor(0.1f, 0.4f, 0.7f, 1.0f); + glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glEnable(GL_DEPTH_TEST); - glEnable(GL_POINT_SPRITE); - glEnable(GL_PROGRAM_POINT_SIZE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glViewport(0,0, windowWidth, windowHeight); //创建一个单位矩阵和一个投影矩阵,后面用来传递到shader @@ -145,14 +138,10 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine 0,0,0,1 }; - glm::mat4 model = glm::translate(0.0f, 0.0f, -3.0f)*glm::rotate(-20.0f, 0.0f, 1.0f, 0.0f); + glm::mat4 model = glm::translate(0.0f, 0.0f, -3.0f); glm::mat4 projection = glm::perspective(45.0f, (float)windowWidth / (float)windowHeight, 0.1f, 1000.0f); glm::mat4 normalMatrix = glm::inverseTranspose(model); - Frustum frustum; - frustum.Init(); - //frustum.InitPerspective(45.0f, (float)windowWidth / (float)windowHeight, 0.1f, 4.0f); - frustum.InitOrtho(-0.5f, 0.5f,-0.5, 0.5,0.1f,4.0f); /*显示窗口*/ ShowWindow(hwnd, SW_SHOW); @@ -170,7 +159,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine glUniformMatrix4fv(PLocation, 1, GL_FALSE, glm::value_ptr(projection)); glUniformMatrix4fv(NMLocation, 1, GL_FALSE, glm::value_ptr(normalMatrix)); - glBindTexture(GL_TEXTURE_2D, secondTexture); + glBindTexture(GL_TEXTURE_2D, mainTexture); glUniform1i(textureLocation, 0); glBindBuffer(GL_ARRAY_BUFFER, vbo); @@ -183,7 +172,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); - glDrawElements(GL_POINTS, 1, GL_UNSIGNED_INT, 0); + glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glUseProgram(0); }; @@ -198,7 +187,6 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - frustum.Draw(glm::value_ptr(model), identify, glm::value_ptr(projection)); what(); SwapBuffers(dc); diff --git a/shader2.vcxproj b/shader2.vcxproj index 2f91c38..f809b4f 100644 --- a/shader2.vcxproj +++ b/shader2.vcxproj @@ -159,10 +159,8 @@ - - - - + + diff --git a/shader2.vcxproj.filters b/shader2.vcxproj.filters index bb179cb..403f9b3 100644 --- a/shader2.vcxproj.filters +++ b/shader2.vcxproj.filters @@ -46,16 +46,10 @@ - + 婧愭枃浠 - - 婧愭枃浠 - - - 婧愭枃浠 - - + 婧愭枃浠