[Scummvm-cvs-logs] CVS: residual color.h,1.1,1.2 colormap.h,1.1,1.2 costume.cpp,1.9,1.10 engine.h,1.3,1.4 lua.cpp,1.30,1.31 main.cpp,1.12,1.13 material.cpp,1.4,1.5 material.h,1.1,1.2 model.cpp,1.10,1.11 model.h,1.3,1.4 resource.cpp,1.7,1.8 resource.h,1.3,1.4 scene.cpp,1.15,1.16 scene.h,1.10,1.11 textobject.cpp,1.2,1.3 textobject.h,1.1,1.2
James Brown
ender at users.sourceforge.net
Sun Oct 5 10:48:05 CEST 2003
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1:/tmp/cvs-serv20976
Modified Files:
color.h colormap.h costume.cpp engine.h lua.cpp main.cpp
material.cpp material.h model.cpp model.h resource.cpp
resource.h scene.cpp scene.h textobject.cpp textobject.h
Log Message:
Enable some hacky non-portable text drawing until I get my LAF font code working. X11-only at the moment (although a Windows equiv should be easy). Note that this breaks Copal's computer again, for some LUA'ish reason involving the parameter table sent to ChangeTextObject. Cleaned up a bit of code and renamed ColorMap class to CMap to prevent conflict against X headers.
Index: color.h
===================================================================
RCS file: /cvsroot/scummvm/residual/color.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- color.h 15 Aug 2003 19:41:26 -0000 1.1
+++ color.h 5 Oct 2003 17:45:46 -0000 1.2
@@ -40,6 +40,11 @@
vals_[0] = c.vals_[0]; vals_[1] = c.vals_[1]; vals_[2] = c.vals_[2];
return *this;
}
+
+ Color& operator =(Color *c) {
+ vals_[0] = c->vals_[0]; vals_[1] = c->vals_[1]; vals_[2] = c->vals_[2];
+ return *this;
+ }
};
#endif
Index: colormap.h
===================================================================
RCS file: /cvsroot/scummvm/residual/colormap.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- colormap.h 15 Aug 2003 19:41:26 -0000 1.1
+++ colormap.h 5 Oct 2003 17:45:46 -0000 1.2
@@ -22,10 +22,10 @@
#include "resource.h"
#include <cstring>
-class Colormap : public Resource {
+class CMap : public Resource {
public:
// Load a colormap from the given data.
- Colormap(const char *filename, const char *data, int len) :
+ CMap(const char *filename, const char *data, int len) :
Resource(filename)
{
if (len < 4 || std::memcmp(data, "CMP ", 4) != 0)
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- costume.cpp 28 Aug 2003 01:55:48 -0000 1.9
+++ costume.cpp 5 Oct 2003 17:45:46 -0000 1.10
@@ -107,7 +107,7 @@
void setKey(int val);
void update();
void reset();
- void setColormap(Colormap *c);
+ void setColormap(CMap *c);
void setMatrix(Matrix4 matrix) { matrix_ = matrix; };
~ModelComponent();
@@ -117,7 +117,7 @@
protected:
std::string filename_;
ResPtr<Model> obj_;
- ResPtr<Colormap> cmap_;
+ ResPtr<CMap> cmap_;
Model::HierNode *hier_;
Matrix4 matrix_;
};
@@ -226,7 +226,7 @@
hier_->hierVisible_ = false;
}
-void ModelComponent::setColormap(Colormap *c) {
+void ModelComponent::setColormap(CMap *c) {
cmap_ = c;
}
@@ -287,7 +287,7 @@
~ColormapComponent();
private:
- ResPtr<Colormap> cmap_;
+ ResPtr<CMap> cmap_;
};
ColormapComponent::ColormapComponent(Costume::Component *parent,
@@ -775,4 +775,4 @@
{
matrix_.pos_ = pos_;
matrix_.rot_.buildFromPitchYawRoll( pitch_, yaw_, roll_ );
-}
\ No newline at end of file
+}
Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- engine.h 21 Aug 2003 15:42:36 -0000 1.3
+++ engine.h 5 Oct 2003 17:45:46 -0000 1.4
@@ -80,6 +80,8 @@
class Engine {
public:
+ GLuint font; // FIXME: Temporary font drawing hack
+
static Engine *instance() {
if (instance_ == NULL)
instance_ = new Engine;
@@ -120,12 +122,16 @@
return textObjects_.end();
}
void registerTextObject(TextObject *a) { textObjects_.push_back(a); }
+ void killTextObject(TextObject *a) {
+ textObjects_.remove(a);
+ }
void killTextObjects() {
while (!textObjects_.empty()) {
delete textObjects_.back();
textObjects_.pop_back();
}
}
+
private:
static Engine *instance_;
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- lua.cpp 26 Aug 2003 09:36:47 -0000 1.30
+++ lua.cpp 5 Oct 2003 17:45:46 -0000 1.31
@@ -882,63 +882,70 @@
}
textObject = new TextObject((const char *)line, x, y, *fgColor);
+ lua_pushstring(line); // FIXME: Register a LUA text object and pass that instead?
}
static void KillTextObject() {
- char *line;
+ char *textID;
if (lua_isnil(lua_getparam(1))) { // FIXME: check this.. nil is kill all lines?
- Engine::instance()->killTextObjects();
+ error("KillTextObject(NULL)");
+ //Engine::instance()->killTextObjects();
return;
}
- line = lua_getstring(lua_getparam(1));
+ textID = lua_getstring(lua_getparam(1));
- error("killTextObject(%s)", line);
+ warning("killTextObject(%s)", textID);
for (Engine::text_list_type::const_iterator i = Engine::instance()->textsBegin();
i != Engine::instance()->textsEnd(); i++) {
TextObject *textO = *i;
- const char *name = textO->name();
- if (name==NULL)
- error("Text object with null name!");
- warning("Comparing **%s** to **%s**", line, name);
- if (strstr(name, line)) {
- error("Wanting to destroy text object %s ", line);
- break;
+ if (strstr(textO->name(), textID)) {
+ Engine::instance()->killTextObject(textO);
+ delete textO;
+ return;
}
}
}
static void ChangeTextObject() {
- char *line = lua_getstring(lua_getparam(1)), *key_text = NULL, *val_text = NULL;
- lua_Object table_obj = lua_getparam(2), key;
+ char *textID = lua_getstring(lua_getparam(1)), *keyText = NULL;
+ lua_Object tableObj = lua_getparam(2), tableKey;
+ TextObject *modifyObject = NULL;
- // FIXME: Disable this for now, as it seems to go into an infinite loop
- // when using Don's computer?!?
- warning("STUB: ChangeTextObject(%s)", line);
- return;
+ for (Engine::text_list_type::const_iterator i = Engine::instance()->textsBegin();
+ i != Engine::instance()->textsEnd(); i++) {
+ TextObject *textO = *i;
- printf("STUB: ChangeTextObject(%s, ", line);
+ if (strstr(textO->name(), textID)) {
+ modifyObject = textO;
+ break;
+ }
+ }
- while(1) {
- lua_pushobject(table_obj);
- if (key_text)
- lua_pushobject(key);
- else
- lua_pushnil();
+ if (!modifyObject)
+ error("ChangeTextObject(%s): Cannot find active text object", textID);
+ while(1) {
+ lua_pushobject(tableObj);
+ if (keyText) lua_pushobject(tableKey); else lua_pushnil();
lua_call("next");
- key=lua_getresult(1);
- if (lua_isnil(key))
+ tableKey=lua_getresult(1);
+ if (lua_isnil(tableKey))
break;
- key_text=lua_getstring(key);
- val_text=lua_getstring(lua_getresult(2));
- printf(" %s=%s ", key_text, val_text);
- }
+ keyText=lua_getstring(tableKey);
- printf(")\n");
+ if (strstr(keyText, "fgcolor"))
+ modifyObject->setColor(check_color(2));
+ else if (strstr(keyText, "x"))
+ ; // modifyObject->setX(atoi(lua_getstring(lua_getresult(2))));
+ else if (strstr(keyText, "y"))
+ ; // modifyObject->setY(atoi(lua_getstring(lua_getresult(2))));
+ else
+ printf("ChangeTextObject(%s) - Unknown key %s\n", textID, keyText);
+ }
}
static void GetTextObjectDimensions() {
Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- main.cpp 21 Sep 2003 09:51:59 -0000 1.12
+++ main.cpp 5 Oct 2003 17:45:46 -0000 1.13
@@ -30,6 +30,14 @@
#include <unistd.h>
#endif
+// Hacky includes for temporary font rendering
+#ifndef WIN32
+ #include <GL/glx.h>
+ #include <X11/Xlib.h>
+#else
+ #include <windows.h>
+#endif
+
// Hacky global toggles for experimental/debug code
int ZBUFFER_GLOBAL, SCREENBLOCKS_GLOBAL;
@@ -117,6 +125,19 @@
lua_call("BOOT");
lua_endblock();
+ // FIXME: Hacky temporary font renderer code
+ Engine::instance()->font = glGenLists(256);
+ #ifdef WIN32
+ #warning FIXME: Do Win32 code
+ #else
+ {
+ Display *dpy = XOpenDisplay(NULL);
+ XFontStruct *XFont = XLoadQueryFont(dpy, "-misc-fixed-medium-r-*-*-20-*-*-*-*-*-*-*" );
+ glXUseXFont(XFont->fid, 0, 256, Engine::instance()->font);
+ XFreeFont(dpy, XFont);
+ XCloseDisplay(dpy);
+ }
+ #endif
Engine::instance()->mainLoop();
return 0;
Index: material.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/material.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- material.cpp 24 Aug 2003 17:56:03 -0000 1.4
+++ material.cpp 5 Oct 2003 17:45:46 -0000 1.5
@@ -22,7 +22,7 @@
#include "debug.h"
Material::Material(const char *filename, const char *data, int len,
- const Colormap &cmap) :
+ const CMap &cmap) :
Resource(filename)
{
if (len < 4 || memcmp(data, "MAT ", 4) != 0)
Index: material.h
===================================================================
RCS file: /cvsroot/scummvm/residual/material.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- material.h 15 Aug 2003 19:41:26 -0000 1.1
+++ material.h 5 Oct 2003 17:45:46 -0000 1.2
@@ -23,13 +23,13 @@
#include <SDL_opengl.h>
#include <cstring>
-class Colormap;
+class CMap;
class Material : public Resource {
public:
// Load a texture from the given data.
Material(const char *filename, const char *data, int len,
- const Colormap &cmap);
+ const CMap &cmap);
// Load this texture into the GL context
void select() const;
Index: model.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/model.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- model.cpp 1 Oct 2003 12:20:27 -0000 1.10
+++ model.cpp 5 Oct 2003 17:45:46 -0000 1.11
@@ -28,7 +28,7 @@
#include "screen.h"
Model::Model(const char *filename, const char *data, int len,
- const Colormap &cmap) : Resource(filename)
+ const CMap &cmap) : Resource(filename)
{
if (len >= 4 && std::memcmp(data, "LDOM", 4) == 0)
loadBinary(data, cmap);
@@ -38,7 +38,7 @@
}
}
-void Model::loadBinary(const char *data, const Colormap &cmap) {
+void Model::loadBinary(const char *data, const CMap &cmap) {
numMaterials_ = get_LE_uint32(data + 4);
data += 8;
materials_ = new ResPtr<Material>[numMaterials_];
@@ -293,7 +293,7 @@
return result;
}
-void Model::loadText(TextSplitter &ts, const Colormap &cmap) {
+void Model::loadText(TextSplitter &ts, const CMap &cmap) {
ts.expectString("section: header");
int major, minor;
ts.scanString("3do %d.%d", 2, &major, &minor);
@@ -650,12 +650,11 @@
// Ender: HACK HACK HACK
// Mannys head isn't computed correctly, so bail out to prevent memory corruption.
// .. at least until it IS computed, or the DirtyScreen code has bounds checking :)
- if (strstr(name_, "m_head_1"))
- return;
+ //if (strstr(name_, "m_head_1"))
+ // return;
// Yaz: debug
// this compute the dirty rect for the mesh
-
glPushMatrix();
glLoadIdentity();
@@ -712,8 +711,8 @@
if (SCREENBLOCKS_GLOBAL == 1)
screenBlocksAddRectangle( top, right, left, bottom, bestDepth );
}
-
- /* glDisable(GL_DEPTH_TEST);
+/*
+ glDisable(GL_DEPTH_TEST);
glPointSize( 3.f );
glColor4f( 1.f, 1.f, 0.f, 1.f );
glDisable(GL_TEXTURE_2D );
@@ -750,8 +749,9 @@
glEnd();
glEnable(GL_DEPTH_TEST);
- glEnable(GL_TEXTURE_2D ); */
+ glEnable(GL_TEXTURE_2D );
glPopMatrix();
+*/
}
void Model::Face::draw(float *vertices, float *vertNormals,
Index: model.h
===================================================================
RCS file: /cvsroot/scummvm/residual/model.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- model.h 30 Aug 2003 19:04:07 -0000 1.3
+++ model.h 5 Oct 2003 17:45:46 -0000 1.4
@@ -23,16 +23,16 @@
#include "resource.h"
#include <cstring>
-class Colormap;
+class CMap;
class Material;
class TextSplitter;
class Model : public Resource {
public:
// Construct a 3D model from the given data.
- Model(const char *filename, const char *data, int len, const Colormap &cmap);
- void loadBinary(const char *data, const Colormap &cmap);
- void loadText(TextSplitter &ts, const Colormap &cmap);
+ Model(const char *filename, const char *data, int len, const CMap &cmap);
+ void loadBinary(const char *data, const CMap &cmap);
+ void loadText(TextSplitter &ts, const CMap &cmap);
void draw() const;
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- resource.cpp 25 Aug 2003 19:47:54 -0000 1.7
+++ resource.cpp 5 Oct 2003 17:45:46 -0000 1.8
@@ -149,18 +149,18 @@
return result;
}
-Colormap *ResourceLoader::loadColormap(const char *filename) {
+CMap *ResourceLoader::loadColormap(const char *filename) {
std::string fname = filename;
makeLower(fname);
cache_type::iterator i = cache_.find(fname);
if (i != cache_.end()) {
- return dynamic_cast<Colormap *>(i->second);
+ return dynamic_cast<CMap *>(i->second);
}
Block *b = getFileBlock(filename);
if (b == NULL)
error("Could not find colormap %s\n", filename);
- Colormap *result = new Colormap(filename, b->data(), b->len());
+ CMap *result = new CMap(filename, b->data(), b->len());
delete b;
cache_[fname] = result;
return result;
@@ -195,7 +195,7 @@
}
Material *ResourceLoader::loadMaterial(const char *filename,
- const Colormap &c) {
+ const CMap &c) {
std::string fname = filename;
makeLower(fname);
cache_type::iterator i = cache_.find(fname);
@@ -212,7 +212,7 @@
return result;
}
-Model *ResourceLoader::loadModel(const char *filename, const Colormap &c) {
+Model *ResourceLoader::loadModel(const char *filename, const CMap &c) {
std::string fname = filename;
makeLower(fname);
cache_type::iterator i = cache_.find(fname);
Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- resource.h 20 Aug 2003 14:29:59 -0000 1.3
+++ resource.h 5 Oct 2003 17:45:46 -0000 1.4
@@ -24,7 +24,7 @@
#include <string>
class Bitmap;
-class Colormap;
+class CMap;
class Costume;
class KeyframeAnim;
class Material;
@@ -94,11 +94,11 @@
}
Bitmap *loadBitmap(const char *fname);
- Colormap *loadColormap(const char *fname);
+ CMap *loadColormap(const char *fname);
Costume *loadCostume(const char *fname, Costume *prevCost);
KeyframeAnim *loadKeyframe(const char *fname);
- Material *loadMaterial(const char *fname, const Colormap &c);
- Model *loadModel(const char *fname, const Colormap &c);
+ Material *loadMaterial(const char *fname, const CMap &c);
+ Model *loadModel(const char *fname, const CMap &c);
Sound *loadSound(const char *fname);
void uncache(const char *fname);
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- scene.cpp 21 Sep 2003 09:51:59 -0000 1.15
+++ scene.cpp 5 Oct 2003 17:45:46 -0000 1.16
@@ -35,7 +35,7 @@
ts.expectString("section: colormaps");
ts.scanString(" numcolormaps %d", 1, &numCmaps_);
- cmaps_ = new ResPtr<Colormap>[numCmaps_];
+ cmaps_ = new ResPtr<CMap>[numCmaps_];
char cmap_name[256];
for (int i = 0; i < numCmaps_; i++) {
ts.scanString(" colormap %256s", 1, cmap_name);
Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- scene.h 30 Aug 2003 17:58:33 -0000 1.10
+++ scene.h 5 Oct 2003 17:45:46 -0000 1.11
@@ -27,7 +27,7 @@
#include <SDL_opengl.h>
#include <string>
-class Colormap;
+class CMap;
class TextSplitter;
// The Lua code calls this a "set".
@@ -86,7 +86,7 @@
std::string name_;
int numCmaps_;
- ResPtr<Colormap> *cmaps_;
+ ResPtr<CMap> *cmaps_;
int numSetups_, numLights_, numSectors_;
Sector *sectors_;
Light *lights_;
Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- textobject.cpp 24 Aug 2003 17:56:03 -0000 1.2
+++ textobject.cpp 5 Oct 2003 17:45:46 -0000 1.3
@@ -28,10 +28,29 @@
void TextObject::setX(int x) {x_ = x;}
void TextObject::setY(int y) {y_ = y;}
-void TextObject::setColor(const Color& newcolor) {fgColor_ = newcolor;}
+void TextObject::setColor(Color *newcolor) {fgColor_ = newcolor;}
void TextObject::draw() {
- std::string result = Localizer::instance()->localize(textID_);
- warning("Drawing text object %s at (%d,%d): %s", textID_, x_, y_, result.c_str());
+ const char *localString = Localizer::instance()->localize(textID_).c_str();
+ //warning("Drawing text object %s at (%d,%d): %s", textID_, x_, y_, localString);
+
+ glMatrixMode( GL_PROJECTION );
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, 640, 480, 0, 0, 1);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ glColor3f(fgColor_.red(), fgColor_.green(), fgColor_.blue());
+ glRasterPos2i(x_, y_);
+ glListBase(Engine::instance()->font);
+ glCallLists(
+ strlen(rindex(localString, '/')) - 1,
+ GL_UNSIGNED_BYTE,
+ rindex(localString, '/') + 1
+ );
+
+ glMatrixMode( GL_PROJECTION );
+ glPopMatrix();
}
Index: textobject.h
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- textobject.h 22 Aug 2003 05:53:29 -0000 1.1
+++ textobject.h 5 Oct 2003 17:45:46 -0000 1.2
@@ -29,7 +29,7 @@
TextObject(const char *text, const int x, const int y, const Color& fgColor);
void setX(int x);
void setY(int y);
- void setColor(const Color& newColor);
+ void setColor(Color *newColor);
const char *name() const { return textID_; }
void draw();
More information about the Scummvm-git-logs
mailing list