2011-02-22 10:33:14 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2011-02-22 10:33:14 +00:00
|
|
|
|
|
|
|
/** \file KX_BlenderCanvas.h
|
|
|
|
* \ingroup blroutines
|
|
|
|
*/
|
|
|
|
|
2012-02-23 10:41:31 +00:00
|
|
|
#ifndef __KX_BLENDERCANVAS_H__
|
|
|
|
#define __KX_BLENDERCANVAS_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
2013-11-04 19:21:16 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "RAS_ICanvas.h"
|
|
|
|
#include "RAS_Rect.h"
|
|
|
|
|
2009-08-18 15:37:31 +00:00
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#endif
|
|
|
|
|
2009-06-13 17:25:54 +00:00
|
|
|
struct ARegion;
|
|
|
|
struct wmWindow;
|
2013-04-18 16:28:39 +00:00
|
|
|
struct wmWindowManager;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 2D Blender device context abstraction.
|
|
|
|
* The connection from 3d rendercontext to 2d Blender surface embedding.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class KX_BlenderCanvas : public RAS_ICanvas
|
|
|
|
{
|
|
|
|
private:
|
2013-02-02 04:48:21 +00:00
|
|
|
/**
|
|
|
|
* Rect that defines the area used for rendering,
|
|
|
|
* relative to the context */
|
2002-10-12 11:37:38 +00:00
|
|
|
RAS_Rect m_displayarea;
|
2012-10-08 03:28:11 +00:00
|
|
|
int m_viewport[4];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/* Construct a new canvas.
|
|
|
|
*
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param area The Blender ARegion to run the game within.
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2013-11-04 19:21:16 +00:00
|
|
|
KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, RAS_Rect &rect, struct ARegion* ar);
|
2002-10-12 11:37:38 +00:00
|
|
|
~KX_BlenderCanvas();
|
|
|
|
|
|
|
|
void
|
|
|
|
Init(
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
SwapBuffers(
|
|
|
|
);
|
2013-07-29 22:31:32 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
SetSwapInterval(
|
|
|
|
int interval
|
|
|
|
);
|
|
|
|
|
|
|
|
int
|
|
|
|
GetSwapInterval(
|
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
2012-01-22 20:25:25 +00:00
|
|
|
ResizeWindow(
|
2002-10-12 11:37:38 +00:00
|
|
|
int width,
|
|
|
|
int height
|
|
|
|
);
|
|
|
|
|
2013-04-13 21:09:02 +00:00
|
|
|
void
|
|
|
|
SetFullScreen(
|
|
|
|
bool enable
|
|
|
|
);
|
|
|
|
|
|
|
|
bool
|
|
|
|
GetFullScreen();
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
|
|
|
BeginFrame(
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
EndFrame(
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
ClearColor(
|
|
|
|
float r,
|
|
|
|
float g,
|
|
|
|
float b,
|
|
|
|
float a
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
ClearBuffer(
|
|
|
|
int type
|
|
|
|
);
|
|
|
|
|
|
|
|
int
|
|
|
|
GetWidth(
|
2012-02-27 10:35:39 +00:00
|
|
|
) const;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
GetHeight(
|
2012-02-27 10:35:39 +00:00
|
|
|
) const;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-04-23 22:48:26 +00:00
|
|
|
int
|
|
|
|
GetMouseX(int x
|
|
|
|
);
|
|
|
|
|
|
|
|
int
|
|
|
|
GetMouseY(int y
|
|
|
|
);
|
|
|
|
|
|
|
|
float
|
|
|
|
GetMouseNormalizedX(int x
|
|
|
|
);
|
|
|
|
|
|
|
|
float
|
|
|
|
GetMouseNormalizedY(int y
|
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
const
|
|
|
|
RAS_Rect &
|
|
|
|
GetDisplayArea(
|
|
|
|
) const {
|
|
|
|
return m_displayarea;
|
|
|
|
};
|
|
|
|
|
2009-10-26 22:33:43 +00:00
|
|
|
void
|
|
|
|
SetDisplayArea(RAS_Rect *rect
|
2002-10-12 11:37:38 +00:00
|
|
|
) {
|
2009-10-26 22:33:43 +00:00
|
|
|
m_displayarea= *rect;
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
2008-07-20 23:03:01 +00:00
|
|
|
RAS_Rect &
|
|
|
|
GetWindowArea(
|
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
|
|
|
SetViewPort(
|
|
|
|
int x1, int y1,
|
|
|
|
int x2, int y2
|
|
|
|
);
|
2012-12-25 06:20:50 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
UpdateViewPort(
|
|
|
|
int x1, int y1,
|
|
|
|
int x2, int y2
|
|
|
|
);
|
|
|
|
|
2012-10-08 03:28:11 +00:00
|
|
|
const int*
|
|
|
|
GetViewPort();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
SetMouseState(
|
|
|
|
RAS_MouseState mousestate
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
SetMousePosition(
|
|
|
|
int x,
|
|
|
|
int y
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
MakeScreenShot(
|
|
|
|
const char* filename
|
|
|
|
);
|
|
|
|
|
|
|
|
bool
|
|
|
|
BeginDraw(
|
2013-04-18 16:28:39 +00:00
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
EndDraw(
|
2013-04-18 16:28:39 +00:00
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/** Blender area the game engine is running within */
|
2013-04-18 16:28:39 +00:00
|
|
|
struct wmWindowManager *m_wm;
|
2009-06-28 02:47:49 +00:00
|
|
|
struct wmWindow* m_win;
|
2009-10-26 23:00:06 +00:00
|
|
|
RAS_Rect m_frame_rect;
|
2008-07-20 23:03:01 +00:00
|
|
|
RAS_Rect m_area_rect;
|
2012-10-14 08:49:01 +00:00
|
|
|
int m_area_left;
|
|
|
|
int m_area_top;
|
2009-08-18 15:37:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
2012-06-25 09:14:37 +00:00
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderCanvas")
|
2009-08-18 15:37:31 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
2002-10-30 02:07:20 +00:00
|
|
|
|
2012-10-09 13:36:42 +00:00
|
|
|
#endif /* __KX_BLENDERCANVAS_H__ */
|