[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Adonthell-commits] CVS: adonthell/src/gfx/sdl screen_sdl.cc, 1.1.1.1, 1
From: |
Alexandre Courbot <address@hidden> |
Subject: |
[Adonthell-commits] CVS: adonthell/src/gfx/sdl screen_sdl.cc, 1.1.1.1, 1.2 screen_sdl.h, 1.1.1.1, 1.2 surface_sdl.cc, 1.2, 1.3 surface_sdl.h, 1.2, 1.3 |
Date: |
Sun, 27 Jul 2003 10:08:23 -0400 |
Update of /cvsroot/adonthell/adonthell/src/gfx/sdl
In directory subversions:/tmp/cvs-serv28382/src/gfx/sdl
Modified Files:
screen_sdl.cc screen_sdl.h surface_sdl.cc surface_sdl.h
Log Message:
Added a surface abstraction for the screen surface
Added gfxtest (which might unveil a bug somewhere)
Index: screen_sdl.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/sdl/screen_sdl.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** screen_sdl.cc 18 Jul 2003 15:16:09 -0000 1.1.1.1
--- screen_sdl.cc 27 Jul 2003 14:08:20 -0000 1.2
***************
*** 18,25 ****
#define gfx_screen_trans_color sdl_LTX_gfx_screen_trans_color
#define gfx_screen_clear sdl_LTX_gfx_screen_clear
! #include "screen_sdl.h"
! SDL_Surface * display = NULL;
u_int32 trans_color = 0;
--- 18,26 ----
#define gfx_screen_trans_color sdl_LTX_gfx_screen_trans_color
#define gfx_screen_clear sdl_LTX_gfx_screen_clear
+ #define gfx_screen_get_surface sdl_LTX_gfx_screen_get_surface
! #include "gfx/sdl/screen_sdl.h"
! gfx::screen_surface_sdl display;
u_int32 trans_color = 0;
***************
*** 30,46 ****
u_int32 gfx_screen_trans_color();
void gfx_screen_clear();
}
-
bool gfx_screen_set_video_mode(u_int16 nl, u_int16 nh, u_int8 depth)
{
u_int32 SDL_flags = SDL_HWSURFACE | SDL_DOUBLEBUF;
! display = SDL_SetVideoMode (nl, nh, depth, SDL_flags);
// Setting up the window title
SDL_WM_SetCaption ("Adonthell", NULL);
! trans_color = SDL_MapRGB(display->format, gfx::screen::TRANS_RED,
gfx::screen::TRANS_GREEN,
gfx::screen::TRANS_BLUE);
--- 31,47 ----
u_int32 gfx_screen_trans_color();
void gfx_screen_clear();
+ gfx::surface * gfx_screen_get_surface();
}
bool gfx_screen_set_video_mode(u_int16 nl, u_int16 nh, u_int8 depth)
{
u_int32 SDL_flags = SDL_HWSURFACE | SDL_DOUBLEBUF;
! if (!display.set_video_mode(nl, nh, depth, SDL_flags)) return false;
// Setting up the window title
SDL_WM_SetCaption ("Adonthell", NULL);
! trans_color = SDL_MapRGB(display.get_vis()->format,
gfx::screen::TRANS_RED, gfx::screen::TRANS_GREEN,
gfx::screen::TRANS_BLUE);
***************
*** 50,54 ****
void gfx_screen_update()
{
! SDL_Flip (display);
}
--- 51,55 ----
void gfx_screen_update()
{
! SDL_Flip (display.get_vis());
}
***************
*** 60,63 ****
void gfx_screen_clear()
{
! SDL_FillRect(display, NULL, 0);
}
--- 61,69 ----
void gfx_screen_clear()
{
! SDL_FillRect(display.get_vis(), NULL, 0);
! }
!
! gfx::surface * gfx_screen_get_surface()
! {
! return &display;
}
Index: screen_sdl.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/sdl/screen_sdl.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** screen_sdl.h 18 Jul 2003 15:16:09 -0000 1.1.1.1
--- screen_sdl.h 27 Jul 2003 14:08:20 -0000 1.2
***************
*** 14,21 ****
#include "SDL.h"
#include "gfx/screen.h"
!
! extern SDL_Surface * display;
extern u_int32 trans_color;
--- 14,47 ----
+ #ifndef GFX_SDL_SCREEN_H_
+ #define GFX_SDL_SCREEN_H_
+
#include "SDL.h"
#include "gfx/screen.h"
! #include "gfx/sdl/surface_sdl.h"
extern u_int32 trans_color;
+
+ namespace gfx
+ {
+ class screen_surface_sdl : public surface_sdl
+ {
+ public:
+ ~screen_surface_sdl() { }
+ SDL_Surface * get_vis() { return vis; }
+ void resize (u_int16 l, u_int16 h) { std::cerr << "Invalid operation:
Can't resize the screen surface!\n"; }
+ void clear () { std::cerr << "Invalid operation: Can't clear the
screen surface!\n"; }
+ bool set_video_mode(u_int16 nl, u_int16 nh, u_int8 depth, u_int32
flags)
+ {
+ vis = SDL_SetVideoMode (nl, nh, depth, flags);
+ if (!vis) return false;
+ set_length(nl);
+ set_height(nh);
+ return true;
+ }
+ };
+ }
+
+ extern gfx::screen_surface_sdl display;
+
+ #endif // GFX_SDL_SCREEN_H_
Index: surface_sdl.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/sdl/surface_sdl.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** surface_sdl.cc 24 Jul 2003 12:57:58 -0000 1.2
--- surface_sdl.cc 27 Jul 2003 14:08:20 -0000 1.3
***************
*** 58,62 ****
SDL_Surface * display_target;
! if (target == NULL) display_target = display;
else display_target = ((surface_sdl *)target)->vis;
--- 58,62 ----
SDL_Surface * display_target;
! if (target == NULL) display_target = display.vis;
else display_target = ((surface_sdl *)target)->vis;
***************
*** 314,322 ****
vis = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY |
SDL_SRCALPHA | SDL_ASYNCBLIT,
length (), height (),
! display->format->BitsPerPixel,
! display->format->Rmask,
! display->format->Gmask,
! display->format->Bmask,
! display->format->Amask);
}
--- 314,322 ----
vis = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY |
SDL_SRCALPHA | SDL_ASYNCBLIT,
length (), height (),
! display.vis->format->BitsPerPixel,
! display.vis->format->Rmask,
! display.vis->format->Gmask,
! display.vis->format->Bmask,
! display.vis->format->Amask);
}
Index: surface_sdl.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/gfx/sdl/surface_sdl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** surface_sdl.h 24 Jul 2003 12:57:58 -0000 1.2
--- surface_sdl.h 27 Jul 2003 14:08:20 -0000 1.3
***************
*** 27,59 ****
surface_sdl ();
! ~surface_sdl ();
! void set_mask (bool m);
! void set_alpha (u_int8 a);
! void draw (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy, u_int16 sl,
! u_int16 sh, const drawing_area * da_opt = NULL,
! surface * target = NULL) const;
! void fillrect (s_int16 x, s_int16 y, u_int16 l, u_int16 h,
! u_int32 col, drawing_area * da_opt = NULL);
! void draw_line (const s_int16 sx, const s_int16 sy, const s_int16 ex,
const s_int16 ey,
! const u_int32 col, const drawing_area * da_opt =
NULL);
! u_int32 map_color(u_int8 r, u_int8 g, u_int8 b) const;
! void unmap_color(u_int32 col, u_int8 & r, u_int8 & g, u_int8 & b)
const;
! void lock () const;
! void unlock () const;
! void put_pix (u_int16 x, u_int16 y, u_int32 col);
! u_int32 get_pix (u_int16 x, u_int16 y) const;
! surface& operator = (const surface& src);
! void resize (u_int16 l, u_int16 h);
!
! void clear ();
protected:
void set_data (void * data, u_int16 l, u_int16 h,
--- 27,59 ----
surface_sdl ();
! virtual ~surface_sdl ();
! virtual void set_mask (bool m);
! virtual void set_alpha (u_int8 a);
! virtual void draw (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy,
u_int16 sl,
! u_int16 sh, const drawing_area * da_opt = NULL,
! surface * target = NULL) const;
! virtual void fillrect (s_int16 x, s_int16 y, u_int16 l, u_int16 h,
! u_int32 col, drawing_area * da_opt = NULL);
! virtual void draw_line (const s_int16 sx, const s_int16 sy, const
s_int16 ex, const s_int16 ey,
! const u_int32 col, const drawing_area *
da_opt = NULL);
! virtual u_int32 map_color(u_int8 r, u_int8 g, u_int8 b) const;
! virtual void unmap_color(u_int32 col, u_int8 & r, u_int8 & g, u_int8
& b) const;
! virtual void lock () const;
! virtual void unlock () const;
! virtual void put_pix (u_int16 x, u_int16 y, u_int32 col);
! virtual u_int32 get_pix (u_int16 x, u_int16 y) const;
! virtual surface& operator = (const surface& src);
! virtual void resize (u_int16 l, u_int16 h);
+ virtual void clear ();
+
protected:
void set_data (void * data, u_int16 l, u_int16 h,
***************
*** 61,75 ****
u_int32 red_mask = RAW_RED_MASK, u_int32 green_mask =
RAW_GREEN_MASK,
u_int32 blue_mask = RAW_BLUE_MASK);
!
void * get_data (u_int8 bytes_per_pixel,
u_int32 red_mask, u_int32 green_mask,
u_int32 blue_mask) const;
private:
- SDL_Surface *vis;
/// Has the mask setting changed?
mutable bool mask_changed;
!
/// SDL_Rects used in every blitting function.
static SDL_Rect srcrect, dstrect;
--- 61,76 ----
u_int32 red_mask = RAW_RED_MASK, u_int32 green_mask =
RAW_GREEN_MASK,
u_int32 blue_mask = RAW_BLUE_MASK);
!
void * get_data (u_int8 bytes_per_pixel,
u_int32 red_mask, u_int32 green_mask,
u_int32 blue_mask) const;
+
+ SDL_Surface *vis;
private:
/// Has the mask setting changed?
mutable bool mask_changed;
!
/// SDL_Rects used in every blitting function.
static SDL_Rect srcrect, dstrect;
***************
*** 84,88 ****
void setup_rects (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy,
u_int16 sl, u_int16 sh, const drawing_area *
draw_to) const;
-
};
}
--- 85,88 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Adonthell-commits] CVS: adonthell/src/gfx/sdl screen_sdl.cc, 1.1.1.1, 1.2 screen_sdl.h, 1.1.1.1, 1.2 surface_sdl.cc, 1.2, 1.3 surface_sdl.h, 1.2, 1.3,
Alexandre Courbot <address@hidden> <=
- Prev by Date:
[Adonthell-commits] CVS: adonthell/test gfxtest.py, NONE, 1.1 Makefile.am, 1.1.1.1, 1.2 inputtest.cc, 1.1.1.1, 1.2 inputtest.py, 1.1.1.1, 1.2
- Next by Date:
[Adonthell-commits] CVS: adonthell/src/gfx gfx.cc, 1.2, 1.3 screen.cc, 1.2, 1.3 screen.h, 1.1.1.1, 1.2
- Previous by thread:
[Adonthell-commits] CVS: adonthell/test gfxtest.py, NONE, 1.1 Makefile.am, 1.1.1.1, 1.2 inputtest.cc, 1.1.1.1, 1.2 inputtest.py, 1.1.1.1, 1.2
- Next by thread:
[Adonthell-commits] CVS: adonthell/src/gfx gfx.cc, 1.2, 1.3 screen.cc, 1.2, 1.3 screen.h, 1.1.1.1, 1.2
- Index(es):