paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/src/draw/opengl pgglroot.cpp,NONE,1.1.2.1 TOD


From: Teunis Peters <address@hidden>
Subject: [paragui-cvs] CVS: paragui/src/draw/opengl pgglroot.cpp,NONE,1.1.2.1 TODO,1.1.2.2,1.1.2.3 pgglsurf.cpp,1.1.2.2,1.1.2.3
Date: Wed, 30 Oct 2002 04:16:32 -0500

Update of /cvsroot/paragui/paragui/src/draw/opengl
In directory subversions:/tmp/cvs-serv26981/src/draw/opengl

Modified Files:
      Tag: devel-opengl
        TODO pgglsurf.cpp 
Added Files:
      Tag: devel-opengl
        pgglroot.cpp 
Log Message:
Updating function names to be more consistent with ParaGUI
There's a persistant memory bug - somewhere - which is attempting to delete 
information already deleted.  Not all demos exhibit this, but paratest is 
amongst those that do.
Significant rewrite of most of OpenGL driver.  There's still more to be done 
and the driver as yet does not work correctly.  Any help would be quite 
appreciated but as I haven't received anything more than a couple comments yet 
I'm not holding my breath - T.


***** Error reading new file: [Errno 2] No such file or directory: 
'pgglroot.cpp'
Index: TODO
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/opengl/Attic/TODO,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** TODO        24 Oct 2002 16:08:13 -0000      1.1.2.2
--- TODO        30 Oct 2002 09:16:29 -0000      1.1.2.3
***************
*** 1,4 ****
--- 1,6 ----
  OpenGL TODO:
  ------------
+ - removing code that allows non-OpenGL fallback inside OpenGL driver because
+   it really doesn't apply.  It's a glSDL leftover....
  - consider having all loaded images loaded into accelerated blocks...
        (actually this is a REALLY good idea... :)
***************
*** 23,25 ****
        FIXME  - this is where a lot of problems are coming from...
  - too much debug code *g*
! - Fonts still don't render.
\ No newline at end of file
--- 25,35 ----
        FIXME  - this is where a lot of problems are coming from...
  - too much debug code *g*
! - Fonts still don't render.
! 
! -> make root screen not an SDL surface (publically) - make it a drawing
!       context... (as it DOES have some metadata) or something.  Basically
!       a different object entirely.
! 
! - Am I going to make PG_Draw.. virtual?
!   I think so... and provide an internal SDL driver...
!   ... but don't know yet.

Index: pgglsurf.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/draw/opengl/Attic/pgglsurf.cpp,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** pgglsurf.cpp        24 Oct 2002 16:08:13 -0000      1.1.2.2
--- pgglsurf.cpp        30 Oct 2002 09:16:29 -0000      1.1.2.3
***************
*** 48,62 ****
  /* drawable surface */
  
! PG_GLDrawableSurface::PG_GLDrawableSurface() : PG_DrawableSurface(), 
glactive(false), scale(1) { host=NULL; };
! PG_GLDrawableSurface::PG_GLDrawableSurface(SDL_Surface* s) : 
PG_DrawableSurface(s), glactive(false), scale(1) { host=NULL; };
  PG_GLDrawableSurface::PG_GLDrawableSurface(PG_GLDraw* refhost, SDL_Surface* s)
!   : PG_DrawableSurface(s), glactive(false), scale(1) {
    ref = s;
    host = refhost;
-   if (s != NULL) {
-     /* if (s != SDL_GetVideoSurface()) { GLSDL_FIX_SURFACE(s); }; */
-     glactive = (GetTexInfo() != NULL);
-     DBG2(PG_LogMSG("%s: handle %p glactive %c", __FUNCTION__, ref, 
(glactive?'T':'F')));
-   };
  };
  
--- 48,62 ----
  /* drawable surface */
  
! /* T's notes:
!  * This project got a whole lot easier when I segregated the root surface
!  * (main screen) from subtextures!
!  */
! 
! PG_GLDrawableSurface::PG_GLDrawableSurface() : PG_DrawableSurface(), scale(1) 
{ host=NULL; };
! 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;
  };
  
***************
*** 64,213 ****
    if ((ref != NULL) && (host != NULL)) {
      /* host->FreeTexInfo(ref); */
!     if (ref != SDL_GetVideoSurface()) host->_FreeSurface(ref);
      ref = NULL;
    };
  };
  
! int PG_GLDrawableSurface::Lock() {
!   if (!SDL_MUSTLOCK(ref) && !is_GL()) return 0;
!   if (!ref) return 0;
!   if (SDL_GetVideoSurface() != ref) {
!     if (is_GL()) Invalidate(PG_Rect());
!   }
!   return SDL_LockSurface(ref);
  };
  
! void PG_GLDrawableSurface::Unlock() {
!   if (!SDL_MUSTLOCK(ref) && !is_GL()) return;
!   if (!ref) return;
!   SDL_UnlockSurface(ref);
!   if (is_GL()) {
!     if (SDL_GetVideoSurface() != ref)
!       host->DownloadSurface(ref);
!     else
!       host->update_screen = 1;        /* SDL will deal with this */
!   }
  };
  
! void PG_GLDrawableSurface::UpdateRects(int numrects, PG_Rect *rects) {
!   /* crashes after this... */
    PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   // return; // DEBUG
!   /* this works more or less */
!   if (!is_GL()) {
!     DBG5(DBGLINE());
!     PG_DrawableSurface::UpdateRects(numrects, rects);
!   } else {
!     DBG5(DBGLINE());
! #if 0 /* not needed at this time... FIXME */
!     PG_Rect tr;
!     if (numrects > 0) {
!       tr = rects[0];
!       if (numrects > 1) {
!       for (int i=1; i<numrects; i++) tr = tr.UnionRect(rects[i]);
!       }
!     } else {
!       tr = PG_Rect(0,0,ref->w, ref->h);
!     };
!     /* find the texture data */
!     glSDL_TexInfo *txi = GetTexInfo();
!     txi->invalid_area.x = tr.x;
!     txi->invalid_area.y = tr.y;
!     txi->invalid_area.w = tr.w;
!     txi->invalid_area.h = tr.h;
! #endif
!     host->Flip();
!     DBG5(DBGLINE());
!   };
  
!   DBG5(DBGLINE());
!   /* otherwise caught by the driver
!    * FIXME note: it would be a GOOD idea to handle surface update here... */
! #if 0
!   if (is_GL()) {
!     host->Flip();
!   } else {
!     PG_DrawableSurface::UpdateRects(numrects, rects);
!   };
! #endif
! #if 0
!   /* note - this maybe shouldn't be called?  or some other handling?? */
!   if (!host->update_screen && IS_GLSDL_SURFACE(ref)) {
!     host->Flip();
!   } else {
!     PG_DrawableSurface::UpdateRects(numrects, rects);
!     /* SDL_UpdateRects(ref, numrects, rects); */
!   };
!   host->update_screen = 0;
! #endif
! }
  
! int PG_GLDrawableSurface::SetColorKey(Uint32 flag, Uint32 key) {
!   // PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   // return 0; // DEBUG
  
!   int res = SDL_SetColorKey(ref, flag, key);
!   if (res < 0) return res;
!   /*
!    * If an application does this *after* SDL_DisplayFormat,
!    * we're basically screwed, unless we want to do an
!    * in-place surface conversion hack here.
!    *
!    * What we do is just kill the glSDL texinfo... No big
!    * deal in most cases, as glSDL only converts once anyway,
!    * *unless* you keep modifying the surface.
!    */
!   if (is_GL()) host->FreeTexInfo(ref);
!   return res;
  };
  
! bool PG_GLDrawableSurface::SetClipRect(const PG_Rect& rect) {
!   // PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   // return true; // DEBUG
  
!   SDL_bool res;
!   SDL_Surface *screen;
!   SDL_Rect* trect;
!   if (!ref) return SDL_FALSE;
!   
!   screen = SDL_GetVideoSurface();
!   
!   res = SDL_SetClipRect(ref, (SDL_Rect*)&rect);
!   if (!res) return SDL_FALSE;
!   trect = &ref->clip_rect;
!   
!   if (ref == host->fake_screen) {
!     SDL_Rect r;
!     r.x = trect->x * scale;
!     r.y = trect->y * scale;
!     r.w = trect->w * scale;
!     r.h = trect->h * scale;
!     screen = ref;
!     SDL_SetClipRect(ref, trect);
!   }
!   
!   if ((screen == ref) && is_GL()) {
!     float xscale, yscale;
!     glSDL_TexInfo *txi = GetTexInfo();
!     glViewport(       trect->x * scale,
!               screen->h - (trect->y + trect->h) * scale,
!               trect->w * scale,
!               trect->h * scale);
!     /*
!      * Note that this projection is upside down in
!      * relation to the OpenGL coordinate system.
!      */
!     glMatrixMode(GL_PROJECTION);
!     glLoadIdentity();
!     xscale = (float)txi->lw / (float)ref->w;
!     yscale = (float)txi->lh / (float)ref->h;
!     glOrtho(  xscale*(float)trect->x,
!               xscale*(float)(trect->w+trect->x),
!               yscale*(float)(trect->h+trect->y),
!               yscale*(float)trect->y,
!               -1.0, 1.0);
!     return SDL_TRUE;
!   }
!   return res;
  };
  
--- 64,113 ----
    if ((ref != NULL) && (host != NULL)) {
      /* host->FreeTexInfo(ref); */
!     host->_FreeSurface(ref);
      ref = NULL;
    };
  };
  
! Uint32 PG_GLDrawableSurface::GetWidth() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetWidth();
  };
  
! Uint32 PG_GLDrawableSurface::GetHeight() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetHeight();
  };
  
! Uint32 PG_GLDrawableSurface::GetDepth() {
    PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetDepth();
! };
  
! SDL_PixelFormat* PG_GLDrawableSurface::GetFormat() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetFormat();
! };
  
! void*  PG_GLDrawableSurface::GetPixels() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetPixels();
! };
  
! Uint32 PG_GLDrawableSurface::GetPitch() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetPitch();
  };
  
! /* SDL references
!  * --------------
!  */
! Uint32 PG_GLDrawableSurface::GetSDLFlags() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::GetSDLFlags();
! };
  
! SDL_Surface* PG_GLDrawableSurface::SDL() {
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::SDL();
  };
  
***************
*** 223,227 ****
  
    SDL_Surface* vs;
-   SDL_Surface* dst;
    if (!srf_src || !ref) return;
  
--- 123,126 ----
***************
*** 256,349 ****
     *      surface->surface:       SDL_BlitSurface()
     */
-   if (!host->is_GL())
-     SDL_BlitSurface((SDL_Surface*)srf_src, a, ref, b);
- 
-   dst = ref;
    vs  = SDL_GetVideoSurface();
-   if (srf_src == host->fake_screen) srf_src = vs;
-   if (dst     == host->fake_screen) dst = vs;
    if (srf_src == vs) {
!     if (dst == vs) {
!       DBG(PG_LogERR("glSDL_BlitSurface(): screen->screen"
!                   " blits not yet implemented!"));
!       return;
!     } else {
!       /* return _glSDL_BlitFromGL((SDL_Surface*)srf_src, a, dst, b); */
!       DBG5(PG_LogWRN("ParaGUI GLcore: WARNING: screen->memory blits don't 
work very well!"));
!       Invalidate(rect_dst);
!       /* This doesn't work. SDL never reads the real framebuffer. */
!       SDL_BlitSurface((SDL_Surface*)srf_src, a, dst, b);
!     }
    } else {
!     if (dst == vs) {
!       host->_BlitGL((SDL_Surface*)srf_src, a, dst, b);
!     } else {
!       Invalidate(rect_dst);
!       SDL_BlitSurface((SDL_Surface*)srf_src, a, dst, b);
!     }
!   }
  };
  
! int PG_GLDrawableSurface::FillRect(const PG_Rect& dstrect, Uint32 color) {
    // PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
    // return 0; // DEBUG
-   SDL_Surface* vs = SDL_GetVideoSurface();
-   SDL_Surface* dst = ref;
-   int dx1, dy1, dx2, dy2;
-   Uint32 r, g, b;
-   // DBG5(DBGLINE());
-   
-   if (dst == host->fake_screen)       dst = vs;
-   if (vs != dst) Invalidate(dstrect);
-   
-   if ((vs != dst) || !host->is_GL()) {
-     if (dstrect.IsNull())
-       return SDL_FillRect(ref, NULL, color);
-     else
-       return SDL_FillRect(ref, (SDL_Rect*)&dstrect, color);
-   };
  
!   host->gl_do_texture(0);
!   host->gl_do_blend(0);
!   
!   if (dstrect.IsNull()) {
!     dx1 = dst->clip_rect.x;
!     dy1 = dst->clip_rect.y;
!     dx2 = dx1 + dst->clip_rect.w;
!     dy2 = dy1 + dst->clip_rect.h;
!   } else {
!     dx1 = dstrect.x;
!     dy1 = dstrect.y;
!     dx2 = dx1 + dstrect.w;
!     dy2 = dy1 + dstrect.h;
!   }
    
!   /* Some ugly reverse conversion for compatibility... */
!   r = color & dst->format->Rmask;
!   r = r >> dst->format->Rshift;
!   r = r << dst->format->Rloss;
!   
!   g = color & dst->format->Gmask;
!   g = g >> dst->format->Gshift;
!   g = g << dst->format->Gloss;
!   
!   b = color & dst->format->Bmask;
!   b = b >> dst->format->Bshift;
!   b = b << dst->format->Bloss;
!   
!   glBegin(GL_QUADS);
!   glColor3ub(r, g, b);
!   glVertex2i(dx1, dy1);
!   glVertex2i(dx2, dy1);
!   glVertex2i(dx2, dy2);
!   glVertex2i(dx1, dy2);
!   glEnd();
    
!   return 0;
  };
  
  void PG_GLDrawableSurface::DrawLine(Uint32 x0, Uint32 y0, Uint32 x1, Uint32 
y1, const SDL_Color& color, Uint8 width = 1) {
    DBG5(DBGLINE());
-   // return; // DEBUG
    PG_DrawableSurface::DrawLine(x0,y0,x1,y1,color,width);
  };
--- 155,269 ----
     *      surface->surface:       SDL_BlitSurface()
     */
    vs  = SDL_GetVideoSurface();
    if (srf_src == vs) {
!     /* return _glSDL_BlitFromGL((SDL_Surface*)srf_src, a, dst, b); */
!     DBG5(PG_LogWRN("ParaGUI GLcore: WARNING: screen->memory blits don't work 
very well!"));
!     Invalidate(rect_dst);
! #if 0
!     /* This doesn't work. SDL never reads the real framebuffer. */
!     SDL_BlitSurface((SDL_Surface*)srf_src, a, dst, b);
! #endif
! #if 0
!    /* how to blit -from- OpenGL */
!    GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y,
!                                      GLsizei width, GLsizei height,
!                                      GLenum format, GLenum type,
!                                      GLvoid *pixels );
!    GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level,
!                                       GLenum format, GLenum type,
!                                       GLvoid *pixels );
! #endif
    } else {
!     Invalidate(rect_dst);
!     SDL_BlitSurface((SDL_Surface*)srf_src, a, ref, b);
!   };
  };
  
