From 2b56cfe3b0701eb347c0f1e22948b4534b055c11 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 25 Mar 2010 01:06:28 +0000 Subject: [PATCH] ported new mouse changes by Titi to win32 (and removed debug output for image classes) --- source/shared_lib/sources/graphics/BMPReader.cpp | 2 +- source/shared_lib/sources/graphics/JPGReader.cpp | 2 +- source/shared_lib/sources/graphics/PNGReader.cpp | 2 +- source/shared_lib/sources/graphics/TGAReader.cpp | 2 +- source/shared_lib/sources/platform/win32/window.cpp | 12 ++++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/shared_lib/sources/graphics/BMPReader.cpp b/source/shared_lib/sources/graphics/BMPReader.cpp index f1dda923..ef5cc89d 100644 --- a/source/shared_lib/sources/graphics/BMPReader.cpp +++ b/source/shared_lib/sources/graphics/BMPReader.cpp @@ -81,7 +81,7 @@ Pixmap2D* BMPReader::read(ifstream& in, const string& path, Pixmap2D* ret) const int h= infoHeader.height; int w= infoHeader.width; int components= (ret->getComponents() == -1)?3:ret->getComponents(); - std::cout << "BMP-Components: Pic: " << components << " old: " << (ret->getComponents()) << " File: " << 3 << std::endl; + //std::cout << "BMP-Components: Pic: " << components << " old: " << (ret->getComponents()) << " File: " << 3 << std::endl; ret->init(w,h,components); uint8* pixels = ret->getPixels(); for(int i=0; igetComponents() == -1)?cinfo.num_components:ret->getComponents(); - std::cout << "JPG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << cinfo.num_components << std::endl; + //std::cout << "JPG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << cinfo.num_components << std::endl; ret->init(cinfo.image_width, cinfo.image_height, picComponents); uint8* pixels = ret->getPixels(); //TODO: Irrlicht has some special CMYK-handling - maybe needed too? diff --git a/source/shared_lib/sources/graphics/PNGReader.cpp b/source/shared_lib/sources/graphics/PNGReader.cpp index 6458ef5d..b4a17e55 100644 --- a/source/shared_lib/sources/graphics/PNGReader.cpp +++ b/source/shared_lib/sources/graphics/PNGReader.cpp @@ -108,7 +108,7 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const png_read_image(png_ptr, row_pointers); int fileComponents = info_ptr->rowbytes/info_ptr->width; int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents(); - std::cout << "PNG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl; + //std::cout << "PNG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl; //Copy image ret->init(width,height,picComponents); uint8* pixels = ret->getPixels(); diff --git a/source/shared_lib/sources/graphics/TGAReader.cpp b/source/shared_lib/sources/graphics/TGAReader.cpp index 4a7f2450..e67ae9b6 100644 --- a/source/shared_lib/sources/graphics/TGAReader.cpp +++ b/source/shared_lib/sources/graphics/TGAReader.cpp @@ -85,7 +85,7 @@ Pixmap2D* TGAReader::read(ifstream& in, const string& path, Pixmap2D* ret) const const int w = fileHeader.width; const int fileComponents= fileHeader.bitsPerPixel/8; const int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents(); - std::cout << "BMP-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl; + //std::cout << "BMP-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl; ret->init(w,h,picComponents); uint8* pixels = ret->getPixels(); //read file diff --git a/source/shared_lib/sources/platform/win32/window.cpp b/source/shared_lib/sources/platform/win32/window.cpp index 58d04715..33b5761c 100644 --- a/source/shared_lib/sources/platform/win32/window.cpp +++ b/source/shared_lib/sources/platform/win32/window.cpp @@ -35,6 +35,7 @@ int Window::nextClassName= 0; Window::WindowMap Window::createdWindows; unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */ +static int oldX=0,oldY=0; Vec2i Window::mousePos; MouseState Window::mouseState; @@ -68,6 +69,13 @@ Window::~Window(){ //static bool Window::handleEvent(){ MSG msg; + + POINT point; + bool ret = GetCursorPos(&point); + if(ret == true) { + oldX = point.x; + oldY = point.y; + } while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){ if(msg.message==WM_QUIT){ @@ -80,6 +88,10 @@ bool Window::handleEvent(){ return true; } +void Window::revertMousePos() { + SetCursorPos(oldX, oldY); +} + string Window::getText(){ if(handle==0){ return text;