From bac6c2db17eedf0e618824fad209484416d3e727 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 6 Oct 2016 22:40:32 +0200 Subject: [PATCH] [DEV] correct Windows Gui (missing the screen DPI) and downgrade log --- gale/context/Windows/Context.cpp | 20 ++++++++++++++++++++ gale/renderer/openGL/openGL.cpp | 6 +++--- gale/resource/Program.cpp | 8 ++++---- gale/resource/Shader.cpp | 8 ++++---- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gale/context/Windows/Context.cpp b/gale/context/Windows/Context.cpp index c0480a2..f377688 100644 --- a/gale/context/Windows/Context.cpp +++ b/gale/context/Windows/Context.cpp @@ -5,6 +5,7 @@ */ #include #include +#include #include #include @@ -143,6 +144,25 @@ class WindowsContext : public gale::Context { MessageBox(hWnd, "Error initilizing open GL\n OPENGL 2.0 not availlable ...\n(gale internal error #75124)", "Error", MB_ICONEXCLAMATION); PostQuitMessage(0); } + // Configure the DPI of the screen: + { + vec2 dpi(0,0); + dpi.setX(GetDeviceCaps(hDC, LOGPIXELSX)); + dpi.setY(GetDeviceCaps(hDC, LOGPIXELSY)); + gale::Dimension::setPixelRatio(dpi, gale::distance::inch); + GALE_INFO("monitor property : dpi=" << dpi << " px/inch"); + } + // Get monitor Size + { + HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + MONITORINFO info; + info.cbSize = sizeof(MONITORINFO); + GetMonitorInfo(monitor, &info); + int monitor_width = info.rcMonitor.right - info.rcMonitor.left; + int monitor_height = info.rcMonitor.bottom - info.rcMonitor.top; + GALE_INFO("monitor property: size=" << ivec2(monitor_width, monitor_height) << " px"); + } + // Now we can show it ... ShowWindow(hWnd, SW_SHOW); //EnableWindow(hWnd, TRUE); diff --git a/gale/renderer/openGL/openGL.cpp b/gale/renderer/openGL/openGL.cpp index 8d0234a..6a6251e 100644 --- a/gale/renderer/openGL/openGL.cpp +++ b/gale/renderer/openGL/openGL.cpp @@ -784,7 +784,7 @@ static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) { GLuint shader = 0; if (_type == gale::openGL::shader::type::vertex) { - GALE_ERROR("create shader: VERTEX"); + GALE_VERBOSE("create shader: VERTEX"); #ifdef GALE_SIMULATION_OPENGL_AVAILLABLE if (s_simulationMode == false) { #endif @@ -796,7 +796,7 @@ int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) { } #endif } else if (_type == gale::openGL::shader::type::fragment) { - GALE_ERROR("create shader: FRAGMENT"); + GALE_VERBOSE("create shader: FRAGMENT"); #ifdef GALE_SIMULATION_OPENGL_AVAILLABLE if (s_simulationMode == false) { #endif @@ -811,7 +811,7 @@ int64_t gale::openGL::shader::create(enum gale::openGL::shader::type _type) { GALE_ERROR("create shader with wrong type ..."); return -1; } - GALE_ERROR("create shader: ... (done)"); + GALE_VERBOSE("create shader: ... (done)"); if (shader == 0) { GALE_ERROR("glCreateShader return error ..."); #ifdef GALE_SIMULATION_OPENGL_AVAILLABLE diff --git a/gale/resource/Program.cpp b/gale/resource/Program.cpp index e31ef9b..3ecbbc0 100644 --- a/gale/resource/Program.cpp +++ b/gale/resource/Program.cpp @@ -33,7 +33,7 @@ void gale::resource::Program::init(const std::string& _filename) { etk::FSNode file(m_name); if (file.exist() == false) { - GALE_INFO("File does not Exist : \"" << file << "\" == > automatic load of framment and shader with same names... "); + GALE_DEBUG("File does not Exist : \"" << file << "\" == > automatic load of framment and shader with same names... "); std::string tmpFilename = m_name; // remove extention ... tmpFilename.erase(tmpFilename.size()-4, 4); @@ -192,7 +192,7 @@ int32_t gale::resource::Program::getAttribute(std::string _elementName) { GALE_WARNING(" {" << m_program << "}[" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); tmp.m_isLinked = false; } else { - GALE_INFO(" {" << m_program << "}[" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); + GALE_DEBUG(" {" << m_program << "}[" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); } } else { // program is not loaded ==> just local reister ... @@ -225,7 +225,7 @@ int32_t gale::resource::Program::getUniform(std::string _elementName) { GALE_WARNING(" {" << m_program << "}[" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); tmp.m_isLinked = false; } else { - GALE_INFO(" {" << m_program << "}[" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); + GALE_DEBUG(" {" << m_program << "}[" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId); } } else { // program is not loaded ==> just local reister ... @@ -246,7 +246,7 @@ bool gale::resource::Program::updateContext() { // Do nothing == > too dangerous ... } else { // create the Shader - GALE_INFO("Create the Program ... \"" << m_name << "\""); + GALE_DEBUG("Create the Program ... \"" << m_name << "\""); m_program = gale::openGL::program::create(); if (m_program < 0) { return true; diff --git a/gale/resource/Shader.cpp b/gale/resource/Shader.cpp index 0cbb675..861c399 100644 --- a/gale/resource/Shader.cpp +++ b/gale/resource/Shader.cpp @@ -66,14 +66,14 @@ bool gale::resource::Shader::updateContext() { GALE_CRITICAL(" can not load shader"); return true; } else { - GALE_INFO("Compile shader with GLID=" << m_shader); + GALE_DEBUG("Compile shader with GLID=" << m_shader); bool ret = gale::openGL::shader::compile(m_shader, m_fileData); if (ret == false) { const char * tmpShaderType = "FRAGMENT SHADER"; if (m_type == gale::openGL::shader::type::vertex){ tmpShaderType = "VERTEX SHADER"; } - GALE_CRITICAL("Could not compile \"" << tmpShaderType << "\" name='" << m_name << "'"); + GALE_CRITICAL("Could not compile '" << tmpShaderType << "' name='" << m_name << "'"); return true; } } @@ -120,11 +120,11 @@ void gale::resource::Shader::reload() { // now change the OGL context ... if (gale::openGL::hasContext() == true) { - GALE_DEBUG("OGL : load SHADER \"" << m_name << "\" ==> call update context (direct)"); + GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> call update context (direct)"); removeContext(); updateContext(); } else { - GALE_DEBUG("OGL : load SHADER \"" << m_name << "\" ==> tagged has update context needed"); + GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> tagged has update context needed"); // TODO : Check this, this is a leek ==> in the GPU ... really bad ... m_exist = false; m_shader = 0;