! void PG_GLDrawableSurface::BlitSurface(const PG_DrawableSurface* srf_src,
!                                      const PG_Rect& rect_src,
!                                      const PG_Rect& rect_dst) {
!   /* fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__); */
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   PG_LogMSG("src creator %s", srf_src->GetCreator()->GetName().c_str());
!   PG_LogMSG("dst creator %s", creator->GetName().c_str());
!   if (srf_src->GetCreator() != creator) {
!     PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!     PG_LogERR("ERROR - source surface in BlitSurface is from alien driver!");
!     return;
!   };
!   /* FIXME theres' a better way to do this... I'm just bored */
!   PG_DrawableSurface* p = (PG_DrawableSurface*)srf_src;
!   const SDL_Surface* src = p->SDL();
!   BlitSurface(/*(SDL_Surface*)*/src, rect_src, rect_dst);
! };
! 
! int PG_GLDrawableSurface::Lock() {
!   /* if (!SDL_MUSTLOCK(ref)) return 0; */
!   if (!ref) return 0;
!   Invalidate(PG_Rect());
!   return SDL_LockSurface(ref);
! };
! 
! void PG_GLDrawableSurface::Unlock() {
!   if (!ref) return;
!   SDL_UnlockSurface(ref);
!   host->DownloadSurface(ref);
! };
! 
! void PG_GLDrawableSurface::UpdateRects(int numrects, PG_Rect *rects) {
!   /* note to self - shouldn't this be called before unlock?
!    * or maybe DownloadSurface should track this or something...?
!    * (T notes)
!    * glSDL just does this...
!    */
!   /* crashes after this... */
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return PG_DrawableSurface::UpdateRects(numrects, rects);
! }
! 
! int PG_GLDrawableSurface::SetColorKey(Uint32 flag, Uint32 key) {
    // PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
    // return 0; // DEBUG
  
!   int res = SDL_SetColorKey(ref, flag, key);
!   if (res < 0) return res;
!   /*
!    * If an application does this *after* SDL_DisplayFormat,
!    * we're basically screwed, unless we want to do an
!    * in-place surface conversion hack here.
!    *
!    * What we do is just kill the glSDL texinfo... No big
!    * deal in most cases, as glSDL only converts once anyway,
!    * *unless* you keep modifying the surface.
!    */
!   host->FreeTexInfo(ref);
!   return res;
! };
! 
! bool PG_GLDrawableSurface::SetClipRect(const PG_Rect& rect) {
!   // PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   // return true; // DEBUG
!   SDL_bool res;
!   SDL_Rect* trect;
!   if (!ref) return SDL_FALSE;
    
!   res = SDL_SetClipRect(ref, (SDL_Rect*)&rect);
!   if (!res) return SDL_FALSE;
!   trect = &ref->clip_rect;
    
!   return res;
! };
! 
! int PG_GLDrawableSurface::FillRect(const PG_Rect& dstrect, Uint32 color) {
!   DBG5(DBGLINE());
!   Invalidate(dstrect);
!   if (dstrect.IsNull())
!     return SDL_FillRect(ref, NULL, color);
!   else
!     return SDL_FillRect(ref, (SDL_Rect*)&dstrect, color);
  };
  
  void PG_GLDrawableSurface::DrawLine(Uint32 x0, Uint32 y0, Uint32 x1, Uint32 
y1, const SDL_Color& color, Uint8 width = 1) {
    DBG5(DBGLINE());
    PG_DrawableSurface::DrawLine(x0,y0,x1,y1,color,width);
  };
***************
*** 351,355 ****
  void PG_GLDrawableSurface::SetPixel(int x, int y, const SDL_Color& color) {
    DBG5(DBGLINE());
-   // return; // DEBUG
    PG_DrawableSurface::SetPixel(x,y,color);
  };
--- 271,274 ----
***************
*** 357,364 ****
  void PG_GLDrawableSurface::DrawTile(const PG_Rect& refr, const PG_Rect& 
drawrect, PG_DrawableSurface* tilemap) {
    DBG5(DBGLINE());
!   PG_LogMSG("src creator %s", tilemap->getCreator()->getName().c_str());
!   PG_LogMSG("dst creator %s", creator->getName().c_str());
!   return; // DEBUG
!   if (tilemap->getCreator() != creator) {
      DBG5(DBGLINE());
      PG_LogERR("ERROR - source tile in DrawTile is from alien driver!");
--- 276,282 ----
  void PG_GLDrawableSurface::DrawTile(const PG_Rect& refr, const PG_Rect& 
drawrect, PG_DrawableSurface* tilemap) {
    DBG5(DBGLINE());
!   PG_LogMSG("src creator %s", tilemap->GetCreator()->GetName().c_str());
!   PG_LogMSG("dst creator %s", creator->GetName().c_str());
!   if (tilemap->GetCreator() != creator) {
      DBG5(DBGLINE());
      PG_LogERR("ERROR - source tile in DrawTile is from alien driver!");
***************
*** 386,427 ****
    PG_Rect r;
    glSDL_TexInfo *txi;
-   if (!is_GL()) return;
    txi = host->GetTexInfo(surface);
    
    txi->lw = w;
    txi->lh = h;
- 
-   if ((SDL_GetVideoSurface() != surface) && (host->fake_screen != surface)) 
return;
- 
-   r.x = r.y = 0;
-   r.w = w;
-   r.h = h;
-   SetClipRect(r);
- 
-   glMatrixMode(GL_MODELVIEW);
-   glLoadIdentity();
-   glTranslatef(0.0f, 0.0f, 0.0f);
-   
-   glDisable(GL_DEPTH_TEST);
-   glDisable(GL_CULL_FACE);
-   
-   host->gl_reset();
  }
  
  glSDL_TexInfo *PG_GLDrawableSurface::GetTexInfo() {
    glSDL_TexInfo *rv;
-   // DBG2(PG_LogMSG("%s:%i: handle %p glactive %c", __FUNCTION__, __LINE__, 
ref, (glactive?'T':'F')));
    rv = host->GetTexInfo(ref);
-   glactive = (rv != NULL);
-   // DBG2(PG_LogMSG("%s:%i: handle %p glactive %c", __FUNCTION__, __LINE__, 
ref, (glactive?'T':'F')));
    return rv;
  };
  
