pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/gui buffer_graphic_context.cxx, NONE,


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/gui buffer_graphic_context.cxx, NONE, 1.1 buffer_graphic_context.hxx, NONE, 1.1
Date: 16 Aug 2003 16:20:32 -0000

Update of /var/lib/cvs/Games/Pingus/src/gui
In directory dark:/tmp/cvs-serv31731/gui

Added Files:
        buffer_graphic_context.cxx buffer_graphic_context.hxx 
Log Message:
- some stuff for rendering level previews

--- NEW FILE: buffer_graphic_context.cxx ---
//  $Id: buffer_graphic_context.cxx,v 1.1 2003/08/16 16:20:30 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#include <iostream>
#include "../pingus_error.hxx"
#include "../blitter.hxx"
#include "../screenshot.hxx"
#include "buffer_graphic_context.hxx"

BufferGraphicContext::BufferGraphicContext(int width, int height)
{
  canvas = new CL_Canvas(width, height);
}

CL_Rect
BufferGraphicContext::get_clip_rect()
{
  return CL_Rect(0,0, get_width(), get_height());
}

void
BufferGraphicContext::clear (float r, float g, float b)
{
  std::cout << "BufferGraphicContext: clear" << std::endl;
}

void
BufferGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos)
{
  //std::cout << "BufferGraphicContext: " << x_pos << ", " << y_pos  << 
std::endl;
  try {
    Blitter::put_surface(canvas, sur.get_provider(), x_pos, y_pos);
  } catch (PingusError& err) {
    std::cout << "BufferGraphicContext: " << err.get_message() << std::endl;
  }
}

void
BufferGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos, int frame)
{
  //std::cout << "BufferGraphicContext: " << x_pos << ", " << y_pos  << " 
frame: " << frame << std::endl;
  try {
    Blitter::put_surface(canvas, sur.get_provider(), x_pos, y_pos);
  } catch (PingusError& err) {
    std::cout << "BufferGraphicContext: " << err.get_message() << std::endl;
  }
}

void
BufferGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos,
                            float size_x, float size_y, int frame)
{
  std::cout << "BufferGraphicContext: unsupported" << std::endl;
}

void
BufferGraphicContext::write(const std::string& filename)
{
  std::cout << "BufferGraphicContext::write: " << filename << std::endl;
  canvas->lock();
  Screenshot::save_target_to_file(canvas, filename);
  canvas->unlock();
}

/* EOF */

--- NEW FILE: buffer_graphic_context.hxx ---
//  $Id: buffer_graphic_context.hxx,v 1.1 2003/08/16 16:20:30 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_PINGUS_BUFFER_GRAPHIC_CONTEXT_HXX
#define HEADER_PINGUS_BUFFER_GRAPHIC_CONTEXT_HXX

#include <string>
#include "../vector.hxx"
#include <ClanLib/Core/Math/rect.h>
#include <ClanLib/Display/SurfaceProviders/canvas.h>
#include "graphic_context.hxx"

class Sprite;
class CL_Surface;
class CL_Font;
class CL_Canvas;

typedef CL_Font* FontHandle;

/** Abstract interface */
class BufferGraphicContext : public GraphicContext
{
private:
  CL_Canvas* canvas; 

public:
  BufferGraphicContext(int width, int height);
  
  Vector get_offset () { return Vector(); }
  void   set_offset (float, float) {}
  
  CL_Rect get_clip_rect ();

  float get_x_offset () { return 0; }
  float get_y_offset () { return 0; }

  int   get_width ()  { return canvas->get_width(); }
  int   get_height () { return canvas->get_height(); }

  float get_zoom () {}
  void  set_zoom (float new_zoom) {}

  void zoom_to (const CL_Rect & rect) {}
  void move (const Vector & delta) {}

  Vector screen_to_world (Vector pos) { return pos; }
  Vector world_to_screen (Vector pos) { return pos; }

  void clear (float r, float g, float b);

  void draw (CL_Surface& sur, int x_pos, int y_pos);
  void draw (CL_Surface& sur, int x_pos, int y_pos, int frame);
  void draw (CL_Surface& sur, int x_pos, int y_pos,
             float size_x, float size_y, int frame);

  void draw_line (const Vector& pos1, const Vector& pos2,
                  float r, float g, float b, float a = 1.0f) {}
  void draw_line (int x1, int y1, int x2, int y2,
                  float r, float g, float b, float a = 1.0f) {}
  void draw_fillrect (int x1, int y1, int x2, int y2,
                      float r, float g, float b, float a = 1.0f) {}
  void draw_rect (int x1, int y1, int x2, int y2,
                          float r, float g, float b, float a = 1.0f) {}
  void draw_pixel (int x_pos, int y_pos,
                   float r, float g, float b, float a = 1.0f) {}
  void draw_circle (int x_pos, int y_pos, int radius,
                    float r, float g, float b, float a = 1.0f) {}

  void print_left (FontHandle font, int x_pos, int y_pos, const std::string& 
str) {}
  void print_center (FontHandle font, int x_pos, int y_pos, const std::string& 
str) {}
  void print_right (FontHandle font, int x_pos, int y_pos, const std::string& 
str) {}

  /** Write the current content of the buffer down to a pnm file */
  void write(const std::string& filename);
};

#endif

/* EOF */





reply via email to

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