4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
30 /** \file gameengine/GamePlayer/ghost/GPG_Canvas.cpp
35 #include "GPG_Canvas.h"
37 #include "GHOST_ISystem.h"
39 GPG_Canvas::GPG_Canvas(GHOST_IWindow* window)
40 : GPC_Canvas(0, 0), m_window(window)
45 m_window->getClientBounds(bnds);
46 this->Resize(bnds.getWidth(), bnds.getHeight());
51 GPG_Canvas::~GPG_Canvas(void)
56 void GPG_Canvas::Init()
60 GHOST_TSuccess success;
61 success = m_window->setDrawingContextType(GHOST_kDrawingContextTypeOpenGL);
62 assert(success == GHOST_kSuccess);
66 void GPG_Canvas::SetMousePosition(int x, int y)
68 GHOST_ISystem* system = GHOST_ISystem::getSystem();
69 if (system && m_window)
71 GHOST_TInt32 gx = (GHOST_TInt32)x;
72 GHOST_TInt32 gy = (GHOST_TInt32)y;
75 m_window->clientToScreen(gx, gy, cx, cy);
76 system->setCursorPosition(cx, cy);
81 void GPG_Canvas::SetMouseState(RAS_MouseState mousestate)
83 m_mousestate = mousestate;
90 m_window->setCursorVisibility(false);
93 m_window->setCursorShape(GHOST_kStandardCursorWait);
94 m_window->setCursorVisibility(true);
97 m_window->setCursorShape(GHOST_kStandardCursorRightArrow);
98 m_window->setCursorVisibility(true);
105 void GPG_Canvas::SwapBuffers()
109 m_window->swapBuffers();
113 float GPG_Canvas::GetMouseNormalizedX(int x)
115 return float(x)/this->GetWidth();
118 float GPG_Canvas::GetMouseNormalizedY(int y)
120 return float(y)/this->GetHeight();