[Scummvm-cvs-logs] CVS: residual Makefile,1.15,1.16 TODO,1.30,1.31 bitmap.cpp,1.18,1.19 bitmap.h,1.5,1.6 costume.cpp,1.12,1.13 engine.cpp,1.23,1.24 lua.cpp,1.47,1.48 main.cpp,1.22,1.23 objectstate.h,1.2,1.3 resource.h,1.6,1.7 scene.cpp,1.19,1.20 scene.h,1.13,1.14

Daniel Schepler dschepler at users.sourceforge.net
Mon Mar 22 03:34:06 CET 2004


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23574

Modified Files:
	Makefile TODO bitmap.cpp bitmap.h costume.cpp engine.cpp 
	lua.cpp main.cpp objectstate.h resource.h scene.cpp scene.h 
Log Message:
Implement drawing bitmapped objects.


Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/residual/Makefile,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Makefile	21 Mar 2004 15:16:56 -0000	1.15
+++ Makefile	22 Mar 2004 11:23:35 -0000	1.16
@@ -16,7 +16,7 @@
 	textsplit.o lua.o registry.o localize.o scene.o engine.o actor.o \
 	sound.o timer.o keyframe.o costume.o walkplane.o textobject.o \
 	matrix3.o matrix4.o screen.o blocky16.o smush.o vima.o driver_gl.o \
-	mixer/mixer.o mixer/rate.o mixer/audiostream.o
+	objectstate.o mixer/mixer.o mixer/rate.o mixer/audiostream.o
 
 DEPS = $(OBJS:.o=.d)
 

Index: TODO
===================================================================
RCS file: /cvsroot/scummvm/residual/TODO,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- TODO	20 Mar 2004 07:55:05 -0000	1.30
+++ TODO	22 Mar 2004 11:23:36 -0000	1.31
@@ -2,7 +2,7 @@
 ------------------------------------------------
 Assigned tasks:
  * Add LAF font and text drawing support (aquadran)
- * Implement drawing 2D objects (ender)
+ * Implement drawing 2D objects (frob)
 
 Unassigned (help wanted):
  * Add OpenGL lighting (ender, possibly)

Index: bitmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- bitmap.cpp	21 Mar 2004 15:16:56 -0000	1.18
+++ bitmap.cpp	22 Mar 2004 11:23:36 -0000	1.19
@@ -110,7 +110,7 @@
 	}
 }
 
