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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-09-02 07:14:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-02 07:14:38 +0400
commita0229b21cb5cfc6e263cc2396d5b1e8530d9d38d (patch)
tree1f1c5e6401d0fe14458db6762886ba31fe1129f8 /source/gameengine
parent32b2b1f544661f6dee4a81428b562fe7a3bc3f13 (diff)
text display (debug info) in the game engine working again & other minor changes.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.cpp34
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.h4
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp8
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp9
4 files changed, 21 insertions, 34 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
index 5cf696fe146..dba6d1113c9 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
@@ -103,6 +103,8 @@ void BL_SwapBuffers(wmWindow *win)
void DisableForText()
{
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */
+
if(glIsEnabled(GL_BLEND)) glDisable(GL_BLEND);
if(glIsEnabled(GL_ALPHA_TEST)) glDisable(GL_ALPHA_TEST);
@@ -135,32 +137,25 @@ void DisableForText()
}
}
-void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height)
+void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height)
{
/* gl prepping */
DisableForText();
- //glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
-
- glOrtho(0, width,
- 0, height, 0, 1);
-
+
+ glOrtho(0, width, 0, height, -100, 100);
+
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glLoadIdentity();
/* the actual drawing */
glColor3ub(255, 255, 255);
- BLF_draw_default(xco, height-yco, 0.0f, text);
+ BLF_draw_default(xco, height-yco, 0.0f, (char *)text);
- glMatrixMode(GL_TEXTURE);
- glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
@@ -168,36 +163,29 @@ void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height
glEnable(GL_DEPTH_TEST);
}
-void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height)
+void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height)
{
/* This is a rather important line :( The gl-mode hasn't been left
* behind quite as neatly as we'd have wanted to. I don't know
* what cause it, though :/ .*/
DisableForText();
- //glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
- glOrtho(0, width,
- 0, height, 0, 1);
+ glOrtho(0, width, 0, height, -100, 100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glLoadIdentity();
/* draw in black first*/
glColor3ub(0, 0, 0);
- BLF_draw_default(xco+1, height-yco-1, 0.0f, text);
+ BLF_draw_default(xco+2, height-yco-2, 0.0f, (char *)text);
glColor3ub(255, 255, 255);
- BLF_draw_default(xco, height-yco, 0.0f, text);
+ BLF_draw_default(xco, height-yco, 0.0f, (char *)text);
- glMatrixMode(GL_TEXTURE);
- glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
index 1e65f29d87c..5c947ff630e 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
@@ -47,8 +47,8 @@ void BL_HideMouse();
void BL_NormalMouse();
void BL_WaitMouse();
-void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height);
-void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height);
+void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height);
+void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
index 8ed36e860b4..ee9dae14b9b 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
@@ -284,12 +284,10 @@ void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
int width,
int height)
{
- STR_String tmpstr(text);
-
if(mode == RAS_IRenderTools::RAS_TEXT_PADDED)
- BL_print_gamedebug_line_padded(tmpstr.Ptr(), xco, yco, width, height);
+ BL_print_gamedebug_line_padded(text, xco, yco, width, height);
else
- BL_print_gamedebug_line(tmpstr.Ptr(), xco, yco, width, height);
+ BL_print_gamedebug_line(text, xco, yco, width, height);
}
/* Render Text renders text into a (series of) polygon, using a texture font,
@@ -390,4 +388,4 @@ void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void*
void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas)
{
m_filtermanager.RenderFilters(canvas);
-} \ No newline at end of file
+}
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 99c943d4f24..1d1d9e6103b 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -751,16 +751,17 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
STR_String *var = reinterpret_cast<STR_String*>(ptr);
if (PyUnicode_Check(value))
{
- char *val = _PyUnicode_AsString(value);
+ Py_ssize_t val_len;
+ char *val = _PyUnicode_AsStringAndSize(value, &val_len);
if (attrdef->m_clamp)
{
- if (strlen(val) < attrdef->m_imin)
+ if (val_len < attrdef->m_imin)
{
// can't increase the length of the string
PyErr_Format(PyExc_ValueError, "string length too short for attribute \"%s\"", attrdef->m_name);
goto FREE_AND_ERROR;
}
- else if (strlen(val) > attrdef->m_imax)
+ else if (val_len > attrdef->m_imax)
{
// trim the string
char c = val[attrdef->m_imax];
@@ -769,7 +770,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
val[attrdef->m_imax] = c;
break;
}
- } else if (strlen(val) < attrdef->m_imin || strlen(val) > attrdef->m_imax)
+ } else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax)
{
PyErr_Format(PyExc_ValueError, "string length out of range for attribute \"%s\"", attrdef->m_name);
goto FREE_AND_ERROR;