-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPBGE: Use KX_OffScreen as python proxy of RAS_IOffScreen.
Previously the RAS_IOffScreen was used in a raw python proxy: PyRASOffScreen. To make the off screen python proxy homogenous with the other sources, a python proxy based on CValue was created.
- Loading branch information
1 parent
413e5d3
commit 78c816e
Showing
12 changed files
with
257 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
KX_OffScreen(CValue) | ||
==================== | ||
|
||
.. module:: bge.types | ||
|
||
base class --- :class:`CValue` | ||
|
||
.. class:: KX_OffScreen(CValue) | ||
|
||
An off-screen render buffer object. | ||
|
||
Use :func:`bge.render.offScreenCreate` to create it. | ||
Currently it can only be used in the :class:`bge.texture.ImageRender` | ||
constructor to render on a FBO rather than the default viewport. | ||
|
||
.. attribute:: width | ||
|
||
The width in pixel of the FBO | ||
|
||
:type: integer | ||
|
||
.. attribute:: height | ||
|
||
The height in pixel of the FBO | ||
|
||
:type: integer | ||
|
||
.. attribute:: color | ||
|
||
The underlying OpenGL bind code of the texture object that holds | ||
the rendered image, 0 if the FBO is using RenderBuffer. | ||
The choice between RenderBuffer and Texture is determined | ||
by the target argument of :func:`bge.render.offScreenCreate`. | ||
|
||
:type: integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* ***** BEGIN GPL LICENSE BLOCK ***** | ||
* | ||
* 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 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* 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, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Contributor(s): Tristan Porteries. | ||
* | ||
* ***** END GPL LICENSE BLOCK ***** | ||
*/ | ||
|
||
/** \file gameengine/Ketsji/KX_OffScreen.cpp | ||
* \ingroup ketsji | ||
*/ | ||
|
||
#include "KX_OffScreen.h" | ||
#include "RAS_IRasterizer.h" | ||
|
||
KX_OffScreen::KX_OffScreen(RAS_IRasterizer *rasterizer, RAS_ICanvas *canvas, int width, int height, int samples, RAS_IOffScreen::RAS_OFS_RENDER_TARGET target) | ||
{ | ||
m_ofs = rasterizer->CreateOffScreen(canvas, width, height, samples, target); | ||
} | ||
|
||
KX_OffScreen::~KX_OffScreen() | ||
{ | ||
delete m_ofs; | ||
} | ||
|
||
STR_String& KX_OffScreen::GetName() | ||
{ | ||
static STR_String offscreenname = "KX_OffScreen"; | ||
return offscreenname; | ||
} | ||
|
||
RAS_IOffScreen *KX_OffScreen::GetOffScreen() const | ||
{ | ||
return m_ofs; | ||
} | ||
|
||
#ifdef WITH_PYTHON | ||
|
||
PyTypeObject KX_OffScreen::Type = { | ||
PyVarObject_HEAD_INIT(NULL, 0) | ||
"KX_OffScreen", | ||
sizeof(PyObjectPlus_Proxy), | ||
0, | ||
py_base_dealloc, | ||
0, | ||
0, | ||
0, | ||
0, | ||
py_base_repr, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | ||
0, 0, 0, 0, 0, 0, 0, | ||
Methods, | ||
0, | ||
0, | ||
&CValue::Type, | ||
0, 0, 0, 0, 0, 0, | ||
py_base_new | ||
}; | ||
|
||
PyMethodDef KX_OffScreen::Methods[] = { | ||
{NULL, NULL} // Sentinel | ||
}; | ||
|
||
PyAttributeDef KX_OffScreen::Attributes[] = { | ||
KX_PYATTRIBUTE_RO_FUNCTION("width", KX_OffScreen, pyattr_get_width), | ||
KX_PYATTRIBUTE_RO_FUNCTION("height", KX_OffScreen, pyattr_get_height), | ||
KX_PYATTRIBUTE_RO_FUNCTION("color", KX_OffScreen, pyattr_get_color), | ||
{NULL} // Sentinel | ||
}; | ||
|
||
PyObject *KX_OffScreen::pyattr_get_width(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||
{ | ||
KX_OffScreen *self = static_cast<KX_OffScreen *>(self_v); | ||
|
||
return PyLong_FromLong(self->GetOffScreen()->GetWidth()); | ||
} | ||
|
||
PyObject *KX_OffScreen::pyattr_get_height(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||
{ | ||
KX_OffScreen *self = static_cast<KX_OffScreen *>(self_v); | ||
|
||
return PyLong_FromLong(self->GetOffScreen()->GetHeight()); | ||
} | ||
|
||
PyObject *KX_OffScreen::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||
{ | ||
KX_OffScreen *self = static_cast<KX_OffScreen *>(self_v); | ||
|
||
return PyLong_FromLong(self->GetOffScreen()->GetColor()); | ||
} | ||
|
||
#endif // WITH_PYTHON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* ***** BEGIN GPL LICENSE BLOCK ***** | ||
* | ||
* 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 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* 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, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Contributor(s): Tristan Porteries. | ||
* | ||
* ***** END GPL LICENSE BLOCK ***** | ||
*/ | ||
|
||
/** \file KX_OffScreen.h | ||
* \ingroup ketsji | ||
* \brief Python proxy of RAS_IOffScreen and RAS_OpenGLOffScreen. | ||
*/ | ||
|
||
#ifndef __KX_OFFSCREEN_H__ | ||
#define __KX_OFFSCREEN_H__ | ||
|
||
#include "EXP_Value.h" | ||
#include "RAS_IOffScreen.h" | ||
|
||
class RAS_IRasterizer; | ||
class RAS_ICanvas; | ||
|
||
class KX_OffScreen : public CValue | ||
{ | ||
Py_Header | ||
private: | ||
RAS_IOffScreen *m_ofs; | ||
|
||
public: | ||
KX_OffScreen(RAS_IRasterizer *rasterizer, RAS_ICanvas *canvas, int width, int height, int samples, RAS_IOffScreen::RAS_OFS_RENDER_TARGET target); | ||
virtual ~KX_OffScreen(); | ||
|
||
virtual STR_String& GetName(); | ||
|
||
RAS_IOffScreen *GetOffScreen() const; | ||
|
||
#ifdef WITH_PYTHON | ||
|
||
static PyObject *pyattr_get_width(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); | ||
static PyObject *pyattr_get_height(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); | ||
static PyObject *pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); | ||
|
||
#endif | ||
}; | ||
|
||
#endif // __KX_OFFSCREEN_H__ |
Oops, something went wrong.