Skip to content
Permalink
Browse files

morph gl.ClipPlane into gl.ClipDist

  • Loading branch information...
rt
rt committed May 4, 2019
1 parent 36ce4ad commit 56c73524eb56e34a4f335b48e8affda13d7cd57a
Showing with 14 additions and 35 deletions.
  1. +2 −0 doc/changelog.txt
  2. +11 −34 rts/Lua/LuaOpenGL.cpp
  3. +1 −1 rts/Lua/LuaOpenGL.h
@@ -73,10 +73,12 @@ Lua:
- remove gl.LineStipple
- remove gl.LineWidth
- remove gl.AlphaTest
- remove gl.ClipPlane
- remove {Unit,Feature}Rendering.{SetPieceList,SetMaterialDisplayLists}
- remove LuaMaterial {pre,post}list handling
- remove 'useCamera' LuaMaterial parameter
- remove 'identities' gl.ActiveFBO argument
- add gl.ClipDist(number index, boolean enable) -> nil
- add gl.{Create,Delete,Update,Render}VertexArray
gl.CreateVertexArray(number vertexCount, number indexCount) -> number id | nil
gl.DeleteVertexArray(number id) -> boolean success | nil
@@ -314,7 +314,7 @@ bool LuaOpenGL::PushEntries(lua_State* L)
REGISTER_LUA_CFUNC(DrawGroundCircle);
REGISTER_LUA_CFUNC(DrawGroundQuad);

REGISTER_LUA_CFUNC(ClipPlane);
REGISTER_LUA_CFUNC(ClipDist);

REGISTER_LUA_CFUNC(MatrixMode);
REGISTER_LUA_CFUNC(LoadIdentity);
@@ -410,16 +410,6 @@ void LuaOpenGL::ResetGLState()
glAttribStatePtr->PolygonOffsetPoint(GL_FALSE);
#endif

#if 0
glDisable(GL_LINE_STIPPLE); // ::LineStipple

glDisable(GL_CLIP_PLANE4); // ::ClipPlane
glDisable(GL_CLIP_PLANE5); // ::ClipPlane
#endif

#if 0
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // ::Color, ::Shape
#endif
glUseProgram(0);
}

@@ -2964,36 +2954,23 @@ int LuaOpenGL::Billboard(lua_State* L)

/******************************************************************************/

int LuaOpenGL::ClipPlane(lua_State* L)
int LuaOpenGL::ClipDist(lua_State* L)
{
CheckDrawingEnabled(L, __func__);

const int plane = luaL_checkint(L, 1);

if ((plane < 1) || (plane > 2))
luaL_error(L, "gl.ClipPlane: bad plane number (use 1 or 2)");
const int index = luaL_checkint(L, 1);

// use GL_CLIP_PLANE4 and GL_CLIP_PLANE5 for LuaOpenGL (6 are guaranteed)
const GLenum glPlane = GL_CLIP_PLANE4 + plane - 1;

if (lua_isboolean(L, 2)) {
if (lua_toboolean(L, 2)) {
glEnable(glPlane);
} else {
glDisable(glPlane);
}
if ((index < 1) || (index > 8))
luaL_error(L, "[gl.%s] bad clip-distance index %d", __func__, index);
if (!lua_isboolean(L, 2))
return 0;
}

const GLdouble equation[4] = {
(double)luaL_checknumber(L, 2),
(double)luaL_checknumber(L, 3),
(double)luaL_checknumber(L, 4),
(double)luaL_checknumber(L, 5),
};
if (lua_toboolean(L, 2)) {
glEnable(GL_CLIP_DISTANCE0 + (index - 1));
} else {
glDisable(GL_CLIP_DISTANCE0 + (index - 1));
}

glClipPlane(glPlane, equation);
glEnable(glPlane);
return 0;
}

@@ -247,7 +247,7 @@ class LuaOpenGL {
static int DrawGroundCircle(lua_State* L);
static int DrawGroundQuad(lua_State* L);

static int ClipPlane(lua_State* L);
static int ClipDist(lua_State* L);

static int MatrixMode(lua_State* L);
static int LoadIdentity(lua_State* L);

0 comments on commit 56c7352

Please sign in to comment.
You can’t perform that action at this time.