Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/windowmanager/intern/wm_window.c10
-rw-r--r--source/blender/windowmanager/wm_window.h2
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp9
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.cpp10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.h2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp7
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp14
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h3
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp30
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h11
12 files changed, 117 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 70541f7cec5..062107f834e 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1324,6 +1324,16 @@ void wm_window_swap_buffers(wmWindow *win)
#endif
}
+void wm_window_set_swap_interval (wmWindow *win, int interval)
+{
+ GHOST_SetSwapInterval(win->ghostwin, interval);
+}
+
+int wm_window_get_swap_interval (wmWindow *win)
+{
+ return GHOST_GetSwapInterval(win->ghostwin);
+}
+
/* ******************* exported api ***************** */
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index 22fa2423f61..d7e938fec7c 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -58,6 +58,8 @@ void wm_window_lower (wmWindow *win);
void wm_window_set_size (wmWindow *win, int width, int height);
void wm_window_get_position (wmWindow *win, int *posx_r, int *posy_r);
void wm_window_swap_buffers (wmWindow *win);
+void wm_window_set_swap_interval (wmWindow *win, int interval);
+int wm_window_get_swap_interval (wmWindow *win);
void wm_get_cursor_position (wmWindow *win, int *x, int *y);
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index bb4c3fd2cbc..5703527eae0 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -284,6 +284,14 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
else
canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
+
+ // Setup vsync
+ int previous_vsync = canvas->GetSwapInterval();
+ if (startscene->gm.vsync == VSYNC_ADAPTIVE)
+ canvas->SetSwapInterval(-1);
+ else
+ canvas->SetSwapInterval(startscene->gm.vsync); // VSYNC_OFF == 0, VSYNC_ON == 1, so this works
+
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
//Don't use displaylists with VBOs
@@ -663,6 +671,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
}
if (canvas)
{
+ canvas->SetSwapInterval(previous_vsync); // Set the swap interval back
delete canvas;
canvas = NULL;
}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 3bd1c02f12e..3089b3fd44d 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -66,6 +66,16 @@ void KX_BlenderCanvas::SwapBuffers()
BL_SwapBuffers(m_win);
}
+void KX_BlenderCanvas::SetSwapInterval(int interval)
+{
+ BL_SetSwapInterval(m_win, interval);
+}
+
+int KX_BlenderCanvas::GetSwapInterval()
+{
+ return BL_GetSwapInterval(m_win);
+}
+
void KX_BlenderCanvas::ResizeWindow(int width, int height)
{
// Not implemented for the embedded player
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index c201d866efe..c5318b882fa 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -80,6 +80,16 @@ public:
void
SwapBuffers(
);
+
+ void
+ SetSwapInterval(
+ int interval
+ );
+
+ int
+ GetSwapInterval(
+ );
+
void
ResizeWindow(
int width,
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
index 61598995040..6ed4866579c 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
@@ -98,6 +98,16 @@ void BL_MakeDrawable(wmWindowManager *wm, wmWindow *win)
wm_window_make_drawable(wm, win);
}
+void BL_SetSwapInterval(struct wmWindow *win, int interval)
+{
+ wm_window_set_swap_interval(win, interval);
+}
+
+int BL_GetSwapInterval(struct wmWindow *win)
+{
+ return wm_window_get_swap_interval(win);
+}
+
static void DisableForText()
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
index 54e76ff6489..8032d9a594a 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
@@ -43,6 +43,8 @@ struct wmWindowManager;
// special swapbuffers, that takes care of which area (viewport) needs to be swapped
void BL_SwapBuffers(struct wmWindow *win);
+void BL_SetSwapInterval(struct wmWindow *win, int interval);
+int BL_GetSwapInterval(struct wmWindow *win);
void BL_MakeDrawable(struct wmWindowManager *wm, struct wmWindow *win);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index bedee5d9a47..6f7a87804dc 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -582,7 +582,12 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
m_canvas = new GPG_Canvas(window);
if (!m_canvas)
return false;
-
+
+ if (gm->vsync == VSYNC_ADAPTIVE)
+ m_canvas->SetSwapInterval(-1);
+ else
+ m_canvas->SetSwapInterval(gm->vsync); // VSYNC_OFF == 0, VSYNC_ON == 1, so this works
+
m_canvas->Init();
if (gm->flag & GAME_SHOW_MOUSE)
m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
index a1d00dad0e1..e0559385ee6 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
@@ -107,6 +107,20 @@ void GPG_Canvas::SwapBuffers()
}
}
+void GPG_Canvas::SetSwapInterval(int interval)
+{
+ if (m_window)
+ m_window->setSwapInterval(interval);
+}
+
+int GPG_Canvas::GetSwapInterval()
+{
+ if (m_window)
+ return m_window->getSwapInterval();
+
+ return 0;
+}
+
void GPG_Canvas::ResizeWindow(int width, int height)
{
if (m_window->getState() == GHOST_kWindowStateFullScreen)
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
index 6168d96b337..6e1f86cac0e 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
@@ -55,6 +55,9 @@ public:
virtual void SetMousePosition(int x, int y);
virtual void SetMouseState(RAS_MouseState mousestate);
virtual void SwapBuffers();
+ virtual void SetSwapInterval(int interval);
+ virtual int GetSwapInterval();
+
virtual int GetMouseX(int x) { return x; }
virtual int GetMouseY(int y) { return y; }
virtual float GetMouseNormalizedX(int x);
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 7845c113643..e595f24a662 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1372,6 +1372,29 @@ static PyObject *gPyGetMipmapping(PyObject *)
return PyLong_FromLong(gp_Rasterizer->GetMipmapping());
}
+static PyObject *gPySetVsync(PyObject *, PyObject *args)
+{
+ int interval;
+
+ if (!PyArg_ParseTuple(args, "i:setVsync", &interval))
+ return NULL;
+
+ if (interval < VSYNC_OFF || interval > VSYNC_ADAPTIVE) {
+ PyErr_SetString(PyExc_ValueError, "Rasterizer.setVsync(value): value must be VSYNC_OFF, VSYNC_ON, or VSYNC_ADAPTIVE");
+ return NULL;
+ }
+
+ if (interval == VSYNC_ADAPTIVE)
+ interval = -1;
+ gp_Canvas->SetSwapInterval(interval);
+ Py_RETURN_NONE;
+}
+
+static PyObject *gPyGetVsync(PyObject *)
+{
+ return PyLong_FromLong(gp_Canvas->GetSwapInterval());
+}
+
static struct PyMethodDef rasterizer_methods[] = {
{"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
METH_VARARGS, "getWindowWidth doc"},
@@ -1417,6 +1440,8 @@ static struct PyMethodDef rasterizer_methods[] = {
{"getFullScreen", (PyCFunction) gPyGetFullScreen, METH_NOARGS, ""},
{"setMipmapping", (PyCFunction) gPySetMipmapping, METH_VARARGS, ""},
{"getMipmapping", (PyCFunction) gPyGetMipmapping, METH_NOARGS, ""},
+ {"setVsync", (PyCFunction) gPySetVsync, METH_VARARGS, ""},
+ {"getVsync", (PyCFunction) gPyGetVsync, METH_NOARGS, ""},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
@@ -2189,6 +2214,11 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
KX_MACRO_addTypesToDict(d, RAS_MIPMAP_NEAREST, RAS_IRasterizer::RAS_MIPMAP_NEAREST);
KX_MACRO_addTypesToDict(d, RAS_MIPMAP_LINEAR, RAS_IRasterizer::RAS_MIPMAP_LINEAR);
+ /* for get/setVsync */
+ KX_MACRO_addTypesToDict(d, VSYNC_OFF, VSYNC_OFF);
+ KX_MACRO_addTypesToDict(d, VSYNC_ON, VSYNC_ON);
+ KX_MACRO_addTypesToDict(d, VSYNC_ADAPTIVE, VSYNC_ADAPTIVE);
+
// XXXX Add constants here
// Check for errors
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index 1b1e43a5257..9e8a6e8ccf6 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -105,6 +105,17 @@ public:
void
SwapBuffers(
)=0;
+
+ virtual
+ void
+ SetSwapInterval(
+ int interval
+ )=0;
+
+ virtual
+ int
+ GetSwapInterval(
+ )=0;
virtual
void