2 #include "../resource.h"
10 #include <glm/gtc/type_ptr.hpp>
11 #include <DevIL/IL/il.h>
18 #define WINDOW_WIDTH 1000
19 #define WINDOW_HEIGHT 750
76 static LPCTSTR temptitle = _T(
"{ddaba162-3aae-41f1-9980-f6a9efcd14dd}");
78 if(GetConsoleTitle(title,
sizeof(title)/
sizeof(TCHAR)) == 0)
80 SetConsoleTitle(temptitle);
81 HWND wnd = FindWindow(NULL, temptitle);
82 SetConsoleTitle(title);
93 LRESULT CALLBACK
DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
104 EndDialog(hWndDlg, 0);
108 EndDialog(hWndDlg, 0);
111 EndDialog(hWndDlg, 0);
154 case GLFW_MOUSE_BUTTON_LEFT:
155 if (_action == GLFW_PRESS)
164 else if (_action == GLFW_RELEASE)
180 case GLFW_MOUSE_BUTTON_RIGHT:
181 if (_action == GLFW_PRESS)
187 case GLFW_MOUSE_BUTTON_MIDDLE:
188 if (_action == GLFW_PRESS)
197 else if (_action == GLFW_RELEASE)
261 std::cout <<
"glfwInit failed!" << std::endl;
269 glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
272 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
273 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
274 glfwOpenWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE);
280 std::cout <<
"glfwOpenWindow failed!" << std::endl;
284 glfwSetWindowTitle(
"VIS 2 DEMO");
288 if(glewInit() != GLEW_OK)
290 std::cout <<
"Failed to initialise GLEW!" << std::endl;
295 __glewGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glfwGetProcAddress(
"glGenVertexArrays");
296 __glewBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)glfwGetProcAddress(
"glBindVertexArray");
297 __glewDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)glfwGetProcAddress(
"glDeleteVertexArrays");
298 __glewGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)glfwGetProcAddress(
"glGenerateMipmap");
299 __glewBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)glfwGetProcAddress(
"glBindFragDataLocation");
301 __glewGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glfwGetProcAddress(
"glGenFramebuffers");
302 __glewBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)glfwGetProcAddress(
"glBindFramebuffer");
303 __glewGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glfwGetProcAddress(
"glGenRenderbuffers");
304 __glewBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glfwGetProcAddress(
"glBindRenderbuffer");
305 __glewRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)glfwGetProcAddress(
"glRenderbufferStorage");
306 __glewFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glfwGetProcAddress(
"glFramebufferRenderbuffer");
307 __glewFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glfwGetProcAddress(
"glFramebufferTexture2D");
308 __glewCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)glfwGetProcAddress(
"glCheckFramebufferStatus");
309 __glewDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glfwGetProcAddress(
"glDeleteFramebuffers");
310 __glewDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glfwGetProcAddress(
"glDeleteRenderbuffers");
322 glClearColor(0.9f, 0.9f, 0.9f, 0.0f);
326 glEnable(GL_DEPTH_TEST);
328 glEnable(GL_CULL_FACE);
332 if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION)
334 std::cout <<
"Wrong DevIL version!" << std::endl;
365 shader_axes_Ptr =
new vis2::Shader(
"_resources/Shader/basic_vert.glsl",
"_resources/Shader/basic_frag.glsl");
366 mM_VP = glm::scale(glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, 3.5f)), glm::vec3(0.2f, 0.2f, 0.2f));
367 mM_VD = glm::scale(glm::mat4(1.0f), glm::vec3(0.1f, 0.1f, 0.1f));
372 axis_X = glm::vec4(1.0f, 0.0f, 0.0f, 0.0f);
373 axis_Y = glm::vec4(0.0f, 1.0f, 0.0f, 0.0f);
374 axis_Z = glm::vec4(0.0f, 0.0f, 1.0f, 0.0f);
391 bool b_rotation =
false;
498 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
560 bool b_running =
true;
562 double d_timeSinceLastFrame = 0.0;
568 double d_time = glfwGetTime();
570 d_timeSinceLastFrame = d_time;
583 b_running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);