added smush gfx output, but it still not working

This commit is contained in:
Pawel Kolodziejski 2003-12-12 22:57:40 +00:00
parent 2744e0ec88
commit 98a3718f92
2 changed files with 98 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include "timer.h"
#include "mixer/mixer.h"
#include <SDL.h>
#include <SDL_opengl.h>
Smush *smush;
@ -89,6 +90,101 @@ void Smush::handleWave(const byte *src, uint32 size) {
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 @@ void Smush::handleFrame() {
if (_frame == _nbframes) {
_videoFinished = true;
}
// updateGLScreen();
updateGLScreen();
}
void Smush::handleFramesHeader() {

View File

@ -92,7 +92,7 @@ private:
void init();
void deinit();
void setupAnim(const char *file, const char *directory);
void updateScreen();
void updateGLScreen();
};
#endif