-void Bitmap::prepareDraw() {
+void Bitmap::draw() const {
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
 	glOrtho(0, 640, 480, 0, 0, 1);
@@ -122,9 +122,6 @@
 	// For now, just keep this here :-)
 	glDisable(GL_LIGHTING);
 	glEnable(GL_TEXTURE_2D);
-}
-
-void Bitmap::draw() const {
 	if (format_ == 1) {		// Normal image
 		if (curr_image_ != 0) {
 			warning("Animation not handled yet in GL texture path !\n");
@@ -132,13 +129,13 @@
 		glDisable(GL_DEPTH_TEST);
 		glDepthMask(GL_FALSE);
 		glEnable(GL_SCISSOR_TEST);
+		glScissor(x_, 480 - (y_ + height_), width_, height_);
 		int cur_tex_idx = 0;
 		for (int y = y_; y < (y_ + height_); y += BITMAP_TEXTURE_SIZE) {
 			for (int x = x_; x < (x_ + width_); x += BITMAP_TEXTURE_SIZE) {
 				int width  = (x + BITMAP_TEXTURE_SIZE >= (x_ + width_))  ? ((x_ + width_)  - x) : BITMAP_TEXTURE_SIZE;
 				int height = (y + BITMAP_TEXTURE_SIZE >= (y_ + height_)) ? ((y_ + height_) - y) : BITMAP_TEXTURE_SIZE;
 				glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
-				glScissor(x, 480 - (y + height), x + width, 480 - y);
 				glBegin(GL_QUADS);
 				glTexCoord2f(0.0, 0.0);
 				glVertex2i(x, y);

Index: bitmap.h
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- bitmap.h	24 Feb 2004 08:20:44 -0000	1.5
+++ bitmap.h	22 Mar 2004 11:23:36 -0000	1.6
@@ -27,8 +27,6 @@
 	// Construct a bitmap from the given data.
 	Bitmap(const char *filename, const char *data, int len);
 
-	// Set up Driver for drawing bitmaps
-	static void prepareDraw();
 	void draw() const;
 
 	// Set which image in an animated bitmap to use

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- costume.cpp	24 Feb 2004 21:09:53 -0000	1.12
+++ costume.cpp	22 Mar 2004 11:23:36 -0000	1.13
@@ -87,14 +87,12 @@
 public:
 	BitmapComponent(Costume::Component *parent, int parentID, const char *filename);
 
-	void update();
-	void draw();
+	void setKey(int val);
 
 private:
 	std::string filename_;
 	std::string zbuf_filename_;
 	ResPtr<Bitmap> bitmap_;
-	ResPtr<Bitmap> zbuffer_;
 };
 
 class ModelComponent : public Costume::Component {
@@ -158,13 +156,11 @@
 		Costume::Component(parent, parentID), filename_(filename) {
 
 	bitmap_ = ResourceLoader::instance()->loadBitmap(filename);
-	warning("Instanced BitmapComponenet from Costume renderer: NOT IMPLEMENTED YET");
-}
-
-void BitmapComponent::draw() {
+	warning("Instanced BitmapComponenet from Costume renderer with filename %s: NOT IMPLEMENTED YET", filename);
 }
 
-void BitmapComponent::update() {
+void BitmapComponent::setKey(int val) {
+	//	bitmap_->setNumber(val);
 }
 
 ModelComponent::ModelComponent(Costume::Component *parent, int parentID,

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- engine.cpp	21 Mar 2004 13:07:15 -0000	1.23
+++ engine.cpp	22 Mar 2004 11:23:37 -0000	1.24
@@ -112,9 +112,11 @@
 			if (SCREENBLOCKS_GLOBAL == 1)
 				screenBlocksBlitDirtyBlocks();
 
-			Bitmap::prepareDraw();
-			if (currScene_ != NULL)
+			if (currScene_ != NULL) {
 				currScene_->drawBackground();
+				currScene_->drawBitmaps(ObjectState::OBJSTATE_UNDERLAY);
+				currScene_->drawBitmaps(ObjectState::OBJSTATE_STATE);
+			}
 
 			if (g_smush->isPlaying()) {
 				movieTime_ = g_smush->getMovieTime();
@@ -148,6 +150,8 @@
 				(*i)->draw();
 			}
 
+			currScene_->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
+			
 			g_driver->flipBuffer();
 		}
 

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- lua.cpp	22 Mar 2004 08:51:54 -0000	1.47
+++ lua.cpp	22 Mar 2004 11:23:37 -0000	1.48
@@ -1087,8 +1087,8 @@
 	ObjectState::Position pos = check_objstate_pos(2); // When to draw
 	char *bitmap = luaL_check_string(3);	// Bitmap
 	char *zbitmap = NULL;			// Zbuffer Bitmap
-	bool unk2 = getbool(5);			// ?
-	bool unk3 = getbool(6);
+	bool unk1 = getbool(5);			// ?
+	bool unk2 = getbool(6);
 
 	if (!lua_isnil(lua_getparam(4)))
 		zbitmap = luaL_check_string(4);
@@ -1096,8 +1096,11 @@
 #ifndef OSX
 	warning("Stub: newObjectState(%d, %d, %s, %s)", setupID, pos, bitmap, zbitmap);
 #endif
-	// object = scene.addObjectState;
-	// lua_pushusertag(object, object_tag);
+
+	object = new ObjectState(setupID, pos, bitmap, zbitmap,
+				 unk1, unk2);
+	Engine::instance()->currScene()->addObjectState(object);
+	lua_pushusertag(object, object_tag);
 }
 
 static void FreeObjectState() {

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- main.cpp	21 Mar 2004 15:16:56 -0000	1.22
+++ main.cpp	22 Mar 2004 11:23:37 -0000	1.23
@@ -98,7 +98,6 @@
 #endif	
 			g_driver->clearScreen();
 
-			Bitmap::prepareDraw();
 			splash_bm->draw();
 
 			g_driver->flipBuffer();

Index: objectstate.h
===================================================================
RCS file: /cvsroot/scummvm/residual/objectstate.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- objectstate.h	22 Mar 2004 08:51:54 -0000	1.2
+++ objectstate.h	22 Mar 2004 11:23:37 -0000	1.3
@@ -3,6 +3,7 @@
 
 #include "vector3d.h"
 #include "resource.h"
+#include "bitmap.h"
 #include <string>
 #include <list>
 
@@ -14,6 +15,26 @@
 		OBJSTATE_OVERLAY = 2,
 		OBJSTATE_STATE = 3
 	};
+
+	ObjectState(int setupID, ObjectState::Position pos,
+		    const char *bitmap, const char *zbitmap,
+		    bool unk1, bool unk2);
+
+	int setupID() const { return setupID_; }
+	Position pos() const { return pos_; }
+	const char *bitmapFilename() const {
+		return bitmap_->filename();
+	}
+
+	void draw() {
+		bitmap_->draw();
+	}
+
+	private:
+	int setupID_;
+	Position pos_;
+	ResPtr<Bitmap> bitmap_, zbitmap_;
+	bool unk1_, unk2_;
 };
 
 

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- resource.h	24 Feb 2004 22:43:32 -0000	1.6
+++ resource.h	22 Mar 2004 11:23:37 -0000	1.7
@@ -57,8 +57,11 @@
 	ResPtr(const ResPtr &p) { ptr_ = p.ptr_; if (ptr_ != NULL) ptr_->ref(); }
 	ResPtr(T* ptr) { ptr_ = ptr; if (ptr_ != NULL) ptr_->ref(); }
 	operator T*() { return ptr_; }
+	operator const T*() const { return ptr_; }
 	T& operator *() { return *ptr_; }
+	const T& operator *() const { return *ptr_; }
 	T* operator ->() { return ptr_; }
+	const T* operator ->() const { return ptr_; }
 	ResPtr& operator =(T* ptr) {
 		if (ptr_ == ptr) return *this;
 		if (ptr_ != NULL) ptr_->deref();

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- scene.cpp	24 Feb 2004 22:43:32 -0000	1.19
+++ scene.cpp	22 Mar 2004 11:23:37 -0000	1.20
@@ -91,7 +91,10 @@
 	if (lights_)
 		delete [] lights_;
 	if (sectors_)
-		delete [] sectors_; 
+		delete [] sectors_;
+	for (StateList::iterator i = states_.begin();
+	     i != states_.end(); i++)
+		delete (*i);
 }
 
 void Scene::Setup::load(TextSplitter &ts) {
@@ -158,3 +161,11 @@
 	else
 		screenBlocksInitEmpty();
 }
+
+void Scene::drawBitmaps(ObjectState::Position stage) {
+	for (StateList::iterator i = states_.begin(); i != states_.end();
+	     i++) {
+		if ((*i)->pos() == stage && currSetup_ == setups_ + (*i)->setupID())
+			(*i)->draw();
+	}
+}

Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- scene.h	25 Feb 2004 08:21:30 -0000	1.13
+++ scene.h	22 Mar 2004 11:23:37 -0000	1.14
@@ -23,6 +23,7 @@
 #include "color.h"
 #include "debug.h"
 #include "walkplane.h"
+#include "objectstate.h"
 #include <SDL.h>
 #include <SDL_opengl.h>
 #include <string>
@@ -47,6 +48,7 @@
 		} 
 		currSetup_->bkgnd_bm_->draw();
 	}
+	void drawBitmaps(ObjectState::Position stage);
 	void setupCamera() {
 		currSetup_->setupCamera();
 	}
@@ -65,6 +67,10 @@
 			return NULL;
 	}
 
+	void addObjectState(ObjectState *s) {
+		states_.push_back(s);
+	}
+
 private:
 	struct Setup {		// Camera setup data
 		void load(TextSplitter &ts);
@@ -92,6 +98,9 @@
 	Light *lights_;
 	Setup *setups_;
 	Setup *currSetup_;
+
+	typedef std::list<ObjectState*> StateList;
+	StateList states_;
 };
 
 #endif





More information about the Scummvm-git-logs mailing list