[prev in list] [next in list] [prev in thread] [next in thread]
List: bzflag-commits
Subject: SF.net SVN: bzflag:[19551] trunk/bzflag
From: trepan () users ! sourceforge ! net
Date: 2009-03-30 17:49:26
Message-ID: E1LoLby-00009w-6x () d5vjzd1 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 19551
http://bzflag.svn.sourceforge.net/bzflag/?rev=19551&view=rev
Author: trepan
Date: 2009-03-30 17:49:26 +0000 (Mon, 30 Mar 2009)
Log Message:
-----------
* added a run-time GL version check (glew makes it easy)
* started to add the re-entrancy indicator for events and call-ins
Modified Paths:
--------------
trunk/bzflag/include/EventHandler.h
trunk/bzflag/src/bzflag/BackgroundRenderer.cxx
trunk/bzflag/src/bzflag/EventHandler.cxx
trunk/bzflag/src/bzflag/bzflag.cxx
trunk/bzflag/src/lua/LuaCallInDB.cxx
trunk/bzflag/src/lua/LuaCallInDB.h
trunk/bzflag/src/lua/LuaClientScripts.cxx
trunk/bzflag/src/lua/LuaHandle.cxx
trunk/bzflag/src/lua/LuaOpenGL.cxx
trunk/bzflag/src/lua/LuaOpenGL.h
trunk/bzflag/src/lua/LuaTextures.h
Modified: trunk/bzflag/include/EventHandler.h
===================================================================
--- trunk/bzflag/include/EventHandler.h 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/include/EventHandler.h 2009-03-30 17:49:26 UTC (rev 19551)
@@ -59,6 +59,7 @@
bool IsKnown(const std::string& eventName) const;
bool IsManaged(const std::string& eventName) const;
bool IsReversed(const std::string& eventName) const;
+ bool IsReentrant(const std::string& eventName) const;
bool ReqFullRead(const std::string& eventName) const;
bool ReqGameCtrl(const std::string& eventName) const;
bool ReqInputCtrl(const std::string& eventName) const;
@@ -158,17 +159,19 @@
, reqGameCtrl (false)
, reqInputCtrl(false)
, reversed (false)
+ , reentrant (false)
, list (NULL)
{}
EventInfo(const std::string& _name, EventClientList* _list,
bool _reqFullRead, bool _reqGameCtrl, bool _reqInputCtrl,
- bool _reversed)
+ bool _reversed, bool _reentrant)
: name (_name)
, reqFullRead (_reqFullRead)
, reqGameCtrl (_reqGameCtrl)
, reqInputCtrl(_reqInputCtrl)
, reversed (_reversed)
+ , reentrant (_reentrant)
, list (_list)
{}
@@ -180,6 +183,7 @@
inline bool ReqInputCtrl() const { return reqInputCtrl; }
inline bool IsManaged() const { return (list != NULL); }
inline bool IsReversed() const { return reversed; }
+ inline bool IsReentrant() const { return reentrant; }
protected:
inline EventClientList* GetList() const { return list; }
@@ -190,6 +194,7 @@
bool reqGameCtrl;
bool reqInputCtrl;
bool reversed;
+ bool reentrant;
EventClientList* list;
};
@@ -198,7 +203,8 @@
private:
void SetupEvent(const std::string& ciName, EventClientList* list,
- int orderType, bool reversed, int propertyBits);
+ int orderType, bool reversed, bool reentrant,
+ int propertyBits);
bool CanUseEvent(EventClient* ec, const EventInfo& eInfo) const;
private:
Modified: trunk/bzflag/src/bzflag/BackgroundRenderer.cxx
===================================================================
--- trunk/bzflag/src/bzflag/BackgroundRenderer.cxx 2009-03-29 22:57:18 UTC (rev \
19550)
+++ trunk/bzflag/src/bzflag/BackgroundRenderer.cxx 2009-03-30 17:49:26 UTC (rev \
19551) @@ -1029,12 +1029,9 @@
// setup the wrap mode
skyboxWrapMode = GL_CLAMP;
-#ifdef GL_VERSION_1_2
- const char* extStr = (const char*) glGetString(GL_EXTENSIONS);
- if (strstr(extStr, "GL_EXT_texture_edge_clamp") != NULL) {
+ if (GLEW_VERSION_1_2) {
skyboxWrapMode = GL_CLAMP_TO_EDGE;
}
-#endif
// setup the corner colors
const int cornerFaces[8][3] = {
Modified: trunk/bzflag/src/bzflag/EventHandler.cxx
===================================================================
--- trunk/bzflag/src/bzflag/EventHandler.cxx 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/bzflag/EventHandler.cxx 2009-03-30 17:49:26 UTC (rev 19551)
@@ -43,7 +43,8 @@
void EventHandler::SetupEvent(const string& eName, EventClientList* list,
- int orderType, bool reversed, int bits)
+ int orderType, bool reversed, bool reentrant,
+ int bits)
{
list->set_order_type(orderType);
list->set_reversed(reversed);
@@ -54,12 +55,12 @@
const bool reqInputCtrl = ((bits & REQ_INPUT_CTRL) ? true : false);
eventMap[eName] = EventInfo(eName, list,
reqFullRead, reqGameCtrl, reqInputCtrl,
- reversed);
+ reversed, reentrant);
}
#define SETUP_EVENT(name, orderType, reversed, bits) \
- SetupEvent(#name, &list ## name, orderType, reversed, bits)
+ SetupEvent(#name, &list ## name, orderType, reversed, false, bits)
//============================================================================//
@@ -223,6 +224,13 @@
}
+bool EventHandler::IsReentrant(const std::string& eName) const
+{
+ const EventInfo* ei = GetEventInfo(eName);
+ return (ei != NULL) && ei->IsReentrant();
+}
+
+
bool EventHandler::ReqFullRead(const std::string& eName) const
{
const EventInfo* ei = GetEventInfo(eName);
Modified: trunk/bzflag/src/bzflag/bzflag.cxx
===================================================================
--- trunk/bzflag/src/bzflag/bzflag.cxx 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/bzflag/bzflag.cxx 2009-03-30 17:49:26 UTC (rev 19551)
@@ -1157,7 +1157,7 @@
// sanity check - make sure OpenGL is actually available or
// there's no sense in continuing.
- const char * const glRenderer = (const char*)glGetString(GL_RENDERER);
+ const char* const glRenderer = (const char*)glGetString(GL_RENDERER);
if (!glRenderer) {
// bad code, no donut for you
@@ -1199,11 +1199,10 @@
printFatalError("ERROR: Unable to initialize an OpenGL renderer");
if (display != NULL) {
delete display;
- display=NULL;
+ display = NULL;
}
bail(1);
exit(1);
-
}
// initialize OpenGL state
@@ -1229,6 +1228,18 @@
}
OpenGLGState::init();
+ // run-time GL version check
+ if (!GLEW_VERSION_1_1) {
+ // DIE
+ printFatalError("ERROR: OpenGL version 1.1 or later is required");
+ if (display != NULL) {
+ delete display;
+ display = NULL;
+ }
+ bail(1);
+ exit(1);
+ }
+
// add the zbuffer callback here, after the OpenGL context is initialized
BZDB.addCallback("zbuffer", Callbacks::setDepthBuffer, NULL);
Modified: trunk/bzflag/src/lua/LuaCallInDB.cxx
===================================================================
--- trunk/bzflag/src/lua/LuaCallInDB.cxx 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaCallInDB.cxx 2009-03-30 17:49:26 UTC (rev 19551)
@@ -75,6 +75,16 @@
LuaCallInDB::LuaCallInDB()
{
+}
+
+
+LuaCallInDB::~LuaCallInDB()
+{
+}
+
+
+bool LuaCallInDB::Init()
+{
// NOTE: less chance of typos doing it this way
const int NO_REQS = 0;
const int REQ_FULL_READ = (1 << 0);
@@ -105,6 +115,7 @@
((bits) & REQ_GAME_CTRL) != 0, \
((bits) & REQ_INPUT_CTRL) != 0, \
(strncmp(#n, "Draw", 4) == 0), \
+ false, \
singleScript, retType)
///////////////////////////////////
@@ -179,11 +190,8 @@
ADD_CI(ForbidShot, REQ_GAME_CTRL, FIRST_FALSE, ANY_SCRIPT);
ADD_CI(ForbidShotLock, REQ_GAME_CTRL, FIRST_FALSE, ANY_SCRIPT);
ADD_CI(ForbidFlagDrop, REQ_GAME_CTRL, FIRST_FALSE, ANY_SCRIPT);
-}
-
-LuaCallInDB::~LuaCallInDB()
-{
+ return true;
}
Modified: trunk/bzflag/src/lua/LuaCallInDB.h
===================================================================
--- trunk/bzflag/src/lua/LuaCallInDB.h 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaCallInDB.h 2009-03-30 17:49:26 UTC (rev 19551)
@@ -93,6 +93,8 @@
LuaCallInDB();
~LuaCallInDB();
+ bool Init();
+
const string& GetEventName(const string& callIn) const;
const string& GetCallInName(const string& event) const;
@@ -101,12 +103,15 @@
CallInInfo() {}
CallInInfo(int c, const char* n,
bool fullRead, bool gameCtrl, bool inputCtrl,
- bool rev, const char* ss, const char* lt)
+ bool rev, bool rec, const char* ss, const char* lt)
: code(c), name(n)
, reqFullRead(fullRead)
, reqGameCtrl(gameCtrl)
, reqInputCtrl(inputCtrl)
- , reversed(rev), loopType(lt), singleScript(ss)
+ , reversed(rev)
+ , reentrant(rec)
+ , loopType(lt)
+ , singleScript(ss)
{}
int code;
std::string name;
@@ -114,6 +119,7 @@
bool reqGameCtrl;
bool reqInputCtrl;
bool reversed;
+ bool reentrant;
std::string loopType; // suggested control loop for lua handlers
std::string singleScript; // can only be used by this script
};
Modified: trunk/bzflag/src/lua/LuaClientScripts.cxx
===================================================================
--- trunk/bzflag/src/lua/LuaClientScripts.cxx 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaClientScripts.cxx 2009-03-30 17:49:26 UTC (rev 19551)
@@ -19,6 +19,7 @@
#include "../bzflag/World.h"
// local headers
+#include "LuaCallInDB.h"
#include "LuaOpenGL.h"
#include "LuaURL.h"
@@ -33,6 +34,8 @@
void LuaClientScripts::Init()
{
+ luaCallInDB.Init();
+
LuaOpenGL::Init();
LuaURLMgr::SetAccessList(Downloads::instance().getAccessList());
}
Modified: trunk/bzflag/src/lua/LuaHandle.cxx
===================================================================
--- trunk/bzflag/src/lua/LuaHandle.cxx 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaHandle.cxx 2009-03-30 17:49:26 UTC (rev 19551)
@@ -529,6 +529,7 @@
LuaPushNamedBool (L, "reqFullRead", ciInfo.reqFullRead);
LuaPushNamedBool (L, "reqInputCtrl", ciInfo.reqInputCtrl);
LuaPushNamedBool (L, "reversed", ciInfo.reversed);
+ LuaPushNamedBool (L, "reentrant", ciInfo.reentrant);
LuaPushNamedString(L, "loopType", ciInfo.loopType);
if (LuaHandle::GetDevMode()) {
lua_pushliteral(L, "func");
Modified: trunk/bzflag/src/lua/LuaOpenGL.cxx
===================================================================
--- trunk/bzflag/src/lua/LuaOpenGL.cxx 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaOpenGL.cxx 2009-03-30 17:49:26 UTC (rev 19551)
@@ -28,6 +28,7 @@
#include "SceneRenderer.h"
#include "StateDatabase.h"
#include "CacheManager.h"
+#include "TextUtils.h"
// local headers
#include "LuaInclude.h"
@@ -53,23 +54,65 @@
//============================================================================//
//============================================================================//
+void LuaOpenGL::Init()
+{
+}
-bool LuaOpenGL::canUseShaders = false;
+void LuaOpenGL::Free()
+{
+}
+
//============================================================================//
//============================================================================//
-void LuaOpenGL::Init()
+static set<string> forbidden;
+
+
+static void ParseForbidden()
{
- if (GLEW_VERSION_2_0 && !BZDB.isTrue("forbidLuaShaders")) {
- canUseShaders = true;
+ static set<string> knownExts;
+ if (knownExts.empty()) {
+ knownExts.insert("FBO");
+ knownExts.insert("Buffer");
+ knownExts.insert("Query");
+ knownExts.insert("Shader");
+ knownExts.insert("DepthClamp");
+ knownExts.insert("PointSprite");
+ knownExts.insert("SeparateBlend");
+ knownExts.insert("SeparateStencil");
}
+
+ forbidden.clear();
+
+ const string extList = BZDB.get("forbidLuaGL");
+
+ if (extList == "*") {
+ forbidden = knownExts;
+ }
+ else {
+ const vector<string> args = TextUtils::tokenize(extList, ",");
+ for (size_t i = 0; i < args.size(); i++) {
+ const string& ext = args[i];
+ if (knownExts.find(ext) != knownExts.end()) {
+ forbidden.insert(ext);
+ } else {
+ LuaLog(1, "LuaGL: unknown extension \"%s\"\n", ext.c_str());
+ }
+ }
+ }
+
+ set<string>::const_iterator it;
+ for (it = forbidden.begin(); it != forbidden.end(); ++it) {
+ LuaLog(1, "LuaGL: forbidding extension \"%s\"\n", (*it).c_str());
+ }
}
-void LuaOpenGL::Free()
+static bool IsAllowed(const string& ext)
{
+ return (forbidden.find(ext) == forbidden.end());
}
@@ -78,6 +121,8 @@
bool LuaOpenGL::PushEntries(lua_State* L)
{
+ ParseForbidden();
+
PUSH_LUA_CFUNC(L, HasExtension);
PUSH_LUA_CFUNC(L, GetNumber);
PUSH_LUA_CFUNC(L, GetString);
@@ -98,7 +143,7 @@
PUSH_LUA_CFUNC(L, ColorMask);
PUSH_LUA_CFUNC(L, DepthMask);
PUSH_LUA_CFUNC(L, DepthTest);
- if (GLEW_NV_depth_clamp) {
+ if (GLEW_NV_depth_clamp && IsAllowed("DepthClamp")) {
PUSH_LUA_CFUNC(L, DepthClamp);
}
PUSH_LUA_CFUNC(L, Culling);
@@ -113,7 +158,7 @@
PUSH_LUA_CFUNC(L, Blending);
PUSH_LUA_CFUNC(L, BlendEquation);
PUSH_LUA_CFUNC(L, BlendFunc);
- if (GLEW_VERSION_2_0) {
+ if (GLEW_VERSION_2_0 && IsAllowed("SeparateBlend")) {
PUSH_LUA_CFUNC(L, BlendEquationSeparate);
PUSH_LUA_CFUNC(L, BlendFuncSeparate);
}
@@ -133,7 +178,7 @@
PUSH_LUA_CFUNC(L, StencilMask);
PUSH_LUA_CFUNC(L, StencilFunc);
PUSH_LUA_CFUNC(L, StencilOp);
- if (GLEW_VERSION_2_0) {
+ if (GLEW_VERSION_2_0 && IsAllowed("SeparateStencil")) {
PUSH_LUA_CFUNC(L, StencilMaskSeparate);
PUSH_LUA_CFUNC(L, StencilFuncSeparate);
PUSH_LUA_CFUNC(L, StencilOpSeparate);
@@ -141,7 +186,7 @@
PUSH_LUA_CFUNC(L, LineWidth);
PUSH_LUA_CFUNC(L, PointSize);
- if (GLEW_VERSION_2_0) {
+ if (GLEW_VERSION_2_0 && IsAllowed("PointSprite")) {
PUSH_LUA_CFUNC(L, PointSprite);
PUSH_LUA_CFUNC(L, PointParameter);
}
@@ -214,28 +259,29 @@
PUSH_LUA_CFUNC(L, ReadPixels);
PUSH_LUA_CFUNC(L, SaveImage);
- if (GLEW_VERSION_2_0) {
+ if (GLEW_VERSION_2_0 && IsAllowed("Query")) {
LuaGLQueryMgr::PushEntries(L);
}
LuaDListMgr::PushEntries(L);
LuaTextureMgr::PushEntries(L);
- if (canUseShaders) {
+ if (IsAllowed("Shader")) {
LuaShaderMgr::PushEntries(L);
}
// should be GL_ARB_framebuffer_object, but glew 1.5.1 has
// a typo from the following: glFramebufferTextureLayer
// (it should be fixed in the next version of glew)
- if (GLEW_VERSION_2_0 && glGenFramebuffers && glGenRenderbuffers) {
+ if (GLEW_VERSION_2_0 && glGenFramebuffers && glGenRenderbuffers &&
+ IsAllowed("FBO")) {
LuaFBOMgr::PushEntries(L);
LuaRBOMgr::PushEntries(L);
}
LuaGLPointers::PushEntries(L);
- if (GLEW_VERSION_1_5) {
+ if (GLEW_VERSION_1_5 && IsAllowed("Buffer")) {
LuaGLBufferMgr::PushEntries(L);
}
Modified: trunk/bzflag/src/lua/LuaOpenGL.h
===================================================================
--- trunk/bzflag/src/lua/LuaOpenGL.h 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaOpenGL.h 2009-03-30 17:49:26 UTC (rev 19551)
@@ -1,9 +1,7 @@
#ifndef LUA_OPENGL_H
#define LUA_OPENGL_H
-#include <set>
-
struct lua_State;
@@ -24,9 +22,6 @@
static void StaticFreeContext(void* data);
private:
- static bool canUseShaders;
-
- private:
static int HasExtension(lua_State* L);
static int GetNumber(lua_State* L);
static int GetString(lua_State* L);
Modified: trunk/bzflag/src/lua/LuaTextures.h
===================================================================
--- trunk/bzflag/src/lua/LuaTextures.h 2009-03-29 22:57:18 UTC (rev 19550)
+++ trunk/bzflag/src/lua/LuaTextures.h 2009-03-30 17:49:26 UTC (rev 19551)
@@ -97,6 +97,8 @@
static int CopyToTexture(lua_State* L);
+ static int TexSubImage2D(lua_State* L);
+
static int GenerateMipMap(lua_State* L);
static int TexBuffer(lua_State* L);
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
BZFlag-commits mailing list
BZFlag-commits@lists.SourceForge.net
https://lists.SourceForge.net/lists/listinfo/bzflag-commits
irc: #BZFlag @ irc.freenode.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic