File: ScreenGraphics.h

package info (click to toggle)
primrose 6%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,304 kB
  • sloc: cpp: 27,318; php: 765; ansic: 636; objc: 272; sh: 136; makefile: 92; perl: 67
file content (127 lines) | stat: -rw-r--r-- 3,094 bytes parent folder | download | duplicates (24)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * Modification History
 *
 * 2000-November-18		Jason Rohrer
 * Created.
 *
 * 2006-April-28		Jason Rohrer
 * Added functions for more direct access to screen pixels.
 *
 * 2006-June-26		Jason Rohrer
 * Added support for dirty rectangle.
 * Added resize support.
 */


#ifndef SCREEN_GRAPHICS_INCLUDED
#define SCREEN_GRAPHICS_INCLUDED


#include "GraphicBuffer.h"

/**
 * Interface for accessing full-screen, 32-bit graphics.
 */
class ScreenGraphics {
	
	public:
		
		/**
		 * Constructs a <code>ScreenGraphics</code>.
		 * Adjusts screen resolution and fills screen with black.
		 *
		 * @param inWidth width of desired full screen.
		 * @param inHeight height of desired full screen.
		 */
		ScreenGraphics( int inWidth, int inHeight );
		
		
		
		/**
		 * Desctructor restores screen to original state.
		 */
		~ScreenGraphics();


        
        /**
         * Resizes the screen.
         *
         * @param inNewWidth the new width.
         * @param inNewHeight the new height.
         */
        void resize( int inNewWidth, int inNewHeight );
        

        
        /**
         * Gets the pixel buffer used by the screen.
         *
         * @return a graphics buffer containing a pointer to the screen
         *   pixels.  Must be destroyed by caller.
         */
        GraphicBuffer *getScreenBuffer();



        /**
         * Flips a dirty rectangle onto the screen.
         *
         * @param inTopLeftX the X coordinate, in pixels, of the top left
         *   point on the rectangle.
         * @param inTopLeftY the Y coordinate, in pixels, of the top left
         *   point on the rectangle.
         * @param inWidth the width of the rectangle.
         * @param inHeight the height of the rectangle.
         */
        void flipDirtyRectangle( int inTopLeftX, int inTopLeftY,
                                 int inWidth, int inHeight );

        
        
        /**
         * Flips all the pixels stored in the location pointed to by
         * getScreenBuffer() onto the screen.
         */
        void flipScreen();

        
        
		/**
		 * Swaps a buffer to the screen.
		 * The next buffer to be filled is returned in
         * <code>inOutBuffer</code>.
         *
		 * No guarentee is made about what will be in the next buffer returned.
		 * (On systems that support on-card double buffering, it may even
		 * be a buffer pointing directly into video memory.)
		 *
		 * @param inOutBuffer pointer to the buffer to swap to the screen,
		 *   and pointer where the next buffer will be stored.
		 */
		void swapBuffers( GraphicBuffer *inOutBuffer );
		
		
		
		/**
		 * Determines whether a particular screen setting is available.
		 *
		 * NOTE:  Do not call after constructing a ScreenGraphics instance.
		 *
		 * @param inWidth width of desired full screen.
		 * @param inHeight height of desired full screen.
		 *
		 * @return true iff screen setting is available.
		 */
		 static char isResolutionAvailable( int inWidth, int inHeight );
			
			
	private:
	
		int mWidth;
		int mHeight;
		
		void *mNativeObjectPointer;
	};
	
#endif