Nux

Merge lp:~unity-team/nux/nux.resolution-change into lp:nux

Proposed by Jay Taoko
Status: Merged
Merged at revision: 263
Proposed branch: lp:~unity-team/nux/nux.resolution-change
Merge into: lp:nux
Diff against target: 968 lines (+170/-563)
10 files modified
Nux/WindowThread.cpp (+13/-1)
Nux/WindowThread.h (+6/-6)
NuxGraphics/GpuDevice.cpp (+7/-118)
NuxGraphics/GpuDevice.h (+0/-28)
NuxGraphics/GpuDeviceVertex.cpp (+33/-143)
NuxGraphics/GraphicsDisplayWin.cpp (+30/-22)
NuxGraphics/GraphicsDisplayWin.h (+7/-0)
NuxGraphics/GraphicsDisplayX11.cpp (+22/-221)
NuxGraphics/GraphicsDisplayX11.h (+21/-4)
NuxGraphics/GraphicsEngine.cpp (+31/-20)
To merge this branch: bzr merge lp:~unity-team/nux/nux.resolution-change
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+52798@code.launchpad.net

Description of the change

Support for window window size change in embedded mode.

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

aweosme approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/WindowThread.cpp'
2--- Nux/WindowThread.cpp 2011-02-28 09:34:22 +0000
3+++ Nux/WindowThread.cpp 2011-03-10 04:33:48 +0000
4@@ -1581,7 +1581,19 @@
5 void WindowThread::SetWindowSize (int width, int height)
6 {
7 if (_graphics_display)
8- _graphics_display->SetWindowSize (width, height);
9+ {
10+ if (IsEmbeddedWindow ())
11+ {
12+ // This is a passive way to set the window size through out the NuxGraphics system. This call gets the
13+ // current window size and sets its accordingly to all sub-system.
14+ _graphics_display->ResetWindowSize ();
15+ }
16+ else
17+ {
18+ _graphics_display->SetWindowSize (width, height);
19+ ReconfigureLayout ();
20+ }
21+ }
22 }
23
24 void WindowThread::SetWindowBackgroundPaintLayer (AbstractPaintLayer *bkg)
25
26=== modified file 'Nux/WindowThread.h' (properties changed: -x to +x)
27--- Nux/WindowThread.h 2011-02-23 03:28:38 +0000
28+++ Nux/WindowThread.h 2011-03-10 04:33:48 +0000
29@@ -560,12 +560,12 @@
30 int _uid;
31 } EventInspectorStorage;
32
33- //! Map of events inspectors
34- /*!
35- Events inspectors get to examine events before they are processed.
36- They may also stop an event from being processed if they return true.
37- */
38- std::map<int, EventInspectorStorage> _event_inspectors_map; //!< map of events inspectors
39+ //! Map of events inspectors
40+ /*!
41+ Events inspectors get to examine events before they are processed.
42+ They may also stop an event from being processed if they return true.
43+ */
44+ std::map<int, EventInspectorStorage> _event_inspectors_map; //!< map of events inspectors
45
46 friend class BasePainter;
47 friend class SystemThread;
48
49=== modified file 'NuxGraphics/GpuDevice.cpp' (properties changed: -x to +x)
50--- NuxGraphics/GpuDevice.cpp 2011-02-17 06:49:43 +0000
51+++ NuxGraphics/GpuDevice.cpp 2011-03-10 04:33:48 +0000
52@@ -234,69 +234,6 @@
53 }
54
55 STREAMSOURCE GpuDevice::_StreamSource[MAX_NUM_STREAM];
56-// ObjectPtr<IOpenGLIndexBuffer> GpuDevice::_CurrentIndexBuffer = 0;
57-// ObjectPtr<IOpenGLVertexBuffer> GpuDevice::_CurrentVertexBuffer = 0;
58-// ObjectPtr<IOpenGLVertexDeclaration> GpuDevice::_CurrentVertexDeclaration = 0;
59-
60-//void TestARBShaders()
61-//{
62-// int OPENGL_PROGRAM_LENGTH_ARB;
63-// int OPENGL_PROGRAM_FORMAT_ARB;
64-// int OPENGL_PROGRAM_BINDING_ARB;
65-// int OPENGL_PROGRAM_INSTRUCTIONS_ARB;
66-// int OPENGL_MAX_PROGRAM_INSTRUCTIONS_ARB;
67-// int OPENGL_PROGRAM_NATIVE_INSTRUCTIONS_ARB;
68-// int OPENGL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB;
69-// int OPENGL_PROGRAM_TEMPORARIES_ARB;
70-// int OPENGL_MAX_PROGRAM_TEMPORARIES_ARB;
71-// int OPENGL_PROGRAM_NATIVE_TEMPORARIES_ARB;
72-// int OPENGL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB;
73-// int OPENGL_PROGRAM_PARAMETERS_ARB;
74-// int OPENGL_MAX_PROGRAM_PARAMETERS_ARB;
75-// int OPENGL_PROGRAM_NATIVE_PARAMETERS_ARB;
76-// int OPENGL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB;
77-// int OPENGL_PROGRAM_ATTRIBS_ARB;
78-// int OPENGL_MAX_PROGRAM_ATTRIBS_ARB;
79-// int OPENGL_PROGRAM_NATIVE_ATTRIBS_ARB;
80-// int OPENGL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB;
81-// int OPENGL_PROGRAM_ADDRESS_REGISTERS_ARB;
82-// int OPENGL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB;
83-// int OPENGL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB;
84-// int OPENGL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB;
85-// int OPENGL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB;
86-// int OPENGL_MAX_PROGRAM_ENV_PARAMETERS_ARB;
87-// int OPENGL_PROGRAM_UNDER_NATIVE_LIMITS_ARB;
88-//
89-// // BEWARE glGetProgramiv != glGetProgramivARB (ARB fragment vertex program)
90-//
91-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_LENGTH_ARB, &OPENGL_PROGRAM_LENGTH_ARB) );
92-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ARB, &OPENGL_PROGRAM_FORMAT_ARB) );
93-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &OPENGL_PROGRAM_BINDING_ARB) );
94-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_INSTRUCTIONS_ARB, &OPENGL_PROGRAM_INSTRUCTIONS_ARB) );
95-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_INSTRUCTIONS_ARB, &OPENGL_MAX_PROGRAM_INSTRUCTIONS_ARB) );
96-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &OPENGL_PROGRAM_NATIVE_INSTRUCTIONS_ARB) );
97-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &OPENGL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB) );
98-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_TEMPORARIES_ARB, &OPENGL_PROGRAM_TEMPORARIES_ARB) );
99-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_TEMPORARIES_ARB, &OPENGL_MAX_PROGRAM_TEMPORARIES_ARB) );
100-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_NATIVE_TEMPORARIES_ARB, &OPENGL_PROGRAM_NATIVE_TEMPORARIES_ARB) );
101-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &OPENGL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB) );
102-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_PARAMETERS_ARB, &OPENGL_PROGRAM_PARAMETERS_ARB) );
103-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_PARAMETERS_ARB, &OPENGL_MAX_PROGRAM_PARAMETERS_ARB) );
104-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_NATIVE_PARAMETERS_ARB, &OPENGL_PROGRAM_NATIVE_PARAMETERS_ARB) );
105-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &OPENGL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB) );
106-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_ATTRIBS_ARB, &OPENGL_PROGRAM_ATTRIBS_ARB) );
107-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ATTRIBS_ARB, &OPENGL_MAX_PROGRAM_ATTRIBS_ARB) );
108-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_NATIVE_ATTRIBS_ARB, &OPENGL_PROGRAM_NATIVE_ATTRIBS_ARB) );
109-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, &OPENGL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB) );
110-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_ADDRESS_REGISTERS_ARB, &OPENGL_PROGRAM_ADDRESS_REGISTERS_ARB) );
111-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, &OPENGL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB) );
112-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, &OPENGL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB) );
113-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, &OPENGL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB) );
114-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &OPENGL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB) );
115-// CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &OPENGL_MAX_PROGRAM_ENV_PARAMETERS_ARB) );
116-// //CHECKGL (glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &OPENGL_PROGRAM_UNDER_NATIVE_LIMITS_ARB) );
117-//}
118-//
119
120 GpuInfo::GpuInfo ()
121 {
122@@ -683,13 +620,13 @@
123 CHECKGL (glPixelStorei (GL_UNPACK_ALIGNMENT, _PixelStoreAlignment));
124 CHECKGL (glPixelStorei (GL_PACK_ALIGNMENT, _PixelStoreAlignment));
125
126- _DeviceWidth = DeviceWidth;
127- _DeviceHeight = DeviceHeight;
128-
129- _ViewportX = 0;
130- _ViewportY = 0;
131- _ViewportWidth = DeviceWidth;
132- _ViewportHeight = DeviceHeight;
133+// _DeviceWidth = DeviceWidth;
134+// _DeviceHeight = DeviceHeight;
135+//
136+// _ViewportX = 0;
137+// _ViewportY = 0;
138+// _ViewportWidth = DeviceWidth;
139+// _ViewportHeight = DeviceHeight;
140
141 for (int i = 0; i < MAX_NUM_STREAM; i++)
142 {
143@@ -996,54 +933,6 @@
144
145 _FrameBufferObject->Activate();
146 }
147- void GpuDevice::Clear (FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha, FLOAT depth, int stencil)
148- {
149- CHECKGL ( glClearColor (red, green, blue, alpha) );
150- CHECKGL ( glClearDepth (depth) );
151- CHECKGL ( glClearStencil (stencil) );
152- CHECKGL ( glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) );
153- }
154-
155- void GpuDevice::ClearColorRT (FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha)
156- {
157- CHECKGL ( glClearColor (red, green, blue, alpha) );
158- CHECKGL ( glClear (GL_COLOR_BUFFER_BIT) );
159- }
160-
161- void GpuDevice::ClearDepthRT (FLOAT depth)
162- {
163- CHECKGL ( glClearDepth (depth) );
164- CHECKGL ( glClear (GL_DEPTH_BUFFER_BIT) );
165- }
166- void GpuDevice::ClearStencilRT (int stencil)
167- {
168- CHECKGL ( glClearStencil (stencil) );
169- CHECKGL ( glClear (GL_STENCIL_BUFFER_BIT) );
170- }
171-
172- void GpuDevice::ClearFloatingPointColorRT (int x, int y, int width, int height,
173- FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha) // use a Quad.
174- {
175- DrawQuad_FixPipe (x, y, width, height, red, green, blue, alpha);
176- }
177-
178- void GpuDevice::ClearSurfaceWithColor (ObjectPtr<IOpenGLSurface> s_, const SURFACE_RECT *rect_, float r, float g, float b, float a)
179- {
180- if (!GetGpuInfo ().Support_EXT_Framebuffer_Object ())
181- {
182- nuxDebugMsg (TEXT ("[GpuDevice::ClearSurfaceWithColor] No support for OpenGL framebuffer extension.") );
183- }
184-
185- FormatFrameBufferObject (s_->GetWidth(), s_->GetHeight(), s_->GetPixelFormat() );
186- SetColorRenderTargetSurface (0, s_);
187- SetDepthRenderTargetSurface (ObjectPtr<IOpenGLSurface> (0));
188- ActivateFrameBuffer();
189- ClearFloatingPointColorRT (rect_->left,
190- rect_->top,
191- rect_->right - rect_->left,
192- rect_->bottom - rect_->top,
193- r, g, b, a);
194- }
195
196 void GpuDevice::SetCurrentFrameBufferObject (ObjectPtr<IOpenGLFrameBufferObject> fbo)
197 {
198
199=== modified file 'NuxGraphics/GpuDevice.h' (properties changed: -x to +x)
200--- NuxGraphics/GpuDevice.h 2011-02-17 06:49:43 +0000
201+++ NuxGraphics/GpuDevice.h 2011-03-10 04:33:48 +0000
202@@ -305,16 +305,6 @@
203 // When using shaders see how a shader sampler parameter links to a texture with a call to setTexture.
204 int SetTexture (unsigned int TextureUnit, IOpenGLBaseTexture *texture);
205
206-
207- void DrawQuad_FixPipe (int x, int y, int width, int height,
208- FLOAT R, FLOAT G, FLOAT B, FLOAT A);
209-
210- void DrawTextureQuad_FixPipe (ObjectPtr<IOpenGLTexture2D> texture, int x, int y, int width, int height,
211- FLOAT u0, FLOAT v0, FLOAT u1, FLOAT v1);
212-
213- void DrawTextureQuad_FixPipe (ObjectPtr<IOpenGLSurface> surface, int x, int y, int width, int height,
214- FLOAT u0, FLOAT v0, FLOAT u1, FLOAT v1);
215-
216 int DrawIndexedPrimitive (
217 ObjectPtr<IOpenGLIndexBuffer> IndexBuffer,
218 ObjectPtr<IOpenGLVertexDeclaration> VertexDeclaration,
219@@ -372,15 +362,6 @@
220 void UnlockUnpackPixelBufferIndex (const int index);
221 void UnlockPackPixelBufferIndex (const int index);
222
223- // Operations on the current render target.
224- void Clear (FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha, FLOAT depth, int stencil);
225- void ClearColorRT (FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha);
226- void ClearDepthRT (FLOAT depth);
227- void ClearStencilRT (int stencil);
228- void ClearFloatingPointColorRT (int x, int y, int width, int height,
229- FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha); // use a Quad.
230- void ClearSurfaceWithColor (ObjectPtr<IOpenGLSurface> s_, const SURFACE_RECT *rect_, float r, float g, float b, float a);
231-
232 // All these operations are done on the default frame buffer object: _FrameBufferObject.
233 int FormatFrameBufferObject (unsigned int Width, unsigned int Height, BitmapFormat PixelFormat);
234 int SetColorRenderTargetSurface (unsigned int ColorAttachmentIndex, ObjectPtr<IOpenGLSurface> pRenderTargetSurface);
235@@ -414,17 +395,8 @@
236
237 std::vector<PixelBufferObject> _PixelBufferArray;
238
239- private:
240- int _DeviceWidth;
241- int _DeviceHeight;
242- int _ViewportX;
243- int _ViewportY;
244- int _ViewportWidth;
245- int _ViewportHeight;
246-
247 public:
248
249-
250 #if (NUX_ENABLE_CG_SHADERS)
251 CGcontext GetCgContext()
252 {
253
254=== modified file 'NuxGraphics/GpuDeviceVertex.cpp' (properties changed: -x to +x)
255--- NuxGraphics/GpuDeviceVertex.cpp 2011-02-17 06:49:43 +0000
256+++ NuxGraphics/GpuDeviceVertex.cpp 2011-03-10 04:33:48 +0000
257@@ -468,149 +468,39 @@
258 return OGL_OK;
259 }
260
261- void GpuDevice::DrawQuad_FixPipe (int x, int y, int width, int height,
262- FLOAT R, FLOAT G, FLOAT B, FLOAT A)
263- {
264- Matrix4 matrix;
265- matrix.Identity();
266- matrix.m[0][0] = 2.0f / (FLOAT) _ViewportWidth;
267- matrix.m[0][3] = -1.0f;
268- matrix.m[1][1] = - (2.0f / (FLOAT) _ViewportHeight);
269- matrix.m[1][3] = 1.0f;
270-
271- matrix.Transpose();
272-
273- FLOAT Vertices[16] =
274- {
275- x, y, 0.0f, 1.0f,
276- x, y + height, 0.0f, 1.0f,
277- x + width, y + height, 0.0f, 1.0f,
278- x + width, y, 0.0f, 1.0f
279- };
280-
281- unsigned int Indices[] = {0, 1, 2, 0, 2, 3};
282-
283- FLOAT VertexColors[16] =
284- {
285- R, G, B, A,
286- R, G, B, A,
287- R, G, B, A,
288- R, G, B, A
289- };
290-
291- CHECKGL ( glMatrixMode (GL_MODELVIEW) );
292- CHECKGL ( glLoadIdentity() );
293- CHECKGL ( glLoadMatrixf ( (FLOAT *) matrix.m) );
294- CHECKGL ( glMatrixMode (GL_PROJECTION) );
295- CHECKGL ( glLoadIdentity() );
296- CHECKGL ( glPolygonMode (GL_FRONT_AND_BACK, GL_FILL) );
297-
298- CHECKGL ( glUseProgramObjectARB (0) );
299- InvalidateVertexBuffer();
300- InvalidateIndexBuffer();
301- InvalidateTextureUnit (GL_TEXTURE0);
302-
303- CHECKGL ( glEnableClientState (GL_VERTEX_ARRAY) );
304- CHECKGL ( glVertexPointer ( 4, GL_FLOAT, 0, (void *) (&Vertices) ) );
305-
306- CHECKGL ( glEnableClientState (GL_COLOR_ARRAY) );
307- CHECKGL ( glColorPointer ( 4, GL_FLOAT, 0, (void *) (&VertexColors) ) );
308-
309- CHECKGL ( glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_INT, (void *) (&Indices) ) );
310-
311- CHECKGL ( glDisableClientState (GL_VERTEX_ARRAY) );
312- CHECKGL ( glDisableClientState (GL_COLOR_ARRAY) );
313- }
314-
315- void GpuDevice::DrawTextureQuad_FixPipe (ObjectPtr<IOpenGLTexture2D> texture, int x, int y, int width, int height,
316- FLOAT u0, FLOAT v0, FLOAT u1, FLOAT v1)
317- {
318-// DirectX Matrix
319-// | 2/W 0 0 -(W+1)/W |
320-// | 0 -2/H 0 (H+1)/H |
321-// | 0 0 1 0 |
322-// | 0 0 0 1 |
323-//
324-// Screen Quad(0, 0, W, H)
325-// Normalized Coord (Xn+1)/2 * W Screen Coord
326-// X: 0 ---> -(1+1/W) ---> -0.5
327-// X: W ---> 1-1/W ---> W-0.5
328-// -(Yn-1)/2 * H
329-// Y: 0 ---> (1+1/H) ---> -0.5
330-// Y: W ---> -1-1/H ---> H-0.5
331-//
332-// The Matrix above is good to do quad on screen in DirectX. DirectX requires that the vertex coordinates be shifted
333-// by (-0.5,-0.5) in order for the center of texel to be located at the center of pixel.
334-// Note: OpenGL maps integral texture coordinates to the texel center
335-// whereas Direct3D maps integral texture coordinates to the upper, left texel corner.
336-
337-// In OpenGL we will use this matrix instead:
338-// | 2/W 0 0 -1 |
339-// | 0 -2/H 0 1 |
340-// | 0 0 1 0 |
341-// | 0 0 0 1 |
342-//
343-// Screen Quad(0, 0, W, H)
344-// Normalized Coord (Xn+1)/2 * W Screen Coord
345-// X: 0 ---> -1 ---> 0.0
346-// X: W ---> 1 ---> W
347-// -(Yn-1)/2 * H
348-// Y: 0 ---> 1 ---> 0.0
349-// Y: W ---> -1
350-
351-
352- Matrix4 matrix;
353- matrix.Identity();
354- matrix.m[0][0] = 2.0f / 1280.0f;
355- matrix.m[3][0] = - (1280.0f + 1.0f) / 1280.0f;
356- matrix.m[1][1] = - (2.0f / 720.0f);
357- matrix.m[3][1] = (720.0f + 1.0f) / 720.0f;
358-
359-
360- matrix.Transpose();
361-
362- FLOAT Vertices[16] =
363- {
364- x, y, 0.0f, 1.0f,
365- x, y + height, 0.0f, 1.0f,
366- x + width, y + height, 0.0f, 1.0f,
367- x + width, y, 0.0f, 1.0f
368- };
369-
370- unsigned int Indices[] = {0, 1, 2, 0, 2, 3};
371-
372- FLOAT UV[8] =
373- {
374- u0, v1,
375- u0, v0,
376- u1, v0,
377- u1, v1,
378- };
379-
380- CHECKGL ( glMatrixMode (GL_MODELVIEW) );
381- CHECKGL ( glLoadIdentity() );
382- CHECKGL ( glLoadMatrixf ( (FLOAT *) matrix.m) );
383- CHECKGL ( glMatrixMode (GL_PROJECTION) );
384- CHECKGL ( glLoadIdentity() );
385- CHECKGL ( glPolygonMode (GL_FRONT_AND_BACK, GL_FILL) );
386-
387- CHECKGL ( glUseProgramObjectARB (0) );
388- InvalidateVertexBuffer();
389- InvalidateIndexBuffer();
390-
391- CHECKGL ( glEnableClientState (GL_VERTEX_ARRAY) );
392- CHECKGL ( glVertexPointer ( 4, GL_FLOAT, 0, (void *) (&Vertices) ) );
393-
394- CHECKGL ( glClientActiveTextureARB (GL_TEXTURE0) );
395- texture->BindTexture();
396- CHECKGL ( glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
397- CHECKGL ( glTexCoordPointer ( 2, GL_FLOAT, 0, (void *) (&UV) ) );
398-
399- CHECKGL ( glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_INT, (void *) (&Indices) ) );
400-
401- CHECKGL ( glDisableClientState (GL_VERTEX_ARRAY) );
402- CHECKGL ( glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
403- }
404+// // DirectX Matrix
405+// // | 2/W 0 0 -(W+1)/W |
406+// // | 0 -2/H 0 (H+1)/H |
407+// // | 0 0 1 0 |
408+// // | 0 0 0 1 |
409+// //
410+// // Screen Quad(0, 0, W, H)
411+// // Normalized Coord (Xn+1)/2 * W Screen Coord
412+// // X: 0 ---> -(1+1/W) ---> -0.5
413+// // X: W ---> 1-1/W ---> W-0.5
414+// // -(Yn-1)/2 * H
415+// // Y: 0 ---> (1+1/H) ---> -0.5
416+// // Y: W ---> -1-1/H ---> H-0.5
417+// //
418+// // The Matrix above is good to do quad on screen in DirectX. DirectX requires that the vertex coordinates be shifted
419+// // by (-0.5,-0.5) in order for the center of texel to be located at the center of pixel.
420+// // Note: OpenGL maps integral texture coordinates to the texel center
421+// // whereas Direct3D maps integral texture coordinates to the upper, left texel corner.
422+//
423+// // In OpenGL we will use this matrix instead:
424+// // | 2/W 0 0 -1 |
425+// // | 0 -2/H 0 1 |
426+// // | 0 0 1 0 |
427+// // | 0 0 0 1 |
428+// //
429+// // Screen Quad(0, 0, W, H)
430+// // Normalized Coord (Xn+1)/2 * W Screen Coord
431+// // X: 0 ---> -1 ---> 0.0
432+// // X: W ---> 1 ---> W
433+// // -(Yn-1)/2 * H
434+// // Y: 0 ---> 1 ---> 0.0
435+// // Y: W ---> -1
436+
437
438 int GpuDevice::SetStreamSource (
439 unsigned int StreamNumber,
440
441=== modified file 'NuxGraphics/GraphicsDisplayWin.cpp' (properties changed: -x to +x)
442--- NuxGraphics/GraphicsDisplayWin.cpp 2011-02-23 03:28:38 +0000
443+++ NuxGraphics/GraphicsDisplayWin.cpp 2011-03-10 04:33:48 +0000
444@@ -533,26 +533,34 @@
445 // NUXTODO: remove this call. Make a direct access to GpuInfo via GpuDevice.
446 bool GraphicsDisplay::HasFrameBufferSupport()
447 {
448- return m_DeviceFactory->GetGpuInfo().Support_EXT_Framebuffer_Object ();
449+ return m_DeviceFactory->GetGpuInfo ().Support_EXT_Framebuffer_Object ();
450 }
451
452 //---------------------------------------------------------------------------------------------------------
453 void GraphicsDisplay::GetWindowSize (int &w, int &h)
454 {
455- w = m_WindowSize.GetWidth();
456- h = m_WindowSize.GetHeight();
457- }
458-
459-//---------------------------------------------------------------------------------------------------------
460- int GraphicsDisplay::GetWindowWidth()
461- {
462- return m_WindowSize.GetWidth();
463- }
464-
465-//---------------------------------------------------------------------------------------------------------
466- int GraphicsDisplay::GetWindowHeight()
467- {
468- return m_WindowSize.GetHeight();
469+ w = m_WindowSize.GetWidth ();
470+ h = m_WindowSize.GetHeight ();
471+ }
472+
473+//---------------------------------------------------------------------------------------------------------
474+ int GraphicsDisplay::GetWindowWidth ()
475+ {
476+ return m_WindowSize.GetWidth ();
477+ }
478+
479+//---------------------------------------------------------------------------------------------------------
480+ int GraphicsDisplay::GetWindowHeight ()
481+ {
482+ return m_WindowSize.GetHeight ();
483+ }
484+
485+ void GraphicsDisplay::ResetWindowSize ()
486+ {
487+ RECT rect;
488+ ::GetClientRect (m_hWnd, &rect);
489+ m_WindowSize = Size (rect.right - rect.left, rect.bottom - rect.top);
490+ m_ViewportSize = Size (rect.right - rect.left, rect.bottom - rect.top);
491 }
492
493 //---------------------------------------------------------------------------------------------------------
494@@ -579,18 +587,18 @@
495 //---------------------------------------------------------------------------------------------------------
496 void GraphicsDisplay::SetViewPort (int x, int y, int width, int height)
497 {
498- if (IsGfxInterfaceCreated() )
499+ if (IsGfxInterfaceCreated ())
500 {
501 //do not rely on m_ViewportSize: glViewport can be called directly
502 m_ViewportSize.SetWidth (width);
503 m_ViewportSize.SetHeight (height);
504
505- m_GraphicsContext->SetViewport (x, y, m_ViewportSize.GetWidth(), m_ViewportSize.GetHeight() );
506+ m_GraphicsContext->SetViewport (x, y, m_ViewportSize.GetWidth (), m_ViewportSize.GetHeight ());
507 m_GraphicsContext->SetScissor (0, 0, width, height);
508 }
509 }
510
511- Point GraphicsDisplay::GetMouseScreenCoord()
512+ Point GraphicsDisplay::GetMouseScreenCoord ()
513 {
514 POINT pt;
515 ::GetCursorPos (&pt);
516@@ -599,7 +607,7 @@
517 return point;
518 }
519
520- Point GraphicsDisplay::GetMouseWindowCoord()
521+ Point GraphicsDisplay::GetMouseWindowCoord ()
522 {
523 POINT pt;
524 ::GetCursorPos (&pt);
525@@ -608,7 +616,7 @@
526 return point;
527 }
528
529- Point GraphicsDisplay::GetWindowCoord()
530+ Point GraphicsDisplay::GetWindowCoord ()
531 {
532 RECT rect;
533 ::GetWindowRect (m_hWnd, &rect);
534@@ -616,7 +624,7 @@
535 return point;
536 }
537
538- Rect GraphicsDisplay::GetWindowGeometry()
539+ Rect GraphicsDisplay::GetWindowGeometry ()
540 {
541 RECT rect;
542 ::GetClientRect (m_hWnd, &rect);
543@@ -624,7 +632,7 @@
544 return geo;
545 }
546
547- Rect GraphicsDisplay::GetNCWindowGeometry()
548+ Rect GraphicsDisplay::GetNCWindowGeometry ()
549 {
550 RECT rect;
551 ::GetWindowRect (m_hWnd, &rect);
552
553=== modified file 'NuxGraphics/GraphicsDisplayWin.h' (properties changed: -x to +x)
554--- NuxGraphics/GraphicsDisplayWin.h 2011-02-17 06:49:43 +0000
555+++ NuxGraphics/GraphicsDisplayWin.h 2011-03-10 04:33:48 +0000
556@@ -204,6 +204,13 @@
557 int GetWindowWidth();
558 int GetWindowHeight();
559
560+ //! Get the window size and reset the GraphicsEngine and GpuDevice accordingly.
561+ /*!
562+ This is a passive way to set the window size through out the NuxGraphics system. This call gets the
563+ current window size and sets its accordingly to all sub-system.
564+ */
565+ void ResetWindowSize ();
566+
567 bool HasFrameBufferSupport();
568 void SetWindowCursor (HCURSOR cursor);
569 HCURSOR GetWindowCursor() const;
570
571=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp' (properties changed: -x to +x)
572--- NuxGraphics/GraphicsDisplayX11.cpp 2011-03-01 06:16:05 +0000
573+++ NuxGraphics/GraphicsDisplayX11.cpp 2011-03-10 04:33:48 +0000
574@@ -728,6 +728,28 @@
575 }
576 }
577
578+ void GraphicsDisplay::ResetWindowSize ()
579+ {
580+ Window root_return;
581+ int x_return, y_return;
582+ unsigned int width_return, height_return;
583+ unsigned int border_width_return;
584+ unsigned int depth_return;
585+
586+ XGetGeometry (m_X11Display,
587+ m_X11Window,
588+ &root_return,
589+ &x_return,
590+ &y_return,
591+ &width_return,
592+ &height_return,
593+ &border_width_return,
594+ &depth_return);
595+
596+ m_WindowSize = Size (width_return, height_return);
597+ m_WindowPosition = Point (x_return, y_return);
598+ }
599+
600 Point GraphicsDisplay::GetMouseScreenCoord()
601 {
602 Window root_return;
603@@ -2365,227 +2387,6 @@
604 EndDndDrag (result);
605 }
606
607- int GraphicsDisplay::X11KeySymToINL (int Keysym)
608- {
609- switch (Keysym)
610- {
611- case XK_BackSpace:
612- return NUX_VK_BACKSPACE;
613- case XK_Tab:
614- return NUX_VK_TAB;
615- case XK_Clear:
616- return NUX_VK_CLEAR;
617- case XK_Return:
618- return NUX_VK_ENTER;
619- case XK_Shift_L:
620- return NUX_VK_SHIFT;
621- case XK_Control_L:
622- return NUX_VK_CONTROL;
623- case XK_Alt_L:
624- return NUX_VK_MENU;
625- case XK_Pause:
626- return NUX_VK_PAUSE;
627- case XK_Caps_Lock:
628- return NUX_VK_CAPITAL;
629- case XK_Escape:
630- return NUX_VK_ESCAPE;
631- case XK_space:
632- return NUX_VK_SPACE;
633- case XK_Page_Up:
634- return NUX_VK_PAGE_UP;
635- case XK_Page_Down:
636- return NUX_VK_PAGE_DOWN;
637- case XK_End:
638- return NUX_VK_END;
639- case XK_Home:
640- return NUX_VK_HOME;
641- case XK_Left:
642- return NUX_VK_LEFT;
643- case XK_Up:
644- return NUX_VK_UP;
645- case XK_Right:
646- return NUX_VK_RIGHT;
647- case XK_Down:
648- return NUX_VK_DOWN;
649- case XK_Print:
650- return NUX_VK_PRINT;
651- case XK_Execute:
652- return NUX_VK_EXECUTE;
653- case XK_Insert:
654- return NUX_VK_INSERT;
655- case XK_Delete:
656- return NUX_VK_DELETE;
657- case XK_0:
658- return NUX_VK_0;
659- case XK_1:
660- return NUX_VK_1;
661- case XK_2:
662- return NUX_VK_2;
663- case XK_3:
664- return NUX_VK_3;
665- case XK_4:
666- return NUX_VK_4;
667- case XK_5:
668- return NUX_VK_5;
669- case XK_6:
670- return NUX_VK_6;
671- case XK_7:
672- return NUX_VK_7;
673- case XK_8:
674- return NUX_VK_8;
675- case XK_9:
676- return NUX_VK_9;
677- case XK_A:
678- return NUX_VK_A;
679- case XK_B:
680- return NUX_VK_B;
681- case XK_C:
682- return NUX_VK_C;
683- case XK_D:
684- return NUX_VK_D;
685- case XK_E:
686- return NUX_VK_E;
687- case XK_F:
688- return NUX_VK_F;
689- case XK_G:
690- return NUX_VK_G;
691- case XK_H:
692- return NUX_VK_H;
693- case XK_I:
694- return NUX_VK_I;
695- case XK_J:
696- return NUX_VK_J;
697- case XK_K:
698- return NUX_VK_K;
699- case XK_L:
700- return NUX_VK_L;
701- case XK_M:
702- return NUX_VK_M;
703- case XK_N:
704- return NUX_VK_N;
705- case XK_O:
706- return NUX_VK_O;
707- case XK_P:
708- return NUX_VK_P;
709- case XK_Q:
710- return NUX_VK_Q;
711- case XK_R:
712- return NUX_VK_R;
713- case XK_S:
714- return NUX_VK_S;
715- case XK_T:
716- return NUX_VK_T;
717- case XK_U:
718- return NUX_VK_U;
719- case XK_V:
720- return NUX_VK_V;
721- case XK_W:
722- return NUX_VK_W;
723- case XK_X:
724- return NUX_VK_X;
725- case XK_Y:
726- return NUX_VK_Y;
727- case XK_Z:
728- return NUX_VK_Z;
729- case XK_Super_L:
730- return NUX_VK_LWIN;
731- case XK_Super_R:
732- return NUX_VK_RWIN;
733- case XK_KP_0:
734- return NUX_VK_NUMPAD0;
735- case XK_KP_1:
736- return NUX_VK_NUMPAD1;
737- case XK_KP_2:
738- return NUX_VK_NUMPAD2;
739- case XK_KP_3:
740- return NUX_VK_NUMPAD3;
741- case XK_KP_4:
742- return NUX_VK_NUMPAD4;
743- case XK_KP_5:
744- return NUX_VK_NUMPAD5;
745- case XK_KP_6:
746- return NUX_VK_NUMPAD6;
747- case XK_KP_7:
748- return NUX_VK_NUMPAD7;
749- case XK_KP_8:
750- return NUX_VK_NUMPAD8;
751- case XK_KP_9:
752- return NUX_VK_NUMPAD9;
753- case XK_KP_Multiply:
754- return NUX_VK_MULTIPLY;
755- case XK_KP_Add:
756- return NUX_VK_ADD;
757- case XK_KP_Separator:
758- return NUX_VK_SEPARATOR;
759- case XK_KP_Subtract:
760- return NUX_VK_SUBTRACT;
761- case XK_KP_Decimal:
762- return NUX_VK_DECIMAL;
763- case XK_KP_Divide:
764- return NUX_VK_DIVIDE;
765- case XK_F1:
766- return NUX_VK_F1;
767- case XK_F2:
768- return NUX_VK_F2;
769- case XK_F3:
770- return NUX_VK_F3;
771- case XK_F4:
772- return NUX_VK_F4;
773- case XK_F5:
774- return NUX_VK_F5;
775- case XK_F6:
776- return NUX_VK_F6;
777- case XK_F7:
778- return NUX_VK_F7;
779- case XK_F8:
780- return NUX_VK_F8;
781- case XK_F9:
782- return NUX_VK_F9;
783- case XK_F10:
784- return NUX_VK_F10;
785- case XK_F11:
786- return NUX_VK_F11;
787- case XK_F12:
788- return NUX_VK_F12;
789- case XK_F13:
790- return NUX_VK_F13;
791- case XK_F14:
792- return NUX_VK_F14;
793- case XK_F15:
794- return NUX_VK_F15;
795- case XK_F16:
796- return NUX_VK_F16;
797- case XK_F17:
798- return NUX_VK_F17;
799- case XK_F18:
800- return NUX_VK_F18;
801- case XK_F19:
802- return NUX_VK_F19;
803- case XK_F20:
804- return NUX_VK_F20;
805- case XK_F21:
806- return NUX_VK_F21;
807- case XK_F22:
808- return NUX_VK_F22;
809- case XK_F23:
810- return NUX_VK_F23;
811- case XK_F24:
812- return NUX_VK_F24;
813- case XK_Num_Lock:
814- return NUX_VK_NUMLOCK;
815- case XK_Scroll_Lock:
816- return NUX_VK_SCROLL;
817- case XK_Shift_R:
818- return NUX_VK_RSHIFT;
819- case XK_Control_R:
820- return NUX_VK_RCONTROL;
821- case XK_Alt_R:
822- return NUX_VK_RMENU;
823- default:
824- return 0x0;
825- }
826- };
827-
828 void GraphicsDisplay::ShowWindow()
829 {
830 XMapRaised (m_X11Display, m_X11Window);
831
832=== modified file 'NuxGraphics/GraphicsDisplayX11.h' (properties changed: -x to +x)
833--- NuxGraphics/GraphicsDisplayX11.h 2011-03-01 06:16:05 +0000
834+++ NuxGraphics/GraphicsDisplayX11.h 2011-03-10 04:33:48 +0000
835@@ -130,8 +130,6 @@
836
837 bool m_is_window_minimized;
838
839- static int X11KeySymToINL (int Keysym);
840-
841 public:
842 typedef struct _DndSourceFuncs
843 {
844@@ -182,9 +180,20 @@
845 void DestroyOpenGLWindow();
846
847 void SetWindowTitle (const TCHAR *Title);
848+
849+ //! Set the window size.
850+ /*!
851+ Actively set the window size to the provided parameters.
852+ \sa ResetWindowSize
853+ */
854 void SetWindowSize (int width, int height);
855+
856+ //! Set the window position.
857 void SetWindowPosition (int width, int height);
858+
859+ //! Set the OpenGL Viewport.
860 void SetViewPort (int x, int y, int width, int height);
861+
862 Point GetMouseScreenCoord();
863 Point GetMouseWindowCoord();
864 Point GetWindowCoord();
865@@ -252,8 +261,16 @@
866
867 void GetDesktopSize (int &w, int &h);
868 void GetWindowSize (int &w, int &h);
869- int GetWindowWidth();
870- int GetWindowHeight();
871+ int GetWindowWidth ();
872+ int GetWindowHeight ();
873+
874+ //! Get the window size and reset the GraphicsEngine and GpuDevice accordingly.
875+ /*!
876+ This is a passive way to set the window size through out the NuxGraphics system. This call gets the
877+ current window size and sets its accordingly to all sub-system.
878+ \sa SetWindowSize
879+ */
880+ void ResetWindowSize ();
881
882 bool HasFrameBufferSupport();
883 /*void SetWindowCursor(HCURSOR cursor);
884
885=== modified file 'NuxGraphics/GraphicsEngine.cpp'
886--- NuxGraphics/GraphicsEngine.cpp 2011-02-27 00:34:59 +0000
887+++ NuxGraphics/GraphicsEngine.cpp 2011-03-10 04:33:48 +0000
888@@ -174,19 +174,29 @@
889 SetScissor (0, 0, _graphics_display.GetWindowWidth(), _graphics_display.GetWindowHeight() );
890 EnableScissoring (true);
891
892+ bool opengl_14_support = true;
893+
894+ if ((_graphics_display.GetGpuDevice ()->GetOpenGLMajorVersion () == 1) &&
895+ (_graphics_display.GetGpuDevice ()->GetOpenGLMinorVersion () < 4))
896+ {
897+ // OpenGL version is less than OpenGL 1.4
898+ opengl_14_support = false;
899+ }
900+
901 if (create_rendering_data)
902 {
903 #ifndef NUX_OPENGLES_20
904 if (UsingGLSLCodePath () &&
905 GetGpuDevice ()->GetGpuInfo ().Support_ARB_Fragment_Shader () &&
906- GetGpuDevice ()->GetGpuInfo ().Support_ARB_Vertex_Shader ())
907+ GetGpuDevice ()->GetGpuInfo ().Support_ARB_Vertex_Shader () &&
908+ opengl_14_support)
909 {
910- InitSlColorShader();
911- InitSlTextureShader();
912+ InitSlColorShader ();
913+ InitSlTextureShader ();
914 InitSlColorModTexMaskAlpha ();
915- InitSl2TextureAdd();
916- InitSl2TextureMod();
917- InitSl4TextureAdd();
918+ InitSl2TextureAdd ();
919+ InitSl2TextureMod ();
920+ InitSl4TextureAdd ();
921
922 InitSLComponentExponentiation ();
923 InitSLAlphaReplicate ();
924@@ -199,16 +209,17 @@
925 InitSLHorizontalHQGaussFilter ();
926 InitSLVerticalHQGaussFilter ();
927 }
928- else if (GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
929- GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Program())
930+ else if (GetGpuDevice ()->GetGpuInfo ().Support_ARB_Fragment_Shader () &&
931+ GetGpuDevice ()->GetGpuInfo ().Support_ARB_Vertex_Program () &&
932+ opengl_14_support)
933 {
934- InitAsmColorShader();
935- InitAsmTextureShader();
936- InitAsmColorModTexMaskAlpha();
937- InitAsm2TextureAdd();
938- InitAsm2TextureMod();
939- InitAsm4TextureAdd();
940- InitAsmBlendModes();
941+ InitAsmColorShader ();
942+ InitAsmTextureShader ();
943+ InitAsmColorModTexMaskAlpha ();
944+ InitAsm2TextureAdd ();
945+ InitAsm2TextureMod ();
946+ InitAsm4TextureAdd ();
947+ InitAsmBlendModes ();
948
949 InitAsmComponentExponentiation ();
950 InitAsmAlphaReplicate ();
951@@ -218,12 +229,12 @@
952 //InitAsm2TextureDepRead (); // NUXTODO: fix the shader
953 }
954 #else
955- InitSlColorShader();
956- InitSlTextureShader();
957+ InitSlColorShader ();
958+ InitSlTextureShader ();
959 InitSlColorModTexMaskAlpha ();
960- InitSl2TextureAdd();
961- InitSl2TextureMod();
962- InitSl4TextureAdd();
963+ InitSl2TextureAdd ();
964+ InitSl2TextureMod ();
965+ InitSl4TextureAdd ();
966
967 InitSLComponentExponentiation ();
968 InitSLAlphaReplicate ();

Subscribers

People subscribed via source and target branches