BGE: Adding mipmapping control to bge.render via bge.render.setMipmapping() and bge.render.getMipmapping().
This commit is contained in:
@@ -243,11 +243,27 @@ Functions
|
||||
:arg level: The new anisotropic filtering level to use
|
||||
:type level: integer (must be one of 1, 2, 4, 8, 16)
|
||||
|
||||
.. note:: Changing this value can cause all textures to be recreated, which can be slow.
|
||||
|
||||
.. function:: getAnisotropicFiltering()
|
||||
|
||||
Get the anisotropic filtering level used for textures.
|
||||
|
||||
:rtype: integer (one of 1, 2, 4, 8, 16)
|
||||
|
||||
.. function:: setMipmapping(value)
|
||||
|
||||
Change how to use mipmapping.
|
||||
|
||||
:type value: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR
|
||||
|
||||
.. note:: Changing this value can cause all textures to be recreated, which can be slow.
|
||||
|
||||
.. function:: getMipmapping()
|
||||
|
||||
Get the current mipmapping setting.
|
||||
|
||||
:rtype: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR
|
||||
|
||||
.. function:: drawLine(fromVec,toVec,color)
|
||||
|
||||
|
@@ -108,6 +108,7 @@ void GPU_render_text(struct MTFace *tface, int mode,
|
||||
void GPU_set_mipmap(int mipmap);
|
||||
int GPU_get_mipmap(void);
|
||||
void GPU_set_linear_mipmap(int linear);
|
||||
int GPU_get_linear_mipmap(void);
|
||||
void GPU_paint_set_mipmap(int mipmap);
|
||||
|
||||
/* Anisotropic filtering settings
|
||||
|
@@ -287,6 +287,11 @@ int GPU_get_mipmap(void)
|
||||
return GTS.domipmap && !GTS.texpaint;
|
||||
}
|
||||
|
||||
int GPU_get_linear_mipmap(void)
|
||||
{
|
||||
return GTS.linearmipmap;
|
||||
}
|
||||
|
||||
static GLenum gpu_get_mipmap_filter(int mag)
|
||||
{
|
||||
/* linearmipmap is off by default *when mipmapping is off,
|
||||
|
@@ -285,13 +285,15 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
|
||||
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
|
||||
RAS_IRasterizer* rasterizer = NULL;
|
||||
|
||||
//Don't use displaylists with VBOs
|
||||
//If auto starts using VBOs, make sure to check for that here
|
||||
if (displaylists && startscene->gm.raster_storage != RAS_STORE_VBO)
|
||||
rasterizer = new RAS_ListRasterizer(canvas, true, startscene->gm.raster_storage);
|
||||
else
|
||||
rasterizer = new RAS_OpenGLRasterizer(canvas, startscene->gm.raster_storage);
|
||||
|
||||
RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping();
|
||||
|
||||
|
||||
// create the inputdevices
|
||||
KX_BlenderKeyboardDevice* keyboarddevice = new KX_BlenderKeyboardDevice();
|
||||
@@ -618,6 +620,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
|
||||
{
|
||||
// set the cursor back to normal
|
||||
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
|
||||
|
||||
// set mipmap setting back to its original value
|
||||
rasterizer->SetMipmapping(mipmapval);
|
||||
}
|
||||
|
||||
// clean up some stuff
|
||||
|
@@ -1338,6 +1338,36 @@ static PyObject *gPyGetFullScreen(PyObject *)
|
||||
return PyBool_FromLong(gp_Canvas->GetFullScreen());
|
||||
}
|
||||
|
||||
static PyObject *gPySetMipmapping(PyObject *, PyObject *args)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i:setMipmapping", &val))
|
||||
return NULL;
|
||||
|
||||
if (val < 0 || val > RAS_IRasterizer::RAS_MIPMAP_MAX) {
|
||||
PyErr_SetString(PyExc_ValueError, "Rasterizer.setMipmapping(val): invalid mipmaping option");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gp_Rasterizer) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Rasterizer.setMipmapping(val): Rasterizer not available");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gp_Rasterizer->SetMipmapping((RAS_IRasterizer::MipmapOption)val);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *gPyGetMipmapping(PyObject *)
|
||||
{
|
||||
if (!gp_Rasterizer) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getMipmapping(): Rasterizer not available");
|
||||
return NULL;
|
||||
}
|
||||
return PyLong_FromLong(gp_Rasterizer->GetMipmapping());
|
||||
}
|
||||
|
||||
static struct PyMethodDef rasterizer_methods[] = {
|
||||
{"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
|
||||
METH_VARARGS, "getWindowWidth doc"},
|
||||
@@ -1381,6 +1411,8 @@ static struct PyMethodDef rasterizer_methods[] = {
|
||||
{"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
|
||||
{"setFullScreen", (PyCFunction) gPySetFullScreen, METH_O, ""},
|
||||
{"getFullScreen", (PyCFunction) gPyGetFullScreen, METH_NOARGS, ""},
|
||||
{"setMipmapping", (PyCFunction) gPySetMipmapping, METH_VARARGS, ""},
|
||||
{"getMipmapping", (PyCFunction) gPyGetMipmapping, METH_NOARGS, ""},
|
||||
{ NULL, (PyCFunction) NULL, 0, NULL }
|
||||
};
|
||||
|
||||
@@ -2147,6 +2179,10 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
|
||||
KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL);
|
||||
KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL);
|
||||
|
||||
KX_MACRO_addTypesToDict(d, RAS_MIPMAP_NONE, RAS_IRasterizer::RAS_MIPMAP_NONE);
|
||||
KX_MACRO_addTypesToDict(d, RAS_MIPMAP_NEAREST, RAS_IRasterizer::RAS_MIPMAP_NEAREST);
|
||||
KX_MACRO_addTypesToDict(d, RAS_MIPMAP_LINEAR, RAS_IRasterizer::RAS_MIPMAP_LINEAR);
|
||||
|
||||
// XXXX Add constants here
|
||||
|
||||
// Check for errors
|
||||
|
@@ -150,6 +150,17 @@ public:
|
||||
RAS_STEREO_RIGHTEYE
|
||||
};
|
||||
|
||||
/**
|
||||
* Mipmap options
|
||||
*/
|
||||
enum MipmapOption {
|
||||
RAS_MIPMAP_NONE,
|
||||
RAS_MIPMAP_NEAREST,
|
||||
RAS_MIPMAP_LINEAR,
|
||||
|
||||
RAS_MIPMAP_MAX, // Should always be last
|
||||
};
|
||||
|
||||
/**
|
||||
* SetDepthMask enables or disables writing a fragment's depth value
|
||||
* to the Z buffer.
|
||||
@@ -417,6 +428,9 @@ public:
|
||||
virtual void SetAnisotropicFiltering(short level)=0;
|
||||
virtual short GetAnisotropicFiltering()=0;
|
||||
|
||||
virtual void SetMipmapping(MipmapOption val)=0;
|
||||
virtual MipmapOption GetMipmapping()=0;
|
||||
|
||||
virtual void SetUsingOverrideShader(bool val)=0;
|
||||
virtual bool GetUsingOverrideShader()=0;
|
||||
|
||||
|
@@ -1064,6 +1064,35 @@ short RAS_OpenGLRasterizer::GetAnisotropicFiltering()
|
||||
return (short)GPU_get_anisotropic();
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::SetMipmapping(MipmapOption val)
|
||||
{
|
||||
if (val == RAS_IRasterizer::RAS_MIPMAP_LINEAR)
|
||||
{
|
||||
GPU_set_linear_mipmap(1);
|
||||
GPU_set_mipmap(1);
|
||||
}
|
||||
else if (val == RAS_IRasterizer::RAS_MIPMAP_NEAREST)
|
||||
{
|
||||
GPU_set_linear_mipmap(0);
|
||||
GPU_set_mipmap(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GPU_set_linear_mipmap(0);
|
||||
GPU_set_mipmap(0);
|
||||
}
|
||||
}
|
||||
|
||||
RAS_IRasterizer::MipmapOption RAS_OpenGLRasterizer::GetMipmapping()
|
||||
{
|
||||
if (GPU_get_linear_mipmap())
|
||||
return RAS_IRasterizer::RAS_MIPMAP_LINEAR;
|
||||
else if (GPU_get_mipmap())
|
||||
return RAS_IRasterizer::RAS_MIPMAP_NEAREST;
|
||||
else
|
||||
return RAS_IRasterizer::RAS_MIPMAP_NONE;
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::SetUsingOverrideShader(bool val)
|
||||
{
|
||||
m_usingoverrideshader = val;
|
||||
|
@@ -324,6 +324,9 @@ public:
|
||||
virtual void SetAnisotropicFiltering(short level);
|
||||
virtual short GetAnisotropicFiltering();
|
||||
|
||||
virtual void SetMipmapping(MipmapOption val);
|
||||
virtual MipmapOption GetMipmapping();
|
||||
|
||||
virtual void SetUsingOverrideShader(bool val);
|
||||
virtual bool GetUsingOverrideShader();
|
||||
|
||||
|
Reference in New Issue
Block a user