aboutsummaryrefslogtreecommitdiff
path: root/backends/sdl/fb2opengl.h
diff options
context:
space:
mode:
authorMax Horn2002-10-22 00:58:48 +0000
committerMax Horn2002-10-22 00:58:48 +0000
commitd3a954861db10097b4d942e83e4bf2ac201ad571 (patch)
tree56f34797f88689100dd0807e820873287c05005e /backends/sdl/fb2opengl.h
parent1c999792f947bf983b4d08622026eb620f5b892c (diff)
downloadscummvm-rg350-d3a954861db10097b4d942e83e4bf2ac201ad571.tar.gz
scummvm-rg350-d3a954861db10097b4d942e83e4bf2ac201ad571.tar.bz2
scummvm-rg350-d3a954861db10097b4d942e83e4bf2ac201ad571.zip
patch #626629: add overlay support to SDL_g+OpenGL backend (still buggy!)
svn-id: r5226
Diffstat (limited to 'backends/sdl/fb2opengl.h')
-rw-r--r--backends/sdl/fb2opengl.h51
1 files changed, 50 insertions, 1 deletions
diff --git a/backends/sdl/fb2opengl.h b/backends/sdl/fb2opengl.h
index 39ab98ddc5..285b12d6ef 100644
--- a/backends/sdl/fb2opengl.h
+++ b/backends/sdl/fb2opengl.h
@@ -58,7 +58,6 @@ class FB2GL {
char flags;
void maketex();
void makedlist(int xf, int yf);
- void display();
public:
SDL_Surface *screen;
@@ -70,6 +69,8 @@ class FB2GL {
void update(void *fb, int width, int height, int pitch, int xskip, int yskip);
void palette(int index, int r, int g, int b);
void setPalette(int first, int ncolors);
+ void update_scummvm_screen(void *fb, int width, int height, int pitch, int x, int y);
+ void display();
};
void FB2GL::maketex()
@@ -207,6 +208,11 @@ int FB2GL::init(int width, int height, int xfix, int yfix, char _flags)
maketex();
makedlist(xfix, yfix);
+/* glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ glAlphaFunc(GL_GREATER,0);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);*/
+
return 1;
}
@@ -236,11 +242,13 @@ void FB2GL::update(void *fb, int w, int h, int pitch, int xskip, int yskip) {
ogl_fb1[y][x][0] = ogl_ctable[*(fb1+x)][0];
ogl_fb1[y][x][1] = ogl_ctable[*(fb1+x)][1];
ogl_fb1[y][x][2] = ogl_ctable[*(fb1+x)][2];
+ ogl_fb1[y][x][3] = 255;
}
else {
ogl_fb2[y][x-256][0] = ogl_ctable[*(fb1+x)][0];
ogl_fb2[y][x-256][1] = ogl_ctable[*(fb1+x)][1];
ogl_fb2[y][x-256][2] = ogl_ctable[*(fb1+x)][2];
+ ogl_fb2[y][x-256][3] = 255;
}
}
fb1 += scr_pitch;
@@ -309,6 +317,47 @@ void FB2GL::update(void *fb, int w, int h, int pitch, int xskip, int yskip) {
}
+void FB2GL::update_scummvm_screen(void *fb, int w, int h, int pitch, int xpos, int ypos) {
+ uint16 *fb1 = (uint16 *)(((SDL_Surface *)fb)->pixels);
+ int x, y;
+ unsigned char r, g, b, a;
+
+ for (y=0; y<h; y++) {
+ for (x=0; x<w; x++) {
+
+ SDL_GetRGBA(fb1[x],((SDL_Surface *)fb)->format,&r,&g,&b,&a);
+
+ if (x<256) {
+ ogl_fb1[y][x][0] = r;
+ ogl_fb1[y][x][1] = g;
+ ogl_fb1[y][x][2] = b;
+ ogl_fb1[y][x][3] = a; // Alpha
+ }
+ else {
+ ogl_fb2[y][x-256][0] = r;
+ ogl_fb2[y][x-256][1] = g;
+ ogl_fb2[y][x-256][2] = b;
+ ogl_fb2[y][x-256][3] = a; // Alpha
+ }
+ }
+ fb1 += pitch;
+ }
+
+ // Update 256x256 texture
+ glBindTexture(GL_TEXTURE_2D,texture);
+ glFlush();
+ glTexSubImage2D(GL_TEXTURE_2D,0,xpos,ypos,256-xpos,256-ypos,GL_RGBA,
+ GL_UNSIGNED_BYTE,ogl_fb1);
+
+ // Update 64x256 texture
+ glBindTexture(GL_TEXTURE_2D,textureb);
+ glFlush();
+ glTexSubImage2D(GL_TEXTURE_2D,0,xpos,ypos,64-xpos,256-ypos,GL_RGBA,
+ GL_UNSIGNED_BYTE,ogl_fb2);
+
+ display();
+}
+
void FB2GL::palette(int i, int r, int g, int b) {
if (flags & FB2GL_EXPAND) {
ogl_temp_ctable[i][0]=r;