|
@ -6,6 +6,7 @@ |
|
|
#include "misc.h"
|
|
|
#include "misc.h"
|
|
|
#include "model.h"
|
|
|
#include "model.h"
|
|
|
#include "timer.h"
|
|
|
#include "timer.h"
|
|
|
|
|
|
#include "frustum.h"
|
|
|
#pragma comment(lib,"opengl32.lib")
|
|
|
#pragma comment(lib,"opengl32.lib")
|
|
|
#pragma comment(lib, "glew32.lib")
|
|
|
#pragma comment(lib, "glew32.lib")
|
|
|
|
|
|
|
|
@ -126,7 +127,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
|
|
|
|
|
|
/*´´½¨ÎÆÀí*/ |
|
|
/*´´½¨ÎÆÀí*/ |
|
|
GLuint mainTexture = CreateTextureFromFile("res/image/stone.jpg"); |
|
|
GLuint mainTexture = CreateTextureFromFile("res/image/stone.jpg"); |
|
|
GLuint secondTexture = CreateTextureFromDds("res/image/150001.dds"); |
|
|
|
|
|
|
|
|
GLuint secondTexture = CreateTextureFromDds("res/image/camera.dds"); |
|
|
|
|
|
|
|
|
glClearColor(0.1f, 0.4f, 0.7f, 1.0f); |
|
|
glClearColor(0.1f, 0.4f, 0.7f, 1.0f); |
|
|
glEnable(GL_DEPTH_TEST); |
|
|
glEnable(GL_DEPTH_TEST); |
|
@ -142,10 +143,14 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
0,0,0,1 |
|
|
0,0,0,1 |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
glm::mat4 model = glm::translate(0.0f, 0.0f, -4.0f); |
|
|
|
|
|
|
|
|
glm::mat4 model = glm::translate(-1.0f, 0.0f, -3.0f)*glm::rotate(-20.0f, 0.0f, 1.0f, 0.0f); |
|
|
glm::mat4 projection = glm::perspective(45.0f, (float)windowWidth / (float)windowHeight, 0.1f, 1000.0f); |
|
|
glm::mat4 projection = glm::perspective(45.0f, (float)windowWidth / (float)windowHeight, 0.1f, 1000.0f); |
|
|
glm::mat4 normalMatrix = glm::inverseTranspose(model); |
|
|
glm::mat4 normalMatrix = glm::inverseTranspose(model); |
|
|
|
|
|
|
|
|
|
|
|
Frustum frustum; |
|
|
|
|
|
frustum.Init(); |
|
|
|
|
|
frustum.InitPerspective(45.0f, (float)windowWidth / (float)windowHeight, 0.1f, 4.0f); |
|
|
|
|
|
|
|
|
/*ÏÔʾ´°¿Ú*/ |
|
|
/*ÏÔʾ´°¿Ú*/ |
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
UpdateWindow(hwnd); |
|
|
UpdateWindow(hwnd); |
|
@ -162,7 +167,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
glUniformMatrix4fv(PLocation, 1, GL_FALSE, glm::value_ptr(projection)); |
|
|
glUniformMatrix4fv(PLocation, 1, GL_FALSE, glm::value_ptr(projection)); |
|
|
glUniformMatrix4fv(NMLocation, 1, GL_FALSE, glm::value_ptr(normalMatrix)); |
|
|
glUniformMatrix4fv(NMLocation, 1, GL_FALSE, glm::value_ptr(normalMatrix)); |
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, mainTexture); |
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, secondTexture); |
|
|
glUniform1i(textureLocation, 0); |
|
|
glUniform1i(textureLocation, 0); |
|
|
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vbo); |
|
|
glBindBuffer(GL_ARRAY_BUFFER, vbo); |
|
@ -190,6 +195,7 @@ INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
|
frustum.Draw(glm::value_ptr(model), identify, glm::value_ptr(projection)); |
|
|
what(); |
|
|
what(); |
|
|
|
|
|
|
|
|
SwapBuffers(dc); |
|
|
SwapBuffers(dc); |
|
|