1 #pragma once
2
3 #include <memory.h>
4
5 enum DISPLAY_TYPE {
6 DIRECT_3D = 0,
7 OPENGL = 1
8 };
9
10 class IDisplay {
11 public:
IDisplay()12 IDisplay() {};
~IDisplay()13 virtual ~IDisplay() {};
14
15 struct VIDEO_MODE
16 {
17 unsigned int adapter;
18 unsigned int width;
19 unsigned int height;
20 unsigned int bitDepth;
21 unsigned int frequency;
22 };
23
24 virtual bool initialize() = 0;
25 virtual void cleanup() = 0;
26 virtual void render() = 0;
27 virtual void clear() = 0;
changeRenderSize(int w,int h)28 virtual bool changeRenderSize(int w, int h) { return true; };
resize(int w,int h)29 virtual void resize(int w, int h) {};
setOption(const char * option,int value)30 virtual void setOption(const char *option, int value) {};
31 virtual DISPLAY_TYPE getType() = 0;
32 virtual bool selectFullScreenMode( VIDEO_MODE &mode ) = 0;
33 };
34
35
cpyImg32(unsigned char * dst,unsigned int dstPitch,unsigned char * src,unsigned int srcPitch,unsigned short width,unsigned short height)36 inline void cpyImg32( unsigned char *dst, unsigned int dstPitch, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height )
37 {
38 // fast, iterative C version
39 // copies an width*height array of visible pixels from src to dst
40 // srcPitch and dstPitch are the number of garbage bytes after a scanline
41 register unsigned short lineSize = width<<2;
42
43 while( height-- ) {
44 memcpy( dst, src, lineSize );
45 src += srcPitch;
46 dst += dstPitch;
47 }
48 }
49
50
cpyImg32bmp(unsigned char * dst,unsigned char * src,unsigned int srcPitch,unsigned short width,unsigned short height)51 inline void cpyImg32bmp( unsigned char *dst, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height )
52 {
53 // dst will be an upside down bitmap with 24bit colors
54 // pix must contain 32bit colors (XRGB)
55 unsigned short srcLineSize = width<<2;
56 dst += height * width * 3; // move to the last scanline
57 register unsigned char r, g, b;
58
59 while( height-- ) {
60 unsigned short x = width;
61 src += srcLineSize;
62 while( x-- ) {
63 --src; // ignore one of 4 bytes
64 b = *--src;
65 g = *--src;
66 r = *--src;
67 *--dst = b;
68 *--dst = g;
69 *--dst = r;
70 }
71 src += srcPitch;
72 }
73 }
74
75
cpyImg16(unsigned char * dst,unsigned int dstPitch,unsigned char * src,unsigned int srcPitch,unsigned short width,unsigned short height)76 inline void cpyImg16( unsigned char *dst, unsigned int dstPitch, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height )
77 {
78 register unsigned short lineSize = width<<1;
79
80 while( height-- ) {
81 memcpy( dst, src, lineSize );
82 src += srcPitch;
83 dst += dstPitch;
84 }
85 }
86
87
cpyImg16bmp(unsigned char * dst,unsigned char * src,unsigned int srcPitch,unsigned short width,unsigned short height)88 inline void cpyImg16bmp( unsigned char *dst, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height )
89 {
90 // dst will be an upside down bitmap with 16bit colors
91 register unsigned short lineSize = width<<1;
92 dst += ( height - 1 ) * lineSize; // move to the last scanline
93
94 while( height-- ) {
95 memcpy( dst, src, lineSize );
96 src += srcPitch;
97 dst -= lineSize;
98 }
99 }
100