| 1 | /*************************************************************************** |
| 2 | surface.cpp - description |
| 3 | ------------------- |
| 4 | begin : Sat Oct 14 2000 |
| 5 | copyright : (C) 2000 by Waldemar Baraldi |
| 6 | email : [email protected] |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | /*************************************************************************** |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | #include "surface.h" |
| 19 | #include <stdio.h> |
| 20 | |
| 21 | Surface::Surface(){ |
| 22 | surface=NULL; |
| 23 | } |
| 24 | |
| 25 | Surface::Surface(int width, int height){ |
| 26 | SDL_Rect rect; |
| 27 | SDL_Surface * aux_surface; |
| 28 | |
| 29 | rect.x=0; |
| 30 | rect.y=0; |
| 31 | rect.w=width; |
| 32 | rect.h=height; |
| 33 | |
| 34 | aux_surface=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_SRCALPHA, width, height, |
| 35 | 32, 0xff, 0x00ff,0x0000ff,0x000000ff); |
| 36 | surface=SDL_DisplayFormatAlpha(aux_surface); |
| 37 | SDL_FreeSurface(aux_surface); |
| 38 | } |
| 39 | |
| 40 | Surface::~Surface(){ |
| 41 | if (surface) SDL_FreeSurface(surface); |
| 42 | } |
| 43 | |
| 44 | int Surface::width(){ |
| 45 | if (surface) return surface->w; |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | int Surface::height(){ |
| 50 | if (surface) return surface->h; |
| 51 | return 0; |
| 52 | } |
| 53 |