diff --git a/.vs/shader2/v14/.suo b/.vs/shader2/v14/.suo index 8cc6f7a..ab310b6 100644 Binary files a/.vs/shader2/v14/.suo and b/.vs/shader2/v14/.suo differ diff --git a/main.cpp b/main.cpp index ad062f4..0658ee1 100644 --- a/main.cpp +++ b/main.cpp @@ -90,7 +90,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine glewInit(); /*创建program*/ - GLuint program = CreateGPUProgram("res/shader/UI FullScreemQuad.vs", "res/shader/UI.fs"); + GLuint program = CreateGPUProgram("res/shader/PointSprite.vs", "res/shader/PointSprite.fs"); GLuint posLocation, texcoordLocation, normalLocation, MLocation, VLocation, PLocation, NMLocation, textureLocation; posLocation = glGetAttribLocation(program, "pos"); @@ -115,6 +115,9 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine 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); @@ -125,8 +128,10 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine GLuint mainTexture = CreateTextureFromFile("res/image/stone.jpg"); GLuint secondTexture = CreateTextureFromDds("res/image/150001.dds"); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClearColor(0.1f, 0.4f, 0.7f, 1.0f); glEnable(GL_DEPTH_TEST); + glEnable(GL_POINT_SPRITE); + glEnable(GL_PROGRAM_POINT_SIZE); glViewport(0,0, windowWidth, windowHeight); //创建一个单位矩阵和一个投影矩阵,后面用来传递到shader @@ -170,7 +175,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); - glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0); + glDrawElements(GL_POINTS, 1, GL_UNSIGNED_INT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glUseProgram(0); }; @@ -185,9 +190,6 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glEnable(GL_SCISSOR_TEST); - glScissor(400,300, 100, 100); what(); SwapBuffers(dc); diff --git a/res/shader/PointSprite.fs b/res/shader/PointSprite.fs new file mode 100644 index 0000000..5518475 --- /dev/null +++ b/res/shader/PointSprite.fs @@ -0,0 +1,5 @@ +uniform sampler2D U_MainTexture; +void main() +{ + gl_FragColor=texture2D(U_MainTexture,gl_PointCoord.xy); +} \ No newline at end of file diff --git a/res/shader/PointSprite.vs b/res/shader/PointSprite.vs new file mode 100644 index 0000000..7c9cab0 --- /dev/null +++ b/res/shader/PointSprite.vs @@ -0,0 +1,13 @@ +attribute vec3 pos; +attribute vec2 texcoord; +attribute vec3 normal; + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; + +void main() +{ + gl_PointSize = 30.0; + gl_Position=P*V*M*vec4(pos,1.0); +} \ No newline at end of file diff --git a/shader2.vcxproj b/shader2.vcxproj index ce6f785..206e497 100644 --- a/shader2.vcxproj +++ b/shader2.vcxproj @@ -157,11 +157,8 @@ - - - - - + + diff --git a/shader2.vcxproj.filters b/shader2.vcxproj.filters index 96d48a3..e0e406c 100644 --- a/shader2.vcxproj.filters +++ b/shader2.vcxproj.filters @@ -40,19 +40,10 @@ - + 婧愭枃浠 - - 婧愭枃浠 - - - 婧愭枃浠 - - - 婧愭枃浠 - - + 婧愭枃浠