1 #ifndef HEADER_PSYCHLOPS_GRAPHIC_API_WIN32
\r
2 #define HEADER_PSYCHLOPS_GRAPHIC_API_WIN32
\r
11 #include "../../core/graphic/psychlops_g_image.h"
\r
12 #include "../../core/graphic/psychlops_g_font.h"
\r
13 #include "../gl/psychlops_g_cache.h"
\r
16 namespace Psychlops {
\r
19 class DebugTweakTool;
\r
20 class APICanvasProperties {
\r
21 friend class Canvas;
\r
22 friend class DebugTweakTool;
\r
24 enum WINDOW_TYPE { FULLSCREEN, WINDOW };
\r
27 static WNDCLASSEX wcx;
28 static bool wcx_setted;
29 static void setWindowClass();
33 HDC the_display_; // Handle for Device Context
\r
34 HWND the_window_; // Handle for Window
\r
35 HGLRC the_GL_context_; // Handle for OpenGL Context
\r
36 DEVMODE mode_, original_mode_;
37 int vleft, vright, vtop, vbottom;
\r
40 bool vsync_available_;
\r
41 WINDOW_TYPE window_type;
\r
46 int width_, height_, colordepth_;
\r
47 double refreshrate_;
\r
50 APICanvasProperties();
\r
51 virtual ~APICanvasProperties();
52 void getDisplayMertix(const Display& d);
\r
53 void generateCanvasInstance(const Display& d);
\r
54 void generateCanvasInstance(int d_width, int d_height, int d_colordepth, double d_refreshrate, const Display& d);
\r
55 void generateCanvasInstance(DEVMODE &d_mode, const Display& d);
\r
56 void destroyCanvasInstance();
\r
58 void attachOpenGLContext(HWND *hWnd, HDC *hDC, HGLRC *hRC, int d_colordepth);
\r
59 void detachOpenGLContext(HWND hWnd, HDC hDC, HGLRC hRC);
\r
61 //// Gamma Table Section
66 void cacheLetters(Letters &letter);
67 void uncacheLetters(Letters &letter);
69 Letters &letters, const double x, const double y,
70 const double r, const double g, const double b, const double a,
71 const int horiz_align, const double max_width);
\r
75 class TextCacheAllocation
\r
80 TextCacheAllocation();
\r
81 ~TextCacheAllocation();
\r
85 std::map<Letters*, TextCacheAllocation *> text_cache;
\r
86 bool isCached(Letters &letters);
\r
89 Utilities::TextCacheManager text_cache;
\r
92 Letters &letters, const double x, const double y,
\r
93 const double r, const double g, const double b, const double a,
\r
94 const int horiz_align, const int vertical_align, const double max_width);
\r
95 //void draw(Letters &letters);
\r
96 void cache(Letters &letters);
\r
97 void uncache(Letters &letters);
\r
98 void uncacheAllLetters();
\r
99 void cacheText(Letters &drawee, Utilities::CacheOnImage &alloc);
\r
102 //// Gamma Table Section
104 enum { RAMP_STEPS_ = 256 };
105 struct GAMMA_RAMP_TABLE {
110 GAMMA_RAMP_TABLE savedGammaRamp_;
111 LPVOID savedGammaRamp_ptr_;
112 int calibration_mode_;
114 double limit(double v);
115 void setGammaValue(const double gamma_r, const double gamma_g, const double gamma_b);
116 void setGammaTable(const std::vector<double> &table_r, const std::vector<double> &table_g, const std::vector<double> &table_b);
117 void setGammaTable(LPVOID table);
118 void saveGammaValue();
120 void destroyGammaSettings();
121 /* Psychlops is not event-message based application,
\r
122 thus we omit "main loop" recieving mesasges from Windows OS or other applications.
\r
123 PsychlopsAPP recieves messages through Canvas::flip(),
\r
124 or recieve on main loop and "virtual main" function runs on another thread. */
\r
127 void shift(int x, int y);
\r
130 class APICanvasPropertiesFullscreen : public APICanvasProperties {
132 APICanvasPropertiesFullscreen(const Display &target);
133 APICanvasPropertiesFullscreen(int d_width, int d_height, int d_colordepth, double d_refreshrate, const Display &target);
136 class APICanvasPropertiesWindow : public APICanvasProperties {
138 APICanvasPropertiesWindow(int d_width, int d_height, const Display& d);
139 APICanvasPropertiesWindow(int d_left, int d_top, int d_width, int d_height);
140 virtual ~APICanvasPropertiesWindow();
141 void generate(int d_left, int d_top, int d_width, int d_height);
146 namespace Devices { class CanvasBits; }
147 class APIImageCache {
150 friend class Devices::CanvasBits;
152 GLuint VRAMoffset, tex_width, tex_height;
154 unsigned int getTexIndex();
156 class APIImageProperties {
\r
158 friend class Image;
\r
159 friend class Devices::CanvasBits;
161 // static int max_reg, rights_[10+1], bottoms_[10+1];
\r
164 static const int PixCompGL_[3];
165 static const int PixPrecGL_[2];
168 // static bool regist(int maxwidth, int maxheight, int width, int height, int &left, int &top);
\r
169 APIImageProperties();
\r
170 APIImageProperties(Image *outer);
171 virtual ~APIImageProperties();
174 void drawText(int x, int y, const char* str, int strlength);
\r
177 class APIFontProperties {
180 GLuint cache_id, length;
\r
181 double base_width, base_height;
183 static const GLushort lists100[100];
187 virtual ~APIFontProperties();
189 void uncache(const HDC &ctx);
190 void cache(const HDC &ctx, Letters &letters);
\r
191 void culcVirtualMetrix(Letters &letters);
192 void draw(const HDC &ctx,
193 const Letters &letters, const double x, const double y,
194 const double r, const double g, const double b, const double a,
195 const int horiz_align, const double max_width) const;
201 } /* <- namespace Psycholops */