openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

Renderer.h (1502B)


      1 #ifndef _RENDERER_H
      2 #define _RENDERER_H
      3 
      4 #include "Rect.h"
      5 
      6 class Renderer {
      7 public:
      8 
      9 	inline Renderer(char *baseAddress, int width, int height, int bytesPerRow);
     10 	virtual void DrawLine(int x1, int y1, int x2, int y2, char color) = 0;
     11 	virtual void FillRect(int x1, int y1, int x2, int y2, char color) = 0;
     12 	virtual void Blit(int x, int y, char image[], int image_width,
     13 		int image_height, int img_bytes_per_row) = 0;
     14 	virtual void StretchBlit(const Rect &imageRect, const Rect &displayRect, char image[],
     15 		int imageBytesPerRow) = 0;
     16 	virtual void CopyRect(const Rect &source, const Rect &dest) = 0;
     17 
     18 	inline Rect Bounds() const;
     19 
     20 	inline char *BufferBaseAddress() const;
     21 	inline int BufferWidth() const;
     22 	inline int BufferHeight() const;
     23 	inline int BufferBytesPerRow() const;
     24 
     25 private:
     26 	char *fBufferBaseAddress;
     27 	int fBufferWidth;
     28 	int fBufferHeight;
     29 	int fBufferBytesPerRow;	
     30 };
     31 
     32 inline Renderer::Renderer(char *baseAddress, int width, int height, int bytesPerRow)
     33 	:	fBufferBaseAddress(baseAddress),
     34 		fBufferWidth(width),
     35 		fBufferHeight(height),
     36 		fBufferBytesPerRow(bytesPerRow)
     37 {
     38 }
     39 
     40 inline char* Renderer::BufferBaseAddress() const
     41 {
     42 	return fBufferBaseAddress;
     43 }
     44 
     45 inline int Renderer::BufferWidth() const
     46 {
     47 	return fBufferWidth;
     48 }
     49 
     50 inline int Renderer::BufferHeight() const
     51 {
     52 	return fBufferHeight;
     53 }
     54 
     55 inline int Renderer::BufferBytesPerRow() const
     56 {
     57 	return fBufferBytesPerRow;
     58 }
     59 
     60 inline Rect Renderer::Bounds() const
     61 {
     62 	return Rect(0, 0, fBufferWidth - 1, fBufferHeight - 1);
     63 }
     64 
     65 
     66 
     67 #endif