[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/src/draw/opengl pgglcore.cpp,1.1.2.4,1.1.2.5
From: |
Teunis Peters <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/src/draw/opengl pgglcore.cpp,1.1.2.4,1.1.2.5 pggloper.cpp,1.1.2.5,1.1.2.6 pgglsurf.cpp,1.1.2.7,1.1.2.8 |
Date: |
Fri, 08 Nov 2002 06:22:04 -0500 |
Update of /cvsroot/paragui/paragui/src/draw/opengl
In directory subversions:/tmp/cvs-serv13762/src/draw/opengl
Modified Files:
Tag: devel-opengl
pgglcore.cpp pggloper.cpp pgglsurf.cpp
Log Message:
Add in greyscale and bitmap images (still largely untested)
also now pango future plugin now renders... :)
Index: pgglcore.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/opengl/Attic/pgglcore.cpp,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -r1.1.2.4 -r1.1.2.5
*** pgglcore.cpp 4 Nov 2002 10:58:32 -0000 1.1.2.4
--- pgglcore.cpp 8 Nov 2002 11:22:01 -0000 1.1.2.5
***************
*** 167,170 ****
--- 167,174 ----
if (!surface) goto pass; /* Well, there ain't much we can do anyway... */
pf = surface->format;
+ if (pf->BitsPerPixel == 1) goto pass; /* binary always passes... it's a
native OpenGL format */
+ if (pf->BitsPerPixel == 8) goto pass; /* Palette formats are also native...
*/
+ if ((pf->BitsPerPixel == 16) && (pf->Amask) && (!pf->Bmask)) goto pass; /*
LA - OpenGL native */
+
/* Colorkeying requires an alpha channel! */
if (surface->flags & SDL_SRCCOLORKEY)
***************
*** 524,528 ****
};
#endif
! GLSDL_FIX_SURFACE(t);
surf = new PG_GLDrawableSurface(this, t);
attach(surf);
--- 528,532 ----
};
#endif
! /* GLSDL_FIX_SURFACE(t); */
surf = new PG_GLDrawableSurface(this, t);
attach(surf);
***************
*** 542,546 ****
t = _CreateRGBSurface(width, height);
if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
! GLSDL_FIX_SURFACE(t);
surf = new PG_GLDrawableSurface(this, t);
attach(surf);
--- 546,550 ----
t = _CreateRGBSurface(width, height);
if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
! /* GLSDL_FIX_SURFACE(t); */
surf = new PG_GLDrawableSurface(this, t);
attach(surf);
***************
*** 555,563 ****
t = _CreateRGBASurface(width, height);
if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
! GLSDL_FIX_SURFACE(t);
surf = new PG_GLDrawableSurface(this, t);
attach(surf);
if (surf == NULL) { PG_LogERR("failed to create window"); exit(-1); }
// PG_LogMSG("%s[%s:%i]: bpp %i rmask %x gmask %x bmask %x", __FUNCTION__,
__FILE__, __LINE__, surf->GetFormat()->BytesPerPixel, surf->GetFormat()->Rmask,
surf->GetFormat()->Gmask, surf->GetFormat()->Bmask);
return surf;
};
--- 559,667 ----
t = _CreateRGBASurface(width, height);
if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
! /* GLSDL_FIX_SURFACE(t); */
surf = new PG_GLDrawableSurface(this, t);
attach(surf);
if (surf == NULL) { PG_LogERR("failed to create window"); exit(-1); }
// PG_LogMSG("%s[%s:%i]: bpp %i rmask %x gmask %x bmask %x", __FUNCTION__,
__FILE__, __LINE__, surf->GetFormat()->BytesPerPixel, surf->GetFormat()->Rmask,
surf->GetFormat()->Gmask, surf->GetFormat()->Bmask);
+ return surf;
+ };
+
+ PG_DrawableSurface* PG_GLDraw::CreateBitmap(int w, int h) {
+ PG_GLDrawableSurface* surf;
+ SDL_Surface* t;
+ Uint32 rmask, gmask, bmask, amask;
+ int bits = 1;
+ #if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ rmask = 0xff000000;
+ gmask = 0x00ff0000;
+ bmask = 0x0000ff00;
+ amask = 0x000000ff;
+ #else
+ rmask = 0x000000ff;
+ gmask = 0x0000ff00;
+ bmask = 0x00ff0000;
+ amask = 0xff000000;
+ #endif
+ t = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, bits, rmask, gmask, bmask,
amask);
+ if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
+ if (t) {
+ GLSDL_FIX_SURFACE(t);
+ };
+
+ switch (AddTexInfo(t)) {
+ case 0: break;
+ case -1: PG_LogERR("AddTexInfo returned: no screen"); break;
+ case -2: PG_LogERR("AddTexInfo returned: no texinfo"); break;
+ case -3: PG_LogERR("AddTexInfo returned: calc chop fail"); break;
+ };
+
+ surf = new PG_GLDrawableSurface(this, t);
+ attach(surf);
+ if (surf == NULL) { PG_LogERR("failed to create window"); exit(-1); }
+ PG_LogMSG("%s[%s:%i]: bpp %i rmask %x gmask %x bmask %x", __FUNCTION__,
__FILE__, __LINE__, surf->GetFormat()->BytesPerPixel, surf->GetFormat()->Rmask,
surf->GetFormat()->Gmask, surf->GetFormat()->Bmask);
+ return surf;
+ };
+
+ PG_DrawableSurface* PG_GLDraw::CreateGrey(int w, int h) {
+ PG_GLDrawableSurface* surf;
+ SDL_Surface* t;
+ t = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8, 0,0,0,0);
+ if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
+ if (t) {
+ GLSDL_FIX_SURFACE(t);
+ };
+
+ switch (AddTexInfo(t)) {
+ case 0: break;
+ case -1: PG_LogERR("AddTexInfo returned: no screen"); break;
+ case -2: PG_LogERR("AddTexInfo returned: no texinfo"); break;
+ case -3: PG_LogERR("AddTexInfo returned: calc chop fail"); break;
+ };
+
+ surf = new PG_GLDrawableSurface(this, t);
+ attach(surf);
+ if (surf == NULL) { PG_LogERR("failed to create window"); exit(-1); }
+ SDL_Color tmp_pal[256];
+ for (int i=0; i<0x100; ++i) {
+ tmp_pal[i].r = i;
+ tmp_pal[i].g = i;
+ tmp_pal[i].b = i;
+ tmp_pal[i].unused = 0xff; /* set alpha... as it IS respected */
+ }
+ surf->SetPalette(SDL_LOGPAL, tmp_pal, 0, 256);
+ surf->isgrey = true;
+ PG_LogMSG("%s[%s:%i]: bpp %i rmask %x gmask %x bmask %x", __FUNCTION__,
__FILE__, __LINE__, surf->GetFormat()->BytesPerPixel, surf->GetFormat()->Rmask,
surf->GetFormat()->Gmask, surf->GetFormat()->Bmask);
+ return surf;
+ };
+
+ PG_DrawableSurface* PG_GLDraw::CreateGreyAlpha(int w, int h) {
+ PG_GLDrawableSurface* surf;
+ SDL_Surface* t;
+ Uint32 rmask, amask;
+ #if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ rmask = 0xff00;
+ amask = 0x00ff;
+ #else
+ rmask = 0x00ff;
+ amask = 0xff00;
+ #endif
+ t = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 16, rmask, 0, 0, amask);
+ if (t == NULL) { PG_LogERR("SDL: %s", SDL_GetError()); exit(-1); }
+ if (t) {
+ GLSDL_FIX_SURFACE(t);
+ };
+
+ switch (AddTexInfo(t)) {
+ case 0: break;
+ case -1: PG_LogERR("AddTexInfo returned: no screen"); break;
+ case -2: PG_LogERR("AddTexInfo returned: no texinfo"); break;
+ case -3: PG_LogERR("AddTexInfo returned: calc chop fail"); break;
+ };
+
+ surf = new PG_GLDrawableSurface(this, t);
+ attach(surf);
+ surf->isgrey = true;
+ if (surf == NULL) { PG_LogERR("failed to create window"); exit(-1); }
+ PG_LogMSG("%s[%s:%i]: bpp %i rmask %x gmask %x bmask %x", __FUNCTION__,
__FILE__, __LINE__, surf->GetFormat()->BytesPerPixel, surf->GetFormat()->Rmask,
surf->GetFormat()->Gmask, surf->GetFormat()->Bmask);
return surf;
};
Index: pggloper.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/opengl/Attic/pggloper.cpp,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -r1.1.2.5 -r1.1.2.6
*** pggloper.cpp 4 Nov 2002 10:58:32 -0000 1.1.2.5
--- pggloper.cpp 8 Nov 2002 11:22:01 -0000 1.1.2.6
***************
*** 452,455 ****
--- 452,456 ----
int PG_GLDraw::_DownloadTexture(SDL_Surface *datasurf,
glSDL_TexInfo *txi, int tex) {
+ enum { _None=0, _Bitmap=1, _Pal=2, _GreyAlpha=3, _RGBx=4 } surftype = _None;
int bpp;
Uint32 rowlength;
***************
*** 468,489 ****
// DBG5(DBGLINE());
glBindTexture(GL_TEXTURE_2D, txi->texture[tex]);
! rowlength = datasurf->pitch / bpp;
// PG_LogDBG("ParaGUI[%s]: %s:%i pitch %i bpp %i", __FILE__, __FUNCTION__,
__LINE__, datasurf->pitch, bpp);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#if 0
! DBG5(PG_LogMSG("amask %s size %ix%i form %s",
! datasurf->format->Amask ? "GL_RGBA8" : "GL_RGB8",
! txi->texsize, txi->texsize,
! datasurf->format->Amask ? "GL_RGBA" : "GL_RGB"));
! #endif
! glTexImage2D(GL_TEXTURE_2D, 0,
! datasurf->format->Amask ? GL_RGBA8 : GL_RGB8,
! txi->texsize, txi->texsize, 0,
! datasurf->format->Amask ? GL_RGBA : GL_RGB,
! GL_UNSIGNED_BYTE, NULL);
! DBG(_print_glerror(1));
!
switch(txi->tilemode)
{
--- 469,560 ----
// DBG5(DBGLINE());
glBindTexture(GL_TEXTURE_2D, txi->texture[tex]);
!
! if (datasurf->format->BitsPerPixel == 1) {
! surftype = _Bitmap;
! } else if(datasurf->format->BitsPerPixel == 8) {
! surftype = _Pal;
! } else if((datasurf->format->BitsPerPixel == 16) &&
(datasurf->format->Amask) && (!datasurf->format->Bmask)) {
! surftype = _GreyAlpha;
! } else {
! surftype = _RGBx;
! };
!
!
! if (surftype == _None) return -2;
! if (surftype == _Bitmap) {
! rowlength = datasurf->pitch;
! } else {
! rowlength = datasurf->pitch / bpp;
! };
// PG_LogDBG("ParaGUI[%s]: %s:%i pitch %i bpp %i", __FILE__, __FUNCTION__,
__LINE__, datasurf->pitch, bpp);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ switch (surftype) {
+ case _None: return -2;
+ case _Bitmap: {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, txi->texsize, txi->texsize,
0, GL_LUMINANCE,
+ GL_UNSIGNED_BYTE, NULL);
+ DBG(_print_glerror(1));
+ break;
+ };
+ case _Pal: {
+ #ifdef GL_VERSION_1_2
+ if (datasurf->format->palette != NULL) {
+ glColorTable(GL_TEXTURE_2D,GL_RGBA,
+ datasurf->format->palette->ncolors,
+ GL_RGBA,GL_UNSIGNED_BYTE,
+ datasurf->format->palette->colors);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT,
+ txi->texsize, txi->texsize, 0, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, NULL);
+ DBG(_print_glerror(1));
+ break;
+ };
+ #else
+ #ifdef GL_EXT_paletted_texture
+ if (datasurf->format->palette != NULL) {
+ glColorTableEXT(GL_TEXTURE_2D,GL_RGBA,
+ datasurf->format->palette->ncolors,
+ GL_RGBA,GL_UNSIGNED_BYTE,
+ datasurf->format->palette->colors);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT,
+ txi->texsize, txi->texsize, 0, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, NULL);
+ DBG(_print_glerror(1));
+ break;
+ };
+ #endif
+ #endif
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8,
+ txi->texsize, txi->texsize, 0, GL_LUMINANCE,
+ GL_UNSIGNED_BYTE, NULL);
+ DBG(_print_glerror(1));
+ break;
+ };
+ case _GreyAlpha: {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8,
+ txi->texsize, txi->texsize, 0, GL_LUMINANCE_ALPHA,
+ GL_UNSIGNED_BYTE, NULL);
+ DBG(_print_glerror(1));
+ break;
+ };
+ case _RGBx: {
#if 0
! DBG5(PG_LogMSG("amask %s size %ix%i form %s",
! datasurf->format->Amask ? "GL_RGBA8" : "GL_RGB8",
! txi->texsize, txi->texsize,
! datasurf->format->Amask ? "GL_RGBA" : "GL_RGB"));
! #endif
! glTexImage2D(GL_TEXTURE_2D, 0,
! datasurf->format->Amask ? GL_RGBA8 : GL_RGB8,
! txi->texsize, txi->texsize, 0,
! datasurf->format->Amask ? GL_RGBA : GL_RGB,
! GL_UNSIGNED_BYTE, NULL);
! DBG(_print_glerror(1));
! break;
! };
! };
switch(txi->tilemode)
{
***************
*** 506,518 ****
/* glPixelStorei(GL_UNPACK_SKIP_PIXELS, textures[i].skip_pixels ); */
#endif
! glTexSubImage2D(GL_TEXTURE_2D, 0,
! 0, toy, /* offset */
! thistw, txi->tileh, /* width, height */
! datasurf->format->Amask ? GL_RGBA : GL_RGB,
! GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! /* ((Uint8 *)datasurf->pixels) + (bpp * fromx)); */
// PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
- DBG4(_print_glerror(2));
fromx += txi->tilew;
toy += txi->tileh;
--- 577,636 ----
/* glPixelStorei(GL_UNPACK_SKIP_PIXELS, textures[i].skip_pixels ); */
#endif
! switch (surftype) {
! case _Bitmap: {
! glTexSubImage2D(GL_TEXTURE_2D, 0,
! 0, toy, /* offset */
! thistw, txi->tileh, /* width, height */
! GL_LUMINANCE,
! GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! DBG(_print_glerror(2));
! break;
! };
! case _Pal: {
! #ifdef GL_VERSION_1_2
! if (datasurf->format->palette != NULL) {
! glTexSubImage2D(GL_TEXTURE_2D,0,0,toy,thistw,txi->tileh,
! GL_COLOR_INDEX,GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! DBG(_print_glerror(2));
! break;
! };
! #else
! #ifdef GL_EXT_paletted_texture
! if (datasurf->format->palette != NULL) {
! glTexSubImage2D(GL_TEXTURE_2D,0,0,toy,thistw,txi->tileh,
! GL_COLOR_INDEX,GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! DBG(_print_glerror(2));
! break;
! };
! #endif
! #endif
! glTexSubImage2D(GL_TEXTURE_2D, 0,0, toy,thistw, txi->tileh,
! GL_LUMINANCE, GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! DBG(_print_glerror(2));
! break;
! };
! case _GreyAlpha: {
! glTexSubImage2D(GL_TEXTURE_2D, 0, 0, toy, thistw, txi->tileh,
! GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! DBG(_print_glerror(2));
! break;
! };
! case _RGBx: {
! glTexSubImage2D(GL_TEXTURE_2D, 0, 0, toy, thistw, txi->tileh,
! datasurf->format->Amask ? GL_RGBA : GL_RGB,
! GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + bpp * fromx);
! /* ((Uint8 *)datasurf->pixels) + (bpp * fromx)); */
! DBG4(_print_glerror(2));
! break;
! };
! case _None: return -2;
! };
// PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
fromx += txi->tilew;
toy += txi->tileh;
***************
*** 540,548 ****
/* glPixelStorei(GL_UNPACK_SKIP_PIXELS, textures[i].skip_pixels ); */
#endif
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0,
! txi->tilew, thisth,
! datasurf->format->Amask ? GL_RGBA : GL_RGB,
! GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
DBG4(_print_glerror(3));
fromy += txi->tileh;
--- 658,712 ----
/* glPixelStorei(GL_UNPACK_SKIP_PIXELS, textures[i].skip_pixels ); */
#endif
! switch (surftype) {
! case _Bitmap: {
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth,
! GL_LUMINANCE, GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
! DBG(_print_glerror(3));
! break;
! };
! case _Pal: {
! #ifdef GL_VERSION_1_2
! if (datasurf->format->palette != NULL) {
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth,
! GL_COLOR_INDEX,GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
! DBG(_print_glerror(3));
! break;
! };
! #else
! #ifdef GL_EXT_paletted_texture
! if (datasurf->format->palette != NULL) {
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth,
! GL_COLOR_INDEX,GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
! DBG(_print_glerror(3));
! break;
! };
! #endif
! #endif
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth,
! GL_LUMINANCE, GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
! DBG(_print_glerror(3));
! break;
! };
! case _GreyAlpha: {
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth,
! GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
! DBG(_print_glerror(3));
! break;
! };
! case _RGBx: {
! glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth,
! datasurf->format->Amask ? GL_RGBA : GL_RGB,
! GL_UNSIGNED_BYTE,
! (Uint8 *)datasurf->pixels + (datasurf->pitch *
fromy));
! DBG4(_print_glerror(3));
! break;
! };
! case _None: return -2;
! };
DBG4(_print_glerror(3));
fromy += txi->tileh;
Index: pgglsurf.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/opengl/Attic/pgglsurf.cpp,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -r1.1.2.7 -r1.1.2.8
*** pgglsurf.cpp 4 Nov 2002 10:58:32 -0000 1.1.2.7
--- pgglsurf.cpp 8 Nov 2002 11:22:01 -0000 1.1.2.8
***************
*** 53,60 ****
*/
! PG_GLDrawableSurface::PG_GLDrawableSurface(PG_GLDraw* refhost) :
PG_DrawableSurface(), scale(1) { host=refhost; };
/* PG_GLDrawableSurface::PG_GLDrawableSurface(SDL_Surface* s) :
PG_DrawableSurface(s), scale(1) { host=NULL; }; */
PG_GLDrawableSurface::PG_GLDrawableSurface(PG_GLDraw* refhost, SDL_Surface* s)
! : PG_DrawableSurface(s), scale(1) {
ref = s;
host = refhost;
--- 53,60 ----
*/
! PG_GLDrawableSurface::PG_GLDrawableSurface(PG_GLDraw* refhost) :
PG_DrawableSurface(), scale(1), isgrey(false) { host=refhost; };
/* PG_GLDrawableSurface::PG_GLDrawableSurface(SDL_Surface* s) :
PG_DrawableSurface(s), scale(1) { host=NULL; }; */
PG_GLDrawableSurface::PG_GLDrawableSurface(PG_GLDraw* refhost, SDL_Surface* s)
! : PG_DrawableSurface(s), scale(1), isgrey(false) {
ref = s;
host = refhost;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/src/draw/opengl pgglcore.cpp,1.1.2.4,1.1.2.5 pggloper.cpp,1.1.2.5,1.1.2.6 pgglsurf.cpp,1.1.2.7,1.1.2.8,
Teunis Peters <address@hidden> <=