Browse Source

使用cpu创建全屏画布

master
blobt 5 years ago
parent
commit
607165311e
  1. BIN
      .vs/shader2/v14/.suo
  2. 23
      main.cpp
  3. 16
      res/shader/UI FullScreemQuad.vs
  4. 1
      shader2.vcxproj
  5. 3
      shader2.vcxproj.filters

BIN
.vs/shader2/v14/.suo

23
main.cpp

@ -87,7 +87,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
glewInit(); glewInit();
/*´´½¨program*/ /*´´½¨program*/
GLuint program = CreateGPUProgram("res/shader/UI.vs", "res/shader/UI.fs");
GLuint program = CreateGPUProgram("res/shader/UI FullScreemQuad.vs", "res/shader/UI.fs");
GLuint posLocation, texcoordLocation, normalLocation, MLocation, VLocation, PLocation, NMLocation, textureLocation; GLuint posLocation, texcoordLocation, normalLocation, MLocation, VLocation, PLocation, NMLocation, textureLocation;
posLocation = glGetAttribLocation(program, "pos"); posLocation = glGetAttribLocation(program, "pos");
@ -109,27 +109,6 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
printf("load obj model fail\n"); printf("load obj model fail\n");
} }
float z = 4.0f;
float halfFOV = 22.5f;
float randianHalfFOV = 3.14 * halfFOV / 180.0f;//½Ç¶Èת»¡¶È
float tanHalfFOV = sinf(randianHalfFOV) / cosf(randianHalfFOV);
float y = tanHalfFOV * z;
float aspect = (float)windowWidth / (float)windowHeight;
float x = y * aspect;
vertexes[0].position[0] = -x;
vertexes[0].position[1] = -y;
vertexes[1].position[0] = x;
vertexes[1].position[1] = -y;
vertexes[2].position[0] = -x;
vertexes[2].position[1] = y;
vertexes[3].position[0] = x;
vertexes[3].position[1] = y;
/*´´½¨vbo*/ /*´´½¨vbo*/
GLuint vbo = CreateBufferObject(GL_ARRAY_BUFFER, sizeof(VertexData) * vertexCount, GL_STATIC_DRAW, vertexes); GLuint vbo = CreateBufferObject(GL_ARRAY_BUFFER, sizeof(VertexData) * vertexCount, GL_STATIC_DRAW, vertexes);

16
res/shader/UI FullScreemQuad.vs

@ -0,0 +1,16 @@
attribute vec3 pos;
attribute vec2 texcoord;
attribute vec3 normal;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 NM;
varying vec2 V_Texcoord;
void main() {
vec4 position = vec4(pos.x*2,pos.y*2,pos.z,1.0);
V_Texcoord = texcoord;
gl_Position = position;
}

1
shader2.vcxproj

@ -157,6 +157,7 @@
<ItemGroup> <ItemGroup>
<None Include="res\shader\test.fs" /> <None Include="res\shader\test.fs" />
<None Include="res\shader\test.vs" /> <None Include="res\shader\test.vs" />
<None Include="res\shader\UI FullScreemQuad.vs" />
<None Include="res\shader\UI.fs" /> <None Include="res\shader\UI.fs" />
<None Include="res\shader\UI.vs" /> <None Include="res\shader\UI.vs" />
</ItemGroup> </ItemGroup>

3
shader2.vcxproj.filters

@ -46,5 +46,8 @@
<None Include="res\shader\UI.vs"> <None Include="res\shader\UI.vs">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</None> </None>
<None Include="res\shader\UI FullScreemQuad.vs">
<Filter>源文件</Filter>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>
Loading…
Cancel
Save