Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

brenderer.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2002 Xavier Trochu
00003 
00004 This software is provided 'as-is', without any express or implied warranty. In no event
00005 will the authors be held liable for any damages arising from the use of this software.
00006 
00007 Permission is granted to anyone to use this software for any purpose, including commercial
00008 applications, and to alter it and redistribute it freely, subject to the following
00009 restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you
00012    wrote the original software. If you use this software in a product, an acknowledgment
00013    in the product documentation would be appreciated but is not required.
00014 
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 
00016    as being the original software.
00017 
00018 3. This notice may not be removed or altered from any source distribution.
00019 */
00020 #include <stdexcept>
00021 #include "brenderer.h"
00022 
00023 using namespace std;
00024 
00025 void base_renderer::clean() throw() {
00026     if(_data) {
00027         delete[] _data;
00028         _data = 0;
00029         _width = _height = 0;
00030     }
00031 }
00032 
00033 base_renderer::base_renderer() throw() : 
00034         _data(0), 
00035         _frame(0), 
00036         _nbframes(0), 
00037         _width(0), 
00038         _height(0) {
00039 }
00040 
00041 base_renderer::~base_renderer() throw() { 
00042     clean(); 
00043 }
00044 
00045 bool base_renderer::init_frame(const point & p) throw(exception) {
00046     clean();
00047     _width = p.get_x();
00048     _height = p.get_y();
00049     assert(_width && _height);
00050     _data = new char[_width * _height];
00051     if(!_data) throw runtime_error("base_renderer unable to allocate frame buffer");
00052     return true;
00053 }
00054 
00055 char * base_renderer::lock_frame(int frame) throw(exception) {
00056     _frame = frame; 
00057     if(!_data) throw runtime_error("no allocated image buffer in lock_frame");
00058     return _data;
00059 }
00060 
00061 bool base_renderer::unlock_frame() throw() {
00062     return true;
00063 }
00064 
00065 bool base_renderer::flip_frame() throw() { 
00066     save(); 
00067     return true;
00068 }
00069 
00070 bool base_renderer::set_palette(const palette & pal) throw() { 
00071     _pal = pal; 
00072     return true;
00073 }

Generated on Fri Aug 9 22:54:29 2002 for san_player by doxygen1.2.16