[DEV] correct Windows Gui (missing the screen DPI) and downgrade log

This commit is contained in:
Edouard DUPIN 2016-10-06 22:40:32 +02:00
parent a0c8a89109
commit bac6c2db17
4 changed files with 31 additions and 11 deletions

View File

@ -5,6 +5,7 @@
*/
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/Dimension.hpp>
#include <etk/types.hpp>
#include <etk/os/FSNode.hpp>
@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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;