[Scummvm-cvs-logs] CVS: residual smush.cpp,1.3,1.4 smush.h,1.3,1.4
Pawel Kolodziejski
aquadran at users.sourceforge.net
Fri Dec 12 14:58:01 CET 2003
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1:/tmp/cvs-serv32472
Modified Files:
smush.cpp smush.h
Log Message:
added smush gfx output, but it still not working
Index: smush.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smush.cpp 12 Dec 2003 22:24:34 -0000 1.3
+++ smush.cpp 12 Dec 2003 22:57:40 -0000 1.4
@@ -23,6 +23,7 @@
#include "timer.h"
#include "mixer/mixer.h"
#include <SDL.h>
+#include <SDL_opengl.h>
Smush *smush;
@@ -89,6 +90,101 @@
g_mixer->appendStream(_soundHandle, (byte *)dst, size * _channels * 2);
}
+#define BITMAP_TEXTURE_SIZE 256
+
+void Smush::updateGLScreen() {
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ int num_tex_;
+ GLuint *tex_ids_;
+
+ // create texture
+ num_tex_ = ((_width + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
+ ((_height + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE);
+ tex_ids_ = new GLuint[num_tex_];
+ glGenTextures(num_tex_, tex_ids_);
+ for (int i = 0; i < num_tex_; i++) {
+ glBindTexture(GL_TEXTURE_2D, tex_ids_[i]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0,
+ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, _width);
+
+ int cur_tex_idx = 0;
+ for (int y = 0; y < _height; y += BITMAP_TEXTURE_SIZE) {
+ for (int x = 0; x < _width; x += BITMAP_TEXTURE_SIZE) {
+ int width = (x + BITMAP_TEXTURE_SIZE >= _width) ? (_width - x) : BITMAP_TEXTURE_SIZE;
+ int height = (y + BITMAP_TEXTURE_SIZE >= _height) ? (_height - y) : BITMAP_TEXTURE_SIZE;
+ glBindTexture(GL_TEXTURE_2D, tex_ids_[cur_tex_idx]);
+ glTexSubImage2D(GL_TEXTURE_2D,
+ 0,
+ 0, 0,
+ width, height,
+ GL_RGB,
+ GL_UNSIGNED_SHORT_5_6_5,
+ _dst + (y * 2 * _width) + (2 * x));
+ cur_tex_idx++;
+ }
+ }
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+
+
+ // prepare view
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, 640, 480, 0, 0, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ // A lot more may need to be put there : disabling Alpha test, blending, ...
+ // For now, just keep this here :-)
+ glDisable(GL_LIGHTING);
+ glEnable(GL_TEXTURE_2D);
+
+ // draw
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ glEnable(GL_SCISSOR_TEST);
+ cur_tex_idx = 0;
+ for (int y = 0; y < _height; y += BITMAP_TEXTURE_SIZE) {
+ for (int x = 0; x < _width; x += BITMAP_TEXTURE_SIZE) {
+ int width = (x + BITMAP_TEXTURE_SIZE >= _width) ? (_width - x) : BITMAP_TEXTURE_SIZE;
+ int height = (y + BITMAP_TEXTURE_SIZE >= _height) ? (_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);
+ glTexCoord2f(1.0, 0.0);
+ glVertex2i(x + BITMAP_TEXTURE_SIZE, y);
+ glTexCoord2f(1.0, 1.0);
+ glVertex2i(x + BITMAP_TEXTURE_SIZE, y + BITMAP_TEXTURE_SIZE);
+ glTexCoord2f(0.0, 1.0);
+ glVertex2i(x, y + BITMAP_TEXTURE_SIZE);
+ glEnd();
+ cur_tex_idx++;
+ }
+ }
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_TEXTURE_2D);
+ glDepthMask(GL_TRUE);
+ glEnable(GL_DEPTH_TEST);
+
+ SDL_GL_SwapBuffers();
+
+ // remove
+ glDeleteTextures(num_tex_, tex_ids_);
+ delete[] tex_ids_;
+}
+
void Smush::handleFrame() {
uint32 tag;
int32 size;
@@ -120,7 +216,7 @@
if (_frame == _nbframes) {
_videoFinished = true;
}
-// updateGLScreen();
+ updateGLScreen();
}
void Smush::handleFramesHeader() {
Index: smush.h
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smush.h 12 Dec 2003 22:24:34 -0000 1.3
+++ smush.h 12 Dec 2003 22:57:40 -0000 1.4
@@ -92,7 +92,7 @@
void init();
void deinit();
void setupAnim(const char *file, const char *directory);
- void updateScreen();
+ void updateGLScreen();
};
#endif
More information about the Scummvm-git-logs
mailing list