- SDL_Surface* PG_GLDrawableSurface::getScreen() {
-   /* PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__); */
-   /* PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__); */
-   return PG_DrawableSurface::getScreen();
- };
- 
  void PG_GLDrawableSurface::GetClipRect(PG_Rect& rect) {
    /* PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__); */
--- 304,319 ----
***************
*** 431,438 ****
  void PG_GLDrawableSurface::BlitScale(PG_DrawableSurface* src, bool smooth) {
    // PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__);
!   // PG_LogMSG("src creator %s", src->getCreator()->getName().c_str());
!   // PG_LogMSG("dst creator %s", creator->getName().c_str());
    // return; // DEBUG
!   if (src->getCreator() != creator) {
      DBG5(DBGLINE());
      PG_LogERR("ERROR - source tile in DrawTile is from alien driver!");
--- 323,330 ----
  void PG_GLDrawableSurface::BlitScale(PG_DrawableSurface* src, bool smooth) {
    // PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__);
!   // PG_LogMSG("src creator %s", src->GetCreator()->GetName().c_str());
!   // PG_LogMSG("dst creator %s", creator->GetName().c_str());
    // return; // DEBUG
!   if (src->GetCreator() != creator) {
      DBG5(DBGLINE());
      PG_LogERR("ERROR - source tile in DrawTile is from alien driver!");
***************
*** 494,502 ****
                                        int bkmode, Uint8 blend) {
    // PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__);
!   // PG_LogMSG("dst creator %s", creator->getName().c_str());
    if (background != NULL) {
!     // PG_LogMSG("background creator %s", 
background->getCreator()->getName().c_str());
      // return; // DEBUG
!     if (background->getCreator() != creator) {
        DBG5(DBGLINE());
        PG_LogERR("ERROR - source tile in DrawTile is from alien driver!");
--- 386,394 ----
                                        int bkmode, Uint8 blend) {
    // PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__);
!   // PG_LogMSG("dst creator %s", creator->GetName().c_str());
    if (background != NULL) {
!     // PG_LogMSG("background creator %s", 
background->GetCreator()->GetName().c_str());
      // return; // DEBUG
!     if (background->GetCreator() != creator) {
        DBG5(DBGLINE());
        PG_LogERR("ERROR - source tile in DrawTile is from alien driver!");
***************
*** 507,510 ****
--- 399,418 ----
  };
  
+ bool PG_GLDrawableSurface::BlitFTBitmap(FT_Bitmap *Bitmap,
+                                       int PosX, int PosY,
+                                       PG_Font* Param,
+                                       PG_Rect *ClipRect) {
+   bool rv;
+   PG_LogDBG("opengl DrawableSurface: %s", __FUNCTION__);
+   rv = PG_DrawableSurface::BlitFTBitmap(Bitmap,PosX,PosY,Param,ClipRect);
+   if (ClipRect != NULL) {
+     Invalidate(*ClipRect);
+   } else {
+     /* Invalidate(PG_Rect()); */ /* Should I? */
+   };
+   return rv;
+ };
+ 
+ #if 0 /* save this for OpenGL root context */
  //PG_Draw:: PG_FontEngine:: = NULL;
    /* from destructor:
***************
*** 523,528 ****
    int         BitmapRealWidth;
  
!   // PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   // return true; // DEBUG
  
    if (Param->GetAlpha() == 0)
--- 431,438 ----
    int         BitmapRealWidth;
  
!   /* screen doesn't have any raw pixels..  FIXME!!!!
!    */
!   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
!   return true; // DEBUG
  
    if (Param->GetAlpha() == 0)
***************
*** 547,552 ****
    //Is host->my_charSurface big enough ??
    if (host->my_charSurface != NULL) {
!     if ((host->my_charSurface->getScreen()->w < BitmapRealWidth) ||
!       (host->my_charSurface->getScreen()->h < Bitmap->rows)) {
        delete host->my_charSurface; // SDL_FreeSurface(host->my_charSurface);
        host->my_charSurface = NULL;
--- 457,462 ----
    //Is host->my_charSurface big enough ??
    if (host->my_charSurface != NULL) {
!     if ((host->my_charSurface->GetWidth() < BitmapRealWidth) ||
!       (host->my_charSurface->GetHeight() < Bitmap->rows)) {
        delete host->my_charSurface; // SDL_FreeSurface(host->my_charSurface);
        host->my_charSurface = NULL;
***************
*** 595,599 ****
    }
    
!   raw_pixels = (Uint32 *) host->my_charSurface->getScreen()->pixels;
    Uint32 pitch_diff = 0;
    
--- 505,509 ----
    }
    
!   raw_pixels = (Uint32 *) host->my_charSurface->GetPixels();
    Uint32 pitch_diff = 0;
    
***************
*** 615,624 ****
          //    a = (a * Param->GetAlpha()) / 255;
          
!         raw_pixels[int(ioffset) + x + 
(host->my_charSurface->getScreen()->pitch/4)*(y)] = 
SDL_MapRGBA(host->my_charSurface->getScreen()->format, Param->GetColor().r, 
Param->GetColor().g, Param->GetColor().b, a);
        }
        SrcPix -= x;
        }
      } else
!       pitch_diff = (host->my_charSurface->getScreen()->pitch/4);
      
      for (y = 0; y < Bitmap->rows; y++, SrcPix += Bitmap->pitch) {
--- 525,534 ----
          //    a = (a * Param->GetAlpha()) / 255;
          
!         raw_pixels[int(ioffset) + x + 
(host->my_charSurface->GetPitch()/4)*(y)] = 
host->my_charSurface->MapRGBA(Param->GetColor().r, Param->GetColor().g, 
Param->GetColor().b, a);
        }
        SrcPix -= x;
        }
      } else
!       pitch_diff = (host->my_charSurface->GetPitch()/4);
      
      for (y = 0; y < Bitmap->rows; y++, SrcPix += Bitmap->pitch) {
***************
*** 633,637 ****
          a = (a * Param->GetAlpha()) / 255;
        
!       *raw_pixels = SDL_MapRGBA(host->my_charSurface->getScreen()->format, 
Param->GetColor().r, Param->GetColor().g, Param->GetColor().b, a);
        raw_pixels++;
        }
--- 543,547 ----
          a = (a * Param->GetAlpha()) / 255;
        
!       *raw_pixels = host->my_charSurface->MapRGBA(Param->GetColor().r, 
Param->GetColor().g, Param->GetColor().b, a);
        raw_pixels++;
        }
***************
*** 661,664 ****
--- 571,586 ----
    
    return true;
+ };
+ #endif /* save for root context */
+ 
+ /* for glTex<...> replace -- glBindTexture + make sure textures active...
+    so that these draw surfaces can be used in 3D rendering */
+ void PG_GLDrawableSurface::TextureRef() {
+   PG_LogDBG("ParaGUI[%s]: %s:%i", __FILE__, __FUNCTION__, __LINE__);
+   glSDL_TexInfo *txi;
+   txi = GetTexInfo();
+   /* Enable texturing */
+   host->gl_do_texture(1);
+   host->gl_texture(txi->texture[0]);
  };
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]