Nux

Merge lp:~linaro-graphics-wg/nux/nux-1.0-gles2 into lp:nux

Proposed by Travis Watkins
Status: Merged
Merge reported by: Travis Watkins
Merged at revision: not available
Proposed branch: lp:~linaro-graphics-wg/nux/nux-1.0-gles2
Merge into: lp:nux
Diff against target: 4646 lines (+1468/-600)
58 files modified
Nux/BezierCurveControl2.cpp (+7/-1)
Nux/Nux.cpp (+6/-0)
Nux/Nux.h (+6/-0)
Nux/WindowThread.cpp (+4/-0)
Nux/WindowThread.h (+10/-0)
Nux/nux.pc.in (+1/-1)
NuxCore/FileManager/NFileManagerStandardAnsi.h (+9/-8)
NuxCore/Logger.cpp (+8/-1)
NuxCore/NuxCore.h (+1/-1)
NuxCore/ObjectPtr.h (+1/-1)
NuxCore/System.h (+38/-38)
NuxGraphics/FontRenderer.cpp (+38/-6)
NuxGraphics/FontTexture.cpp (+5/-0)
NuxGraphics/GLDeviceFrameBufferObject.cpp (+21/-1)
NuxGraphics/GLError.cpp (+4/-0)
NuxGraphics/GLPBuffer.cpp (+4/-0)
NuxGraphics/GLPBuffer.h (+4/-0)
NuxGraphics/GLRenderStates.cpp (+2/-0)
NuxGraphics/GLRenderStates.h (+38/-1)
NuxGraphics/GLResource.cpp (+6/-0)
NuxGraphics/GLResource.h (+29/-3)
NuxGraphics/GLSh_ColorPicker.cpp (+29/-8)
NuxGraphics/GLSh_DrawFunction.cpp (+5/-2)
NuxGraphics/GLTextureStates.cpp (+38/-0)
NuxGraphics/GLWindowManager.cpp (+7/-1)
NuxGraphics/GLWindowManager.h (+4/-0)
NuxGraphics/GpuDevice.cpp (+159/-165)
NuxGraphics/GpuDevice.h (+23/-9)
NuxGraphics/GpuDeviceVertex.cpp (+3/-1)
NuxGraphics/GraphicsDisplayX11.cpp (+115/-0)
NuxGraphics/GraphicsDisplayX11.h (+14/-0)
NuxGraphics/IOpenGLAsmShader.cpp (+20/-1)
NuxGraphics/IOpenGLBaseTexture.cpp (+12/-0)
NuxGraphics/IOpenGLFrameBufferObject.cpp (+1/-0)
NuxGraphics/IOpenGLGLSLShader.cpp (+6/-4)
NuxGraphics/IOpenGLGLSLShader.h (+2/-2)
NuxGraphics/IOpenGLIndexBuffer.cpp (+14/-3)
NuxGraphics/IOpenGLPixelBufferOject.cpp (+9/-1)
NuxGraphics/IOpenGLQuery.cpp (+13/-4)
NuxGraphics/IOpenGLRectangleTexture.cpp (+3/-0)
NuxGraphics/IOpenGLSurface.cpp (+37/-11)
NuxGraphics/IOpenGLTexture2D.cpp (+11/-0)
NuxGraphics/IOpenGLVertexBuffer.cpp (+10/-1)
NuxGraphics/IOpenGLVolume.cpp (+6/-0)
NuxGraphics/IOpenGLVolumeTexture.cpp (+3/-0)
NuxGraphics/Makefile.am (+1/-0)
NuxGraphics/OpenGLMapping.h (+129/-0)
NuxGraphics/RenderingPipe.cpp (+38/-1)
NuxGraphics/RenderingPipeGLSL.cpp (+160/-171)
NuxGraphics/XInputWindow.cpp (+15/-4)
NuxGraphics/nux-graphics.pc.in (+1/-1)
NuxImage/BitmapFormats.cpp (+60/-55)
NuxImage/BitmapFormats.h (+10/-35)
configure.ac (+25/-26)
gputests/Makefile.am (+5/-1)
gputests/texture_power_of_2.cpp (+2/-18)
tools/Makefile.am (+1/-1)
tools/unity_support_test.c (+235/-12)
To merge this branch: bzr merge lp:~linaro-graphics-wg/nux/nux-1.0-gles2
Reviewer Review Type Date Requested Status
Jay Taoko Pending
Review via email: mp+70279@code.launchpad.net

Description of the change

Add GLESv2 support to nux.

All tests and examples work correctly, there is a blending issue when used with GLESv2 unity that hasn't been tracked down yet.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

> NuxCore/Math/Matrix4.h

Instead of adding a Print method to the class, you should make a streaming
operator that is outside the class.

template <typename T>
ostream& operator<<(ostream& out, Matrix4x4<T> const& matrix)
{
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      out << matrix.m[i][j] << " ";
    }
  }
  return out;
}

Revision history for this message
Jay Taoko (jaytaoko) wrote :

I am at Siggraph. I will review the branch after I return.

387. By Travis Watkins

merge with upstream

388. By Travis Watkins

merge with latest upstream

389. By Travis Watkins

merge in latest lp:nux

390. By Travis Watkins

remove debug code, remove API changes when compiling for desktop GL

Revision history for this message
Travis Watkins (amaranth) wrote :

I've removed the Matrix4::Print and IOpenGLFramebufferObject::WriteToFile methods, they were only meant for debugging during the porting process. I've also changed things so there should be no API/ABI changes at all unless you compile for GLES.

Revision history for this message
Jay Taoko (jaytaoko) wrote :

There changes needed to get this branch working with unity.

- In IOpenGLGLSLShader.cpp line 1904
The code that is removed is necessary to load some shaders. We have shaders that contains the "#version" information in unity. Also, "#version" information in a GLSL shader is valid and we need to preserve it even if it is not supported by GLSL.

- One problem I have encountered many times is the support of macros in GLSL with intel drivers. My last check a few months ago showed that Intel's driver didn't support macros very well. So I am not sure that "#ifdef GL_ES" will work with Intel driver on the desktop... I still have to check. If the intel's driver still fails with macros in GLSL, I think we could use the C++ pre-processor to enable the GL_ES bits in the shaders.

- Around line 1037
Some texture format definitions have been invalidated... For formats that are not available in OpenGL ES, they removed with macros in the C++ pre-processor.

Revision history for this message
Travis Watkins (amaranth) wrote :

I removed the #version lines because GLES GLSL uses different versions than GL GLSL even if they support the same features. I also removed them from unity so there should be no problems caused by that. The only solution that would allow keeping the #version lines is to #ifdef them in C++ so the correct version is generated depending on what you are compiling for but it didn't seem worthwhile.

There is no specific GLSL compiler for intel so I assume you mean mesa here. Mesa's GLSL compiler certainly supports #ifdef and I've been using the mesa GL and GLES stacks with an intel GPU while testing.

These are only invalidated in the GLES codepath, do you mean I should remove them in a different way?

Revision history for this message
Jay Taoko (jaytaoko) wrote :

> I removed the #version lines because GLES GLSL uses different versions than GL
> GLSL even if they support the same features. I also removed them from unity so
> there should be no problems caused by that. The only solution that would allow
> keeping the #version lines is to #ifdef them in C++ so the correct version is
> generated depending on what you are compiling for but it didn't seem
> worthwhile.
>
> There is no specific GLSL compiler for intel so I assume you mean mesa here.
> Mesa's GLSL compiler certainly supports #ifdef and I've been using the mesa GL
> and GLES stacks with an intel GPU while testing.
>
> These are only invalidated in the GLES codepath, do you mean I should remove
> them in a different way?

It is just from a brief experience that I am talking about with macros in GLSL shaders with the open source driver. Lets assume for now that all is fine.
Since #version must appear before anything else in the shader code (except for comment and white space, we can't do something like this:

#ifndef GL_ES
    #version 110
#else
    precision mediump float;
#endif

The solution, as you said, is to use C++ pre-processors to select the proper code in the shader string. Unless the body of the shaders in OpenGL and OpenGL ES start to diverge, we don't need to create a special text strings for GL ES shaders.

Revision history for this message
Jesse Barker (jesse-barker) wrote :

On Wed, Sep 7, 2011 at 7:55 PM, Jay Taoko <email address hidden> wrote:
> There changes needed to get this branch working with unity.
>
> - In IOpenGLGLSLShader.cpp line 1904
> The code that is removed is necessary to load some shaders. We have shaders that contains the "#version" information in unity. Also, "#version" information in a GLSL shader is valid and we need to preserve it even if it is not supported by GLSL.
>
> - One problem I have encountered many times is the support of macros in GLSL with intel drivers. My last check a few months ago showed that Intel's driver didn't support macros very well. So I am not sure that "#ifdef GL_ES" will work with Intel driver on the desktop... I still have to check. If the intel's driver still fails with macros in GLSL, I think we could use the C++ pre-processor to enable the GL_ES bits in the shaders.

This would be a huge bug for them as this is precisely how Khronos
recommends doing this (explicitly part of the preprocessor details;
GLSL is not supposed to define it whereas GLSL ES is).

cheers,
jesse

>
> - Around line 1037
> Some texture format definitions have been invalidated... For formats that are not available in OpenGL ES, they removed with macros in the C++ pre-processor.
>
>
> --
> https://code.launchpad.net/~linaro-graphics-wg/nux/nux-gles2/+merge/70279
> Your team Linaro Graphics Working Group is subscribed to branch lp:~linaro-graphics-wg/nux/nux-gles2.
>

Revision history for this message
Jay Taoko (jaytaoko) wrote :

> This would be a huge bug for them as this is precisely how Khronos
> recommends doing this (explicitly part of the preprocessor details;
> GLSL is not supposed to define it whereas GLSL ES is).
>

You are right, that would be a big bug. In my dealings with shaders I have encountered a few cases where I have come to question the support of macros with the open source driver... but I was never quite sure of what was going on... This may not be a problem anymore.

I have started a Nux branch that mixes this branch and Nux trunk. I have made some changes to get the branch to work with Unity. The most important change is that I use the C++ pre-processor to select add/remove options in shaders. For instance, if nux is being built for GLSL, the precision hint is added in opengl es fragment shaders (precision mediump float).

I will continue making changes to that branch and update it with nux trunk. I will also make sure that it works with Unity until the moment the branch is merged into nux trunk.

The branch is here: lp:~jaytaoko/nux/nux-opengles20

391. By Travis Watkins

merge with latest nux trunk

392. By Travis Watkins

sync up with jaytaoko's nux-opengles2 changes

393. By Travis Watkins

handle cases where Xinerama isn't available (thanks Jesse)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/BezierCurveControl2.cpp'
2--- Nux/BezierCurveControl2.cpp 2011-09-20 06:03:43 +0000
3+++ Nux/BezierCurveControl2.cpp 2011-10-24 21:19:23 +0000
4@@ -143,11 +143,15 @@
5
6 int X0, Y0, X1, Y1, X2, Y2;
7
8+#ifndef NUX_OPENGLES_20
9+ // GLES 2.0 doesn't support anti-aliased lines/points
10 glEnable (GL_POINT_SMOOTH);
11 glEnable (GL_LINE_SMOOTH);
12- glLineWidth (1);
13 glHint (GL_POINT_SMOOTH_HINT, GL_NICEST); // Make round points, not square points
14 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); // Antialias the lines
15+#endif
16+
17+ glLineWidth (1);
18 GfxContext.GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
19
20 for (i = 1; i < (t_u32) nsample; i++ )
21@@ -186,8 +190,10 @@
22 GetPainter().Draw2DLine (GfxContext, X0, Y0, base.x + base.GetWidth(), Y0, Color (0xFFFFFFFF) );
23 }
24
25+#ifndef NUX_OPENGLES_20
26 glDisable (GL_POINT_SMOOTH);
27 glDisable (GL_LINE_SMOOTH);
28+#endif
29 GfxContext.GetRenderStates().SetBlend (FALSE);
30
31 for (i = 0; i <= nbKnot - 1; i += CURVE_DEGREE)
32
33=== modified file 'Nux/Nux.cpp'
34--- Nux/Nux.cpp 2011-09-20 06:03:43 +0000
35+++ Nux/Nux.cpp 2011-10-24 21:19:23 +0000
36@@ -124,9 +124,15 @@
37 }
38
39 #elif defined(NUX_OS_LINUX)
40+#ifdef NUX_OPENGLES_20
41+ WindowThread *CreateFromForeignWindow (Window X11Window, EGLContext OpenGLContext,
42+ ThreadUserInitFunc UserInitFunc,
43+ void *InitData)
44+#else
45 WindowThread *CreateFromForeignWindow (Window X11Window, GLXContext OpenGLContext,
46 ThreadUserInitFunc UserInitFunc,
47 void *InitData)
48+#endif
49 {
50 if (GetWindowThread() )
51 {
52
53=== modified file 'Nux/Nux.h'
54--- Nux/Nux.h 2011-09-20 06:03:43 +0000
55+++ Nux/Nux.h 2011-10-24 21:19:23 +0000
56@@ -96,10 +96,16 @@
57 void *InitData);
58 #elif defined(NUX_OS_LINUX)
59 //! Create a main graphics thread. This thread has a window and no parent window.
60+#ifdef NUX_OPENGLES_20
61+ WindowThread *CreateFromForeignWindow (Window X11Window, EGLContext OpenGLContext,
62+ ThreadUserInitFunc UserInitFunc,
63+ void *InitData);
64+#else
65 WindowThread *CreateFromForeignWindow (Window X11Window, GLXContext OpenGLContext,
66 ThreadUserInitFunc UserInitFunc,
67 void *InitData);
68 #endif
69+#endif
70
71 // Create a window thread that is a child of the Parent. This thread has a window.
72 WindowThread *CreateWindowThread (WindowStyle WndStyle,
73
74=== modified file 'Nux/WindowThread.cpp'
75--- Nux/WindowThread.cpp 2011-09-20 06:03:43 +0000
76+++ Nux/WindowThread.cpp 2011-10-24 21:19:23 +0000
77@@ -1524,7 +1524,11 @@
78 return true;
79 }
80 #elif defined(NUX_OS_LINUX)
81+#ifdef NUX_OPENGLES_20
82+ bool WindowThread::ThreadCtor (Display *X11Display, Window X11Window, EGLContext OpenGLContext)
83+#else
84 bool WindowThread::ThreadCtor (Display *X11Display, Window X11Window, GLXContext OpenGLContext)
85+#endif
86 {
87 nuxAssertMsg (m_ThreadCtorCalled == false, TEXT ("[WindowThread::ThreadCtor] ThreadCtor should not be called more than once.") );
88 NUX_RETURN_VALUE_IF_TRUE (m_ThreadCtorCalled, true);
89
90=== modified file 'Nux/WindowThread.h'
91--- Nux/WindowThread.h 2011-09-20 06:03:43 +0000
92+++ Nux/WindowThread.h 2011-10-24 21:19:23 +0000
93@@ -261,7 +261,11 @@
94
95
96 */
97+#ifdef NUX_OPENGLES_20
98+ virtual bool ThreadCtor (Display *X11Display, Window X11Window, EGLContext OpenGLContext);
99+#else
100 virtual bool ThreadCtor (Display *X11Display, Window X11Window, GLXContext OpenGLContext);
101+#endif
102 Display *_x11display;
103 bool _ownx11display;
104 #endif
105@@ -618,10 +622,16 @@
106 ThreadUserInitFunc UserInitFunc,
107 void *InitData);
108 #elif defined(NUX_OS_LINUX)
109+#ifdef NUX_OPENGLES_20
110+ friend WindowThread *CreateFromForeignWindow (Window X11Window, EGLContext OpenGLContext,
111+ ThreadUserInitFunc UserInitFunc,
112+ void *InitData);
113+#else
114 friend WindowThread *CreateFromForeignWindow (Window X11Window, GLXContext OpenGLContext,
115 ThreadUserInitFunc UserInitFunc,
116 void *InitData);
117 #endif
118+#endif
119
120 friend SystemThread *CreateSystemThread (AbstractThread *Parent, ThreadUserInitFunc UserInitFunc, void *InitData);
121
122
123=== modified file 'Nux/nux.pc.in'
124--- Nux/nux.pc.in 2011-09-20 06:03:43 +0000
125+++ Nux/nux.pc.in 2011-10-24 21:19:23 +0000
126@@ -8,4 +8,4 @@
127 Version: @VERSION@
128 Libs: -L${libdir} -lnux-@NUX_API_VERSION@
129 Cflags: -I${includedir}/Nux-@NUX_API_VERSION@
130-Requires: glib-2.0 nux-core-@NUX_API_VERSION@ nux-image-@NUX_API_VERSION@ nux-graphics-@NUX_API_VERSION@ gl glu sigc++-2.0 glew glewmx libpcre
131+Requires: glib-2.0 nux-core-@NUX_API_VERSION@ nux-image-@NUX_API_VERSION@ nux-graphics-@NUX_API_VERSION@ @GL_PKGS@ sigc++-2.0 libpcre
132
133=== modified file 'NuxCore/FileManager/NFileManagerStandardAnsi.h'
134--- NuxCore/FileManager/NFileManagerStandardAnsi.h 2011-09-20 06:03:43 +0000
135+++ NuxCore/FileManager/NFileManagerStandardAnsi.h 2011-10-24 21:19:23 +0000
136@@ -338,15 +338,16 @@
137 {
138 time_t FileTime;
139 FileTime = FileInfo.st_mtime;
140- tm *pTime = ::gmtime (&FileTime);
141+ tm tme;
142+ errno_t err = gmtime_s(&tme, &FileTime);
143
144- Timestamp.Day = pTime->tm_mday;
145- Timestamp.DayOfWeek = pTime->tm_wday;
146- Timestamp.DayOfYear = pTime->tm_yday;
147- Timestamp.Hour = pTime->tm_hour;
148- Timestamp.Minute = pTime->tm_min;
149- Timestamp.Second = pTime->tm_sec;
150- Timestamp.Year = pTime->tm_year + 1900;
151+ Timestamp.Day = tme.tm_mday;
152+ Timestamp.DayOfWeek = tme.tm_wday;
153+ Timestamp.DayOfYear = tme.tm_yday;
154+ Timestamp.Hour = tme.tm_hour;
155+ Timestamp.Minute = tme.tm_min;
156+ Timestamp.Second = tme.tm_sec;
157+ Timestamp.Year = tme.tm_year + 1900;
158 return TRUE;
159 }
160
161
162=== modified file 'NuxCore/Logger.cpp'
163--- NuxCore/Logger.cpp 2011-09-02 19:19:56 +0000
164+++ NuxCore/Logger.cpp 2011-10-24 21:19:23 +0000
165@@ -20,10 +20,16 @@
166 *
167 */
168
169+#pragma warning(disable: 4996) // 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
170+ // 'std::_Equal1': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
171+
172+#include "NuxCore.h"
173 #include "Logger.h"
174 #include "LoggingWriter.h"
175
176+#if defined(NUX_OS_LINUX)
177 #include <execinfo.h>
178+#endif
179
180 #include <map>
181 #include <sstream>
182@@ -378,6 +384,7 @@
183 return Warning;
184 }
185
186+#if defined(NUX_OS_LINUX)
187 std::string backtrace(int levels)
188 {
189 std::ostringstream sout;
190@@ -402,7 +409,7 @@
191
192 return sout.str();
193 }
194-
195+#endif
196
197 BlockTracer::BlockTracer(Logger& logger,
198 Level level,
199
200=== modified file 'NuxCore/NuxCore.h'
201--- NuxCore/NuxCore.h 2011-09-20 06:03:43 +0000
202+++ NuxCore/NuxCore.h 2011-10-24 21:19:23 +0000
203@@ -67,7 +67,7 @@
204
205
206 // WIN32_SECURE if define for the latest version of Visual Studio starting at VS 2005. We use it for security improvement.
207-#if (defined NUX_VISUAL_STUDIO_2005) || (defined NUX_VISUAL_STUDIO_2008)
208+#if (defined NUX_VISUAL_STUDIO_2005) || (defined NUX_VISUAL_STUDIO_2008) || (defined NUX_VISUAL_STUDIO_2010)
209 #define WIN32_SECURE
210 #endif
211
212
213=== modified file 'NuxCore/ObjectPtr.h'
214--- NuxCore/ObjectPtr.h 2011-09-20 06:03:43 +0000
215+++ NuxCore/ObjectPtr.h 2011-10-24 21:19:23 +0000
216@@ -252,7 +252,7 @@
217 */
218 bool IsValid() const
219 {
220- return bool(ptr_);
221+ return (ptr_ != NULL) ? true : false;
222 }
223
224 bool operator < (T *ptr) const
225
226=== modified file 'NuxCore/System.h'
227--- NuxCore/System.h 2011-09-20 06:03:43 +0000
228+++ NuxCore/System.h 2011-10-24 21:19:23 +0000
229@@ -24,7 +24,7 @@
230 #define SYSTEM_H
231
232 #ifdef _DEBUG
233-#define NUX_DEBUG
234+ #define NUX_DEBUG
235 #endif
236
237 #ifdef _WIN32
238@@ -36,41 +36,41 @@
239 #endif
240
241 #if __GNUC__
242- #define NUX_GNUC_COMPILER
243-#if __GNUG__
244+ #define NUX_GNUC_COMPILER
245+ #if __GNUG__
246 #define NUX_GNUCPP_COMPILER
247-#else
248+ #else
249 #error Support only g++.
250-#endif
251-
252-// Compiler string.
253-#define NUX_COMPILER_STRING "GNU CPP Compiler"
254-
255-// Build string
256-#ifdef NUX_DEBUG
257+ #endif
258+
259+ // Compiler string.
260+ #define NUX_COMPILER_STRING "GNU CPP Compiler"
261+
262+ // Build string
263+ #ifdef NUX_DEBUG
264 #define NUX_BUILD_STRING "Debug build compiled with " NUX_COMPILER_STRING
265-#else
266+ #else
267 #define NUX_BUILD_STRING "Compiled with " NUX_COMPILER_STRING
268-#endif
269+ #endif
270 #endif
271
272 #if __APPLE_CC__
273-#define NUX_APPLE_COMPILER
274+ #define NUX_APPLE_COMPILER
275+#endif
276+
277+#if defined(_MSC_VER)
278+ #define NUX_MICROSOFT_COMPILER
279 #endif
280
281 #if defined(_M_X64) || defined(__amd64__) || defined(__ia64__)
282-#define NUX_ARCH_x64
283+ #define NUX_ARCH_x64
284 #elif defined(_M_IX86) || defined(__i386__)
285-#define NUX_ARCH_i386
286+ #define NUX_ARCH_i386
287 #elif defined(__arm__)
288-#define NUX_ARCH_arm
289-#elif defined(__cell)
290-#define NUX_ARCH_cell
291-#endif
292-
293-#if _MSC_VER
294-#define NUX_MICROSOFT_COMPILER
295-#endif
296+ #define NUX_ARCH_arm
297+#endif
298+
299+
300
301 // Compiler Macros:
302 // NUX_GNUCPP_COMPILER
303@@ -105,10 +105,10 @@
304 #error Support only Visual Studio Compiler.
305 #endif
306
307+#define VISUAL_STUDIO_2010_COMPILER 1600
308 #define VISUAL_STUDIO_2008_COMPILER 1500
309 #define VISUAL_STUDIO_2005_COMPILER 1400
310 #define VISUAL_STUDIO_2003_COMPILER 1310
311-#define VISUAL_STUDIO_2003_COMPILER 1310
312
313 #if _MSC_VER >= 1600
314 #define NUX_VISUAL_STUDIO_2010
315@@ -122,11 +122,11 @@
316
317 // Compiler string.
318 #if (_MSC_VER >= VISUAL_STUDIO_2008_COMPILER)
319-#define NUX_COMPILER_STRING "Visual Studio 2008"
320+ #define NUX_COMPILER_STRING "Visual Studio 2008"
321 #elif (_MSC_VER >= VISUAL_STUDIO_2005_COMPILER)
322-#define NUX_COMPILER_STRING "Visual Studio 2005"
323+ #define NUX_COMPILER_STRING "Visual Studio 2005"
324 #elif (_MSC_VER >= VISUAL_STUDIO_2003_COMPILER)
325-#define NUX_COMPILER_STRING "Visual Studio 2003"
326+ #define NUX_COMPILER_STRING "Visual Studio 2003"
327 #endif
328
329 // Build String
330@@ -177,11 +177,11 @@
331
332 // Logging
333 #if defined(NUX_OS_WINDOWS) && defined(NUX_DEBUG)
334-#define NUX_ENABLE_ASSERT_MACROS
335-#define NUX_ENABLE_LOGGING
336+ #define NUX_ENABLE_ASSERT_MACROS
337+ #define NUX_ENABLE_LOGGING
338 #elif defined(NUX_OS_LINUX) && defined(NUX_DEBUG)
339-#define NUX_ENABLE_ASSERT_MACROS
340-#define NUX_ENABLE_LOGGING
341+ #define NUX_ENABLE_ASSERT_MACROS
342+ #define NUX_ENABLE_LOGGING
343 #endif
344
345 // NOP: no operation
346@@ -190,21 +190,21 @@
347 // debug functions that take a variable number of arguments.
348
349 #if defined(NUX_MICROSOFT_COMPILER)
350- #define NUX_COMPILER_SUPPORTS_NOOP
351- #define NUX_NOOP __noop
352+ #define NUX_COMPILER_SUPPORTS_NOOP
353+ #define NUX_NOOP __noop
354 #elif defined(NUX_GNUCPP_COMPILER)
355- #define NUX_COMPILER_SUPPORTS_NOOP
356- #define NUX_NOOP __asm__("nop")
357+ #define NUX_COMPILER_SUPPORTS_NOOP
358+ #define NUX_NOOP __asm__("nop")
359 #endif
360
361 // Pragma pack support
362 #if defined(NUX_MICROSOFT_COMPILER) || defined(NUX_GNUCPP_COMPILER)
363- #define NUX_SUPPORTS_PRAGMA_PACK
364+ #define NUX_SUPPORTS_PRAGMA_PACK
365 #endif
366
367
368 // Define variadic macro support
369-#if defined(NUX_MICROSOFT_COMPILER) && (defined(NUX_VISUAL_STUDIO_2005) || defined(NUX_VISUAL_STUDIO_2008))
370+#if defined(NUX_MICROSOFT_COMPILER) && (defined(NUX_VISUAL_STUDIO_2005) || defined(NUX_VISUAL_STUDIO_2008) || defined(NUX_VISUAL_STUDIO_2010))
371 #define NUX_VARIADIC_MACROS_SUPPORT
372 #elif defined(NUX_GNUCPP_COMPILER)
373 #define NUX_VARIADIC_MACROS_SUPPORT
374
375=== modified file 'NuxGraphics/FontRenderer.cpp'
376--- NuxGraphics/FontRenderer.cpp 2011-09-20 06:03:43 +0000
377+++ NuxGraphics/FontRenderer.cpp 2011-10-24 21:19:23 +0000
378@@ -41,7 +41,7 @@
379 // - declare the vertex attribute name before any other attribute.
380 // - Give the vertex attribute a name that comes before any other attribute name. For instance prefix the vertex attribute name with "_".
381
382- NString gFontVtxShader = TEXT ("#version 110 \n\
383+ NString gFontVtxShader = TEXT (" \n\
384 attribute vec4 _Position; \n\
385 attribute vec4 iOffset; \n\
386 attribute vec4 iScale; \n\
387@@ -55,14 +55,29 @@
388 gl_Position = ViewProjectionMatrix * myvertex; \n\
389 }");
390
391- NString gFontFragShader = TEXT ("#version 110 \n\
392+ NString gFontFragShader = TEXT (" \n\
393 #extension GL_ARB_texture_rectangle : enable \n\
394- uniform sampler2DRect FontTexture; \n\
395+ #ifdef GL_ES \n\
396+ precision mediump float; \n\
397+ #endif \n\
398 uniform vec4 TextColor; \n\
399 varying vec4 oTexCoord0; \n\
400+ #ifdef SAMPLERTEX2D \n\
401+ uniform sampler2D FontTexture; \n\
402+ vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
403+ { \n\
404+ return texture2D(TexObject, TexCoord.st); \n\
405+ } \n\
406+ #elif defined SAMPLERTEX2DRECT \n\
407+ uniform sampler2DRect FontTexture; \n\
408+ vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
409+ { \n\
410+ return texture2DRect(TexObject, TexCoord.st); \n\
411+ } \n\
412+ #endif \n\
413 void main() \n\
414 { \n\
415- vec4 diffuse = texture2DRect(FontTexture, oTexCoord0.st); \n\
416+ vec4 diffuse = SampleTexture(FontTexture, oTexCoord0); \n\
417 gl_FragColor = vec4(TextColor.x, TextColor.y, TextColor.z, diffuse.w); \n\
418 }");
419
420@@ -112,7 +127,11 @@
421 _shader_prog = GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram();
422
423 _vertex_shader_prog->SetShaderCode (TCHAR_TO_ANSI (*gFontVtxShader) );
424- _pixel_shader_prog->SetShaderCode (TCHAR_TO_ANSI (*gFontFragShader) );
425+#ifndef NUX_OPENGLES_20
426+ _pixel_shader_prog->SetShaderCode (TCHAR_TO_ANSI (*gFontFragShader), TEXT ("#define SAMPLERTEX2DRECT") );
427+#else
428+ _pixel_shader_prog->SetShaderCode (TCHAR_TO_ANSI (*gFontFragShader), TEXT ("#define SAMPLERTEX2D") );
429+#endif
430
431 _shader_prog->ClearShaderObjects();
432 _shader_prog->AddShaderObject (_vertex_shader_prog);
433@@ -296,6 +315,7 @@
434 _graphics_engine.GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
435 _graphics_engine.GetRenderStates().SetColorMask (TRUE, TRUE, TRUE, WriteAlphaChannel); // Do not write the alpha of characters
436
437+ GLshort *Index = new GLshort[StrLength*6];
438 Vector4 *Position = new Vector4[StrLength*4];
439 Vector4 *UV = new Vector4[StrLength*4];
440 Vector4 *Offset = new Vector4[StrLength*4];
441@@ -410,6 +430,15 @@
442 }
443 }
444
445+ // Set up element array indices
446+ Index[i*6 + 0] = i*4;
447+ Index[i*6 + 1] = i*4 + 2;
448+ Index[i*6 + 2] = i*4 + 3;
449+
450+ Index[i*6 + 3] = i*4;
451+ Index[i*6 + 4] = i*4 + 1;
452+ Index[i*6 + 5] = i*4 + 2;
453+
454 CurX += abcA + abcB + abcC;
455 }
456
457@@ -450,6 +479,7 @@
458 CHECKGL(glUniform4fARB(TextColor, color.red, color.green, color.blue, color.alpha));
459 }
460 }
461+#ifndef NUX_OPENGLES_20
462 else
463 {
464 shader_program = _asm_shader_prog;
465@@ -480,6 +510,7 @@
466
467 _graphics_engine.SetTexture (GL_TEXTURE0, glTexture->m_Texture);
468 }
469+#endif
470
471 if (in_attrib_offset != -1)
472 {
473@@ -506,7 +537,7 @@
474 }
475
476 if (NumCharToDraw > 0)
477- CHECKGL ( glDrawArrays ( GL_QUADS, 0, NumCharToDraw * 4 ) );
478+ CHECKGL ( glDrawElements ( GL_TRIANGLES, NumCharToDraw * 6, GL_UNSIGNED_SHORT, Index ) );
479
480 if (in_attrib_position != -1)
481 CHECKGL ( glDisableVertexAttribArrayARB (in_attrib_position) );
482@@ -534,6 +565,7 @@
483
484 CurX -= x + CURSOR_OFFSET;
485
486+ delete [] Index;
487 delete [] Position;
488 delete [] UV;
489 delete [] Scale;
490
491=== modified file 'NuxGraphics/FontTexture.cpp'
492--- NuxGraphics/FontTexture.cpp 2011-09-20 06:03:43 +0000
493+++ NuxGraphics/FontTexture.cpp 2011-10-24 21:19:23 +0000
494@@ -221,7 +221,12 @@
495 NString font_texture_file = GNuxGraphicsResources.FindResourceLocation (texture);
496 #endif
497
498+#ifdef NUX_OPENGLES_20
499+ Texture2D *Texture = new Texture2D (NUX_TRACKER_LOCATION);
500+#else
501 TextureRectangle *Texture = new TextureRectangle (NUX_TRACKER_LOCATION);
502+#endif
503+
504 NBitmapData* bitmap_data = LoadImageFile(font_texture_file.GetTCharPtr ());
505
506 if (bitmap_data)
507
508=== modified file 'NuxGraphics/GLDeviceFrameBufferObject.cpp'
509--- NuxGraphics/GLDeviceFrameBufferObject.cpp 2011-04-06 21:54:09 +0000
510+++ NuxGraphics/GLDeviceFrameBufferObject.cpp 2011-10-24 21:19:23 +0000
511@@ -37,9 +37,11 @@
512 GLenum AttachmentBuffer[] =
513 {
514 GL_COLOR_ATTACHMENT0_EXT
515+#ifndef NUX_OPENGLES_20 // GLES 2.0 only supports one color attachment
516 , GL_COLOR_ATTACHMENT1_EXT
517 , GL_COLOR_ATTACHMENT2_EXT
518 , GL_COLOR_ATTACHMENT3_EXT
519+#endif
520 };
521
522 //////////////////////////////////////////////////////////////////////////
523@@ -148,9 +150,13 @@
524
525 GLint GLFramebufferObject::GetMaxColorAttachments()
526 {
527+#ifndef NUX_OPENGLES_20
528 GLint maxAttach = 0;
529 CHECKGL ( glGetIntegerv ( GL_MAX_COLOR_ATTACHMENTS_EXT, &maxAttach ) );
530 return maxAttach;
531+#else
532+ return 1;
533+#endif
534 }
535
536 GLuint GLFramebufferObject::_GenerateFboId()
537@@ -171,7 +177,13 @@
538 CHECKGL ( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, m_fboId) );
539 }
540 #else
541- CHECKGL ( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, m_fboId) );
542+ // Only binds if m_fboId is different than the currently bound FBO
543+ CHECKGL ( glGetIntegerv ( GL_FRAMEBUFFER_BINDING_EXT, &m_savedFboId ) );
544+
545+ if (m_fboId != m_savedFboId)
546+ {
547+ CHECKGL ( glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId) );
548+ }
549 #endif
550 }
551
552@@ -195,6 +207,7 @@
553 CHECKGL ( glFramebufferTexture2DEXT ( GL_FRAMEBUFFER_EXT, attachment,
554 texType, texId, mipLevel ) );
555 }
556+#ifndef NUX_OPENGLES_20
557 else if (texType == GL_TEXTURE_1D)
558 {
559 CHECKGL ( glFramebufferTexture1DEXT ( GL_FRAMEBUFFER_EXT, attachment,
560@@ -205,6 +218,7 @@
561 CHECKGL ( glFramebufferTexture3DEXT ( GL_FRAMEBUFFER_EXT, attachment,
562 GL_TEXTURE_3D, texId, mipLevel, zSlice ) );
563 }
564+#endif
565 }
566
567 bool GLFramebufferObject::IsValid()
568@@ -239,6 +253,7 @@
569 nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT") );
570 isOK = false;
571 break;
572+#ifndef NUX_OPENGLES_20
573 case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
574 nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT") );
575 isOK = false;
576@@ -251,6 +266,7 @@
577 nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT") );
578 isOK = false;
579 break;
580+#endif
581 // case GL_FRAMEBUFFER_STATUS_ERROR_EXT:
582 // nuxError(TEXT("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_STATUS_ERROR_EXT"));
583 // isOK = false;
584@@ -307,9 +323,11 @@
585 {
586 _GuardedBind();
587 GLint level = 0;
588+#ifndef NUX_OPENGLES_20
589 CHECKGL ( glGetFramebufferAttachmentParameterivEXT (GL_FRAMEBUFFER_EXT, attachment,
590 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT,
591 &level) );
592+#endif
593 _GuardedUnbind();
594 return level;
595 }
596@@ -318,9 +336,11 @@
597 {
598 _GuardedBind();
599 GLint slice = 0;
600+#ifndef NUX_OPENGLES_20
601 CHECKGL ( glGetFramebufferAttachmentParameterivEXT (GL_FRAMEBUFFER_EXT, attachment,
602 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT,
603 &slice) );
604+#endif
605 _GuardedUnbind();
606 return slice;
607 }
608
609=== modified file 'NuxGraphics/GLError.cpp'
610--- NuxGraphics/GLError.cpp 2011-04-06 21:54:09 +0000
611+++ NuxGraphics/GLError.cpp 2011-10-24 21:19:23 +0000
612@@ -49,12 +49,14 @@
613 case GL_INVALID_OPERATION:
614 nuxWarningMsg (TEXT ("[CheckGLError] GL_INVALID_OPERATION error in File %s at line: %d"), file, line);
615 break;
616+#ifndef NUX_OPENGLES_20
617 case GL_STACK_OVERFLOW:
618 nuxWarningMsg (TEXT ("[CheckGLError] GL_STACK_OVERFLOW error in File %s at line: %d"), file, line);
619 break;
620 case GL_STACK_UNDERFLOW:
621 nuxWarningMsg (TEXT ("[CheckGLError] GL_STACK_UNDERFLOW error in File %s at line: %d"), file, line);
622 break;
623+#endif
624 case GL_OUT_OF_MEMORY:
625 nuxWarningMsg (TEXT ("[CheckGLError] GL_OUT_OF_MEMORY error in File %s at line: %d"), file, line);
626 break;
627@@ -62,7 +64,9 @@
628 nuxWarningMsg (TEXT ("[CheckGLError] UNKNOWN ERROR in File %s at line: %d"), file, line);
629 }
630
631+#ifndef NUX_OPENGLES_20
632 nuxWarningMsg (TEXT ("[CheckGLError] OpenGL Error %d ( %s ) in File %s at line: %d \n"), glErr, ANSI_TO_TCHAR (gluErrorString (glErr) ), ANSI_TO_TCHAR (file), line);
633+#endif
634 retCode = 1;
635
636 #ifdef NUX_DEBUG
637
638=== modified file 'NuxGraphics/GLPBuffer.cpp'
639--- NuxGraphics/GLPBuffer.cpp 2011-09-20 06:03:43 +0000
640+++ NuxGraphics/GLPBuffer.cpp 2011-10-24 21:19:23 +0000
641@@ -19,6 +19,7 @@
642 *
643 */
644
645+#ifndef NUX_OPENGLES_20
646
647 #include "NuxCore/NuxCore.h"
648 #include "GLResource.h"
649@@ -1059,3 +1060,6 @@
650 }
651
652 }
653+
654+#endif // NUX_OPENGLES_20
655+
656
657=== modified file 'NuxGraphics/GLPBuffer.h'
658--- NuxGraphics/GLPBuffer.h 2011-04-06 21:54:09 +0000
659+++ NuxGraphics/GLPBuffer.h 2011-10-24 21:19:23 +0000
660@@ -23,6 +23,8 @@
661 #ifndef __PBUFFERS_H__
662 #define __PBUFFERS_H__
663
664+#ifndef NUX_OPENGLES_20
665+
666 #if defined(WIN32)
667 #include "GLResource.h"
668
669@@ -172,4 +174,6 @@
670 };
671 }
672
673+#endif // NUX_OPENGLES_20
674+
675 #endif // __PBUFFERS_H__
676
677=== modified file 'NuxGraphics/GLRenderStates.cpp'
678--- NuxGraphics/GLRenderStates.cpp 2011-04-06 21:54:09 +0000
679+++ NuxGraphics/GLRenderStates.cpp 2011-10-24 21:19:23 +0000
680@@ -40,8 +40,10 @@
681 default_render_state[GFXRS_##state__].Checked = checked__; \
682
683
684+#ifndef NUX_OPENGLES_20
685 UL_MAP (FRONT_POLYGONMODE , GL_FILL , 1);
686 UL_MAP (BACK_POLYGONMODE , GL_FILL , 1);
687+#endif
688 UL_MAP (CULLFACEENABLE , GL_FALSE , 1);
689 UL_MAP (CULLFACE , GL_BACK , 1);
690 UL_MAP (FRONTFACE , GL_CCW , 1);
691
692=== modified file 'NuxGraphics/GLRenderStates.h'
693--- NuxGraphics/GLRenderStates.h 2011-09-20 06:03:43 +0000
694+++ NuxGraphics/GLRenderStates.h 2011-10-24 21:19:23 +0000
695@@ -256,7 +256,11 @@
696
697 inline void EnableScissor (t_u32 bScissor = FALSE);
698 inline void EnableFog (t_u32 bFog = FALSE);
699+#ifndef NUX_OPENGLES_20
700 inline void SetPolygonMode (t_u32 FrontMode = GL_FILL, t_u32 BackMode = GL_FILL);
701+#else
702+ inline void SetPolygonMode (t_u32 FrontMode, t_u32 BackMode);
703+#endif
704
705 inline void SetPolygonOffset (t_u32 bEnable,
706 float Factor = 0.0f, float Units = 0.0f);
707@@ -852,6 +856,7 @@
708 //////////////////////////////////////
709 inline void GpuRenderStates::HW__EnableAlphaTest (t_u32 b)
710 {
711+#ifndef NUX_OPENGLES_20
712 if (b)
713 {
714 CHECKGL (glEnable (GL_ALPHA_TEST) );
715@@ -862,11 +867,13 @@
716 }
717
718 SET_RS_VALUE (m_RenderStateChanges[GFXRS_ALPHATESTENABLE], b ? GL_TRUE : GL_FALSE);
719+#endif
720 }
721
722 inline void GpuRenderStates::HW__SetAlphaTestFunc (t_u32 AlphaTestFunc_,
723 BYTE AlphaTestRef_)
724 {
725+#ifndef NUX_OPENGLES_20
726 nuxAssertMsg (
727 (AlphaTestFunc_ == GL_NEVER) ||
728 (AlphaTestFunc_ == GL_LESS) ||
729@@ -881,6 +888,7 @@
730 CHECKGL (glAlphaFunc (AlphaTestFunc_, (float) AlphaTestRef_ * (1.0f / 255.0f) ) );
731 SET_RS_VALUE (m_RenderStateChanges[GFXRS_ALPHATESTFUNC], AlphaTestFunc_);
732 SET_RS_VALUE (m_RenderStateChanges[GFXRS_ALPHATESTREF], AlphaTestRef_);
733+#endif
734 }
735
736 inline void GpuRenderStates::HW__EnableAlphaBlend (t_u32 b)
737@@ -928,6 +936,21 @@
738 t_u32 BlendOpRGB_,
739 t_u32 BlendOpAlpha_)
740 {
741+#ifdef NUX_OPENGLES_20
742+ nuxAssertMsg (
743+ (BlendOpRGB_ == GL_FUNC_ADD) ||
744+ (BlendOpRGB_ == GL_FUNC_SUBTRACT) ||
745+ (BlendOpRGB_ == GL_FUNC_REVERSE_SUBTRACT),
746+ TEXT ("Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState") );
747+ nuxAssertMsg (
748+ (BlendOpAlpha_ == GL_FUNC_ADD) ||
749+ (BlendOpAlpha_ == GL_FUNC_SUBTRACT) ||
750+ (BlendOpAlpha_ == GL_FUNC_REVERSE_SUBTRACT),
751+ TEXT ("Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState") );
752+
753+ CHECKGL (glBlendEquationSeparate (BlendOpRGB_, BlendOpAlpha_) );
754+
755+#else
756 nuxAssertMsg (
757 (BlendOpRGB_ == GL_FUNC_ADD) ||
758 (BlendOpRGB_ == GL_FUNC_SUBTRACT) ||
759@@ -955,6 +978,7 @@
760 {
761 CHECKGL (glBlendEquation (BlendOpRGB_) );
762 }
763+#endif
764
765 SET_RS_VALUE (m_RenderStateChanges[GFXRS_BLENDOP], BlendOpRGB_);
766 SET_RS_VALUE (m_RenderStateChanges[GFXRS_BLENDOPALPHA], BlendOpAlpha_);
767@@ -1318,6 +1342,7 @@
768
769 inline void GpuRenderStates::HW__EnableLineSmooth (t_u32 EnableLineSmooth)
770 {
771+#ifndef NUX_OPENGLES_20
772 if (EnableLineSmooth)
773 {
774 CHECKGL (glEnable (GL_LINE_SMOOTH) );
775@@ -1328,6 +1353,7 @@
776 }
777
778 SET_RS_VALUE (m_RenderStateChanges[GFXRS_LINESMOOTHENABLE], EnableLineSmooth ? GL_TRUE : GL_FALSE);
779+#endif
780 }
781
782 inline void GpuRenderStates::HW__SetLineWidth (t_u32 width, t_u32 Hint)
783@@ -1339,13 +1365,17 @@
784 TEXT ("Error(HW__SetLineWidth): Invalid Line Hint RenderState") );
785
786 CHECKGL (glLineWidth (width) );
787+ SET_RS_VALUE (m_RenderStateChanges[GFXRS_LINEWIDTH], width);
788+
789+#ifndef NUX_OPENGLES_20
790 CHECKGL (glHint (GL_LINE_SMOOTH_HINT, Hint) );
791- SET_RS_VALUE (m_RenderStateChanges[GFXRS_LINEWIDTH], width);
792 SET_RS_VALUE (m_RenderStateChanges[GFXRS_LINEHINT], Hint);
793+#endif
794 }
795
796 inline void GpuRenderStates::HW__EnablePointSmooth (t_u32 EnablePointSmooth)
797 {
798+#ifndef NUX_OPENGLES_20
799 if (EnablePointSmooth)
800 {
801 CHECKGL (glEnable (GL_POINT_SMOOTH) );
802@@ -1356,10 +1386,12 @@
803 }
804
805 SET_RS_VALUE (m_RenderStateChanges[GFXRS_POINTSMOOTHENABLE], EnablePointSmooth ? GL_TRUE : GL_FALSE);
806+#endif
807 }
808
809 inline void GpuRenderStates::HW__SetPointSize (t_u32 size, t_u32 Hint)
810 {
811+#ifndef NUX_OPENGLES_20
812 nuxAssertMsg (
813 (Hint == GL_NICEST) ||
814 (Hint == GL_FASTEST) ||
815@@ -1370,6 +1402,7 @@
816 CHECKGL (glHint (GL_POINT_SMOOTH_HINT, Hint);)
817 SET_RS_VALUE (m_RenderStateChanges[GFXRS_POINTSIZE], size);
818 SET_RS_VALUE (m_RenderStateChanges[GFXRS_POINTHINT], Hint);
819+#endif
820 }
821
822 inline void GpuRenderStates::HW__SetColorMask (
823@@ -1407,6 +1440,7 @@
824
825 inline void GpuRenderStates::HW__EnableFog (t_u32 bFog)
826 {
827+#ifndef NUX_OPENGLES_20
828 if (bFog)
829 {
830 CHECKGL (glEnable (GL_FOG) );
831@@ -1417,10 +1451,12 @@
832 }
833
834 SET_RS_VALUE (m_RenderStateChanges[GFXRS_FOGENABLE], bFog ? GL_TRUE : GL_FALSE);
835+#endif
836 }
837
838 inline void GpuRenderStates::HW__SetPolygonMode (t_u32 FrontMode, t_u32 BackMode)
839 {
840+#ifndef NUX_OPENGLES_20
841 nuxAssertMsg (
842 (FrontMode == GL_FILL) ||
843 (FrontMode == GL_LINE) ||
844@@ -1438,6 +1474,7 @@
845
846 SET_RS_VALUE (m_RenderStateChanges[GFXRS_FRONT_POLYGONMODE], FrontMode);
847 SET_RS_VALUE (m_RenderStateChanges[GFXRS_BACK_POLYGONMODE], BackMode);
848+#endif
849 }
850
851 inline void GpuRenderStates::HW__EnablePolygonOffset (t_u32 EnablePolygonOffset)
852
853=== modified file 'NuxGraphics/GLResource.cpp'
854--- NuxGraphics/GLResource.cpp 2011-09-20 06:03:43 +0000
855+++ NuxGraphics/GLResource.cpp 2011-10-24 21:19:23 +0000
856@@ -171,6 +171,7 @@
857 break;
858 }
859
860+#ifndef NUX_OPENGLES_20
861 case ATTRIB_DECLTYPE_FLOAT16_2:
862 {
863 NumComponent = 2;
864@@ -183,6 +184,7 @@
865 ComponentType = ATTRIB_CT_HALF_FLOAT;
866 break;
867 }
868+#endif
869
870 case ATTRIB_DECLTYPE_UNUSED:
871 default:
872@@ -212,10 +214,12 @@
873 case ATTRIB_CT_UNSIGNED_INT:
874 case ATTRIB_CT_FLOAT:
875 return 4 * NumComponent;
876+#ifndef NUX_OPENGLES_20
877 case ATTRIB_CT_HALF_FLOAT:
878 return 2 * NumComponent;
879 case ATTRIB_CT_DOUBLE:
880 return 8 * NumComponent;
881+#endif
882 case ATTRIB_CT_UNKNOWN:
883 default:
884 nuxAssert (TEXT ("Unknown Component Type") );
885@@ -263,10 +267,12 @@
886 return InPrimitiveCount + 2;
887 case PRIMITIVE_TYPE_TRIANGLEFAN:
888 return InPrimitiveCount;
889+#ifndef NUX_OPENGLES_20
890 case PRIMITIVE_TYPE_QUADLIST:
891 return InPrimitiveCount * 4;
892 case PRIMITIVE_TYPE_QUADSTRIP:
893 return InPrimitiveCount * 2 + 2;
894+#endif
895 default:
896 return 0;
897 }
898
899=== modified file 'NuxGraphics/GLResource.h'
900--- NuxGraphics/GLResource.h 2011-09-20 06:03:43 +0000
901+++ NuxGraphics/GLResource.h 2011-10-24 21:19:23 +0000
902@@ -89,11 +89,14 @@
903 #elif defined(NUX_OS_LINUX)
904
905 #ifdef NUX_OPENGLES_20
906- #ifndef GLEW_MX
907- #define GLEW_MX
908- #endif
909+ #include "NuxGraphics/OpenGLMapping.h"
910 #include "EGL/egl.h"
911 #include "GLES2/gl2.h"
912+ #include "GLES2/gl2ext.h"
913+ // Explicitly include X11 headers as many EGL implementations don't
914+ // do it for us.
915+ #include <X11/Xlib.h>
916+ #include <X11/Xutil.h>
917 #else
918 #ifndef GLEW_MX
919 #define GLEW_MX
920@@ -153,6 +156,7 @@
921
922 //if(Result!=OGL_OK) {nuxError(TEXT("OGL Object Error: Error # %d - %s"), Result, OGLDeviceErrorMessages[Result]);}
923
924+#ifndef NUX_OPENGLES_20
925 enum TEXTURE_FORMAT
926 {
927 TEXTURE_FMT_UNKNOWN = 0,
928@@ -193,6 +197,24 @@
929 TEXTURE_FMT_COMPRESSED_RGBA_S3TC_DXT5_EXT = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
930 TEXTURE_FMT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
931 };
932+#else
933+
934+ enum TEXTURE_FORMAT
935+ {
936+ TEXTURE_FMT_UNKNOWN = 0,
937+ TEXTURE_FMT_ALPHA = GL_ALPHA,
938+
939+ TEXTURE_FMT_LUMINANCE = GL_LUMINANCE,
940+ TEXTURE_FMT_LUMINANCE_ALPHA = GL_LUMINANCE_ALPHA,
941+
942+ TEXTURE_FMT_GL_DEPTH_COMPONENT = GL_DEPTH_COMPONENT,
943+
944+ TEXTURE_FMT_RGBA = GL_RGBA,
945+ TEXTURE_FMT_RGB = GL_RGB,
946+
947+ TEXTURE_FMT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
948+ };
949+#endif
950
951 struct PixelFormatReadInfo
952 {
953@@ -242,8 +264,10 @@
954 PRIMITIVE_TYPE_TRIANGLELIST = GL_TRIANGLES,
955 PRIMITIVE_TYPE_TRIANGLESTRIP = GL_TRIANGLE_STRIP,
956 PRIMITIVE_TYPE_TRIANGLEFAN = GL_TRIANGLE_FAN,
957+#ifndef NUX_OPENGLES_20
958 PRIMITIVE_TYPE_QUADLIST = GL_QUADS,
959 PRIMITIVE_TYPE_QUADSTRIP = GL_QUAD_STRIP,
960+#endif
961 PRIMITIVE_TYPE_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
962 } PRIMITIVE_TYPE;
963
964@@ -438,11 +462,13 @@
965 ATTRIB_CT_INT = GL_INT,
966 ATTRIB_CT_UNSIGNED_INT = GL_UNSIGNED_INT,
967 ATTRIB_CT_FLOAT = GL_FLOAT,
968+#ifndef NUX_OPENGLES_20
969 ATTRIB_CT_HALF_FLOAT = GL_HALF_FLOAT_ARB,
970 // ATTRIB_CT_2_BYTES = GL_2_BYTES,
971 // ATTRIB_CT_3_BYTES = GL_3_BYTES,
972 // ATTRIB_CT_4_BYTES = GL_4_BYTES,
973 ATTRIB_CT_DOUBLE = GL_DOUBLE,
974+#endif
975 // Type can be GL_UNSIGNED_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE
976 ATTRIB_CT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
977 } ATTRIB_COMPONENT_TYPE;
978
979=== modified file 'NuxGraphics/GLSh_ColorPicker.cpp'
980--- NuxGraphics/GLSh_ColorPicker.cpp 2011-09-20 06:03:43 +0000
981+++ NuxGraphics/GLSh_ColorPicker.cpp 2011-10-24 21:19:23 +0000
982@@ -40,7 +40,7 @@
983 // Use assembly shaders for Intel GPUs: ARB_fragment_program does not have the required
984 // instruction to implement the HSV to RGB color conversion.
985
986- static NString VtxShader = TEXT ("#version 110 \n\
987+ static NString VtxShader = TEXT (" \n\
988 uniform mat4 ViewProjectionMatrix; \n\
989 attribute vec4 AVertex; \n\
990 attribute vec4 VertexColor; \n\
991@@ -49,7 +49,10 @@
992 gl_Position = ViewProjectionMatrix * AVertex; \n\
993 }");
994
995- static NString RedFrgShader = TEXT ("#version 110 \n\
996+ static NString RedFrgShader = TEXT (" \n\
997+ #ifdef GL_ES \n\
998+ precision mediump float; \n\
999+ #endif \n\
1000 uniform vec4 RectPosition; \n\
1001 uniform vec4 RectDimension; \n\
1002 uniform vec4 Color; \n\
1003@@ -60,7 +63,10 @@
1004 gl_FragColor = vec4(Color.r, y, x, 1.0); \n\
1005 }");
1006
1007- static NString GreenFrgShader = TEXT ("#version 110 \n\
1008+ static NString GreenFrgShader = TEXT (" \n\
1009+ #ifdef GL_ES \n\
1010+ precision mediump float; \n\
1011+ #endif \n\
1012 uniform vec4 RectPosition; \n\
1013 uniform vec4 RectDimension; \n\
1014 uniform vec4 Color; \n\
1015@@ -71,7 +77,10 @@
1016 gl_FragColor = vec4(y, Color.g, x, 1.0); \n\
1017 }");
1018
1019- static NString BlueFrgShader = TEXT ("#version 110 \n\
1020+ static NString BlueFrgShader = TEXT (" \n\
1021+ #ifdef GL_ES \n\
1022+ precision mediump float; \n\
1023+ #endif \n\
1024 uniform vec4 RectPosition; \n\
1025 uniform vec4 RectDimension; \n\
1026 uniform vec4 Color; \n\
1027@@ -82,7 +91,10 @@
1028 gl_FragColor = vec4(x, y, Color.b, 1.0); \n\
1029 }");
1030
1031- static NString HueFrgShader = TEXT ("#version 110 \n\
1032+ static NString HueFrgShader = TEXT (" \n\
1033+ #ifdef GL_ES \n\
1034+ precision mediump float; \n\
1035+ #endif \n\
1036 vec3 HSV_To_RGB(vec3 HSV); \n\
1037 uniform vec4 RectPosition; \n\
1038 uniform vec4 RectDimension; \n\
1039@@ -95,7 +107,10 @@
1040 gl_FragColor = vec4(rgb, 1.0); \n\
1041 }");
1042
1043- static NString SaturationFrgShader = TEXT ("#version 110 \n\
1044+ static NString SaturationFrgShader = TEXT (" \n\
1045+ #ifdef GL_ES \n\
1046+ precision mediump float; \n\
1047+ #endif \n\
1048 vec3 HSV_To_RGB(vec3 HSV); \n\
1049 uniform vec4 RectPosition; \n\
1050 uniform vec4 RectDimension; \n\
1051@@ -108,7 +123,10 @@
1052 gl_FragColor = vec4(rgb, 1.0); \n\
1053 }");
1054
1055- static NString ValueFrgShader = TEXT ("#version 110 \n\
1056+ static NString ValueFrgShader = TEXT (" \n\
1057+ #ifdef GL_ES \n\
1058+ precision mediump float; \n\
1059+ #endif \n\
1060 vec3 HSV_To_RGB(vec3 HSV); \n\
1061 uniform vec4 RectPosition; \n\
1062 uniform vec4 RectDimension; \n\
1063@@ -121,7 +139,10 @@
1064 gl_FragColor = vec4(rgb, 1.0); \n\
1065 }");
1066
1067- static NString HSV_To_RGBFrgShader = TEXT ("#version 110 \n\
1068+ static NString HSV_To_RGBFrgShader = TEXT (" \n\
1069+ #ifdef GL_ES \n\
1070+ precision mediump float; \n\
1071+ #endif \n\
1072 vec3 HSV_To_RGB(vec3 HSV) \n\
1073 { \n\
1074 vec3 RGB = vec3(HSV.z); \n\
1075
1076=== modified file 'NuxGraphics/GLSh_DrawFunction.cpp'
1077--- NuxGraphics/GLSh_DrawFunction.cpp 2011-09-20 06:03:43 +0000
1078+++ NuxGraphics/GLSh_DrawFunction.cpp 2011-10-24 21:19:23 +0000
1079@@ -32,7 +32,7 @@
1080 namespace nux
1081 {
1082
1083- static NString VtxShader = TEXT ("#version 110 \n\
1084+ static NString VtxShader = TEXT (" \n\
1085 uniform mat4 ViewProjectionMatrix; \n\
1086 attribute vec4 AVertex; \n\
1087 attribute vec4 VertexColor; \n\
1088@@ -41,7 +41,10 @@
1089 gl_Position = ViewProjectionMatrix * AVertex; \n\
1090 }");
1091
1092- static NString FrgShader = TEXT ("#version 110 \n\
1093+ static NString FrgShader = TEXT (" \n\
1094+ #ifdef GL_ES \n\
1095+ precision mediump float; \n\
1096+ #endif \n\
1097 uniform sampler2D TextureFunction; \n\
1098 uniform vec4 RectPosition; \n\
1099 uniform vec4 RectDimension; \n\
1100
1101=== modified file 'NuxGraphics/GLTextureStates.cpp'
1102--- NuxGraphics/GLTextureStates.cpp 2011-04-06 21:54:09 +0000
1103+++ NuxGraphics/GLTextureStates.cpp 2011-10-24 21:19:23 +0000
1104@@ -75,6 +75,7 @@
1105
1106 void GLTextureStates::SetType (GLuint Type)
1107 {
1108+#ifndef NUX_OPENGLES_20
1109 nuxAssertMsg (
1110 (Type == GL_TEXTURE_1D) ||
1111 (Type == GL_TEXTURE_2D) ||
1112@@ -82,6 +83,11 @@
1113 (Type == GL_TEXTURE_3D) ||
1114 (Type == GL_TEXTURE_CUBE_MAP_ARB),
1115 TEXT ("Error[GLTextureStates::GLTextureStates]: Invalid texture type.") );
1116+#else
1117+ nuxAssertMsg (
1118+ (Type == GL_TEXTURE_2D),
1119+ TEXT ("Error[GLTextureStates::GLTextureStates]: Invalid texture type.") );
1120+#endif
1121
1122 m_Type = Type;
1123 }
1124@@ -130,7 +136,9 @@
1125 {
1126 CHECKGL ( glTexParameteri (m_Type, GL_TEXTURE_WRAP_S, m_TextureStateChanges[GFXTS_ADDRESSU].iValue) );
1127 CHECKGL ( glTexParameteri (m_Type, GL_TEXTURE_WRAP_T, m_TextureStateChanges[GFXTS_ADDRESSV].iValue) );
1128+#ifndef NUX_OPENGLES_20
1129 CHECKGL ( glTexParameteri (m_Type, GL_TEXTURE_WRAP_R, m_TextureStateChanges[GFXTS_ADDRESSW].iValue) );
1130+#endif
1131 m_TextureStateChanges[GFXTS_ADDRESSU].Dirty = false;
1132 m_TextureStateChanges[GFXTS_ADDRESSV].Dirty = false;
1133 m_TextureStateChanges[GFXTS_ADDRESSW].Dirty = false;
1134@@ -139,6 +147,7 @@
1135
1136 void GLTextureStates::HW_SetLOD()
1137 {
1138+#ifndef NUX_OPENGLES_20
1139 if (m_Type == GL_TEXTURE_RECTANGLE_ARB)
1140 {
1141 // No support for mip LOP on rectangle texture.
1142@@ -156,10 +165,12 @@
1143 m_TextureStateChanges[GFXTS_MIN_LOD].Dirty = false;
1144 m_TextureStateChanges[GFXTS_MAX_LOD].Dirty = false;
1145 }
1146+#endif
1147 }
1148
1149 void GLTextureStates::HW_SetMipLevel()
1150 {
1151+#ifndef NUX_OPENGLES_20
1152 if (m_TextureStateChanges[GFXTS_MIN_LOD].Dirty || m_TextureStateChanges[GFXTS_MAX_LOD].Dirty)
1153 {
1154 CHECKGL ( glTexParameteri (m_Type, GL_TEXTURE_MIN_LOD, m_TextureStateChanges[GFXTS_MIN_LOD].fValue) );
1155@@ -167,6 +178,7 @@
1156 m_TextureStateChanges[GFXTS_MIN_LOD].Dirty = false;
1157 m_TextureStateChanges[GFXTS_MAX_LOD].Dirty = false;
1158 }
1159+#endif
1160 }
1161
1162 void GLTextureStates::HW_SetBorderColor()
1163@@ -198,6 +210,7 @@
1164 // (MIP == GL_NEAREST),
1165 // TEXT("Error[GLTextureStates::SetFiltering]: Invalid Mipmap Filter State"));
1166
1167+#ifndef NUX_OPENGLES_20
1168 if (m_Type == GL_TEXTURE_RECTANGLE_ARB)
1169 {
1170 if ( (MinFilter != GL_NEAREST) && (MinFilter != GL_LINEAR) )
1171@@ -225,6 +238,10 @@
1172 SET_TS_VALUE (m_TextureStateChanges[GFXTS_MINFILTER], MinFilter);
1173 SET_TS_VALUE (m_TextureStateChanges[GFXTS_MAGFILTER], MagFilter);
1174 }
1175+#else
1176+ SET_TS_VALUE (m_TextureStateChanges[GFXTS_MINFILTER], MinFilter);
1177+ SET_TS_VALUE (m_TextureStateChanges[GFXTS_MAGFILTER], MagFilter);
1178+#endif
1179
1180 //SET_TS_VALUE(m_TextureStateChanges[GFXTS_MIPFILTER], MIP);
1181 }
1182@@ -234,6 +251,7 @@
1183 unsigned int V,
1184 unsigned int W)
1185 {
1186+#ifndef NUX_OPENGLES_20
1187 nuxAssertMsg (
1188 (U == GL_CLAMP) ||
1189 (U == GL_CLAMP_TO_EDGE) ||
1190@@ -304,6 +322,26 @@
1191 SET_TS_VALUE (m_TextureStateChanges[GFXTS_ADDRESSV], V);
1192 SET_TS_VALUE (m_TextureStateChanges[GFXTS_ADDRESSW], W);
1193 }
1194+#else
1195+ nuxAssertMsg (
1196+ (U == GL_CLAMP) ||
1197+ (U == GL_CLAMP_TO_EDGE) ||
1198+ (U == GL_CLAMP_TO_BORDER) ||
1199+ (U == GL_MIRRORED_REPEAT) ||
1200+ (U == GL_REPEAT),
1201+ TEXT ("Error[GLTextureStates::SetWrap]: Invalid U Wrap State") );
1202+
1203+ nuxAssertMsg (
1204+ (V == GL_CLAMP) ||
1205+ (V == GL_CLAMP_TO_EDGE) ||
1206+ (V == GL_CLAMP_TO_BORDER) ||
1207+ (V == GL_MIRRORED_REPEAT) ||
1208+ (V == GL_REPEAT),
1209+ TEXT ("Error[GLTextureStates::SetWrap]: Invalid V Wrap State") );
1210+
1211+ SET_TS_VALUE (m_TextureStateChanges[GFXTS_ADDRESSU], U);
1212+ SET_TS_VALUE (m_TextureStateChanges[GFXTS_ADDRESSV], V);
1213+#endif
1214 }
1215
1216 void GLTextureStates::SetLOD (float MinLod,
1217
1218=== modified file 'NuxGraphics/GLWindowManager.cpp'
1219--- NuxGraphics/GLWindowManager.cpp 2011-05-27 03:49:21 +0000
1220+++ NuxGraphics/GLWindowManager.cpp 2011-10-24 21:19:23 +0000
1221@@ -131,7 +131,11 @@
1222 return glwindow;
1223 }
1224 #elif defined(NUX_OS_LINUX)
1225+#ifdef NUX_OPENGLES_20
1226+ GraphicsDisplay *DisplayAccessController::CreateFromForeignWindow (Display *X11Display, Window X11Window, EGLContext OpenGLContext)
1227+#else
1228 GraphicsDisplay *DisplayAccessController::CreateFromForeignWindow (Display *X11Display, Window X11Window, GLXContext OpenGLContext)
1229+#endif
1230 {
1231 if (GetGraphicsDisplay())
1232 {
1233@@ -148,17 +152,19 @@
1234 #endif
1235 }
1236
1237+#ifndef NUX_OPENGLES_20
1238 GLEWContext *glewGetContext()
1239 {
1240 return nux::GetGraphicsDisplay()->GetGLEWContext();
1241 }
1242+#endif
1243
1244 #if defined(NUX_OS_WINDOWS)
1245 WGLEWContext *wglewGetContext()
1246 {
1247 return nux::GetGraphicsDisplay()->GetWGLEWContext();
1248 }
1249-#elif defined(NUX_OS_LINUX)
1250+#elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
1251 GLXEWContext *glxewGetContext()
1252 {
1253 return nux::GetGraphicsDisplay()->GetGLXEWContext();
1254
1255=== modified file 'NuxGraphics/GLWindowManager.h'
1256--- NuxGraphics/GLWindowManager.h 2011-04-06 21:54:09 +0000
1257+++ NuxGraphics/GLWindowManager.h 2011-10-24 21:19:23 +0000
1258@@ -69,8 +69,12 @@
1259 GraphicsDisplay *CreateFromForeignWindow (HWND WindowHandle, HDC WindowDCHandle, HGLRC OpenGLRenderingContext);
1260 #elif defined(NUX_OS_LINUX)
1261 //! Create a GraphicsDisplay from a foreign window and display.
1262+#ifdef NUX_OPENGLES_20
1263+ GraphicsDisplay *CreateFromForeignWindow (Display *X11Display, Window X11Window, EGLContext OpenGLContext);
1264+#else
1265 GraphicsDisplay *CreateFromForeignWindow (Display *X11Display, Window X11Window, GLXContext OpenGLContext);
1266 #endif
1267+#endif
1268
1269 static DisplayAccessController &Instance();
1270 private:
1271
1272=== modified file 'NuxGraphics/GpuDevice.cpp'
1273--- NuxGraphics/GpuDevice.cpp 2011-05-27 03:49:21 +0000
1274+++ NuxGraphics/GpuDevice.cpp 2011-10-24 21:19:23 +0000
1275@@ -78,158 +78,110 @@
1276 GPixelFormats[ BITFMT_UNKNOWN ].PlatformFormat = GL_NONE; // Not supported for rendering.
1277
1278 // Data in PC system memory: R(LSB) G B A(MSB) ---> GL Format:GL_RGBA - GL Type:GL_UNSIGNED_INT_8_8_8_8_REV
1279- GPixelFormats[ BITFMT_R8G8B8A8 ].PlatformFormat = GL_RGBA8;
1280- GPixelFormats[ BITFMT_R8G8B8A8 ].Format = GL_RGBA;
1281- GPixelFormats[ BITFMT_R8G8B8A8 ].type = GL_UNSIGNED_INT_8_8_8_8_REV;
1282+ GPixelFormats[BITFMT_R8G8B8A8].PlatformFormat = GL_RGBA8;
1283+ GPixelFormats[BITFMT_R8G8B8A8].Format = GL_RGBA;
1284+ GPixelFormats[BITFMT_R8G8B8A8].type = GL_UNSIGNED_INT_8_8_8_8_REV;
1285
1286 // Data in PC system memory: A(LSB) B G R(MSB) ---> GL Format:GL_RGBA - GL Type:GL_UNSIGNED_INT_8_8_8_8
1287- GPixelFormats[ BITFMT_A8B8G8R8 ].PlatformFormat = GL_RGBA8;
1288- GPixelFormats[ BITFMT_A8B8G8R8 ].Format = GL_RGBA;
1289- GPixelFormats[ BITFMT_A8B8G8R8 ].type = GL_UNSIGNED_INT_8_8_8_8;
1290+ GPixelFormats[BITFMT_A8B8G8R8].PlatformFormat = GL_RGBA8;
1291+ GPixelFormats[BITFMT_A8B8G8R8].Format = GL_RGBA;
1292+ GPixelFormats[BITFMT_A8B8G8R8].type = GL_UNSIGNED_INT_8_8_8_8;
1293
1294 // Data in PC system memory: B(LSB) G R A(MSB) ---> GL Format:GL_BGRA - GL Type:GL_UNSIGNED_INT_8_8_8_8_REV
1295- GPixelFormats[ BITFMT_B8G8R8A8 ].PlatformFormat = GL_RGBA8;
1296- GPixelFormats[ BITFMT_B8G8R8A8 ].Format = GL_BGRA;
1297- GPixelFormats[ BITFMT_B8G8R8A8 ].type = GL_UNSIGNED_INT_8_8_8_8_REV;
1298+ GPixelFormats[BITFMT_B8G8R8A8].PlatformFormat = GL_RGBA8;
1299+ GPixelFormats[BITFMT_B8G8R8A8].Format = GL_BGRA;
1300+ GPixelFormats[BITFMT_B8G8R8A8].type = GL_UNSIGNED_INT_8_8_8_8_REV;
1301
1302 // Data in PC system memory: A(LSB) R G B(MSB) ---> GL Format:GL_BGRA - GL Type:GL_UNSIGNED_INT_8_8_8_8
1303- GPixelFormats[ BITFMT_A8R8G8B8 ].PlatformFormat = GL_RGBA8;
1304- GPixelFormats[ BITFMT_A8R8G8B8 ].Format = GL_BGRA;
1305- GPixelFormats[ BITFMT_A8R8G8B8 ].type = GL_UNSIGNED_INT_8_8_8_8;
1306+ GPixelFormats[BITFMT_A8R8G8B8].PlatformFormat = GL_RGBA8;
1307+ GPixelFormats[BITFMT_A8R8G8B8].Format = GL_BGRA;
1308+ GPixelFormats[BITFMT_A8R8G8B8].type = GL_UNSIGNED_INT_8_8_8_8;
1309
1310 // Data in PC system memory: R(LSB) G B(MSB) ---> GL Format:GL_RGB - GL Type:GL_UNSIGNED
1311- GPixelFormats[ BITFMT_R8G8B8 ].PlatformFormat = GL_RGB8;
1312- GPixelFormats[ BITFMT_R8G8B8 ].Format = GL_RGB;
1313- GPixelFormats[ BITFMT_R8G8B8 ].type = GL_UNSIGNED_BYTE;
1314-
1315- GPixelFormats[ BITFMT_B8G8R8 ].PlatformFormat = GL_RGB8;
1316- GPixelFormats[ BITFMT_B8G8R8 ].Format = GL_BGR;
1317- GPixelFormats[ BITFMT_B8G8R8 ].type = GL_UNSIGNED_BYTE;
1318-
1319- GPixelFormats[ BITFMT_R5G6B5 ].PlatformFormat = GL_RGB5;
1320- GPixelFormats[ BITFMT_R5G6B5 ].Format = GL_RGB;
1321- GPixelFormats[ BITFMT_R5G6B5 ].type = GL_UNSIGNED_SHORT_5_6_5;
1322-
1323- GPixelFormats[ BITFMT_RGBA16F ].PlatformFormat = GL_RGBA16F_ARB;
1324- GPixelFormats[ BITFMT_RGBA16F ].Format = GL_RGBA;
1325- GPixelFormats[ BITFMT_RGBA16F ].type = GL_HALF_FLOAT_ARB;
1326-
1327- GPixelFormats[ BITFMT_RGB32F ].PlatformFormat = GL_RGB;
1328- GPixelFormats[ BITFMT_RGB32F ].Format = GL_RGB;
1329- GPixelFormats[ BITFMT_RGB32F ].type = GL_FLOAT;
1330-
1331- GPixelFormats[ BITFMT_RGBA32F ].PlatformFormat = GL_RGBA32F_ARB;
1332- GPixelFormats[ BITFMT_RGBA32F ].Format = GL_RGBA;
1333- GPixelFormats[ BITFMT_RGBA32F ].type = GL_FLOAT;
1334+ GPixelFormats[BITFMT_R8G8B8].PlatformFormat = GL_RGB8;
1335+ GPixelFormats[BITFMT_R8G8B8].Format = GL_RGB;
1336+ GPixelFormats[BITFMT_R8G8B8].type = GL_UNSIGNED_BYTE;
1337+
1338+ GPixelFormats[BITFMT_B8G8R8].PlatformFormat = GL_RGB8;
1339+ GPixelFormats[BITFMT_B8G8R8].Format = GL_BGR;
1340+ GPixelFormats[BITFMT_B8G8R8].type = GL_UNSIGNED_BYTE;
1341+
1342+ GPixelFormats[BITFMT_R5G6B5].PlatformFormat = GL_RGB5;
1343+ GPixelFormats[BITFMT_R5G6B5].Format = GL_RGB;
1344+ GPixelFormats[BITFMT_R5G6B5].type = GL_UNSIGNED_SHORT_5_6_5;
1345+
1346+ GPixelFormats[BITFMT_RGBA16F].PlatformFormat = GL_RGBA16F_ARB;
1347+ GPixelFormats[BITFMT_RGBA16F].Format = GL_RGBA;
1348+ GPixelFormats[BITFMT_RGBA16F].type = GL_HALF_FLOAT_ARB;
1349+
1350+ GPixelFormats[BITFMT_RGB32F].PlatformFormat = GL_RGB;
1351+ GPixelFormats[BITFMT_RGB32F].Format = GL_RGB;
1352+ GPixelFormats[BITFMT_RGB32F].type = GL_FLOAT;
1353+
1354+ GPixelFormats[BITFMT_RGBA32F].PlatformFormat = GL_RGBA32F_ARB;
1355+ GPixelFormats[BITFMT_RGBA32F].Format = GL_RGBA;
1356+ GPixelFormats[BITFMT_RGBA32F].type = GL_FLOAT;
1357
1358 // Note: Using GL_DEPTH_COMPONENT24 or GL_DEPTH_COMPONENT for PlatformFormat generate error GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT.
1359- GPixelFormats[ BITFMT_D24S8 ].PlatformFormat = GL_DEPTH24_STENCIL8_EXT;
1360- GPixelFormats[ BITFMT_D24S8 ].Format = GL_DEPTH_STENCIL_EXT; // or GL_DEPTH_STENCIL_NV;
1361- GPixelFormats[ BITFMT_D24S8 ].type = GL_UNSIGNED_INT_24_8_EXT; // or GL_UNSIGNED_INT_24_8_NV;
1362-
1363- GPixelFormats[ BITFMT_DXT1 ].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
1364- GPixelFormats[ BITFMT_DXT2 ].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
1365- GPixelFormats[ BITFMT_DXT3 ].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
1366- GPixelFormats[ BITFMT_DXT4 ].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
1367- GPixelFormats[ BITFMT_DXT5 ].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
1368-
1369- GPixelFormats[ BITFMT_R10G10B10A2 ].PlatformFormat = GL_RGB10_A2;
1370- GPixelFormats[ BITFMT_R10G10B10A2 ].Format = GL_RGBA;
1371- GPixelFormats[ BITFMT_R10G10B10A2 ].type = GL_UNSIGNED_INT_10_10_10_2;
1372-
1373- GPixelFormats[ BITFMT_A2B10G10R10 ].PlatformFormat = GL_RGB10_A2;
1374- GPixelFormats[ BITFMT_A2B10G10R10 ].Format = GL_RGBA;
1375- GPixelFormats[ BITFMT_A2B10G10R10 ].type = GL_UNSIGNED_INT_2_10_10_10_REV;
1376-
1377- GPixelFormats[ BITFMT_B10G10R10A2 ].PlatformFormat = GL_RGB10_A2;
1378- GPixelFormats[ BITFMT_B10G10R10A2 ].Format = GL_BGRA;
1379- GPixelFormats[ BITFMT_B10G10R10A2 ].type = GL_UNSIGNED_INT_10_10_10_2;
1380-
1381- GPixelFormats[ BITFMT_A2R10G10B10 ].PlatformFormat = GL_RGB10_A2;
1382- GPixelFormats[ BITFMT_A2R10G10B10 ].Format = GL_BGRA;
1383- GPixelFormats[ BITFMT_A2R10G10B10 ].type = GL_UNSIGNED_INT_2_10_10_10_REV;
1384-
1385- GPixelFormats[ BITFMT_A8 ].PlatformFormat = GL_RGBA8;
1386- GPixelFormats[ BITFMT_A8 ].Format = GL_LUMINANCE;
1387- GPixelFormats[ BITFMT_A8 ].type = GL_UNSIGNED_BYTE;
1388+ GPixelFormats[BITFMT_D24S8].PlatformFormat = GL_DEPTH24_STENCIL8_EXT;
1389+ GPixelFormats[BITFMT_D24S8].Format = GL_DEPTH_STENCIL_EXT; // or GL_DEPTH_STENCIL_NV;
1390+ GPixelFormats[BITFMT_D24S8].type = GL_UNSIGNED_INT_24_8_EXT; // or GL_UNSIGNED_INT_24_8_NV;
1391+
1392+ GPixelFormats[BITFMT_DXT1].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
1393+ GPixelFormats[BITFMT_DXT2].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
1394+ GPixelFormats[BITFMT_DXT3].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
1395+ GPixelFormats[BITFMT_DXT4].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
1396+ GPixelFormats[BITFMT_DXT5].PlatformFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
1397+
1398+ GPixelFormats[BITFMT_R10G10B10A2].PlatformFormat = GL_RGB10_A2;
1399+ GPixelFormats[BITFMT_R10G10B10A2].Format = GL_RGBA;
1400+ GPixelFormats[BITFMT_R10G10B10A2].type = GL_UNSIGNED_INT_10_10_10_2;
1401+
1402+ GPixelFormats[BITFMT_A2B10G10R10].PlatformFormat = GL_RGB10_A2;
1403+ GPixelFormats[BITFMT_A2B10G10R10].Format = GL_RGBA;
1404+ GPixelFormats[BITFMT_A2B10G10R10].type = GL_UNSIGNED_INT_2_10_10_10_REV;
1405+
1406+ GPixelFormats[BITFMT_B10G10R10A2].PlatformFormat = GL_RGB10_A2;
1407+ GPixelFormats[BITFMT_B10G10R10A2].Format = GL_BGRA;
1408+ GPixelFormats[BITFMT_B10G10R10A2].type = GL_UNSIGNED_INT_10_10_10_2;
1409+
1410+ GPixelFormats[BITFMT_A2R10G10B10].PlatformFormat = GL_RGB10_A2;
1411+ GPixelFormats[BITFMT_A2R10G10B10].Format = GL_BGRA;
1412+ GPixelFormats[BITFMT_A2R10G10B10].type = GL_UNSIGNED_INT_2_10_10_10_REV;
1413+
1414+ GPixelFormats[BITFMT_A8].PlatformFormat = GL_RGBA8;
1415+ GPixelFormats[BITFMT_A8].Format = GL_LUMINANCE;
1416+ GPixelFormats[BITFMT_A8].type = GL_UNSIGNED_BYTE;
1417 #else
1418 GPixelFormats[ BITFMT_UNKNOWN ].PlatformFormat = GL_NONE; // Not supported for rendering.
1419
1420 // Data in PC system memory: R(LSB) G B A(MSB) ---> GL Format:GL_RGBA - GL Type:GL_UNSIGNED_INT_8_8_8_8_REV
1421- GPixelFormats[ BITFMT_R8G8B8A8 ].PlatformFormat = GL_RGBA;
1422- GPixelFormats[ BITFMT_R8G8B8A8 ].Format = GL_RGBA;
1423- GPixelFormats[ BITFMT_R8G8B8A8 ].type = GL_UNSIGNED_BYTE;
1424-
1425- // Data in PC system memory: A(LSB) B G R(MSB) ---> GL Format:GL_RGBA - GL Type:GL_UNSIGNED_INT_8_8_8_8
1426- GPixelFormats[ BITFMT_A8B8G8R8 ].PlatformFormat = GL_RGBA;
1427- GPixelFormats[ BITFMT_A8B8G8R8 ].Format = GL_RGBA;
1428- GPixelFormats[ BITFMT_A8B8G8R8 ].type = GL_UNSIGNED_BYTE;
1429+ GPixelFormats[BITFMT_R8G8B8A8].PlatformFormat = GL_RGBA;
1430+ GPixelFormats[BITFMT_R8G8B8A8].Format = GL_RGBA;
1431+ GPixelFormats[BITFMT_R8G8B8A8].type = GL_UNSIGNED_BYTE;
1432
1433 // Data in PC system memory: B(LSB) G R A(MSB) ---> GL Format:GL_BGRA - GL Type:GL_UNSIGNED_INT_8_8_8_8_REV
1434- GPixelFormats[ BITFMT_B8G8R8A8 ].PlatformFormat = GL_RGBA;
1435- GPixelFormats[ BITFMT_B8G8R8A8 ].Format = GL_RGBA;
1436- GPixelFormats[ BITFMT_B8G8R8A8 ].type = GL_UNSIGNED_BYTE;
1437-
1438- // Data in PC system memory: A(LSB) R G B(MSB) ---> GL Format:GL_BGRA - GL Type:GL_UNSIGNED_INT_8_8_8_8
1439- GPixelFormats[ BITFMT_A8R8G8B8 ].PlatformFormat = GL_RGBA;
1440- GPixelFormats[ BITFMT_A8R8G8B8 ].Format = GL_RGBA;
1441- GPixelFormats[ BITFMT_A8R8G8B8 ].type = GL_UNSIGNED_BYTE;
1442+ GPixelFormats[BITFMT_B8G8R8A8].PlatformFormat = GL_BGRA_EXT;
1443+ GPixelFormats[BITFMT_B8G8R8A8].Format = GL_BGRA_EXT;
1444+ GPixelFormats[BITFMT_B8G8R8A8].type = GL_UNSIGNED_BYTE;
1445
1446 // Data in PC system memory: R(LSB) G B(MSB) ---> GL Format:GL_RGB - GL Type:GL_UNSIGNED
1447- GPixelFormats[ BITFMT_R8G8B8 ].PlatformFormat = GL_RGB;
1448- GPixelFormats[ BITFMT_R8G8B8 ].Format = GL_RGB;
1449- GPixelFormats[ BITFMT_R8G8B8 ].type = GL_UNSIGNED_BYTE;
1450-
1451- GPixelFormats[ BITFMT_B8G8R8 ].PlatformFormat = GL_RGB;
1452- GPixelFormats[ BITFMT_B8G8R8 ].Format = GL_RGB;
1453- GPixelFormats[ BITFMT_B8G8R8 ].type = GL_UNSIGNED_BYTE;
1454-
1455- GPixelFormats[ BITFMT_R5G6B5 ].PlatformFormat = GL_RGB;
1456- GPixelFormats[ BITFMT_R5G6B5 ].Format = GL_RGB;
1457- GPixelFormats[ BITFMT_R5G6B5 ].type = GL_UNSIGNED_SHORT_5_6_5;
1458-
1459- GPixelFormats[ BITFMT_RGBA16F ].PlatformFormat = GL_NONE;
1460- GPixelFormats[ BITFMT_RGBA16F ].Format = GL_NONE;
1461- GPixelFormats[ BITFMT_RGBA16F ].type = GL_NONE;
1462-
1463- GPixelFormats[ BITFMT_RGB32F ].PlatformFormat = GL_NONE;
1464- GPixelFormats[ BITFMT_RGB32F ].Format = GL_NONE;
1465- GPixelFormats[ BITFMT_RGB32F ].type = GL_NONE;
1466-
1467- GPixelFormats[ BITFMT_RGBA32F ].PlatformFormat = GL_NONE;
1468- GPixelFormats[ BITFMT_RGBA32F ].Format = GL_NONE;
1469- GPixelFormats[ BITFMT_RGBA32F ].type = GL_NONE;
1470+ GPixelFormats[BITFMT_R8G8B8].PlatformFormat = GL_RGB;
1471+ GPixelFormats[BITFMT_R8G8B8].Format = GL_RGB;
1472+ GPixelFormats[BITFMT_R8G8B8].type = GL_UNSIGNED_BYTE;
1473+
1474+ GPixelFormats[BITFMT_R5G6B5].PlatformFormat = GL_RGB;
1475+ GPixelFormats[BITFMT_R5G6B5].Format = GL_RGB;
1476+ GPixelFormats[BITFMT_R5G6B5].type = GL_UNSIGNED_SHORT_5_6_5;
1477
1478 // Note: Using GL_DEPTH_COMPONENT24 or GL_DEPTH_COMPONENT for PlatformFormat generate error GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT.
1479- GPixelFormats[ BITFMT_D24S8 ].PlatformFormat = GL_NONE;
1480- GPixelFormats[ BITFMT_D24S8 ].Format = GL_NONE; // or GL_DEPTH_STENCIL_NV;
1481- GPixelFormats[ BITFMT_D24S8 ].type = GL_NONE; // or GL_UNSIGNED_INT_24_8_NV;
1482-
1483- GPixelFormats[ BITFMT_DXT1 ].PlatformFormat = GL_NONE;
1484- GPixelFormats[ BITFMT_DXT2 ].PlatformFormat = GL_NONE;
1485- GPixelFormats[ BITFMT_DXT3 ].PlatformFormat = GL_NONE;
1486- GPixelFormats[ BITFMT_DXT4 ].PlatformFormat = GL_NONE;
1487- GPixelFormats[ BITFMT_DXT5 ].PlatformFormat = GL_NONE;
1488-
1489- GPixelFormats[ BITFMT_R10G10B10A2 ].PlatformFormat = GL_NONE;
1490- GPixelFormats[ BITFMT_R10G10B10A2 ].Format = GL_NONE;
1491- GPixelFormats[ BITFMT_R10G10B10A2 ].type = GL_NONE;
1492-
1493- GPixelFormats[ BITFMT_A2B10G10R10 ].PlatformFormat = GL_NONE;
1494- GPixelFormats[ BITFMT_A2B10G10R10 ].Format = GL_NONE;
1495- GPixelFormats[ BITFMT_A2B10G10R10 ].type = GL_NONE;
1496-
1497- GPixelFormats[ BITFMT_B10G10R10A2 ].PlatformFormat = GL_NONE;
1498- GPixelFormats[ BITFMT_B10G10R10A2 ].Format = GL_NONE;
1499- GPixelFormats[ BITFMT_B10G10R10A2 ].type = GL_NONE;
1500-
1501- GPixelFormats[ BITFMT_A2R10G10B10 ].PlatformFormat = GL_NONE;
1502- GPixelFormats[ BITFMT_A2R10G10B10 ].Format = GL_NONE;
1503- GPixelFormats[ BITFMT_A2R10G10B10 ].type = GL_NONE;
1504-
1505- GPixelFormats[ BITFMT_A8 ].PlatformFormat = GL_ALPHA;
1506- GPixelFormats[ BITFMT_A8 ].Format = GL_ALPHA;
1507- GPixelFormats[ BITFMT_A8 ].type = GL_UNSIGNED_BYTE;
1508+ GPixelFormats[BITFMT_D24S8].PlatformFormat = GL_DEPTH_STENCIL_OES;
1509+ GPixelFormats[BITFMT_D24S8].Format = GL_DEPTH_STENCIL_OES;
1510+ GPixelFormats[BITFMT_D24S8].type = GL_UNSIGNED_INT_24_8_OES;
1511+
1512+ GPixelFormats[BITFMT_A8].PlatformFormat = GL_ALPHA;
1513+ GPixelFormats[BITFMT_A8].Format = GL_ALPHA;
1514+ GPixelFormats[BITFMT_A8].type = GL_UNSIGNED_BYTE;
1515 #endif
1516 }
1517
1518@@ -254,6 +206,7 @@
1519
1520 void GpuInfo::Setup()
1521 {
1522+#ifndef NUX_OPENGLES_20
1523 _support_opengl_version_11 = GLEW_VERSION_1_1 ? true : false;
1524 _support_opengl_version_12 = GLEW_VERSION_1_2 ? true : false;
1525 _support_opengl_version_13 = GLEW_VERSION_1_3 ? true : false;
1526@@ -268,7 +221,6 @@
1527 // _support_opengl_version_40 = GLEW_VERSION_4_0 ? true : false;
1528 // _support_opengl_version_41 = GLEW_VERSION_4_1 ? true : false;
1529
1530-#ifndef NUX_OPENGLES_20
1531 // See: http://developer.nvidia.com/object/General_FAQ.html
1532 // The value of GL_MAX_TEXTURE_UNITS is 4 for GeForce FX and GeForce 6 Series GPUs. Why is that, since those GPUs have 16 texture units?
1533 CHECKGL (glGetIntegerv (GL_MAX_TEXTURE_UNITS, &_opengl_max_texture_units));
1534@@ -282,11 +234,11 @@
1535
1536 #if defined(NUX_OS_WINDOWS)
1537 _support_ext_swap_control = WGLEW_EXT_swap_control ? true : false;
1538-#elif defined(NUX_OS_LINUX)
1539- _support_ext_swap_control = GLXEW_SGI_swap_control ? true : false;
1540-#elif defined(NUX_OS_LINUX)
1541+#elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
1542 _support_ext_swap_control = GLXEW_SGI_swap_control ? true : false;
1543 #endif
1544+
1545+#ifndef NUX_OPENGLES_20
1546 _support_arb_vertex_program = GLEW_ARB_vertex_program ? true : false;
1547 _support_arb_fragment_program = GLEW_ARB_fragment_program ? true : false;
1548 _support_ext_framebuffer_object = GLEW_EXT_framebuffer_object ? true : false;
1549@@ -302,11 +254,26 @@
1550 _support_nv_texture_rectangle = GLEW_NV_texture_rectangle ? true : false;
1551 _support_arb_pixel_buffer_object = GLEW_ARB_pixel_buffer_object ? true : false;
1552 _support_ext_blend_equation_separate = GLEW_EXT_blend_equation_separate ? true : false;
1553-#ifndef NUX_OPENGLES_20
1554 _support_ext_texture_srgb = GLEW_EXT_texture_sRGB ? true : false;
1555 _support_ext_texture_srgb_decode = false; //GLEW_EXT_texture_sRGB_decode ? true : false;
1556 _support_ext_framebuffer_srgb = GLEW_EXT_framebuffer_sRGB ? true : false;
1557 _support_arb_framebuffer_srgb = GLEW_ARB_framebuffer_sRGB ? true : false;
1558+#else
1559+ _support_arb_vertex_program = false;
1560+ _support_arb_fragment_program = false;
1561+ _support_arb_shader_objects = true;
1562+ _support_arb_vertex_shader = true;
1563+ _support_arb_fragment_shader = true;
1564+ _support_arb_vertex_buffer_object = true;
1565+ _support_arb_texture_non_power_of_two = true;
1566+ _support_ext_framebuffer_object = true;
1567+ _support_ext_draw_range_elements = false;
1568+ _support_ext_stencil_two_side = false;
1569+ _support_ext_texture_rectangle = false;
1570+ _support_arb_texture_rectangle = false;
1571+ _support_nv_texture_rectangle = false;
1572+ _support_arb_pixel_buffer_object = false;
1573+ _support_ext_blend_equation_separate = true;
1574 #endif
1575 }
1576
1577@@ -318,6 +285,17 @@
1578 int req_opengl_minor,
1579 bool opengl_es_20)
1580 #elif defined (NUX_OS_LINUX)
1581+#ifdef NUX_OPENGLES_20
1582+ GpuDevice::GpuDevice (t_u32 DeviceWidth, t_u32 DeviceHeight, BitmapFormat DeviceFormat,
1583+ Display *display,
1584+ Window window,
1585+ bool has_glx_13_support,
1586+ EGLConfig fb_config,
1587+ EGLContext &opengl_rendering_context,
1588+ int req_opengl_major,
1589+ int req_opengl_minor,
1590+ bool opengl_es_20)
1591+#else
1592 GpuDevice::GpuDevice (t_u32 DeviceWidth, t_u32 DeviceHeight, BitmapFormat DeviceFormat,
1593 Display *display,
1594 Window window,
1595@@ -328,12 +306,14 @@
1596 int req_opengl_minor,
1597 bool opengl_es_20)
1598 #endif
1599+#endif
1600 {
1601 _PixelStoreAlignment = 4;
1602 _UsePixelBufferObject = false;
1603 _gpu_info = NULL;
1604 _gpu_brand = GPU_VENDOR_UNKNOWN;
1605-
1606+
1607+#ifndef NUX_OPENGLES_20
1608 // OpenGL extension initialization
1609 GLenum Glew_Ok = 0;
1610 #ifdef GLEW_MX
1611@@ -347,10 +327,12 @@
1612 #elif defined(NUX_OS_MACOSX)
1613 Glew_Ok = glxewContextInit (glxewGetContext() );
1614 #endif
1615+
1616 nuxAssertMsg (Glew_Ok == GLEW_OK, TEXT ("[GpuDevice::GpuDevice] OpenGL Extensions failed to initialize."));
1617 #else
1618 Glew_Ok = glewInit();
1619 #endif
1620+#endif
1621
1622 #ifndef NUX_OPENGLES_20
1623 CHECKGL (glGetIntegerv (GL_MAJOR_VERSION, &_opengl_major));
1624@@ -360,11 +342,11 @@
1625 _opengl_minor = 0;
1626 #endif
1627
1628+#if defined (NUX_OS_WINDOWS)
1629 bool opengl_es_context_created = false;
1630-
1631-#if defined (NUX_OS_WINDOWS)
1632 if (((_opengl_major >= 3) && (req_opengl_major >= 3)) || (_opengl_major >= 3) || opengl_es_20)
1633 #elif defined (NUX_OS_LINUX)
1634+ //bool opengl_es_context_created = false;
1635 if (has_glx_13_support && (((_opengl_major >= 3) && (req_opengl_major >= 3)) || ((_opengl_major >= 3) && opengl_es_20)))
1636 #endif
1637 {
1638@@ -426,7 +408,7 @@
1639 opengl_es_context_created = true;
1640 }
1641 #elif defined (NUX_OS_LINUX)
1642- int attribs[] =
1643+/* int attribs[] =
1644 {
1645 GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
1646 GLX_CONTEXT_MINOR_VERSION_ARB, 0,
1647@@ -445,7 +427,7 @@
1648 opengl_rendering_context = new_opengl_rendering_context;
1649 glXMakeCurrent (display, window, opengl_rendering_context);
1650 opengl_es_context_created = true;
1651- }
1652+ }*/
1653 #endif
1654 }
1655 else if (requested_profile_is_supported)
1656@@ -486,7 +468,7 @@
1657 opengl_rendering_context = new_opengl_rendering_context;
1658 wglMakeCurrent (device_context, opengl_rendering_context);
1659 }
1660-#elif defined (NUX_OS_LINUX)
1661+#elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
1662 if (((req_opengl_major == 3) && (req_opengl_minor >= 3)) || (req_opengl_major >= 4))
1663 {
1664 profile_mask = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
1665@@ -540,7 +522,11 @@
1666 CHECKGL_MSG (glGetString (GL_RENDERER) );
1667 _openGL_version_string = ANSI_TO_TCHAR (NUX_REINTERPRET_CAST (const char *, glGetString (GL_VERSION) ) );
1668 CHECKGL_MSG (glGetString (GL_VERSION) );
1669+#ifndef NUX_OPENGLES_20
1670 if (GLEW_VERSION_2_0)
1671+#else
1672+ if (1)
1673+#endif
1674 {
1675 _glsl_version_string = ANSI_TO_TCHAR (NUX_REINTERPRET_CAST (const char *, glGetString (GL_SHADING_LANGUAGE_VERSION) ) );
1676 CHECKGL_MSG (glGetString (GL_SHADING_LANGUAGE_VERSION) );
1677@@ -557,24 +543,18 @@
1678 nuxDebugMsg (TEXT ("Gpu OpenGL Version: %s"), _openGL_version_string.GetTCharPtr() );
1679 nuxDebugMsg (TEXT ("Gpu GLSL Version: %s"), _glsl_version_string.GetTCharPtr() );
1680
1681+#ifndef NUX_OPENGLES_20
1682 // Get the version supported by the context that was set.
1683-
1684- if (opengl_es_20 && opengl_es_context_created)
1685- {
1686-
1687- }
1688- else
1689- {
1690- int new_opengl_major;
1691- int new_opengl_minor;
1692- CHECKGL (glGetIntegerv (GL_MAJOR_VERSION, &new_opengl_major));
1693- CHECKGL (glGetIntegerv (GL_MINOR_VERSION, &new_opengl_minor));
1694-
1695- if ((new_opengl_major != _opengl_major) || (new_opengl_minor != _opengl_minor))
1696- {
1697- nuxDebugMsg (TEXT ("The Gpu supports OpenGL %d.%d but version %d.%d has been requested."), _opengl_major, _opengl_minor, new_opengl_major, new_opengl_minor);
1698- }
1699- }
1700+ int new_opengl_major;
1701+ int new_opengl_minor;
1702+ CHECKGL (glGetIntegerv (GL_MAJOR_VERSION, &new_opengl_major));
1703+ CHECKGL (glGetIntegerv (GL_MINOR_VERSION, &new_opengl_minor));
1704+
1705+ if ((new_opengl_major != _opengl_major) || (new_opengl_minor != _opengl_minor))
1706+ {
1707+ nuxDebugMsg (TEXT ("The Gpu supports OpenGL %d.%d but version %d.%d has been requested."), _opengl_major, _opengl_minor, new_opengl_major, new_opengl_minor);
1708+ }
1709+#endif
1710
1711 NString TempStr = (const TCHAR *) TCharToUpperCase (_board_vendor_string.GetTCharPtr() );
1712
1713@@ -609,9 +589,7 @@
1714
1715 #if defined(NUX_OS_WINDOWS)
1716 OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control ? true : false;
1717-#elif defined(NUX_OS_LINUX)
1718- OGL_EXT_SWAP_CONTROL = GLXEW_SGI_swap_control ? true : false;
1719-#elif defined(NUX_OS_LINUX)
1720+#elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
1721 OGL_EXT_SWAP_CONTROL = GLXEW_SGI_swap_control ? true : false;
1722 #endif
1723
1724@@ -736,11 +714,13 @@
1725 {
1726 CHECKGL (glActiveTextureARB (TextureUnitIndex) );
1727
1728+ CHECKGL (glBindTexture (GL_TEXTURE_2D, 0) );
1729+#ifndef NUX_OPENGLES_20
1730 CHECKGL (glBindTexture (GL_TEXTURE_1D, 0) );
1731- CHECKGL (glBindTexture (GL_TEXTURE_2D, 0) );
1732 CHECKGL (glBindTexture (GL_TEXTURE_CUBE_MAP, 0) );
1733 CHECKGL (glBindTexture (GL_TEXTURE_3D, 0) );
1734 CHECKGL (glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0) );
1735+#endif
1736
1737 // From lowest priority to highest priority:
1738 // GL_TEXTURE_1D,
1739@@ -749,11 +729,13 @@
1740 // GL_TEXTURE_3D,
1741 // GL_TEXTURE_CUBE_MAP.
1742
1743+#ifndef NUX_OPENGLES_20
1744+ CHECKGL (glDisable (GL_TEXTURE_2D) );
1745 CHECKGL (glDisable (GL_TEXTURE_1D) );
1746- CHECKGL (glDisable (GL_TEXTURE_2D) );
1747 CHECKGL (glDisable (GL_TEXTURE_RECTANGLE_ARB) );
1748 CHECKGL (glDisable (GL_TEXTURE_3D) );
1749 CHECKGL (glDisable (GL_TEXTURE_CUBE_MAP) );
1750+#endif
1751 }
1752
1753 int GpuDevice::AllocateUnpackPixelBufferIndex (int *index)
1754@@ -802,36 +784,48 @@
1755
1756 void *GpuDevice::LockUnpackPixelBufferIndex (const int index, int Size)
1757 {
1758+#ifndef NUX_OPENGLES_20
1759 BindUnpackPixelBufferIndex (index);
1760 CHECKGL ( glBufferDataARB (GL_PIXEL_UNPACK_BUFFER_ARB, Size, NULL, GL_STREAM_DRAW) );
1761 void *pBits = glMapBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);
1762 CHECKGL_MSG (glMapBufferARB );
1763 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0) );
1764 return pBits;
1765+#else
1766+ return NULL;
1767+#endif
1768 }
1769
1770 void* GpuDevice::LockPackPixelBufferIndex (const int index, int Size)
1771 {
1772+#ifndef NUX_OPENGLES_20
1773 BindPackPixelBufferIndex (index);
1774 CHECKGL ( glBufferDataARB (GL_PIXEL_PACK_BUFFER_ARB, Size, NULL, GL_STREAM_DRAW) );
1775 void *pBits = glMapBufferARB (GL_PIXEL_PACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);
1776 CHECKGL_MSG (glMapBufferARB );
1777 CHECKGL ( glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, 0) );
1778 return pBits;
1779+#else
1780+ return NULL;
1781+#endif
1782 }
1783
1784 void GpuDevice::UnlockUnpackPixelBufferIndex (const int index)
1785 {
1786+#ifndef NUX_OPENGLES_20
1787 BindUnpackPixelBufferIndex (index);
1788 CHECKGL ( glUnmapBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB) );
1789 CHECKGL ( glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, 0) );
1790+#endif
1791 }
1792
1793 void GpuDevice::UnlockPackPixelBufferIndex (const int index)
1794 {
1795+#ifndef NUX_OPENGLES_20
1796 BindPackPixelBufferIndex (index);
1797 CHECKGL ( glUnmapBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB) );
1798 CHECKGL ( glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, 0) );
1799+#endif
1800 }
1801
1802 int GpuDevice::BindUnpackPixelBufferIndex (const int index)
1803
1804=== modified file 'NuxGraphics/GpuDevice.h'
1805--- NuxGraphics/GpuDevice.h 2011-09-20 06:03:43 +0000
1806+++ NuxGraphics/GpuDevice.h 2011-10-24 21:19:23 +0000
1807@@ -528,15 +528,29 @@
1808 bool opengl_es_20 = false);
1809
1810 #elif defined (NUX_OS_LINUX)
1811- GpuDevice (t_u32 DeviceWidth, t_u32 DeviceHeight, BitmapFormat DeviceFormat,
1812- Display *display,
1813- Window window,
1814- bool has_new_glx_support,
1815- GLXFBConfig fb_config,
1816- GLXContext &opengl_rendering_context,
1817- int req_opengl_major = 1, // requested opengl major version.
1818- int req_opengl_minor = 0, // requested opengl minor version.
1819- bool opengl_es_20 = false);
1820+ #ifdef NUX_OPENGLES_20
1821+ GpuDevice (t_u32 DeviceWidth, t_u32 DeviceHeight,
1822+ BitmapFormat DeviceFormat,
1823+ Display *display,
1824+ Window window,
1825+ bool has_new_glx_support,
1826+ EGLConfig fb_config,
1827+ EGLContext &opengl_rendering_context,
1828+ int req_opengl_major = 2,
1829+ int req_opengl_minor = 0,
1830+ bool opengl_es_20 = true);
1831+ #else
1832+ GpuDevice (t_u32 DeviceWidth, t_u32 DeviceHeight,
1833+ BitmapFormat DeviceFormat,
1834+ Display *display,
1835+ Window window,
1836+ bool has_new_glx_support,
1837+ GLXFBConfig fb_config,
1838+ GLXContext &opengl_rendering_context,
1839+ int req_opengl_major = 1, // requested opengl major version.
1840+ int req_opengl_minor = 0, // requested opengl minor version.
1841+ bool opengl_es_20 = false);
1842+ #endif
1843 #endif
1844
1845 ~GpuDevice();
1846
1847=== modified file 'NuxGraphics/GpuDeviceVertex.cpp'
1848--- NuxGraphics/GpuDeviceVertex.cpp 2011-09-20 06:03:43 +0000
1849+++ NuxGraphics/GpuDeviceVertex.cpp 2011-10-24 21:19:23 +0000
1850@@ -160,7 +160,7 @@
1851 vtxelement.Type,
1852 GL_FALSE,
1853 vtxelement.stride_,
1854- (void*)vtxelement.Offset));
1855+ (void*)&vtxelement.Offset));
1856
1857 VertexDeclaration->_valid_vertex_input[shader_attribute_location] = 1;
1858 ++decl;
1859@@ -233,6 +233,7 @@
1860 }
1861
1862
1863+#ifndef NUX_OPENGLES_20
1864 // Draw Primitive without index buffer
1865 int GpuDevice::DrawPrimitive (ObjectPtr<IOpenGLVertexDeclaration> VertexDeclaration,
1866 PRIMITIVE_TYPE PrimitiveType,
1867@@ -443,6 +444,7 @@
1868 // // }
1869 return OGL_OK;
1870 }
1871+#endif
1872
1873 // // DirectX Matrix
1874 // // | 2/W 0 0 -(W+1)/W |
1875
1876=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
1877--- NuxGraphics/GraphicsDisplayX11.cpp 2011-09-30 18:57:00 +0000
1878+++ NuxGraphics/GraphicsDisplayX11.cpp 2011-10-24 21:19:23 +0000
1879@@ -253,6 +253,7 @@
1880 }
1881 }
1882
1883+#ifndef NUX_OPENGLES_20
1884 // Check support for GLX
1885 int dummy0, dummy1;
1886 if (!glXQueryExtension(m_X11Display, &dummy0, &dummy1))
1887@@ -372,6 +373,64 @@
1888 m_X11VisualInfo->visual,
1889 AllocNone);
1890 }
1891+#else
1892+ EGLDisplay dpy = eglGetDisplay ((EGLNativeDisplayType)m_X11Display);
1893+ if (dpy == EGL_NO_DISPLAY)
1894+ {
1895+ nuxDebugMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Cannot get EGL display."));
1896+ return false;
1897+ }
1898+ EGLint major, minor;
1899+ if (!eglInitialize (dpy, &major, &minor))
1900+ {
1901+ nuxDebugMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Cannot initialize EGL."));
1902+ return false;
1903+ }
1904+
1905+ eglBindAPI (EGL_OPENGL_ES_API);
1906+
1907+ const EGLint config_attribs[] =
1908+ {
1909+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1910+ EGL_RED_SIZE, 1,
1911+ EGL_GREEN_SIZE, 1,
1912+ EGL_BLUE_SIZE, 1,
1913+ EGL_ALPHA_SIZE, 1,
1914+ EGL_DEPTH_SIZE, 1,
1915+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1916+ EGL_CONFIG_CAVEAT, EGL_NONE,
1917+ EGL_NONE,
1918+ };
1919+ EGLConfig configs[1024];
1920+ EGLint count;
1921+ if (!eglChooseConfig (dpy, config_attribs, configs, 1024, &count))
1922+ {
1923+ nuxDebugMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Cannot get EGL config."));
1924+ return false;
1925+ }
1926+
1927+ EGLConfig config = configs[0];
1928+ EGLint visualid = 0;
1929+ if (!eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &visualid))
1930+ {
1931+ nuxDebugMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Cannot get native visual ID from EGL config."));
1932+ return false;
1933+ }
1934+
1935+ XVisualInfo visual_info = {0};
1936+ visual_info.visualid = visualid;
1937+ m_X11VisualInfo = XGetVisualInfo (m_X11Display, VisualIDMask, &visual_info, &count);
1938+ if (!m_X11VisualInfo)
1939+ {
1940+ nuxCriticalMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Cannot get appropriate visual."));
1941+ return false;
1942+ }
1943+
1944+ m_X11Colormap = XCreateColormap (m_X11Display,
1945+ RootWindow (m_X11Display, m_X11VisualInfo->screen),
1946+ m_X11VisualInfo->visual,
1947+ AllocNone);
1948+#endif
1949
1950 m_X11Attr.background_pixmap = 0;
1951 m_X11Attr.border_pixel = 0;
1952@@ -474,6 +533,7 @@
1953 //XMapRaised (m_X11Display, m_X11Window);
1954 }
1955
1956+#ifndef NUX_OPENGLES_20
1957 if (0 /*_has_glx_13*/)
1958 {
1959 XFree (m_X11VisualInfo);
1960@@ -494,6 +554,26 @@
1961 /* Bind the GLX context to the Window */
1962 glXMakeContextCurrent (m_X11Display, glxWin, glxWin, m_GLCtx);
1963 }
1964+#else
1965+ m_GLSurface = eglCreateWindowSurface (dpy, config, (EGLNativeWindowType)m_X11Window, 0);
1966+ if (!m_GLSurface)
1967+ {
1968+ nuxCriticalMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Failed to create surface."));
1969+ return false;
1970+ }
1971+
1972+ const EGLint context_attribs[] =
1973+ {
1974+ EGL_CONTEXT_CLIENT_VERSION, 2,
1975+ EGL_NONE
1976+ };
1977+ m_GLCtx = eglCreateContext (dpy, config, EGL_NO_CONTEXT, context_attribs);
1978+ if (m_GLCtx == EGL_NO_CONTEXT)
1979+ {
1980+ nuxCriticalMsg (TEXT ("[GraphicsDisplay::CreateOpenGLWindow] Failed to create EGL context."));
1981+ return false;
1982+ }
1983+#endif
1984
1985 MakeGLContextCurrent();
1986 glClearColor (0.0, 0.0, 0.0, 0.0);
1987@@ -520,7 +600,11 @@
1988 return TRUE;
1989 }
1990
1991+#ifdef NUX_OPENGLES_20
1992+ bool GraphicsDisplay::CreateFromOpenGLWindow (Display *X11Display, Window X11Window, EGLContext OpenGLContext)
1993+#else
1994 bool GraphicsDisplay::CreateFromOpenGLWindow (Display *X11Display, Window X11Window, GLXContext OpenGLContext)
1995+#endif
1996 {
1997 // Do not make the opengl context current
1998 // Do not swap the framebuffer
1999@@ -868,10 +952,19 @@
2000
2001 void GraphicsDisplay::MakeGLContextCurrent()
2002 {
2003+#ifndef NUX_OPENGLES_20
2004 if (!glXMakeCurrent (m_X11Display, m_X11Window, m_GLCtx) )
2005 {
2006 DestroyOpenGLWindow();
2007 }
2008+#else
2009+ EGLDisplay dpy = eglGetDisplay ((EGLNativeDisplayType)m_X11Display);
2010+
2011+ if (!eglMakeCurrent (dpy, m_GLSurface, m_GLSurface, m_GLCtx))
2012+ {
2013+ DestroyOpenGLWindow();
2014+ }
2015+#endif
2016 }
2017
2018 void GraphicsDisplay::SwapBuffer (bool glswap)
2019@@ -903,7 +996,11 @@
2020
2021 if (glswap)
2022 {
2023+#ifndef NUX_OPENGLES_20
2024 glXSwapBuffers (m_X11Display, m_X11Window);
2025+#else
2026+ eglSwapBuffers (eglGetDisplay ((EGLNativeDisplayType)m_X11Display), m_GLSurface);
2027+#endif
2028 }
2029
2030 m_FrameTime = m_Timer.PassedMilliseconds();
2031@@ -934,12 +1031,26 @@
2032 {
2033 if (m_GLCtx)
2034 {
2035+#ifndef NUX_OPENGLES_20
2036 if (!glXMakeCurrent (m_X11Display, None, NULL) )
2037 {
2038 nuxAssert (TEXT ("[GraphicsDisplay::DestroyOpenGLWindow] glXMakeCurrent failed.") );
2039 }
2040
2041 glXDestroyContext (m_X11Display, m_GLCtx);
2042+#else
2043+ EGLDisplay dpy = eglGetDisplay ((EGLNativeDisplayType)m_X11Display);
2044+
2045+ if (!eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT))
2046+ {
2047+ nuxAssert (TEXT ("[GraphicsDisplay::DestroyOpenGLWindow] eglMakeCurrent failed.") );
2048+ }
2049+
2050+ eglDestroyContext (dpy, m_GLCtx);
2051+ eglDestroySurface (dpy, m_GLSurface);
2052+ eglTerminate (dpy);
2053+ eglReleaseThread ();
2054+#endif
2055 m_GLCtx = NULL;
2056 }
2057
2058@@ -2686,20 +2797,24 @@
2059
2060 void GraphicsDisplay::EnableVSyncSwapControl ()
2061 {
2062+#ifndef NUX_OPENGLES_20
2063 if (GetGpuDevice ()->GetGpuInfo ().Support_EXT_Swap_Control ())
2064 {
2065 GLXDrawable drawable = glXGetCurrentDrawable();
2066 glXSwapIntervalEXT(m_X11Display, drawable, 1);
2067 }
2068+#endif
2069 }
2070
2071 void GraphicsDisplay::DisableVSyncSwapControl ()
2072 {
2073+#ifndef NUX_OPENGLES_20
2074 if (GetGpuDevice ()->GetGpuInfo ().Support_EXT_Swap_Control ())
2075 {
2076 GLXDrawable drawable = glXGetCurrentDrawable ();
2077 glXSwapIntervalEXT (m_X11Display, drawable, 0);
2078 }
2079+#endif
2080 }
2081
2082 float GraphicsDisplay::GetFrameTime () const
2083
2084=== modified file 'NuxGraphics/GraphicsDisplayX11.h'
2085--- NuxGraphics/GraphicsDisplayX11.h 2011-09-28 12:00:11 +0000
2086+++ NuxGraphics/GraphicsDisplayX11.h 2011-10-24 21:19:23 +0000
2087@@ -87,8 +87,14 @@
2088 XVisualInfo *m_X11VisualInfo;
2089
2090 int m_ParentWindow;
2091+#ifndef NUX_OPENGLES_20
2092 GLXContext m_GLCtx;
2093 GLXFBConfig _fb_config;
2094+#else
2095+ EGLContext m_GLCtx;
2096+ EGLSurface m_GLSurface;
2097+ EGLConfig _fb_config;
2098+#endif
2099 XSetWindowAttributes m_X11Attr;
2100
2101 int m_NumVideoModes;
2102@@ -178,7 +184,11 @@
2103 @param X11Display Provided display.
2104 @param X11Window Provided window.
2105 */
2106+#ifdef NUX_OPENGLES_20
2107+ bool CreateFromOpenGLWindow (Display *X11Display, Window X11Window, EGLContext OpenGLContext);
2108+#else
2109 bool CreateFromOpenGLWindow (Display *X11Display, Window X11Window, GLXContext OpenGLContext);
2110+#endif
2111
2112 void DestroyOpenGLWindow();
2113
2114@@ -382,6 +392,7 @@
2115 bool _dnd_source_drop_sent;
2116 public:
2117 ~GraphicsDisplay();
2118+#ifndef NUX_OPENGLES_20
2119 GLEWContext *GetGLEWContext()
2120 {
2121 return &m_GLEWContext;
2122@@ -390,6 +401,7 @@
2123 {
2124 return &m_GLXEWContext;
2125 }
2126+#endif
2127
2128 NString FindResourceLocation (const TCHAR *ResourceFileName, bool ErrorOnFail = false);
2129 NString FindUITextureLocation (const TCHAR *ResourceFileName, bool ErrorOnFail = false);
2130@@ -420,8 +432,10 @@
2131 // Does not make sense for a singleton. This is a self assignment.
2132 GraphicsDisplay &operator= (const GraphicsDisplay &);
2133
2134+#ifndef NUX_OPENGLES_20
2135 GLEWContext m_GLEWContext;
2136 GLXEWContext m_GLXEWContext;
2137+#endif
2138 friend class DisplayAccessController;
2139 };
2140
2141
2142=== modified file 'NuxGraphics/IOpenGLAsmShader.cpp'
2143--- NuxGraphics/IOpenGLAsmShader.cpp 2011-09-20 06:03:43 +0000
2144+++ NuxGraphics/IOpenGLAsmShader.cpp 2011-10-24 21:19:23 +0000
2145@@ -52,14 +52,18 @@
2146 : IOpenGLAsmShader (ShaderName, RT_GLSL_VERTEXSHADER)
2147 , m_CompiledAndReady (false)
2148 {
2149+#ifndef NUX_OPENGLES_20
2150 CHECKGL ( glGenProgramsARB (1, &_OpenGLID) );
2151+#endif
2152 }
2153
2154 IOpenGLAsmVertexShader::~IOpenGLAsmVertexShader()
2155 {
2156+#ifndef NUX_OPENGLES_20
2157 CHECKGL ( glDeleteProgramsARB (1, &_OpenGLID) );
2158 _OpenGLID = 0;
2159 m_CompiledAndReady = false;
2160+#endif
2161 }
2162
2163 void IOpenGLAsmVertexShader::SetShaderCode (const TCHAR *ShaderCode)
2164@@ -73,6 +77,7 @@
2165 bool IOpenGLAsmVertexShader::Compile()
2166 {
2167 m_CompiledAndReady = false;
2168+#ifndef NUX_OPENGLES_20
2169 t_size CodeSize = _ShaderCode.Size();
2170
2171 if (CodeSize == 0)
2172@@ -103,6 +108,7 @@
2173 delete[] ShaderSource;
2174
2175 m_CompiledAndReady = true;
2176+#endif
2177 return m_CompiledAndReady;
2178 }
2179
2180@@ -115,14 +121,18 @@
2181 : IOpenGLAsmShader (ShaderName, RT_GLSL_PIXELSHADER)
2182 , m_CompiledAndReady (false)
2183 {
2184+#ifndef NUX_OPENGLES_20
2185 CHECKGL ( glGenProgramsARB (1, &_OpenGLID) );
2186+#endif
2187 }
2188
2189 IOpenGLAsmPixelShader::~IOpenGLAsmPixelShader()
2190 {
2191+#ifndef NUX_OPENGLES_20
2192 CHECKGL ( glDeleteProgramsARB (1, &_OpenGLID) );
2193 _OpenGLID = 0;
2194 m_CompiledAndReady = false;
2195+#endif
2196 }
2197
2198 void IOpenGLAsmPixelShader::SetShaderCode (const TCHAR *ShaderCode)
2199@@ -136,6 +146,7 @@
2200 bool IOpenGLAsmPixelShader::Compile()
2201 {
2202 m_CompiledAndReady = false;
2203+#ifndef NUX_OPENGLES_20
2204 t_size CodeSize = _ShaderCode.Size();
2205
2206 if (CodeSize == 0)
2207@@ -165,6 +176,7 @@
2208 delete[] ShaderSource;
2209
2210 m_CompiledAndReady = true;
2211+#endif
2212 return m_CompiledAndReady;
2213 }
2214
2215@@ -244,20 +256,25 @@
2216
2217 void IOpenGLAsmShaderProgram::Begin (void)
2218 {
2219+#ifndef NUX_OPENGLES_20
2220 CHECKGL ( glEnable (GL_VERTEX_PROGRAM_ARB) );
2221 CHECKGL ( glBindProgramARB (GL_VERTEX_PROGRAM_ARB, m_AsmVertexProgram->GetOpenGLID() ) );
2222 CHECKGL ( glEnable (GL_FRAGMENT_PROGRAM_ARB) );
2223 CHECKGL ( glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, m_AsmFragmentProgram->GetOpenGLID() ) );
2224+#endif
2225 }
2226
2227 void IOpenGLAsmShaderProgram::End (void)
2228 {
2229+#ifndef NUX_OPENGLES_20
2230 CHECKGL ( glDisable (GL_VERTEX_PROGRAM_ARB) );
2231 CHECKGL ( glBindProgramARB (GL_VERTEX_PROGRAM_ARB, 0) );
2232 CHECKGL ( glDisable (GL_FRAGMENT_PROGRAM_ARB) );
2233 CHECKGL ( glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, 0) );
2234+#endif
2235 }
2236
2237+#ifndef NUX_OPENGLES_20
2238 void IOpenGLAsmShaderProgram::SetVertexEnvParameter4dARB (t_uint32 index, double x, double y, double z, double w)
2239 {
2240 CHECKGL ( glProgramEnvParameter4dARB (GL_VERTEX_PROGRAM_ARB, index, x, y, z, w) );
2241@@ -337,5 +354,7 @@
2242 {
2243 CHECKGL ( glProgramEnvParameter4fvARB (GL_FRAGMENT_PROGRAM_ARB, index, params) );
2244 }
2245-
2246+#endif
2247 }
2248+
2249+
2250
2251=== modified file 'NuxGraphics/IOpenGLBaseTexture.cpp'
2252--- NuxGraphics/IOpenGLBaseTexture.cpp 2011-04-06 21:54:09 +0000
2253+++ NuxGraphics/IOpenGLBaseTexture.cpp 2011-10-24 21:19:23 +0000
2254@@ -59,6 +59,7 @@
2255 if (_ResourceType == RTTEXTURE)
2256 _TextureStates.SetType (GL_TEXTURE_2D);
2257
2258+#ifndef NUX_OPENGLES_20
2259 if (_ResourceType == RTTEXTURERECTANGLE)
2260 _TextureStates.SetType (GL_TEXTURE_RECTANGLE_ARB);
2261
2262@@ -70,6 +71,7 @@
2263
2264 if (_ResourceType == RTANIMATEDTEXTURE)
2265 _TextureStates.SetType (GL_TEXTURE_RECTANGLE_ARB);
2266+#endif
2267
2268 _RowMemoryAlignment = ImageSurface::GetMemAlignment (PixelFormat);
2269
2270@@ -90,6 +92,7 @@
2271 {
2272 CHECKGL ( glBindTexture (GL_TEXTURE_2D, _OpenGLID) );
2273 }
2274+#ifndef NUX_OPENGLES_20
2275 else if (_ResourceType == RTTEXTURERECTANGLE)
2276 {
2277 CHECKGL ( glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _OpenGLID) );
2278@@ -106,6 +109,7 @@
2279 {
2280 CHECKGL ( glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _OpenGLID) );
2281 }
2282+#endif
2283 else
2284 {
2285 nuxError (TEXT ("[IOpenGLBaseTexture::SetRenderStates] Incorrect texture resource type.") );
2286@@ -149,6 +153,7 @@
2287 {
2288 CHECKGL ( glBindTexture (GL_TEXTURE_2D, _OpenGLID) );
2289 }
2290+#ifndef NUX_OPENGLES_20
2291 else if (_ResourceType == RTTEXTURERECTANGLE)
2292 {
2293 CHECKGL ( glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _OpenGLID) );
2294@@ -165,6 +170,7 @@
2295 {
2296 CHECKGL (glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _OpenGLID) );
2297 }
2298+#endif
2299 else
2300 {
2301 nuxError (TEXT ("[GpuDevice::BindTexture] Unknown texture type.") );
2302@@ -179,6 +185,7 @@
2303 {
2304 CHECKGL ( glActiveTextureARB (TextureUnitIndex) );
2305 CHECKGL ( glBindTexture (GL_TEXTURE_2D, 0) );
2306+#ifndef NUX_OPENGLES_20
2307 CHECKGL ( glBindTexture (GL_TEXTURE_3D, 0) );
2308 CHECKGL ( glBindTexture (GL_TEXTURE_CUBE_MAP, 0) );
2309 CHECKGL ( glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0) );
2310@@ -186,12 +193,16 @@
2311 CHECKGL ( glDisable (GL_TEXTURE_3D) );
2312 CHECKGL ( glDisable (GL_TEXTURE_RECTANGLE_ARB) );
2313 CHECKGL ( glDisable (GL_TEXTURE_CUBE_MAP) );
2314+#endif
2315
2316 if (_ResourceType == RTTEXTURE)
2317 {
2318 CHECKGL (glBindTexture (GL_TEXTURE_2D, _OpenGLID) );
2319+#ifndef NUX_OPENGLES_20
2320 CHECKGL (glEnable (GL_TEXTURE_2D) );
2321+#endif
2322 }
2323+#ifndef NUX_OPENGLES_20
2324 else if (_ResourceType == RTTEXTURERECTANGLE)
2325 {
2326 CHECKGL (glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _OpenGLID) );
2327@@ -212,6 +223,7 @@
2328 CHECKGL (glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _OpenGLID) );
2329 CHECKGL (glEnable (GL_TEXTURE_RECTANGLE_ARB) );
2330 }
2331+#endif
2332 else
2333 {
2334 nuxError (TEXT ("[IOpenGLBaseTexture::BindTexture] unknown texture type.") );
2335
2336=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.cpp'
2337--- NuxGraphics/IOpenGLFrameBufferObject.cpp 2011-09-20 06:03:43 +0000
2338+++ NuxGraphics/IOpenGLFrameBufferObject.cpp 2011-10-24 21:19:23 +0000
2339@@ -371,3 +371,4 @@
2340 return _ClippingRegionStack.size ();
2341 }
2342 }
2343+
2344
2345=== modified file 'NuxGraphics/IOpenGLGLSLShader.cpp'
2346--- NuxGraphics/IOpenGLGLSLShader.cpp 2011-09-20 06:03:43 +0000
2347+++ NuxGraphics/IOpenGLGLSLShader.cpp 2011-10-24 21:19:23 +0000
2348@@ -1,5 +1,5 @@
2349 /*
2350- * Copyright 2010 Inalogic® Inc.
2351+ * Copyright 2010 Inalogic® Inc.
2352 *
2353 * This program is free software: you can redistribute it and/or modify it
2354 * under the terms of the GNU Lesser General Public License, as
2355@@ -718,12 +718,12 @@
2356
2357
2358 // Vertex Attribute Aliasing
2359- // GLSL attempts to eliminate aliasing of vertex attributes but this is integral to NVIDIA’s hardware
2360+ // GLSL attempts to eliminate aliasing of vertex attributes but this is integral to NVIDIA's hardware
2361 // approach and necessary for maintaining compatibility with existing OpenGL applications that NVIDIA customers rely on.
2362- // NVIDIA’s GLSL implementation therefore does not allow built-in vertex attributes to collide with a
2363+ // NVIDIA's GLSL implementation therefore does not allow built-in vertex attributes to collide with a
2364 // generic vertex attributes that is assigned to a particular vertex attribute index with glBindAttribLocation.
2365 // For example, you should not use gl_Normal (a built-in vertex attribute) and also use glBindAttribLocation to
2366- // bind a generic vertex attribute named “whatever” to vertex attribute index 2 because gl_Normal aliases to index 2.
2367+ // bind a generic vertex attribute named "whatever" to vertex attribute index 2 because gl_Normal aliases to index 2.
2368 //
2369 // Built-in vertex attribute name Incompatible aliased vertex attribute index
2370 // gl_Vertex 0
2371@@ -1252,10 +1252,12 @@
2372 void IOpenGLShaderProgram::GetObjectParameterfvARB (GLenum pname,
2373 GLfloat *params)
2374 {
2375+#ifndef NUX_OPENGLES_20
2376 glGetObjectParameterfvARB (_OpenGLID,
2377 pname,
2378 params);
2379 CHECKGL_MSG (glGetObjectParameterfvARB);
2380+#endif
2381 }
2382
2383 bool IOpenGLShaderProgram::SetSampler (char *name, int texture_unit)
2384
2385=== modified file 'NuxGraphics/IOpenGLGLSLShader.h'
2386--- NuxGraphics/IOpenGLGLSLShader.h 2011-09-20 06:03:43 +0000
2387+++ NuxGraphics/IOpenGLGLSLShader.h 2011-10-24 21:19:23 +0000
2388@@ -167,13 +167,13 @@
2389
2390 void GetUniformfv (char *name, GLfloat *values);
2391 void GetUniformiv (char *name, GLint *values);
2392- int GetUniformLocationARB (const GLcharARB *name);
2393+ int GetUniformLocationARB (const GLchar *name);
2394 void GetActiveUniformARB (GLuint index,
2395 GLsizei maxLength,
2396 GLsizei *length,
2397 GLint *size,
2398 GLenum *type,
2399- GLcharARB *name);
2400+ GLchar *name);
2401
2402 // glGetObjectParameterARBfv Parameters
2403 // object
2404
2405=== modified file 'NuxGraphics/IOpenGLIndexBuffer.cpp'
2406--- NuxGraphics/IOpenGLIndexBuffer.cpp 2011-04-06 21:54:09 +0000
2407+++ NuxGraphics/IOpenGLIndexBuffer.cpp 2011-10-24 21:19:23 +0000
2408@@ -79,9 +79,14 @@
2409
2410 CHECKGL ( glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, _OpenGLID) );
2411 // Map the Entire buffer into system memory
2412+#ifndef NUX_OPENGLES_20
2413 _MemMap = (BYTE *) glMapBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); // todo: use Format instead of GL_WRITE_ONLY_ARB
2414 CHECKGL_MSG (glMapBufferARB);
2415 *ppbData = (void *) (_MemMap + OffsetToLock);
2416+#else
2417+ _MemMap = new BYTE[SizeToLock];
2418+ *ppbData = _MemMap;
2419+#endif
2420
2421 _OffsetToLock = OffsetToLock;
2422 _SizeToLock = SizeToLock;
2423@@ -99,13 +104,19 @@
2424 // No need to bind
2425 CHECKGL ( glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, _OpenGLID) );
2426
2427+#ifndef NUX_OPENGLES_20
2428+ CHECKGL ( glUnmapBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB) );
2429+#else
2430+ CHECKGL( glBufferSubData (GL_ELEMENT_ARRAY_BUFFER_ARB, _OffsetToLock, _SizeToLock, _MemMap) );
2431+ delete [] _MemMap;
2432+#endif
2433+
2434+ CHECKGL ( glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, 0) );
2435+
2436 _MemMap = 0;
2437 _OffsetToLock = 0;
2438 _SizeToLock = 0;
2439
2440- CHECKGL ( glUnmapBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB) );
2441- CHECKGL ( glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, 0) );
2442-
2443 return OGL_OK;
2444 }
2445
2446
2447=== modified file 'NuxGraphics/IOpenGLPixelBufferOject.cpp'
2448--- NuxGraphics/IOpenGLPixelBufferOject.cpp 2011-04-06 21:54:09 +0000
2449+++ NuxGraphics/IOpenGLPixelBufferOject.cpp 2011-10-24 21:19:23 +0000
2450@@ -75,6 +75,8 @@
2451 nuxAssert (_OffsetToLock == 0);
2452 nuxAssert (_SizeToLock == 0);
2453
2454+#ifndef NUX_OPENGLES_20
2455+//FIXME: GLES 2.0 doesn't support PBOs, we need to allocate client memory and copy data there
2456 // When locking it shouldn't matter if we use GL_PIXEL_UNPACK_BUFFER_ARB or GL_PIXEL_PACK_BUFFER_ARB.
2457 // We just want a pointer to the data.
2458 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, _OpenGLID) );
2459@@ -88,19 +90,21 @@
2460
2461 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0) );
2462 CHECKGL ( glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, 0) );
2463+#endif
2464
2465 return OGL_OK;
2466 }
2467
2468 int IOpenGLPixelBufferObject::Unlock()
2469 {
2470+#ifndef NUX_OPENGLES_20
2471 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, _OpenGLID) );
2472 //CHECKGL( glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, _OffsetToLock, _SizeToLock, _MemMap) );
2473
2474 CHECKGL ( glUnmapBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB) );
2475 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0) );
2476 CHECKGL ( glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, 0) );
2477-
2478+#endif
2479
2480 _MemMap = 0;
2481 _OffsetToLock = 0;
2482@@ -110,12 +114,16 @@
2483
2484 void IOpenGLPixelBufferObject::BindPackPixelBufferObject()
2485 {
2486+#ifndef NUX_OPENGLES_20
2487 CHECKGL (glBindBufferARB (GL_PIXEL_PACK_BUFFER_ARB, _OpenGLID) );
2488+#endif
2489 }
2490
2491 void IOpenGLPixelBufferObject::BindUnpackPixelBufferObject()
2492 {
2493+#ifndef NUX_OPENGLES_20
2494 CHECKGL (glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, _OpenGLID) );
2495+#endif
2496 }
2497
2498 t_u32 IOpenGLPixelBufferObject::GetSize()
2499
2500=== modified file 'NuxGraphics/IOpenGLQuery.cpp'
2501--- NuxGraphics/IOpenGLQuery.cpp 2011-04-06 21:54:09 +0000
2502+++ NuxGraphics/IOpenGLQuery.cpp 2011-10-24 21:19:23 +0000
2503@@ -38,7 +38,9 @@
2504 , _Type (Type)
2505 , _QueryStarted (false)
2506 {
2507+#ifndef NUX_OPENGLES_20
2508 CHECKGL ( glGenQueriesARB (1, &_OpenGLID) ) ;
2509+#endif
2510 }
2511
2512 // The return type identifies the query state (see Queries).
2513@@ -50,6 +52,7 @@
2514 t_u32 GetDataFlags
2515 )
2516 {
2517+#ifndef NUX_OPENGLES_20
2518 unsigned int ResultReady = 0;
2519 glGetQueryObjectuivARB (_OpenGLID, GL_QUERY_RESULT_AVAILABLE_ARB, &ResultReady);
2520 CHECKGL_MSG ( glGetQueryObjectuivARB );
2521@@ -60,10 +63,9 @@
2522 CHECKGL_MSG ( glGetQueryObjectuivARB );
2523 return 1;
2524 }
2525- else
2526- {
2527- return 0;
2528- }
2529+#endif
2530+
2531+ return 0;
2532 }
2533
2534 t_u32 IOpenGLQuery::GetDataSize()
2535@@ -86,6 +88,7 @@
2536 t_u32 IssueFlags
2537 )
2538 {
2539+#ifndef NUX_OPENGLES_20
2540 if (IssueFlags == (t_u32) ISSUE_BEGIN)
2541 {
2542 nuxAssert (_CurrentlyActiveQuery == 0);
2543@@ -116,6 +119,7 @@
2544 _CurrentlyActiveQuery = 0;
2545 }
2546 }
2547+#endif
2548 }
2549
2550 // Return True is the result is available. That is glGetQueryObjectuivARB won't block
2551@@ -123,8 +127,10 @@
2552 bool IOpenGLQuery::IsResultAvailable()
2553 {
2554 unsigned int ResultReady = 0;
2555+#ifndef NUX_OPENGLES_20
2556 glGetQueryObjectuivARB (_OpenGLID, GL_QUERY_RESULT_AVAILABLE_ARB, &ResultReady);
2557 CHECKGL_MSG ( glGetQueryObjectuivARB );
2558+#endif
2559
2560 return ResultReady != 0;
2561 }
2562@@ -133,10 +139,13 @@
2563 unsigned int IOpenGLQuery::GetResult()
2564 {
2565 unsigned int SamplesPassed = 0;
2566+#ifndef NUX_OPENGLES_20
2567 glGetQueryObjectuivARB (_OpenGLID, GL_QUERY_RESULT_ARB, &SamplesPassed);
2568 CHECKGL_MSG ( glGetQueryObjectuivARB );
2569+#endif
2570
2571 return SamplesPassed;
2572 }
2573
2574 }
2575+
2576
2577=== modified file 'NuxGraphics/IOpenGLRectangleTexture.cpp'
2578--- NuxGraphics/IOpenGLRectangleTexture.cpp 2011-04-06 21:54:09 +0000
2579+++ NuxGraphics/IOpenGLRectangleTexture.cpp 2011-10-24 21:19:23 +0000
2580@@ -35,6 +35,7 @@
2581 , BitmapFormat PixelFormat, bool Dummy, NUX_FILE_LINE_DECL)
2582 : IOpenGLBaseTexture (RTTEXTURERECTANGLE, Width, Height, 1, Levels, PixelFormat, NUX_FILE_LINE_PARAM)
2583 {
2584+#ifndef NUX_OPENGLES_20
2585 if (Dummy == false)
2586 {
2587 glGenTextures (1, &_OpenGLID);
2588@@ -56,6 +57,7 @@
2589 SetWrap (GL_CLAMP, GL_CLAMP, GL_CLAMP);
2590 SetRenderStates();
2591 GRunTimeStats.Register (this);
2592+#endif
2593 }
2594
2595 IOpenGLRectangleTexture::~IOpenGLRectangleTexture()
2596@@ -160,3 +162,4 @@
2597 }
2598 }
2599 }
2600+
2601
2602=== modified file 'NuxGraphics/IOpenGLSurface.cpp'
2603--- NuxGraphics/IOpenGLSurface.cpp 2011-09-21 03:14:43 +0000
2604+++ NuxGraphics/IOpenGLSurface.cpp 2011-10-24 21:19:23 +0000
2605@@ -241,12 +241,17 @@
2606
2607 BYTE *DataPtr = 0;
2608
2609+#ifndef NUX_OPENGLES_20
2610 if (_STextureTarget == GL_TEXTURE_2D || _STextureTarget == GL_TEXTURE_RECTANGLE_ARB || _STextureTarget == GL_TEXTURE_CUBE_MAP || _STextureTarget == GL_TEXTURE_3D)
2611+#else
2612+ if (_STextureTarget == GL_TEXTURE_2D)
2613+#endif
2614 {
2615 int w = _Rect.right - _Rect.left;
2616 int h = _Rect.bottom - _Rect.top;
2617 CHECKGL ( glBindTexture (_STextureTarget, _BaseTexture->_OpenGLID) );
2618
2619+#ifndef NUX_OPENGLES_20
2620 if (GetGraphicsDisplay()->GetGpuDevice()->UsePixelBufferObjects() )
2621 {
2622 // Unmap the texture image buffer
2623@@ -257,11 +262,15 @@
2624 else
2625 {
2626 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0) );
2627+#endif
2628 DataPtr = (BYTE *) _LockedRect.pBits;
2629+#ifndef NUX_OPENGLES_20
2630 }
2631+#endif
2632
2633 IOpenGLTexture2D *texture = (IOpenGLTexture2D *) _BaseTexture;
2634
2635+#ifndef NUX_OPENGLES_20
2636 if ( /*texture->_PixelFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||*/
2637 texture->_PixelFormat == BITFMT_DXT1 ||
2638 texture->_PixelFormat == BITFMT_DXT2 ||
2639@@ -344,6 +353,7 @@
2640 //CHECKGL( glPixelStorei(GL_UNPACK_ROW_LENGTH, w) );
2641 if (_STextureTarget != GL_TEXTURE_3D)
2642 {
2643+#endif
2644 CHECKGL ( glTexSubImage2D (_SSurfaceTarget,
2645 _SMipLevel,
2646 _Rect.left,
2647@@ -354,6 +364,7 @@
2648 GPixelFormats[texture->_PixelFormat].type,
2649 DataPtr
2650 ) );
2651+#ifndef NUX_OPENGLES_20
2652 }
2653 else
2654 {
2655@@ -388,12 +399,14 @@
2656 // ) );
2657
2658 }
2659+#endif
2660 }
2661 else
2662 {
2663 nuxDebugMsg (TEXT("[IOpenGLSurface::UnlockRect] Incorrect Texture Target."));
2664 }
2665
2666+#ifndef NUX_OPENGLES_20
2667 if (GetGraphicsDisplay()->GetGpuDevice()->UsePixelBufferObjects() )
2668 {
2669 CHECKGL ( glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0) );
2670@@ -401,12 +414,15 @@
2671 }
2672 else
2673 {
2674+#endif
2675 //[DEBUGGING - NO PBO]
2676 if (_LockedRect.pBits)
2677 {
2678 delete [] ( (BYTE *) _LockedRect.pBits);
2679 }
2680+#ifndef NUX_OPENGLES_20
2681 }
2682+#endif
2683
2684 CHECKGL ( glPixelStorei (GL_UNPACK_ALIGNMENT, GetGraphicsDisplay()->GetGpuDevice()->GetPixelStoreAlignment() ) );
2685
2686@@ -433,6 +449,7 @@
2687
2688 CHECKGL ( glPixelStorei (GL_UNPACK_ALIGNMENT, MemAlignment) );
2689
2690+#ifndef NUX_OPENGLES_20
2691 if ( _BaseTexture->_PixelFormat == BITFMT_DXT1 ||
2692 _BaseTexture->_PixelFormat == BITFMT_DXT2 ||
2693 _BaseTexture->_PixelFormat == BITFMT_DXT3 ||
2694@@ -473,6 +490,7 @@
2695 {
2696 if (_STextureTarget != GL_TEXTURE_3D)
2697 {
2698+#endif
2699 glTexImage2D (
2700 _SSurfaceTarget,
2701 _SMipLevel, // level
2702@@ -484,6 +502,7 @@
2703 GPixelFormats[_BaseTexture->_PixelFormat].type,
2704 DummyBuffer);
2705 CHECKGL_MSG (glTexImage2D);
2706+#ifndef NUX_OPENGLES_20
2707 }
2708 else
2709 {
2710@@ -501,6 +520,7 @@
2711 // CHECKGL_MSG(glTexImage3D);
2712 }
2713 }
2714+#endif
2715
2716 free (DummyBuffer);
2717
2718@@ -533,7 +553,11 @@
2719 {
2720 CHECKGL (glPixelStorei (GL_UNPACK_ALIGNMENT, _BaseTexture->GetFormatRowMemoryAlignment ()));
2721
2722+#ifndef NUX_OPENGLES_20
2723 if (_STextureTarget == GL_TEXTURE_2D || _STextureTarget == GL_TEXTURE_RECTANGLE_ARB || _STextureTarget == GL_TEXTURE_CUBE_MAP || _STextureTarget == GL_TEXTURE_3D)
2724+#else
2725+ if (_STextureTarget == GL_TEXTURE_2D)
2726+#endif
2727 {
2728 CHECKGL ( glBindTexture (_STextureTarget, _BaseTexture->_OpenGLID) );
2729
2730@@ -563,17 +587,14 @@
2731 height));
2732 }
2733 #else
2734- if (_STextureTarget != GL_TEXTURE_3D)
2735- {
2736- CHECKGL (glCopyTexImage2D (_SSurfaceTarget,
2737- _SMipLevel,
2738- GPixelFormats [texture->_PixelFormat].Format,
2739- x,
2740- y,
2741- width,
2742- height,
2743- 0));
2744- }
2745+ CHECKGL (glCopyTexImage2D (_SSurfaceTarget,
2746+ _SMipLevel,
2747+ GPixelFormats [_BaseTexture->_PixelFormat].Format,
2748+ x,
2749+ y,
2750+ width,
2751+ height,
2752+ 0));
2753 #endif
2754 }
2755 }
2756@@ -584,6 +605,7 @@
2757 height = 0;
2758 format = BITFMT_UNKNOWN;
2759
2760+#ifndef NUX_OPENGLES_20
2761 // Because we use SubImage when unlocking surfaces, we must first get some dummy data in the surface before we can make a lock.
2762 int texwidth = ImageSurface::GetLevelWidth (_BaseTexture->_PixelFormat, _BaseTexture->_Width, _SMipLevel);
2763 int texheight = ImageSurface::GetLevelHeight (_BaseTexture->_PixelFormat, _BaseTexture->_Height, _SMipLevel);
2764@@ -604,6 +626,10 @@
2765 height = _BaseTexture->_Height;
2766 format = BITFMT_R8G8B8A8;
2767 return img;
2768+#else
2769+//FIXME: need to render to framebuffer and use glReadPixels
2770+ return NULL;
2771+#endif
2772 }
2773
2774 }
2775
2776=== modified file 'NuxGraphics/IOpenGLTexture2D.cpp'
2777--- NuxGraphics/IOpenGLTexture2D.cpp 2011-09-20 06:03:43 +0000
2778+++ NuxGraphics/IOpenGLTexture2D.cpp 2011-10-24 21:19:23 +0000
2779@@ -53,6 +53,17 @@
2780
2781 SetFiltering (GL_NEAREST, GL_NEAREST);
2782 SetWrap (GL_REPEAT, GL_REPEAT, GL_REPEAT);
2783+
2784+#ifdef NUX_OPENGLES_20
2785+ // NPOT textures in GLES2 only support GL_CLAMP_TO_EDGE unless
2786+ // GL_OES_texture_npot is supported.
2787+ // TODO: Check for GL_OES_texture_npot
2788+ if (!_IsPOT)
2789+ {
2790+ SetWrap (GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
2791+ }
2792+#endif
2793+
2794 SetRenderStates();
2795
2796 GRunTimeStats.Register (this);
2797
2798=== modified file 'NuxGraphics/IOpenGLVertexBuffer.cpp'
2799--- NuxGraphics/IOpenGLVertexBuffer.cpp 2011-04-06 21:54:09 +0000
2800+++ NuxGraphics/IOpenGLVertexBuffer.cpp 2011-10-24 21:19:23 +0000
2801@@ -80,10 +80,15 @@
2802 nuxAssert (_SizeToLock == 0);
2803
2804 CHECKGL ( glBindBufferARB (GL_ARRAY_BUFFER_ARB, _OpenGLID) );
2805+#ifndef NUX_OPENGLES_20
2806 // Map the Entire buffer into system memory
2807 _MemMap = (BYTE *) glMapBufferARB (GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
2808 CHECKGL_MSG (glMapBufferARB);
2809 *ppbData = (void *) (_MemMap + OffsetToLock);
2810+#else
2811+ _MemMap = new BYTE[SizeToLock];
2812+ *ppbData = _MemMap;
2813+#endif
2814
2815 _OffsetToLock = OffsetToLock;
2816 _SizeToLock = SizeToLock;
2817@@ -96,9 +101,13 @@
2818 int IOpenGLVertexBuffer::Unlock()
2819 {
2820 CHECKGL ( glBindBufferARB (GL_ARRAY_BUFFER_ARB, _OpenGLID) );
2821- //CHECKGL( glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, _OffsetToLock, _SizeToLock, _MemMap) );
2822
2823+#ifndef NUX_OPENGLES_20
2824 CHECKGL ( glUnmapBufferARB (GL_ARRAY_BUFFER_ARB) );
2825+#else
2826+ CHECKGL( glBufferSubData (GL_ARRAY_BUFFER_ARB, _OffsetToLock, _SizeToLock, _MemMap) );
2827+ delete [] _MemMap;
2828+#endif
2829 CHECKGL ( glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0) );
2830
2831 _MemMap = 0;
2832
2833=== modified file 'NuxGraphics/IOpenGLVolume.cpp'
2834--- NuxGraphics/IOpenGLVolume.cpp 2011-09-20 06:03:43 +0000
2835+++ NuxGraphics/IOpenGLVolume.cpp 2011-10-24 21:19:23 +0000
2836@@ -49,6 +49,7 @@
2837 const VOLUME_BOX *pBox)
2838
2839 {
2840+#ifndef NUX_OPENGLES_20
2841 // If _LockedRect.pBits or _LockedRect.Pitch are not equal to zero, then we have already Locked the buffer
2842 // Unlock it before locking again.
2843 nuxAssert (_LockedBox.pBits == 0);
2844@@ -254,12 +255,14 @@
2845 _Box.Front = pBox->Front;
2846 _Box.Back = pBox->Back;
2847 }
2848+#endif
2849
2850 return OGL_OK;
2851 }
2852
2853 int IOpenGLVolume::UnlockBox()
2854 {
2855+#ifndef NUX_OPENGLES_20
2856 if (_LockedBox.pBits == 0)
2857 {
2858 return OGL_INVALID_UNLOCK;
2859@@ -372,12 +375,14 @@
2860 _LockedBox.pBits = 0;
2861 _LockedBox.RowPitch = 0;
2862 _CompressedDataSize = 0;
2863+#endif
2864
2865 return OGL_OK;
2866 }
2867
2868 int IOpenGLVolume::InitializeLevel()
2869 {
2870+#ifndef NUX_OPENGLES_20
2871 // Because we use SubImage when unlocking surfaces, we must first get some dummy data in the surface before we can make a lock.
2872 int volwidth = ImageSurface::GetLevelDim (_VolumeTexture->_PixelFormat, _VolumeTexture->_Width, _SMipLevel);
2873 int volheight = ImageSurface::GetLevelDim (_VolumeTexture->_PixelFormat, _VolumeTexture->_Height, _SMipLevel);
2874@@ -462,6 +467,7 @@
2875 CHECKGL ( glPixelStorei (GL_UNPACK_ALIGNMENT, GetGraphicsDisplay()->GetGpuDevice()->GetPixelStoreAlignment() ) );
2876
2877 _Initialized = true;
2878+#endif
2879 return OGL_OK;
2880 }
2881
2882
2883=== modified file 'NuxGraphics/IOpenGLVolumeTexture.cpp'
2884--- NuxGraphics/IOpenGLVolumeTexture.cpp 2011-04-06 21:54:09 +0000
2885+++ NuxGraphics/IOpenGLVolumeTexture.cpp 2011-10-24 21:19:23 +0000
2886@@ -36,6 +36,7 @@
2887 , BitmapFormat PixelFormat)
2888 : IOpenGLBaseTexture (RTVOLUMETEXTURE, Width, Height, Depth, Levels, PixelFormat)
2889 {
2890+#ifndef NUX_OPENGLES_20
2891 CHECKGL ( glGenTextures (1, &_OpenGLID) );
2892 CHECKGL ( glBindTexture (GL_TEXTURE_3D, _OpenGLID) );
2893
2894@@ -65,6 +66,7 @@
2895 SetWrap (GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
2896 SetRenderStates();
2897 GRunTimeStats.Register (this);
2898+#endif
2899 }
2900
2901 IOpenGLVolumeTexture::~IOpenGLVolumeTexture()
2902@@ -177,3 +179,4 @@
2903 }
2904
2905 }
2906+
2907
2908=== modified file 'NuxGraphics/Makefile.am'
2909--- NuxGraphics/Makefile.am 2011-09-20 06:03:43 +0000
2910+++ NuxGraphics/Makefile.am 2011-10-24 21:19:23 +0000
2911@@ -78,6 +78,7 @@
2912 $(srcdir)/NuxGraphicsObject.h \
2913 $(srcdir)/NuxGraphicsResources.h \
2914 $(srcdir)/OpenGLDefinitions.h \
2915+ $(srcdir)/OpenGLMapping.h \
2916 $(srcdir)/RenderingPipe.h \
2917 $(srcdir)/RenderingPipeAsm.h \
2918 $(srcdir)/RenderingPipeGLSL.h \
2919
2920=== added file 'NuxGraphics/OpenGLMapping.h'
2921--- NuxGraphics/OpenGLMapping.h 1970-01-01 00:00:00 +0000
2922+++ NuxGraphics/OpenGLMapping.h 2011-10-24 21:19:23 +0000
2923@@ -0,0 +1,129 @@
2924+/*
2925+ * Copyright 2011 Inalogic® Inc.
2926+ *
2927+ * This program is free software: you can redistribute it and/or modify it
2928+ * under the terms of the GNU Lesser General Public License, as
2929+ * published by the Free Software Foundation; either version 2.1 or 3.0
2930+ * of the License.
2931+ *
2932+ * This program is distributed in the hope that it will be useful, but
2933+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2934+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
2935+ * PURPOSE. See the applicable version of the GNU Lesser General Public
2936+ * License for more details.
2937+ *
2938+ * You should have received a copy of both the GNU Lesser General Public
2939+ * License along with this program. If not, see <http://www.gnu.org/licenses/>
2940+ *
2941+ * Authored by: Travis Watkins <travis.watkins@linaro.org>
2942+ *
2943+ */
2944+
2945+// A series of defines to map GL functions to GLES functions
2946+
2947+#ifndef OPENGLMAPPING_H
2948+#define OPENGLMAPPING_H
2949+
2950+#define GL_GLEXT_PROTOTYPES
2951+
2952+#define GLcharARB GLchar
2953+
2954+#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
2955+#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
2956+#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
2957+#define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING
2958+#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
2959+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
2960+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
2961+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
2962+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
2963+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT GL_FRAMEBUFFER_UNSUPPORTED
2964+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2965+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
2966+
2967+#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER
2968+#define GL_RENDERBUFFER_BINDING_EXT GL_RENDERBUFFER_BINDING
2969+#define GL_MAX_RENDERBUFFER_SIZE_EXT GL_MAX_RENDERBUFFER_SIZE
2970+
2971+#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER
2972+#define GL_ELEMENT_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER
2973+
2974+// not sure if this will work in all cases
2975+#define GL_CLAMP GL_CLAMP_TO_EDGE
2976+// needs extra shader code but otherwise is equivalent
2977+#define GL_CLAMP_TO_BORDER GL_CLAMP_TO_EDGE
2978+
2979+#define GL_WRITE_ONLY_ARB GL_WRITE_ONLY_OES
2980+
2981+#define GL_VERTEX_SHADER_ARB GL_VERTEX_SHADER
2982+#define GL_FRAGMENT_SHADER_ARB GL_FRAGMENT_SHADER
2983+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB GL_ACTIVE_ATTRIBUTES
2984+
2985+#define glActiveTextureARB glActiveTexture
2986+
2987+#define glGenBuffersARB glGenBuffers
2988+#define glDeleteBuffersARB glDeleteBuffers
2989+#define glBindBufferARB glBindBuffer
2990+#define glBufferDataARB glBufferData
2991+#define glMapBufferARB glMapBufferOES
2992+#define glUnmapBufferARB glUnmapBufferOES
2993+
2994+#define glBindBufferARB glBindBuffer
2995+#define glEnableVertexAttribArrayARB glEnableVertexAttribArray
2996+#define glDisableVertexAttribArrayARB glDisableVertexAttribArray
2997+#define glVertexAttribPointerARB glVertexAttribPointer
2998+
2999+#define glDeleteFramebuffersEXT glDeleteFramebuffers
3000+#define glBindFramebufferEXT glBindFramebuffer
3001+#define glGenFramebuffersEXT glGenFramebuffers
3002+#define glFramebufferTexture2DEXT glFramebufferTexture2D
3003+#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
3004+#define glGetFramebufferAttachmentParameterivEXT glGetFramebufferAttachmentParameteriv
3005+#define glFramebufferRenderbufferEXT glFramebufferRenderbuffer
3006+
3007+#define glBindRenderbufferEXT glBindRenderbuffer
3008+#define glRenderbufferStorageEXT glRenderbufferStorage
3009+#define glGenRenderbuffersEXT glGenRenderbuffers
3010+#define glDeleteRenderbuffersEXT glDeleteRenderbuffers
3011+
3012+#define glUseProgramObjectARB glUseProgram
3013+#define glGetObjectParameteriv glGetProgramiv
3014+
3015+#define glUniform1iARB glUniform1i
3016+#define glUniform2iARB glUniform2i
3017+#define glUniform3iARB glUniform3i
3018+#define glUniform4iARB glUniform4i
3019+
3020+#define glUniform1ivARB glUniform1iv
3021+#define glUniform2ivARB glUniform2iv
3022+#define glUniform3ivARB glUniform3iv
3023+#define glUniform4ivARB glUniform4iv
3024+
3025+#define glUniform1fARB glUniform1f
3026+#define glUniform2fARB glUniform2f
3027+#define glUniform3fARB glUniform3f
3028+#define glUniform4fARB glUniform4f
3029+
3030+#define glUniform1fvARB glUniform1fv
3031+#define glUniform2fvARB glUniform2fv
3032+#define glUniform3fvARB glUniform3fv
3033+#define glUniform4fvARB glUniform4fv
3034+
3035+#define glGetUniformfvARB glGetUniformfv
3036+#define glGetUniformivARB glGetUniformiv
3037+
3038+#define glUniformMatrix2fvARB glUniformMatrix2fv
3039+#define glUniformMatrix3fvARB glUniformMatrix3fv
3040+#define glUniformMatrix4fvARB glUniformMatrix4fv
3041+
3042+#define glGetActiveAttribARB glGetActiveAttrib
3043+#define glGetActiveUniformARB glGetActiveUniform
3044+#define glGetObjectParameterivARB glGetObjectParameteriv
3045+#define glGetUniformLocationARB glGetUniformLocation
3046+#define glGetAttribLocationARB glGetAttribLocation
3047+
3048+#define glDepthRange glDepthRangef
3049+#define glClearDepth glClearDepthf
3050+
3051+#endif // OPENGLMAPPING_H
3052+
3053
3054=== modified file 'NuxGraphics/RenderingPipe.cpp'
3055--- NuxGraphics/RenderingPipe.cpp 2011-09-20 06:03:43 +0000
3056+++ NuxGraphics/RenderingPipe.cpp 2011-10-24 21:19:23 +0000
3057@@ -43,9 +43,11 @@
3058 {TEXWRAP_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE},
3059 {TEXWRAP_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER},
3060 {TEXWRAP_MIRRORED_REPEAT, GL_MIRRORED_REPEAT},
3061+#ifndef NUX_OPENGLES_20
3062 {TEXWRAP_MIRROR_CLAMP_EXT, GL_MIRROR_CLAMP_EXT},
3063 {TEXWRAP_MIRROR_CLAMP_TO_EDGE_EXT, GL_MIRROR_CLAMP_TO_EDGE_EXT},
3064 {TEXWRAP_MIRROR_CLAMP_TO_BORDER_EXT, GL_MIRROR_CLAMP_TO_BORDER_EXT},
3065+#endif
3066 {TEXWRAP_UNKNOWN, 0}
3067 };
3068
3069@@ -286,6 +288,41 @@
3070 texxform.vwrap = TEXWRAP_CLAMP;
3071 }
3072 }
3073+
3074+#ifdef NUX_OPENGLES_20
3075+ // Enforce OpenGL ES 2.0 texture restrictions
3076+ // 1. There is neither CLAMP nor CLAMP_TO_BORDER
3077+ // 2. For NPOT textures, only CLAMP_TO_EDGE is supported
3078+ // 3. For NPOT textures, only NEAREST and LINEAR are supported
3079+ //
3080+ // The last two constraints are relaxed by the GL_OES_texture_npot
3081+ // extension which unfortunately is not supported by all implementations.
3082+ //
3083+ // Notes: we have mapped GL_CLAMP to GL_CLAMP_TO_EDGE in OpenGLMapping.h
3084+ // so we also "support" TEXWRAP_CLAMP.
3085+ if (texxform.uwrap == TEXWRAP_CLAMP_TO_BORDER ||
3086+ texxform.vwrap == TEXWRAP_CLAMP_TO_BORDER ||
3087+ (!tex->IsPowerOfTwo() &&
3088+ ((texxform.uwrap != TEXWRAP_CLAMP &&
3089+ texxform.uwrap != TEXWRAP_CLAMP_TO_EDGE) ||
3090+ (texxform.vwrap != TEXWRAP_CLAMP &&
3091+ texxform.vwrap != TEXWRAP_CLAMP_TO_EDGE))))
3092+ {
3093+ texxform.uwrap = TEXWRAP_CLAMP_TO_EDGE;
3094+ texxform.vwrap = TEXWRAP_CLAMP_TO_EDGE;
3095+ }
3096+
3097+ if (!tex->IsPowerOfTwo() &&
3098+ ((texxform.min_filter != TEXFILTER_NEAREST &&
3099+ texxform.min_filter != TEXFILTER_LINEAR) ||
3100+ (texxform.mag_filter != TEXFILTER_NEAREST &&
3101+ texxform.mag_filter != TEXFILTER_LINEAR)))
3102+ {
3103+ texxform.min_filter = TEXFILTER_LINEAR;
3104+ texxform.mag_filter = TEXFILTER_LINEAR;
3105+ }
3106+#endif
3107+
3108 tex->SetWrap (TexWrapGLMapping (texxform.uwrap), TexWrapGLMapping (texxform.vwrap), GL_CLAMP);
3109 tex->SetFiltering (TexFilterGLMapping (texxform.min_filter), TexFilterGLMapping (texxform.mag_filter) );
3110 }
3111@@ -559,7 +596,7 @@
3112 else
3113 return QRP_ASM_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
3114 #else
3115- return QRP_ASM_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
3116+ return QRP_GLSL_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
3117 #endif
3118 }
3119
3120
3121=== modified file 'NuxGraphics/RenderingPipeGLSL.cpp'
3122--- NuxGraphics/RenderingPipeGLSL.cpp 2011-09-21 03:14:43 +0000
3123+++ NuxGraphics/RenderingPipeGLSL.cpp 2011-10-24 21:19:23 +0000
3124@@ -31,6 +31,17 @@
3125
3126 namespace nux
3127 {
3128+#ifndef NUX_OPENGLES_20
3129+ #define VertexShaderHeader "#version 110 \n"
3130+#else
3131+ #define VertexShaderHeader
3132+#endif
3133+
3134+#ifndef NUX_OPENGLES_20
3135+ #define FragmentShaderHeader "#version 110 \n"
3136+#else
3137+ #define FragmentShaderHeader "precision mediump float; \n"
3138+#endif
3139
3140 // For some strange reason, make sure that the attribute holding the vertex position has a name that comes first in alphabetic order before all
3141 // other attributes. Otherwise you get a bug on NVidia! Why is that???
3142@@ -48,22 +59,26 @@
3143 NString VSString;
3144 NString PSString;
3145
3146- VSString = TEXT ("#version 110 \n\
3147- uniform mat4 ViewProjectionMatrix; \n\
3148+ VSString = TEXT (
3149+ VertexShaderHeader
3150+ "uniform mat4 ViewProjectionMatrix; \n\
3151 attribute vec4 AVertex; \n\
3152 attribute vec4 VertexColor; \n\
3153+ varying vec4 vColor; \n\
3154 void main() \n\
3155 { \n\
3156 gl_Position = ViewProjectionMatrix * AVertex; \n\
3157- gl_FrontColor = VertexColor; \n\
3158+ vColor = VertexColor; \n\
3159 }");
3160
3161 VS->SetShaderCode (TCHAR_TO_ANSI (*VSString) );
3162
3163- PSString = TEXT ("#version 110 \n\
3164+ PSString = TEXT (
3165+ FragmentShaderHeader
3166+ "varying vec4 vColor; \n\
3167 void main() \n\
3168 { \n\
3169- gl_FragColor = gl_Color; \n\
3170+ gl_FragColor = vColor; \n\
3171 }");
3172 PS->SetShaderCode (TCHAR_TO_ANSI (*PSString) );
3173
3174@@ -81,8 +96,9 @@
3175 NString VSString;
3176 NString PSString;
3177
3178- VSString = TEXT ("#version 110 \n\
3179- attribute vec4 AVertex; \n\
3180+ VSString = TEXT (
3181+ VertexShaderHeader
3182+ "attribute vec4 AVertex; \n\
3183 attribute vec4 MyTextureCoord0; \n\
3184 attribute vec4 VertexColor; \n\
3185 uniform mat4 ViewProjectionMatrix; \n\
3186@@ -95,23 +111,15 @@
3187 varyVertexColor = VertexColor; \n\
3188 }");
3189
3190- PSString = TEXT ("#version 110 \n\
3191- #extension GL_ARB_texture_rectangle : enable \n\
3192- varying vec4 varyTexCoord0; \n\
3193+ PSString = TEXT (
3194+ FragmentShaderHeader
3195+ "varying vec4 varyTexCoord0; \n\
3196 varying vec4 varyVertexColor; \n\
3197- #ifdef SAMPLERTEX2D \n\
3198 uniform sampler2D TextureObject0; \n\
3199 vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3200 { \n\
3201 return texture2D(TexObject, TexCoord.st); \n\
3202 } \n\
3203- #elif defined SAMPLERTEX2DRECT \n\
3204- uniform sampler2DRect TextureObject0; \n\
3205- vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
3206- { \n\
3207- return texture2DRect(TexObject, TexCoord.st); \n\
3208- } \n\
3209- #endif \n\
3210 void main() \n\
3211 { \n\
3212 vec4 v = SampleTexture(TextureObject0, varyTexCoord0); \n\
3213@@ -137,8 +145,9 @@
3214 NString VSString;
3215 NString PSString;
3216
3217- VSString = TEXT ("#version 110 \n\
3218- attribute vec4 AVertex; \n\
3219+ VSString = TEXT (
3220+ VertexShaderHeader
3221+ "attribute vec4 AVertex; \n\
3222 attribute vec4 MyTextureCoord0; \n\
3223 attribute vec4 VertexColor; \n\
3224 uniform mat4 ViewProjectionMatrix; \n\
3225@@ -151,23 +160,15 @@
3226 varyVertexColor = VertexColor; \n\
3227 }");
3228
3229- PSString = TEXT ("#version 110 \n\
3230- #extension GL_ARB_texture_rectangle : enable \n\
3231- varying vec4 varyTexCoord0; \n\
3232+ PSString = TEXT (
3233+ FragmentShaderHeader
3234+ "varying vec4 varyTexCoord0; \n\
3235 varying vec4 varyVertexColor; \n\
3236- #ifdef SAMPLERTEX2D \n\
3237 uniform sampler2D TextureObject0; \n\
3238 vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3239 { \n\
3240 return texture2D(TexObject, TexCoord.st); \n\
3241 } \n\
3242- #elif defined SAMPLERTEX2DRECT \n\
3243- uniform sampler2DRect TextureObject0; \n\
3244- vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
3245- { \n\
3246- return texture2DRect(TexObject, TexCoord.st); \n\
3247- } \n\
3248- #endif \n\
3249 void main() \n\
3250 { \n\
3251 float alpha = SampleTexture(TextureObject0, varyTexCoord0).w; \n\
3252@@ -184,17 +185,6 @@
3253 CHECKGL ( glBindAttribLocation (m_SlColorModTexMaskAlpha->GetOpenGLID(), 1, "MyTextureCoord0") );
3254 CHECKGL ( glBindAttribLocation (m_SlColorModTexMaskAlpha->GetOpenGLID(), 2, "VectexColor") );
3255 m_SlColorModTexMaskAlpha->Link();
3256-
3257- m_SlColorModTexRectMaskAlpha = _graphics_display.m_DeviceFactory->CreateShaderProgram();
3258- VS->SetShaderCode (TCHAR_TO_ANSI (*VSString) );
3259- PS->SetShaderCode (TCHAR_TO_ANSI (*PSString), TEXT ("#define SAMPLERTEX2DRECT") );
3260- m_SlColorModTexRectMaskAlpha->ClearShaderObjects();
3261- m_SlColorModTexRectMaskAlpha->AddShaderObject (VS);
3262- m_SlColorModTexRectMaskAlpha->AddShaderObject (PS);
3263- CHECKGL ( glBindAttribLocation (m_SlColorModTexRectMaskAlpha->GetOpenGLID(), 0, "AVertex") );
3264- CHECKGL ( glBindAttribLocation (m_SlColorModTexRectMaskAlpha->GetOpenGLID(), 1, "MyTextureCoord0") );
3265- CHECKGL ( glBindAttribLocation (m_SlColorModTexRectMaskAlpha->GetOpenGLID(), 2, "VectexColor") );
3266- m_SlColorModTexRectMaskAlpha->Link();
3267 }
3268
3269 void GraphicsEngine::InitSl2TextureAdd()
3270@@ -208,47 +198,48 @@
3271 // other attributes. Otherwise you get a bug on NVidia! Why is that???
3272
3273 ////////////////////////////////////////////////////////////////////////////////////////////////////
3274- VSString = TEXT ( "#version 110 \n\
3275- uniform mat4 ViewProjectionMatrix; \n\
3276- attribute vec4 AVertex; \n\
3277- attribute vec4 MyTextureCoord0; \n\
3278- attribute vec4 MyTextureCoord1; \n\
3279- varying vec4 varyTexCoord0; \n\
3280- varying vec4 varyTexCoord1; \n\
3281- void main() \n\
3282- { \n\
3283- varyTexCoord0 = MyTextureCoord0; \n\
3284- varyTexCoord1 = MyTextureCoord1; \n\
3285- gl_Position = ViewProjectionMatrix * (AVertex); \n\
3286- }");
3287+ VSString = TEXT (
3288+ VertexShaderHeader
3289+ "uniform mat4 ViewProjectionMatrix; \n\
3290+ attribute vec4 AVertex; \n\
3291+ attribute vec4 MyTextureCoord0; \n\
3292+ attribute vec4 MyTextureCoord1; \n\
3293+ varying vec4 varyTexCoord0; \n\
3294+ varying vec4 varyTexCoord1; \n\
3295+ void main() \n\
3296+ { \n\
3297+ varyTexCoord0 = MyTextureCoord0; \n\
3298+ varyTexCoord1 = MyTextureCoord1; \n\
3299+ gl_Position = ViewProjectionMatrix * (AVertex); \n\
3300+ }");
3301
3302- PSString = TEXT ( "#version 110 \n\
3303- #extension GL_ARB_texture_rectangle : enable \n\
3304- varying vec4 varyTexCoord0; \n\
3305- varying vec4 varyTexCoord1; \n\
3306- uniform vec4 color0; \n\
3307- uniform vec4 color1; \n\
3308- #ifdef SAMPLERTEX2D \n\
3309- uniform sampler2D TextureObject0; \n\
3310- uniform sampler2D TextureObject1; \n\
3311- vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3312- { \n\
3313- return texture2D(TexObject, TexCoord.st); \n\
3314- } \n\
3315- #elif defined SAMPLERTEX2DRECT \n\
3316- uniform sampler2DRect TextureObject0; \n\
3317- uniform sampler2DRect TextureObject1; \n\
3318- vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
3319- { \n\
3320- return texture2DRect(TexObject, TexCoord.st); \n\
3321- } \n\
3322- #endif \n\
3323- void main() \n\
3324- { \n\
3325- vec4 b0 = color0*SampleTexture(TextureObject0, varyTexCoord0); \n\
3326- vec4 b1 = color1*SampleTexture(TextureObject1, varyTexCoord1); \n\
3327- gl_FragColor = b0 + b1; \n\
3328- }");
3329+ PSString = TEXT (
3330+ FragmentShaderHeader
3331+ "varying vec4 varyTexCoord0; \n\
3332+ varying vec4 varyTexCoord1; \n\
3333+ uniform vec4 color0; \n\
3334+ uniform vec4 color1; \n\
3335+ #ifdef SAMPLERTEX2D \n\
3336+ uniform sampler2D TextureObject0; \n\
3337+ uniform sampler2D TextureObject1; \n\
3338+ vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3339+ { \n\
3340+ return texture2D(TexObject, TexCoord.st); \n\
3341+ } \n\
3342+ #elif defined SAMPLERTEX2DRECT \n\
3343+ uniform sampler2DRect TextureObject0; \n\
3344+ uniform sampler2DRect TextureObject1; \n\
3345+ vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
3346+ { \n\
3347+ return texture2DRect(TexObject, TexCoord.st); \n\
3348+ } \n\
3349+ #endif \n\
3350+ void main() \n\
3351+ { \n\
3352+ vec4 b0 = color0*SampleTexture(TextureObject0, varyTexCoord0); \n\
3353+ vec4 b1 = color1*SampleTexture(TextureObject1, varyTexCoord1); \n\
3354+ gl_FragColor = b0 + b1; \n\
3355+ }");
3356
3357 m_Sl2TextureAdd = _graphics_display.m_DeviceFactory->CreateShaderProgram();
3358 VS->SetShaderCode (TCHAR_TO_ANSI (*VSString) );
3359@@ -272,8 +263,9 @@
3360 // other attributes. Otherwise you get a bug on NVidia! Why is that???
3361
3362 ////////////////////////////////////////////////////////////////////////////////////////////////////
3363- VSString = TEXT ( "#version 110 \n\
3364- uniform mat4 ViewProjectionMatrix; \n\
3365+ VSString = TEXT (
3366+ VertexShaderHeader
3367+ "uniform mat4 ViewProjectionMatrix; \n\
3368 attribute vec4 AVertex; \n\
3369 attribute vec4 MyTextureCoord0; \n\
3370 attribute vec4 MyTextureCoord1; \n\
3371@@ -286,24 +278,25 @@
3372 gl_Position = ViewProjectionMatrix * (AVertex); \n\
3373 }");
3374
3375- PSString = TEXT ( "#version 110 \n\
3376- varying vec4 varyTexCoord0; \n\
3377- varying vec4 varyTexCoord1; \n\
3378- uniform vec4 color0; \n\
3379- uniform vec4 color1; \n\
3380- uniform sampler2D TextureObject0; \n\
3381- uniform sampler2D TextureObject1; \n\
3382- vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3383- { \n\
3384- return texture2D(TexObject, TexCoord.st); \n\
3385- } \n\
3386- void main() \n\
3387- { \n\
3388- vec4 noise = SampleTexture (TextureObject0, varyTexCoord0); \n\
3389- vec4 noise_bx2 = color0 * (2.0 * noise - vec4 (1.0, 1.0, 1.0, 1.0)); \n\
3390- vec4 b1 = color1 * SampleTexture(TextureObject1, varyTexCoord1 + noise_bx2); \n\
3391- gl_FragColor = b1; \n\
3392- }");
3393+ PSString = TEXT (
3394+ FragmentShaderHeader
3395+ "varying vec4 varyTexCoord0; \n\
3396+ varying vec4 varyTexCoord1; \n\
3397+ uniform vec4 color0; \n\
3398+ uniform vec4 color1; \n\
3399+ uniform sampler2D TextureObject0; \n\
3400+ uniform sampler2D TextureObject1; \n\
3401+ vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3402+ { \n\
3403+ return texture2D(TexObject, TexCoord.st); \n\
3404+ } \n\
3405+ void main() \n\
3406+ { \n\
3407+ vec4 noise = SampleTexture (TextureObject0, varyTexCoord0); \n\
3408+ vec4 noise_bx2 = color0 * (2.0 * noise - vec4 (1.0, 1.0, 1.0, 1.0)); \n\
3409+ vec4 b1 = color1 * SampleTexture(TextureObject1, varyTexCoord1 + noise_bx2); \n\
3410+ gl_FragColor = b1; \n\
3411+ }");
3412
3413 m_Sl2TextureDepRead = _graphics_display.m_DeviceFactory->CreateShaderProgram();
3414 VS->SetShaderCode (TCHAR_TO_ANSI (*VSString) );
3415@@ -327,8 +320,9 @@
3416 // other attributes. Otherwise you get a bug on NVidia! Why is that???
3417
3418 ////////////////////////////////////////////////////////////////////////////////////////////////////
3419- VSString = TEXT ( "#version 110 \n\
3420- uniform mat4 ViewProjectionMatrix; \n\
3421+ VSString = TEXT (
3422+ VertexShaderHeader
3423+ "uniform mat4 ViewProjectionMatrix; \n\
3424 attribute vec4 AVertex; \n\
3425 attribute vec4 MyTextureCoord0; \n\
3426 attribute vec4 MyTextureCoord1; \n\
3427@@ -341,9 +335,9 @@
3428 gl_Position = ViewProjectionMatrix * (AVertex); \n\
3429 }");
3430
3431- PSString = TEXT ( "#version 110 \n\
3432- #extension GL_ARB_texture_rectangle : enable \n\
3433- varying vec4 varyTexCoord0; \n\
3434+ PSString = TEXT (
3435+ FragmentShaderHeader
3436+ "varying vec4 varyTexCoord0; \n\
3437 varying vec4 varyTexCoord1; \n\
3438 uniform vec4 color0; \n\
3439 uniform vec4 color1; \n\
3440@@ -391,8 +385,9 @@
3441 // other attributes. Otherwise you get a bug on NVidia! Why is that???
3442
3443 ////////////////////////////////////////////////////////////////////////////////////////////////////
3444- VSString = TEXT ( "#version 110 \n\
3445- uniform mat4 ViewProjectionMatrix; \n\
3446+ VSString = TEXT (
3447+ VertexShaderHeader
3448+ "uniform mat4 ViewProjectionMatrix; \n\
3449 attribute vec4 AVertex; \n\
3450 attribute vec4 MyTextureCoord0; \n\
3451 attribute vec4 MyTextureCoord1; \n\
3452@@ -411,9 +406,9 @@
3453 gl_Position = ViewProjectionMatrix * (AVertex); \n\
3454 }");
3455
3456- PSString = TEXT ( "#version 110 \n\
3457- #extension GL_ARB_texture_rectangle : enable \n\
3458- varying vec4 varyTexCoord0; \n\
3459+ PSString = TEXT (
3460+ FragmentShaderHeader
3461+ "varying vec4 varyTexCoord0; \n\
3462 varying vec4 varyTexCoord1; \n\
3463 varying vec4 varyTexCoord2; \n\
3464 varying vec4 varyTexCoord3; \n\
3465@@ -438,8 +433,6 @@
3466 gl_FragColor = b0+b1+b2+b3; \n\
3467 }");
3468
3469- //vec4(v.w, v.w, v.w, v.w)
3470-
3471 // Textured 2D Primitive Shader
3472 m_Sl4TextureAdd = _graphics_display.m_DeviceFactory->CreateShaderProgram();
3473 VS->SetShaderCode (TCHAR_TO_ANSI (*VSString) );
3474@@ -450,16 +443,6 @@
3475 m_Sl4TextureAdd->AddShaderObject (PS);
3476 CHECKGL ( glBindAttribLocation (m_Sl4TextureAdd->GetOpenGLID(), 0, "AVertex") );
3477 m_Sl4TextureAdd->Link();
3478-
3479-// // Textured Rect Primitive Shader
3480-// m_4TexBlendRectProg = _graphics_display.m_DeviceFactory->CreateShaderProgram();
3481-// VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
3482-// PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), TEXT("#define SAMPLERTEX2DRECT"));
3483-// m_4TexBlendRectProg->ClearShaderObjects();
3484-// m_4TexBlendRectProg->AddShaderObject(VS);
3485-// m_4TexBlendRectProg->AddShaderObject(PS);
3486-// CHECKGL( glBindAttribLocation(m_4TexBlendRectProg->GetOpenGLID(), 0, "AVertex") );
3487-// m_4TexBlendRectProg->Link();
3488 }
3489
3490 void GraphicsEngine::InitSLPower ()
3491@@ -469,8 +452,9 @@
3492 NString VSString;
3493 NString PSString;
3494
3495- VSString = TEXT ("#version 110 \n\
3496- uniform mat4 ViewProjectionMatrix; \n\
3497+ VSString = TEXT (
3498+ VertexShaderHeader
3499+ "uniform mat4 ViewProjectionMatrix; \n\
3500 attribute vec4 AVertex; \n\
3501 attribute vec4 MyTextureCoord0; \n\
3502 varying vec4 varyTexCoord0; \n\
3503@@ -480,8 +464,9 @@
3504 gl_Position = ViewProjectionMatrix * (AVertex); \n\
3505 }");
3506
3507- PSString = TEXT ("#version 110 \n\
3508- varying vec4 varyTexCoord0; \n\
3509+ PSString = TEXT (
3510+ FragmentShaderHeader
3511+ "varying vec4 varyTexCoord0; \n\
3512 uniform sampler2D TextureObject0; \n\
3513 uniform vec2 TextureSize0; \n\
3514 uniform vec4 exponent; \n\
3515@@ -518,8 +503,9 @@
3516 NString PSString;
3517
3518
3519- VSString = TEXT ("#version 110 \n\
3520- uniform mat4 ViewProjectionMatrix; \n\
3521+ VSString = TEXT (
3522+ VertexShaderHeader
3523+ "uniform mat4 ViewProjectionMatrix; \n\
3524 attribute vec4 AVertex; \n\
3525 attribute vec4 MyTextureCoord0; \n\
3526 varying vec4 varyTexCoord0; \n\
3527@@ -529,8 +515,9 @@
3528 gl_Position = ViewProjectionMatrix * (AVertex); \n\
3529 }");
3530
3531- PSString = TEXT ("#version 110 \n\
3532- varying vec4 varyTexCoord0; \n\
3533+ PSString = TEXT (
3534+ FragmentShaderHeader
3535+ "varying vec4 varyTexCoord0; \n\
3536 uniform sampler2D TextureObject0; \n\
3537 uniform vec4 color0; \n\
3538 vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3539@@ -562,8 +549,9 @@
3540 NString PSString;
3541
3542
3543- VSString = TEXT ("#version 120 \n\
3544- uniform mat4 ViewProjectionMatrix; \n\
3545+ VSString = TEXT (
3546+ VertexShaderHeader
3547+ "uniform mat4 ViewProjectionMatrix; \n\
3548 attribute vec4 AVertex; \n\
3549 attribute vec4 MyTextureCoord0; \n\
3550 attribute vec4 VertexColor; \n\
3551@@ -577,8 +565,9 @@
3552 }");
3553
3554
3555- PSString = TEXT ("#version 120 \n\
3556- varying vec4 varyTexCoord0; \n\
3557+ PSString = TEXT (
3558+ FragmentShaderHeader
3559+ "varying vec4 varyTexCoord0; \n\
3560 varying vec4 varyVertexColor; \n\
3561 uniform sampler2D TextureObject0; \n\
3562 uniform vec2 TextureSize0; \n\
3563@@ -593,7 +582,7 @@
3564 vec4 sum = vec4 (0.0, 0.0, 0.0, 0.0); \n\
3565 vec2 delta = vec2 (1.0 / TextureSize0.x, 0.0); \n\
3566 vec2 texCoord = vec2 (varyTexCoord0.s, varyTexCoord0.t); \n\
3567- texCoord.x -= ((NUM_SAMPLES - 1) / 2) / TextureSize0.x; \n\
3568+ texCoord.x -= float ((NUM_SAMPLES - 1) / 2) / TextureSize0.x; \n\
3569 texCoord.y += 0.0 / TextureSize0.y; \n\
3570 sum += SampleTexture (TextureObject0, texCoord) * W[0]; \n\
3571 texCoord += delta; \n\
3572@@ -631,8 +620,9 @@
3573 NString VSString;
3574 NString PSString;
3575
3576- VSString = TEXT ("#version 110 \n\
3577- uniform mat4 ViewProjectionMatrix; \n\
3578+ VSString = TEXT (
3579+ VertexShaderHeader
3580+ "uniform mat4 ViewProjectionMatrix; \n\
3581 attribute vec4 AVertex; \n\
3582 attribute vec4 MyTextureCoord0; \n\
3583 attribute vec4 VertexColor; \n\
3584@@ -642,12 +632,13 @@
3585 { \n\
3586 varyTexCoord0 = MyTextureCoord0; \n\
3587 varyVertexColor = VertexColor; \n\
3588- gl_Position = ViewProjectionMatrix * (AVertex); \n\
3589+ gl_Position = ViewProjectionMatrix * (AVertex); \n\
3590 }");
3591
3592
3593- PSString = TEXT ("#version 120 \n\
3594- varying vec4 varyTexCoord0; \n\
3595+ PSString = TEXT (
3596+ FragmentShaderHeader
3597+ "varying vec4 varyTexCoord0; \n\
3598 varying vec4 varyVertexColor; \n\
3599 uniform sampler2D TextureObject0; \n\
3600 uniform vec2 TextureSize0; \n\
3601@@ -663,7 +654,7 @@
3602 vec2 delta = vec2 (0.0, 1.0 / TextureSize0.y); \n\
3603 vec2 texCoord = vec2 (varyTexCoord0.s, varyTexCoord0.t); \n\
3604 texCoord.x += 0.0 / TextureSize0.x; \n\
3605- texCoord.y -= ((NUM_SAMPLES - 1) / 2) / TextureSize0.y; \n\
3606+ texCoord.y -= float ((NUM_SAMPLES - 1) / 2) / TextureSize0.y; \n\
3607 sum += SampleTexture (TextureObject0, texCoord) * W[0]; \n\
3608 texCoord += delta; \n\
3609 sum += SampleTexture (TextureObject0, texCoord) * W[1]; \n\
3610@@ -707,8 +698,9 @@
3611 NString PSString;
3612
3613
3614- VSString = TEXT ("#version 120 \n\
3615- uniform mat4 ViewProjectionMatrix; \n\
3616+ VSString = TEXT (
3617+ VertexShaderHeader
3618+ "uniform mat4 ViewProjectionMatrix; \n\
3619 attribute vec4 AVertex; \n\
3620 attribute vec4 MyTextureCoord0; \n\
3621 attribute vec4 VertexColor; \n\
3622@@ -722,8 +714,9 @@
3623 }");
3624
3625
3626- PSString = TEXT ("#version 120 \n\
3627- varying vec4 varyTexCoord0; \n\
3628+ PSString = TEXT (
3629+ FragmentShaderHeader
3630+ "varying vec4 varyTexCoord0; \n\
3631 varying vec4 varyVertexColor; \n\
3632 uniform sampler2D TextureObject0; \n\
3633 uniform vec2 TextureSize0; \n\
3634@@ -738,7 +731,7 @@
3635 vec4 sum = vec4(0.0, 0.0, 0.0, 0.0); \n\
3636 vec2 delta = vec2(1.0 / TextureSize0.x, 0.0); \n\
3637 vec2 texCoord = vec2(varyTexCoord0.s, varyTexCoord0.t); \n\
3638- texCoord.x -= ((NUM_SAMPLES - 1) / 2) / TextureSize0.x; \n\
3639+ texCoord.x -= float ((NUM_SAMPLES - 1) / 2) / TextureSize0.x; \n\
3640 texCoord.y += 0.0 / TextureSize0.y; \n\
3641 for(int i = 0; i < NUM_SAMPLES; i++) \n\
3642 { \n\
3643@@ -779,8 +772,9 @@
3644 NString VSString;
3645 NString PSString;
3646
3647- VSString = TEXT ("#version 110 \n\
3648- uniform mat4 ViewProjectionMatrix; \n\
3649+ VSString = TEXT (
3650+ VertexShaderHeader
3651+ "uniform mat4 ViewProjectionMatrix; \n\
3652 attribute vec4 AVertex; \n\
3653 attribute vec4 MyTextureCoord0; \n\
3654 attribute vec4 VertexColor; \n\
3655@@ -794,8 +788,9 @@
3656 }");
3657
3658
3659- PSString = TEXT ("#version 120 \n\
3660- varying vec4 varyTexCoord0; \n\
3661+ PSString = TEXT (
3662+ FragmentShaderHeader
3663+ "varying vec4 varyTexCoord0; \n\
3664 varying vec4 varyVertexColor; \n\
3665 uniform sampler2D TextureObject0; \n\
3666 uniform vec2 TextureSize0; \n\
3667@@ -811,7 +806,7 @@
3668 vec2 delta = vec2 (0.0, 1.0 / TextureSize0.y); \n\
3669 vec2 texCoord = vec2 (varyTexCoord0.s, varyTexCoord0.t); \n\
3670 texCoord.x += 0.0 / TextureSize0.x; \n\
3671- texCoord.y -= ((NUM_SAMPLES - 1) / 2) / TextureSize0.y; \n\
3672+ texCoord.y -= float ((NUM_SAMPLES - 1) / 2) / TextureSize0.y; \n\
3673 for (int i = 0; i < NUM_SAMPLES; ++i) \n\
3674 { \n\
3675 sum += SampleTexture (TextureObject0, texCoord) * W[i]; \n\
3676@@ -844,8 +839,9 @@
3677 NString PSString;
3678
3679
3680- VSString = TEXT ("#version 110 \n\
3681- uniform mat4 ViewProjectionMatrix; \n\
3682+ VSString = TEXT (
3683+ VertexShaderHeader
3684+ "uniform mat4 ViewProjectionMatrix; \n\
3685 attribute vec4 AVertex; \n\
3686 attribute vec4 MyTextureCoord0; \n\
3687 varying vec4 varyTexCoord0; \n\
3688@@ -855,9 +851,9 @@
3689 gl_Position = ViewProjectionMatrix * (AVertex); \n\
3690 }");
3691
3692- PSString = TEXT ("#version 110 \n\
3693- #extension GL_ARB_texture_rectangle : enable \n\
3694- varying vec4 varyTexCoord0; \n\
3695+ PSString = TEXT (
3696+ FragmentShaderHeader
3697+ "varying vec4 varyTexCoord0; \n\
3698 uniform sampler2D TextureObject0; \n\
3699 uniform vec4 color0; \n\
3700 vec4 SampleTexture(sampler2D TexObject, vec2 TexCoord) \n\
3701@@ -2630,8 +2626,9 @@
3702 NString VSString;
3703 NString PSString;
3704
3705- VSString = TEXT ("#version 110 \n\
3706- attribute vec4 AVertex; \n\
3707+ VSString = TEXT (
3708+ VertexShaderHeader
3709+ "attribute vec4 AVertex; \n\
3710 attribute vec4 MyTextureCoord0; \n\
3711 attribute vec4 VertexColor; \n\
3712 uniform mat4 ViewProjectionMatrix; \n\
3713@@ -2644,25 +2641,17 @@
3714 varyVertexColor = VertexColor; \n\
3715 }");
3716
3717- PSString = TEXT ("#version 110 \n\
3718- #extension GL_ARB_texture_rectangle : enable \n\
3719- varying vec4 varyTexCoord0; \n\
3720+ PSString = TEXT (
3721+ FragmentShaderHeader
3722+ "varying vec4 varyTexCoord0; \n\
3723 varying vec4 varyVertexColor; \n\
3724 uniform vec4 pixel_size; \n\
3725 uniform vec4 pixel_size_inv; \n\
3726- #ifdef SAMPLERTEX2D \n\
3727 uniform sampler2D TextureObject0; \n\
3728 vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
3729 { \n\
3730 return texture2D(TexObject, TexCoord.st); \n\
3731 } \n\
3732- #elif defined SAMPLERTEX2DRECT \n\
3733- uniform sampler2DRect TextureObject0; \n\
3734- vec4 SampleTexture(sampler2DRect TexObject, vec4 TexCoord) \n\
3735- { \n\
3736- return texture2DRect(TexObject, TexCoord.st); \n\
3737- } \n\
3738- #endif \n\
3739 void main() \n\
3740 { \n\
3741 vec4 tex_coord = floor(varyTexCoord0 * pixel_size_inv) * pixel_size; \n\
3742
3743=== modified file 'NuxGraphics/XInputWindow.cpp'
3744--- NuxGraphics/XInputWindow.cpp 2011-09-28 12:00:11 +0000
3745+++ NuxGraphics/XInputWindow.cpp 2011-10-24 21:19:23 +0000
3746@@ -109,7 +109,7 @@
3747 Region total_screen_region = XCreateRegion ();
3748 Region input_window_region = XCreateRegion ();
3749 Region intersection = XCreateRegion ();
3750- XineramaScreenInfo monitor;
3751+ XRectangle monitor;
3752 XRectangle tmp_rect;
3753 int largestWidth = 0, largestHeight = 0;
3754 int screenWidth, screenHeight;
3755@@ -123,6 +123,14 @@
3756
3757 XUnionRectWithRegion (&tmp_rect, input_window_region, input_window_region);
3758
3759+ // If there is no Xinerama extension on this server, just use the
3760+ // screen geometry we have.
3761+ if (!info)
3762+ {
3763+ monitor = tmp_rect;
3764+ n_info = 0;
3765+ }
3766+
3767 for (int i = 0; i < n_info; i++)
3768 {
3769 tmp_rect.x = info[i].x_org;
3770@@ -146,7 +154,10 @@
3771 largestWidth = width;
3772 largestHeight = height;
3773
3774- monitor = info[i];
3775+ monitor.x = info[i].x_org;
3776+ monitor.y = info[i].y_org;
3777+ monitor.width = info[i].width;
3778+ monitor.height = info[i].height;
3779 }
3780 }
3781
3782@@ -165,7 +176,7 @@
3783
3784 if (geometry_.width > geometry_.height)
3785 {
3786- if (geometry_.y - monitor.y_org < monitor.height / 2)
3787+ if (geometry_.y - monitor.y < monitor.height / 2)
3788 {
3789 /* top */
3790 data[2] = geometry_.y + geometry_.height;
3791@@ -182,7 +193,7 @@
3792 }
3793 else
3794 {
3795- if (geometry_.x - monitor.x_org < monitor.width / 2)
3796+ if (geometry_.x - monitor.x < monitor.width / 2)
3797 {
3798 /* left */
3799 data[0] = geometry_.x + geometry_.width;
3800
3801=== modified file 'NuxGraphics/nux-graphics.pc.in'
3802--- NuxGraphics/nux-graphics.pc.in 2011-09-28 12:00:11 +0000
3803+++ NuxGraphics/nux-graphics.pc.in 2011-10-24 21:19:23 +0000
3804@@ -8,4 +8,4 @@
3805 Version: @VERSION@
3806 Libs: -L${libdir} -lnux-graphics-@NUX_API_VERSION@
3807 Cflags: -I${includedir}/Nux-@NUX_API_VERSION@
3808-Requires: glib-2.0 nux-core-@NUX_API_VERSION@ nux-image-@NUX_API_VERSION@ gl glu xxf86vm glew glewmx xinerama
3809+Requires: glib-2.0 nux-core-@NUX_API_VERSION@ nux-image-@NUX_API_VERSION@ @GL_PKGS@ xxf86vm xinerama
3810
3811=== modified file 'NuxImage/BitmapFormats.cpp'
3812--- NuxImage/BitmapFormats.cpp 2011-04-06 21:54:09 +0000
3813+++ NuxImage/BitmapFormats.cpp 2011-10-24 21:19:23 +0000
3814@@ -26,66 +26,71 @@
3815 namespace nux
3816 {
3817
3818- PixelFormatInfo GPixelFormats[] =
3819+ PixelFormatInfo GPixelFormats[] =
3820 {
3821- // Name BlockSizeX BlockSizeY BlockSizeZ BlockBytes NumComponents Platform Internal Type Memory Flags Supported EPixelFormat
3822- // Format Format Alignment
3823- { TEXT ("BITFMT_UNKNOWN"), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false }, // BITFMT_Unknown
3824- { TEXT ("BITFMT_R8G8B8A8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_R8G8B8A8
3825- { TEXT ("BITFMT_A8B8G8R8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A8B8G8R8
3826- { TEXT ("BITFMT_B8G8R8A8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_B8G8R8A8
3827- { TEXT ("BITFMT_A8R8G8B8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A8R8G8B8
3828- { TEXT ("BITFMT_R8G8B8"), 1, 1, 1, 3, 3, 0, 0, 0, 1, 0, true }, // BITFMT_R8G8B8
3829- { TEXT ("BITFMT_B8G8R8"), 1, 1, 1, 3, 3, 0, 0, 0, 1, 0, true }, // BITFMT_B8G8R8
3830- { TEXT ("BITFMT_R5G6B5"), 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, true }, // BITFMT_R5G6B5
3831- { TEXT ("BITFMT_RGBA16F"), 1, 1, 1, 8, 4, 0, 0, 0, 1, 0, true }, // BITFMT_RGBA16F
3832- { TEXT ("BITFMT_RGB32F"), 1, 1, 1, 12, 3, 0, 0, 0, 1, 0, true }, // BITFMT_RGB32F
3833- { TEXT ("BITFMT_RGBA32F"), 1, 1, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_RGBA32F
3834- { TEXT ("BITFMT_D24S8"), 1, 1, 1, 4, 2, 0, 0, 0, 1, 0, true }, // BITFMT_D24S8
3835- { TEXT ("BITFMT_DXT1"), 4, 4, 1, 8, 3, 0, 0, 0, 1, 0, true }, // BITFMT_DXT1
3836- { TEXT ("BITFMT_DXT2"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT2
3837- { TEXT ("BITFMT_DXT3"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT3
3838- { TEXT ("BITFMT_DXT4"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT4
3839- { TEXT ("BITFMT_DXT5"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT5
3840- { TEXT ("BITFMT_R10G10B10A2"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_R10G10B10A2
3841- { TEXT ("BITFMT_A2B10G10R10"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A2B10G10R10
3842- { TEXT ("BITFMT_B10G10R10A2"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_B10G10R10A2
3843- { TEXT ("BITFMT_A2R10G10B10"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A2R10G10B10
3844-
3845- { TEXT ("BITFMT_A8"), 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, true }, // BITFMT_A8
3846-
3847- { TEXT ("BITFMT_END_GFX_FORMATS"), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false }, // BITFMT_END_GFX_FORMATS
3848+ // Name BlockSizeX BlockSizeY BlockSizeZ BlockBytes NumComponents Platform Internal Memory Flags Supported
3849+ // Format Format Alignment
3850+ { TEXT ("BITFMT_UNKNOWN"), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false }, // BITFMT_Unknown
3851+ { TEXT ("BITFMT_R8G8B8A8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_R8G8B8A8
3852+ { TEXT ("BITFMT_B8G8R8A8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_B8G8R8A8
3853+ { TEXT ("BITFMT_R8G8B8"), 1, 1, 1, 3, 3, 0, 0, 0, 1, 0, true }, // BITFMT_R8G8B8
3854+ { TEXT ("BITFMT_R5G6B5"), 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, true }, // BITFMT_R5G6B5
3855+ { TEXT ("BITFMT_D24S8"), 1, 1, 1, 4, 2, 0, 0, 0, 1, 0, true }, // BITFMT_D24S8
3856+ { TEXT ("BITFMT_A8"), 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, true }, // BITFMT_A8
3857+
3858+ { TEXT ("BITFMT_DXT1"), 4, 4, 1, 8, 3, 0, 0, 0, 1, 0, true }, // BITFMT_DXT1
3859+ { TEXT ("BITFMT_DXT2"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT2
3860+ { TEXT ("BITFMT_DXT3"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT3
3861+ { TEXT ("BITFMT_DXT4"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT4
3862+ { TEXT ("BITFMT_DXT5"), 4, 4, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_DXT5
3863+
3864+#ifndef NUX_OPENGLES_20
3865+ { TEXT ("BITFMT_A8R8G8B8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A8R8G8B8
3866+ { TEXT ("BITFMT_A8B8G8R8"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A8B8G8R8
3867+ { TEXT ("BITFMT_B8G8R8"), 1, 1, 1, 3, 3, 0, 0, 0, 1, 0, true }, // BITFMT_B8G8R8
3868+ { TEXT ("BITFMT_RGBA16F"), 1, 1, 1, 8, 4, 0, 0, 0, 1, 0, true }, // BITFMT_RGBA16F
3869+ { TEXT ("BITFMT_RGB32F"), 1, 1, 1, 12, 3, 0, 0, 0, 1, 0, true }, // BITFMT_RGB32F
3870+ { TEXT ("BITFMT_RGBA32F"), 1, 1, 1, 16, 4, 0, 0, 0, 1, 0, true }, // BITFMT_RGBA32F
3871+ { TEXT ("BITFMT_R10G10B10A2"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_R10G10B10A2
3872+ { TEXT ("BITFMT_B10G10R10A2"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_B10G10R10A2
3873+ { TEXT ("BITFMT_A2R10G10B10"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A2R10G10B10
3874+ { TEXT ("BITFMT_A2B10G10R10"), 1, 1, 1, 4, 4, 0, 0, 0, 4, 0, true }, // BITFMT_A2B10G10R10
3875+#endif
3876+ { TEXT ("BITFMT_END_GFX_FORMATS"), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false }, // BITFMT_END_GFX_FORMATS
3877 };
3878
3879
3880- ReadBackPixelFormatInfo GReadBackPixelFormats[] =
3881+ ReadBackPixelFormatInfo GReadBackPixelFormats[] =
3882 {
3883- // Name BlockBytes NumComponents Format Type Flags Supported EPixelFormat
3884-
3885- { TEXT ("BITFMT_UNKNOWN"), 0, 0, 0, 0, 0, false }, // BITFMT_Unknown
3886- { TEXT ("BITFMT_R8G8B8A8"), 4, 4, 0, 0, 0, true }, // BITFMT_R8G8B8A8
3887- { TEXT ("BITFMT_A8B8G8R8"), 4, 4, 0, 0, 0, true }, // BITFMT_A8B8G8R8
3888- { TEXT ("BITFMT_B8G8R8A8"), 4, 4, 0, 0, 0, true }, // BITFMT_B8G8R8A8
3889- { TEXT ("BITFMT_A8R8G8B8"), 4, 4, 0, 0, 0, true }, // BITFMT_A8R8G8B8
3890- { TEXT ("BITFMT_R8G8B8"), 3, 3, 0, 0, 0, true }, // BITFMT_R8G8B8
3891- { TEXT ("BITFMT_B8G8R8"), 3, 3, 0, 0, 0, true }, // BITFMT_B8G8R8
3892- { TEXT ("BITFMT_R5G6B5"), 2, 3, 0, 0, 0, true }, // BITFMT_R5G6B5
3893- { TEXT ("BITFMT_RGBA16F"), 8, 4, 0, 0, 0, true }, // BITFMT_RGBA16F
3894- { TEXT ("BITFMT_RGBA32F"), 16, 4, 0, 0, 0, true }, // BITFMT_RGBA32F
3895- { TEXT ("BITFMT_D24S8"), 4, 2, 0, 0, 0, true }, // BITFMT_D24S8
3896- { TEXT ("BITFMT_DXT1"), 8, 3, 0, 0, 0, true }, // BITFMT_DXT1
3897- { TEXT ("BITFMT_DXT2"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT2
3898- { TEXT ("BITFMT_DXT3"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT3
3899- { TEXT ("BITFMT_DXT4"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT4
3900- { TEXT ("BITFMT_DXT5"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT5
3901- { TEXT ("BITFMT_R10G10B10A2"), 4, 4, 0, 0, 0, true }, // BITFMT_R10G10B10A2
3902- { TEXT ("BITFMT_A2B10G10R10"), 4, 4, 0, 0, 0, true }, // BITFMT_A2B10G10R10
3903- { TEXT ("BITFMT_B10G10R10A2"), 4, 4, 0, 0, 0, true }, // BITFMT_B10G10R10A2
3904- { TEXT ("BITFMT_A2R10G10B10"), 4, 4, 0, 0, 0, true }, // BITFMT_A2R10G10B10
3905-
3906- { TEXT ("BITFMT_A8"), 1, 1, 0, 0, 0, true }, // BITFMT_A8
3907-
3908- { TEXT ("BITFMT_END_GFX_FORMATS"), 0, 0, 0, 0, 0, false }, // BITFMT_END_GFX_FORMATS
3909+ // Name BlockBytes NumComponents Format Type Flags Supported
3910+
3911+ { TEXT ("BITFMT_UNKNOWN"), 0, 0, 0, 0, 0, false }, // BITFMT_Unknown
3912+ { TEXT ("BITFMT_R8G8B8A8"), 4, 4, 0, 0, 0, true }, // BITFMT_R8G8B8A8
3913+ { TEXT ("BITFMT_B8G8R8A8"), 4, 4, 0, 0, 0, true }, // BITFMT_B8G8R8A8
3914+ { TEXT ("BITFMT_R8G8B8"), 3, 3, 0, 0, 0, true }, // BITFMT_R8G8B8
3915+ { TEXT ("BITFMT_R5G6B5"), 2, 3, 0, 0, 0, true }, // BITFMT_R5G6B5
3916+ { TEXT ("BITFMT_D24S8"), 4, 2, 0, 0, 0, true }, // BITFMT_D24S8
3917+ { TEXT ("BITFMT_A8"), 1, 1, 0, 0, 0, true }, // BITFMT_A8
3918+
3919+ { TEXT ("BITFMT_DXT1"), 8, 3, 0, 0, 0, true }, // BITFMT_DXT1
3920+ { TEXT ("BITFMT_DXT2"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT2
3921+ { TEXT ("BITFMT_DXT3"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT3
3922+ { TEXT ("BITFMT_DXT4"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT4
3923+ { TEXT ("BITFMT_DXT5"), 16, 4, 0, 0, 0, true }, // BITFMT_DXT5
3924+
3925+#ifndef NUX_OPENGLES_20
3926+ { TEXT ("BITFMT_A8R8G8B8"), 4, 4, 0, 0, 0, true }, // BITFMT_A8R8G8B8
3927+ { TEXT ("BITFMT_A8B8G8R8"), 4, 4, 0, 0, 0, true }, // BITFMT_A8B8G8R8
3928+ { TEXT ("BITFMT_B8G8R8"), 3, 3, 0, 0, 0, true }, // BITFMT_B8G8R8
3929+ { TEXT ("BITFMT_RGBA16F"), 8, 4, 0, 0, 0, true }, // BITFMT_RGBA16F
3930+ { TEXT ("BITFMT_RGB32F"), 12, 3, 0, 0, 0, true }, // BITFMT_RGBA32F
3931+ { TEXT ("BITFMT_RGBA32F"), 16, 4, 0, 0, 0, true }, // BITFMT_RGBA32F
3932+ { TEXT ("BITFMT_R10G10B10A2"), 4, 4, 0, 0, 0, true }, // BITFMT_R10G10B10A2
3933+ { TEXT ("BITFMT_B10G10R10A2"), 4, 4, 0, 0, 0, true }, // BITFMT_B10G10R10A2
3934+ { TEXT ("BITFMT_A2B10G10R10"), 4, 4, 0, 0, 0, true }, // BITFMT_A2B10G10R10
3935+ { TEXT ("BITFMT_A2R10G10B10"), 4, 4, 0, 0, 0, true }, // BITFMT_A2R10G10B10
3936+#endif
3937+ { TEXT ("BITFMT_END_GFX_FORMATS"), 0, 0, 0, 0, 0, false }, // BITFMT_END_GFX_FORMATS
3938 };
3939
3940 }
3941
3942=== modified file 'NuxImage/BitmapFormats.h'
3943--- NuxImage/BitmapFormats.h 2011-05-26 21:08:18 +0000
3944+++ NuxImage/BitmapFormats.h 2011-10-24 21:19:23 +0000
3945@@ -57,20 +57,11 @@
3946 {
3947 BITFMT_UNKNOWN = 0,
3948 BITFMT_R8G8B8A8, // 32-bit RGBA pixel format with alpha, using 8 bits per channel.
3949- BITFMT_A8B8G8R8, // 32-bit ABGR pixel format with alpha, using 8 bits per channel.
3950-
3951 BITFMT_B8G8R8A8, // 32-bit BGRA pixel format with alpha, using 8 bits per channel.
3952- BITFMT_A8R8G8B8, // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
3953-
3954 BITFMT_R8G8B8, // 24-bit RGB pixel format with 8 bits per channel.
3955- BITFMT_B8G8R8, // 24-bit RGB pixel format with 8 bits per channel.
3956-
3957 BITFMT_R5G6B5, // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
3958-
3959- BITFMT_RGBA16F,
3960- BITFMT_RGB32F,
3961- BITFMT_RGBA32F,
3962 BITFMT_D24S8,
3963+ BITFMT_A8, // Gray level 8 bits
3964
3965 BITFMT_DXT1,
3966 BITFMT_DXT2,
3967@@ -78,36 +69,20 @@
3968 BITFMT_DXT4,
3969 BITFMT_DXT5,
3970
3971+#ifndef NUX_OPENGLES_20
3972+ BITFMT_A8R8G8B8, // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
3973+ BITFMT_A8B8G8R8, // 32-bit ABGR pixel format with alpha, using 8 bits per channel.
3974+ BITFMT_B8G8R8, // 24-bit RGB pixel format with 8 bits per channel.
3975+ BITFMT_RGBA16F,
3976+ BITFMT_RGB32F,
3977+ BITFMT_RGBA32F,
3978+
3979 BITFMT_R10G10B10A2, // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
3980 BITFMT_B10G10R10A2, // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
3981 BITFMT_A2R10G10B10, // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
3982 BITFMT_A2B10G10R10, // 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
3983-
3984- BITFMT_A8, // Gray level 8 bits
3985-
3986+#endif
3987 BITFMT_END_GFX_FORMATS,
3988-
3989- BITFMT_X8R8G8B8, // 32-bit RGB pixel format, where 8 bits are reserved for each color.
3990- BITFMT_X8B8G8R8, // 32-bit RGB pixel format, where 8 bits are reserved for each color.
3991-
3992- BITFMT_X1R5G5B5, // 16-bit pixel format where 5 bits are reserved for each color.
3993- BITFMT_A1R5G5B5, // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
3994- BITFMT_A4R4G4B4, // 16-bit ARGB pixel format with 4 bits for each channel.
3995- BITFMT_X4R4G4B4, // 16-bit RGB pixel format using 4 bits for each color.
3996- BITFMT_A8R3G3B2, // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
3997-
3998- //BITFMT_A8P8, // 8-bit color indexed with 8 bits of alpha.
3999- //BITFMT_A8L8, // 16-bit using 8 bits each for alpha and luminance.
4000- //BITFMT_GRAY16, // Gray level 16 bits
4001-
4002- BITFMT_R3G3B2, // 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
4003-
4004- //BITFMT_P8, // 8-bit color indexed.
4005- //BITFMT_L8, // 8-bit luminance only.
4006- //BITFMT_A4L4, // 8-bit using 4 bits each for alpha and luminance.
4007- //BITFMT_A8, // 8-bit alpha only.
4008-
4009-
4010 } BitmapFormat;
4011
4012 extern PixelFormatInfo GPixelFormats[];
4013
4014=== modified file 'configure.ac'
4015--- configure.ac 2011-10-12 11:38:16 +0000
4016+++ configure.ac 2011-10-24 21:19:23 +0000
4017@@ -109,6 +109,27 @@
4018 PKG_PROG_PKG_CONFIG
4019
4020 dnl ===========================================================================
4021+GL_PKGS="gl glu glew glewmx"
4022+MAINTAINER_CFLAGS=""
4023+
4024+# Enable opengl es 20 code path
4025+AC_ARG_ENABLE([opengles_20],
4026+ [AC_HELP_STRING([--enable-opengles-20=@<:@no/yes@:>@],
4027+ [Enable OpenGL ES 20 code path @<:@default=no@:>@])],
4028+ [],
4029+ [enable_opengles_20=no])
4030+AS_IF([test "x$enable_opengles_20" = "xyes"],
4031+ [
4032+ MAINTAINER_CFLAGS+=" -DNUX_OPENGLES_20"
4033+ GL_PKGS="egl glesv2"
4034+ ]
4035+)
4036+AM_CONDITIONAL(NUX_OPENGLES_20, [test "x$enable_opengles_20" = "xyes"])
4037+
4038+AC_SUBST(GL_PKGS)
4039+AC_SUBST(MAINTAINER_CFLAGS)
4040+
4041+dnl ===========================================================================
4042
4043 PKG_CHECK_MODULES(NUX_CORE, glib-2.0 >= 2.25.14 gthread-2.0 sigc++-2.0 gio-2.0)
4044 AC_SUBST(NUX_CORE_CFLAGS)
4045@@ -127,8 +148,7 @@
4046 PKG_CHECK_MODULES(NUX_MESH,
4047 glib-2.0 >= 2.25.14
4048 gdk-pixbuf-2.0
4049- glew
4050- glewmx
4051+ $GL_PKGS
4052 sigc++-2.0
4053 )
4054 AC_SUBST(NUX_MESH_CFLAGS)
4055@@ -137,10 +157,7 @@
4056 PKG_CHECK_MODULES(NUX_GRAPHICS,
4057 glib-2.0 >= 2.25.14
4058 gdk-pixbuf-2.0
4059- gl
4060- glu
4061- glew
4062- glewmx
4063+ $GL_PKGS
4064 xxf86vm
4065 sigc++-2.0
4066 xinerama
4067@@ -152,10 +169,7 @@
4068 glib-2.0 >= 2.25.14
4069 gdk-pixbuf-2.0
4070 gthread-2.0
4071- gl
4072- glu
4073- glew
4074- glewmx
4075+ $GL_PKGS
4076 sigc++-2.0
4077 pango
4078 pangocairo
4079@@ -166,9 +180,9 @@
4080
4081 PKG_CHECK_MODULES(UNITY_SUPPORT_TEST,
4082 x11
4083+ $GL_PKGS
4084 xcomposite
4085 xdamage
4086- gl
4087 libpci
4088 )
4089 AC_SUBST(UNITY_SUPPORT_TEST_CFLAGS)
4090@@ -236,7 +250,6 @@
4091 [],
4092 [enable_maintainer_mode=maintainer_mode_default])
4093
4094-MAINTAINER_CFLAGS=""
4095 AS_IF([test "x$enable_maintainer_mode" = "xyes" && test "x$GCC" = "xyes"],
4096 [
4097 MAINTAINER_CFLAGS+="-Werror -Wall -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self"
4098@@ -257,20 +270,6 @@
4099
4100 AC_SUBST(MAINTAINER_CFLAGS)
4101
4102-# Enable opengl es 20 code path
4103-AC_ARG_ENABLE([opengles_20],
4104- [AC_HELP_STRING([--enable-opengles-20=@<:@no/yes@:>@],
4105- [Enable OpenGL ES 20 code path @<:@default=no@:>@])],
4106- [],
4107- [enable_opengles_20=no])
4108-AS_IF([test "x$enable_opengles_20" = "xyes"],
4109- [
4110- MAINTAINER_CFLAGS+=" -DNUX_OPENGLES_20"
4111- ]
4112-)
4113-
4114-AC_SUBST(MAINTAINER_CFLAGS)
4115-
4116 # this enables lots of useful debugging output in Nux
4117 AC_ARG_ENABLE([examples],
4118 [AC_HELP_STRING([--enable-examples=@<:@no/yes@:>@],
4119
4120=== modified file 'gputests/Makefile.am'
4121--- gputests/Makefile.am 2011-02-11 21:22:08 +0000
4122+++ gputests/Makefile.am 2011-10-24 21:19:23 +0000
4123@@ -7,7 +7,11 @@
4124 # This tells automake that we want to build binaries, but they shouldn't be
4125 # installed. For each individual test, add it's binary name here
4126
4127-noinst_PROGRAMS = texture_power_of_2 framebufferobject quad_2texmod texture_copy_blur texture_blur texture_data arb_programs_limits
4128+noinst_PROGRAMS = texture_power_of_2 framebufferobject quad_2texmod texture_copy_blur texture_blur texture_data
4129+
4130+if !NUX_OPENGLES_20
4131+noinst_PROGRAMS += arb_programs_limits
4132+endif
4133
4134 # We only have to do this AM_ once to affect all the binaries we build from
4135 # this Makefile
4136
4137=== modified file 'gputests/texture_power_of_2.cpp'
4138--- gputests/texture_power_of_2.cpp 2011-09-20 06:03:43 +0000
4139+++ gputests/texture_power_of_2.cpp 2011-10-24 21:19:23 +0000
4140@@ -119,12 +119,6 @@
4141 for (int i = 0; i < 9; i++)
4142 {
4143 m_GraphicsContext->SetTexture(GL_TEXTURE0, tex [i]);
4144- CHECKGL( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) );
4145- CHECKGL( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) );
4146-
4147- glEnable(GL_TEXTURE_2D);
4148- glDisable(GL_TEXTURE_3D);
4149- glDisable(GL_TEXTURE_CUBE_MAP);
4150
4151 if (i > 0)
4152 x += tex[i-1]->GetWidth () + 5;
4153@@ -132,18 +126,8 @@
4154 int width = tex[i]->GetWidth ();
4155 int height = tex[i]->GetHeight ();
4156
4157- glBegin(GL_QUADS);
4158- {
4159- glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f, 0.0f);
4160- glVertex3f(x, y, 0);
4161- glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f, 1.0);
4162- glVertex3f(x, y + height, 0);
4163- glMultiTexCoord2fARB(GL_TEXTURE0, 1.0f, 1.0);
4164- glVertex3f(x + width, y + height, 0);
4165- glMultiTexCoord2fARB(GL_TEXTURE0, 1.0f, 0.0);
4166- glVertex3f(x + width, y, 0);
4167- }
4168- glEnd();
4169+ nux::TexCoordXForm texxform;
4170+ m_GraphicsContext->QRP_GLSL_1Tex(x, y, width, height, tex[i], texxform, nux::color::White);
4171 }
4172
4173 m_GLWindow->SwapBuffer();
4174
4175=== modified file 'tools/Makefile.am'
4176--- tools/Makefile.am 2011-03-24 20:50:43 +0000
4177+++ tools/Makefile.am 2011-10-24 21:19:23 +0000
4178@@ -4,5 +4,5 @@
4179
4180 libexec_PROGRAMS = unity_support_test
4181
4182-unity_support_test_CFLAGS = $(UNITY_SUPPORT_TEST_CFLAGS)
4183+unity_support_test_CFLAGS = $(UNITY_SUPPORT_TEST_CFLAGS) $(MAINTAINER_CFLAGS)
4184 unity_support_test_LDFLAGS = $(UNITY_SUPPORT_TEST_LIBS)
4185
4186=== modified file 'tools/unity_support_test.c'
4187--- tools/unity_support_test.c 2011-09-29 11:59:51 +0000
4188+++ tools/unity_support_test.c 2011-10-24 21:19:23 +0000
4189@@ -24,10 +24,16 @@
4190 #include <X11/Xutil.h>
4191 #include <X11/extensions/Xcomposite.h>
4192 #include <X11/extensions/Xdamage.h>
4193+#ifndef NUX_OPENGLES_20
4194 #include <GL/gl.h>
4195 #define GLX_GLXEXT_PROTOTYPES
4196 #include <GL/glx.h>
4197 #undef GLX_GLXEXT_PROTOTYPES
4198+#else
4199+#include <EGL/egl.h>
4200+#include <GLES2/gl2.h>
4201+#include <GLES2/gl2ext.h>
4202+#endif
4203 #include <stdio.h>
4204 #include <string.h>
4205 #include <stdlib.h>
4206@@ -35,6 +41,12 @@
4207 #include <fcntl.h>
4208 #include <unistd.h>
4209
4210+#ifndef NUX_OPENGLES_20
4211+typedef GLXContext NUXContext;
4212+#else
4213+typedef EGLConfig NUXContext;
4214+#endif
4215+
4216 // Enables colored console output at build time.
4217 #define COLORED_OUTPUT 1
4218
4219@@ -56,6 +68,8 @@
4220 FLAG_GL_ARB_FRAMEBUFFER_OBJECT = (1 << 10),
4221 FLAG_SOFTWARE_RENDERING = (1 << 11),
4222 FLAG_BLACKLISTED = (1 << 12),
4223+ FLAG_GL_OES_EGL_IMAGE = (1 << 13),
4224+ FLAG_EGL_KHR_IMAGE_PIXMAP = (1 << 14),
4225
4226 // Extension masks.
4227 MASK_GL_NON_POWER_OF_TWO = (FLAG_GL_ARB_NON_POWER_OF_TWO
4228@@ -176,6 +190,7 @@
4229 flags & FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP ? yes : no,
4230 flags & MASK_GL_NON_POWER_OF_TWO ? yes : no);
4231 if (compiz == 0) {
4232+#ifndef NUX_OPENGLES_20
4233 fprintf (stdout,
4234 "GL vertex program: %s\n"
4235 "GL fragment program: %s\n"
4236@@ -190,6 +205,18 @@
4237 flags & MASK_GL_FRAMEBUFFER_OBJECT ? yes : no,
4238 (major >= 2 || (major == 1 && minor >= 4)) ? yes : no,
4239 result == 0 ? yes : no);
4240+#else
4241+ fprintf (stdout,
4242+ "GL OES EGL image: %s\n"
4243+ "EGL KHR image pixmap: %s\n"
4244+ "EGL version is 1.4+: %s\n"
4245+ "\n"
4246+ "Unity supported: %s\n",
4247+ flags & FLAG_GL_OES_EGL_IMAGE ? yes : no,
4248+ flags & FLAG_EGL_KHR_IMAGE_PIXMAP ? yes : no,
4249+ (major >= 2 || (major == 1 && minor >= 4)) ? yes : no,
4250+ result == 0 ? yes : no);
4251+#endif
4252 } else {
4253 fprintf (stdout, "\nCompiz supported: %s\n",
4254 result == 0 ? yes : no);
4255@@ -202,7 +229,7 @@
4256 static int check_root_visual (Display *display,
4257 unsigned int screen,
4258 Window root,
4259- GLXContext *context,
4260+ NUXContext *context,
4261 XVisualInfo **vinfos,
4262 TestResults *results)
4263 {
4264@@ -229,7 +256,7 @@
4265 static int check_xcomposite (Display *display,
4266 unsigned int screen,
4267 Window root,
4268- GLXContext *context,
4269+ NUXContext *context,
4270 XVisualInfo **vinfos,
4271 TestResults *results)
4272 {
4273@@ -259,7 +286,7 @@
4274 static int check_damage_extension (Display *display,
4275 unsigned int screen,
4276 Window root,
4277- GLXContext *context,
4278+ NUXContext *context,
4279 XVisualInfo **vinfos,
4280 TestResults *results)
4281 {
4282@@ -278,7 +305,7 @@
4283 static int check_fixes_extension (Display *display,
4284 unsigned int screen,
4285 Window root,
4286- GLXContext *context,
4287+ NUXContext *context,
4288 XVisualInfo **vinfos,
4289 TestResults *results)
4290 {
4291@@ -294,10 +321,130 @@
4292 return 1;
4293 }
4294
4295+#ifdef NUX_OPENGLES_20
4296+
4297+static int check_egl_config (Display *display,
4298+ unsigned int screen,
4299+ Window root,
4300+ NUXContext *context,
4301+ XVisualInfo **vinfos,
4302+ TestResults *results)
4303+{
4304+ EGLint attribs[] = {
4305+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
4306+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
4307+ EGL_RED_SIZE, 1,
4308+ EGL_GREEN_SIZE, 1,
4309+ EGL_BLUE_SIZE, 1,
4310+ EGL_NONE
4311+ };
4312+ EGLint ctx_attribs[] = {
4313+ EGL_CONTEXT_CLIENT_VERSION, 2,
4314+ EGL_NONE
4315+ };
4316+
4317+ XVisualInfo *visInfo, visTemplate;
4318+ XSetWindowAttributes attr;
4319+ Window win;
4320+ int num_visuals;
4321+ unsigned long mask;
4322+ const int width = 400, height = 300;
4323+ const char* name = "Unity Support Test";
4324+ EGLDisplay egl_dpy;
4325+ EGLSurface egl_surf;
4326+ EGLContext egl_ctx;
4327+ EGLConfig config;
4328+ EGLint num_configs;
4329+ EGLint vid;
4330+
4331+ egl_dpy = eglGetDisplay(display);
4332+
4333+ if (!eglChooseConfig (egl_dpy, attribs, &config, 1, &num_configs)) {
4334+ results->error = strdup ("OpenGLES: couldn't get an EGL visual config");
4335+ results->result = 1;
4336+ return 0;
4337+ }
4338+
4339+ if (num_configs <= 0) {
4340+ results->error = strdup ("OpenGLES: no valid config found (!num_configs)");
4341+ results->result = 1;
4342+ return 0;
4343+ }
4344+
4345+ if (!eglGetConfigAttrib (egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
4346+ results->error = strdup ("OpenGLES: eglGetConfigAttrib() failed");
4347+ results->result = 1;
4348+ return 0;
4349+ }
4350+
4351+ /* The X window visual must match the EGL config */
4352+ visTemplate.visualid = vid;
4353+ visInfo = XGetVisualInfo (display, VisualIDMask, &visTemplate, &num_visuals);
4354+ if (!visInfo) {
4355+ results->error = strdup ("OpenGLES: unable to get a matching X visual");
4356+ results->result = 1;
4357+ return 0;
4358+ }
4359+
4360+ /* window attributes */
4361+ attr.background_pixel = 0;
4362+ attr.border_pixel = 0;
4363+ attr.colormap = XCreateColormap (display, root, visInfo->visual, AllocNone);
4364+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
4365+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
4366+
4367+ win = XCreateWindow (display, root, 0, 0, width, height,
4368+ 0, visInfo->depth, InputOutput,
4369+ visInfo->visual, mask, &attr);
4370+
4371+ /* set hints and properties */
4372+ {
4373+ XSizeHints sizehints;
4374+ sizehints.x = 0;
4375+ sizehints.y = 0;
4376+ sizehints.width = width;
4377+ sizehints.height = height;
4378+ sizehints.flags = USSize | USPosition;
4379+ XSetNormalHints (display, win, &sizehints);
4380+ XSetStandardProperties (display, win, name, name,
4381+ None, (char **)NULL, 0, &sizehints);
4382+ }
4383+
4384+ eglBindAPI (EGL_OPENGL_ES_API);
4385+
4386+ egl_surf = eglCreateWindowSurface (egl_dpy, config, win, NULL);
4387+ if (egl_surf == EGL_NO_SURFACE) {
4388+ results->error = strdup ("OpenGLES: eglCreateWindowSurface failed");
4389+ results->result = 1;
4390+ return 0;
4391+ }
4392+
4393+ context = eglCreateContext (egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs);
4394+ if (context == EGL_NO_CONTEXT) {
4395+ results->error = strdup ("OpenGLES: eglCreateContext failed");
4396+ results->result = 1;
4397+ return 0;
4398+ }
4399+
4400+ if (!eglMakeCurrent (egl_dpy, egl_surf, egl_surf, context)) {
4401+ results->error = strdup ("OpenGLES: eglMakeCurrent() failed");
4402+ results->result = 1;
4403+ return 0;
4404+ }
4405+
4406+ XFree(visInfo);
4407+ eglDestroySurface (egl_dpy, egl_surf);
4408+ XDestroyWindow (display, win);
4409+
4410+ return 1;
4411+}
4412+
4413+#else
4414+
4415 static int check_glx_config (Display *display,
4416 unsigned int screen,
4417 Window root,
4418- GLXContext *context,
4419+ NUXContext *context,
4420 XVisualInfo **vinfos,
4421 TestResults *results)
4422 {
4423@@ -316,7 +463,7 @@
4424 static int check_colorbuffers (Display *display,
4425 unsigned int screen,
4426 Window root,
4427- GLXContext *context,
4428+ NUXContext *context,
4429 XVisualInfo **vinfos,
4430 TestResults *results)
4431 {
4432@@ -330,14 +477,16 @@
4433
4434 return 1;
4435 }
4436+#endif
4437
4438 static int check_context (Display *display,
4439 unsigned int screen,
4440 Window root,
4441- GLXContext *context,
4442+ NUXContext *context,
4443 XVisualInfo **vinfos,
4444 TestResults *results)
4445 {
4446+#ifndef NUX_OPENGLES_20
4447 // Create and map the OpenGL context to the root window and get the strings.
4448 *context = glXCreateContext (display, *vinfos, NULL, !results->indirect);
4449 if (*context == NULL) {
4450@@ -346,6 +495,8 @@
4451 return 0;
4452 }
4453 glXMakeCurrent (display, root, *context);
4454+#endif
4455+
4456 results->vendor = (char*) glGetString (GL_VENDOR);
4457 results->renderer = (char*) glGetString (GL_RENDERER);
4458 results->version = (char*) glGetString (GL_VERSION);
4459@@ -356,7 +507,7 @@
4460 static int check_extensions (Display *display,
4461 unsigned int screen,
4462 Window root,
4463- GLXContext *context,
4464+ NUXContext *context,
4465 XVisualInfo **vinfos,
4466 TestResults *results)
4467 {
4468@@ -377,12 +528,14 @@
4469 { "GL_ARB_vertex_buffer_object", FLAG_GL_ARB_VERTEX_BUFFER_OBJECT },
4470 { "GL_EXT_framebuffer_object", FLAG_GL_EXT_FRAMEBUFFER_OBJECT },
4471 { "GL_ARB_framebuffer_object", FLAG_GL_ARB_FRAMEBUFFER_OBJECT },
4472+ { "GL_OES_EGL_image", FLAG_GL_OES_EGL_IMAGE },
4473 { NULL, 0 }
4474 };
4475 for (int i = 0; gl_extension[i].name != NULL; i++)
4476 if (is_extension_supported (gl_extensions, gl_extension[i].name) == 1)
4477 results->flags |= gl_extension[i].flag;
4478
4479+#ifndef NUX_OPENGLES_20
4480 // Fill results->flags with the supported GLX extensions.
4481 const char* glx_extensions = glXQueryExtensionsString (display, screen);
4482 const struct { const char* name; const unsigned int flag; } glx_extension[] = {
4483@@ -408,6 +561,17 @@
4484 results->flags &= ~FLAG_GLX_EXT_TEXTURE_FROM_PIXMAP;
4485 }
4486 }
4487+#else
4488+ EGLDisplay egl_dpy = eglGetDisplay(display);
4489+ const char* egl_extensions = eglQueryString (egl_dpy, EGL_EXTENSIONS);
4490+ const struct { const char* name; const unsigned int flag; } egl_extension[] = {
4491+ { "EGL_KHR_image_pixmap", FLAG_EGL_KHR_IMAGE_PIXMAP },
4492+ { NULL, 0 }
4493+ };
4494+ for (int i = 0; egl_extension[i].name != NULL; i++)
4495+ if (is_extension_supported (egl_extensions, egl_extension[i].name) == 1)
4496+ results->flags |= egl_extension[i].flag;
4497+#endif
4498
4499 return 1;
4500 }
4501@@ -415,14 +579,15 @@
4502 static int check_blacklist (Display *display,
4503 unsigned int screen,
4504 Window root,
4505- GLXContext *context,
4506+ NUXContext *context,
4507 XVisualInfo **vinfos,
4508 TestResults *results)
4509 {
4510 // Check for software rendering.
4511 if (results->renderer != NULL &&
4512 (strncmp (results->renderer, "Software Rasterizer", 19) == 0 ||
4513- strncmp (results->renderer, "Mesa X11", 8) == 0)) {
4514+ strncmp (results->renderer, "Mesa X11", 8) == 0 ||
4515+ strstr (results->renderer, "on softpipe") != NULL)) {
4516 results->flags |= FLAG_SOFTWARE_RENDERING;
4517 }
4518
4519@@ -438,6 +603,9 @@
4520 // available for the default depth or not.
4521
4522 // Scan the PCI devices searching for blacklisted GPUs.
4523+// FIXME: pci or not is not actually related with PCI, it's just that if pci_init
4524+// fails it exit directly :-(
4525+#ifndef NUX_OPENGLES_20
4526 const int gpu_blacklist_size = ARRAY_SIZE (gpu_blacklist);
4527 struct pci_access* access;
4528 struct pci_dev* dev;
4529@@ -456,6 +624,7 @@
4530 dev = dev->next;
4531 }
4532 pci_cleanup (access);
4533+#endif
4534
4535 return 1;
4536 }
4537@@ -463,21 +632,29 @@
4538 int (*tests[]) (Display *display,
4539 unsigned int screen,
4540 Window root,
4541- GLXContext *context,
4542+ NUXContext *context,
4543 XVisualInfo **vinfos,
4544 TestResults *results) = {
4545 check_root_visual,
4546 check_xcomposite,
4547 check_damage_extension,
4548 check_fixes_extension,
4549+#ifndef NUX_OPENGLES_20
4550 check_glx_config,
4551 check_colorbuffers,
4552+#else
4553+ check_egl_config,
4554+#endif
4555 check_context,
4556 check_extensions,
4557 check_blacklist
4558 };
4559
4560+#ifndef NUX_OPENGLES_20
4561 const unsigned int c_num_tests = 9;
4562+#else
4563+const unsigned int c_num_tests = 8;
4564+#endif
4565
4566 int main (int argc, char* argv[]) {
4567 char *display_name = NULL;
4568@@ -486,8 +663,11 @@
4569 Window root;
4570 XVisualInfo *vinfos = NULL;
4571 Display *display = NULL;
4572- GLXContext context = NULL;
4573+ NUXContext context = NULL;
4574 TestResults results;
4575+#ifdef NUX_OPENGLES_20
4576+ EGLDisplay egl_dpy;
4577+#endif
4578 char resultfilename[30];
4579 int resultfile;
4580 int forcecheck = 0;
4581@@ -550,6 +730,7 @@
4582 screen = DefaultScreen (display);
4583 root = XRootWindow (display, screen);
4584
4585+#ifndef NUX_OPENGLES_20
4586 // Do the tests, if one of them fails break out of the loop
4587
4588 for (unsigned int i = 0; i < c_num_tests; i++)
4589@@ -585,6 +766,41 @@
4590 results.result = 1;
4591 }
4592 }
4593+#else
4594+ egl_dpy = eglGetDisplay(display);
4595+ if (!eglInitialize (egl_dpy, &results.major, &results.minor)) {
4596+ results.error = strdup ("OpenGLES: eglInitialize() failed");
4597+ results.result = 1;
4598+ } else {
4599+ // Do the tests, if one of them fails break out of the loop
4600+ for (unsigned int i = 0; i < c_num_tests; i++)
4601+ if (!(*tests[i]) (display, screen, root, &context, &vinfos, &results))
4602+ break;
4603+
4604+ if (results.compiz == 0) {
4605+ // Unity compatibility checks.
4606+ if ((results.major >= 2 || (results.major == 1 && results.minor >= 4)) &&
4607+ (results.flags & FLAG_GL_OES_EGL_IMAGE) &&
4608+ (results.flags & FLAG_EGL_KHR_IMAGE_PIXMAP) &&
4609+ (~results.flags & FLAG_SOFTWARE_RENDERING) &&
4610+ (~results.flags & FLAG_BLACKLISTED)) {
4611+ results.result = 0;
4612+ } else {
4613+ results.result = 1;
4614+ }
4615+ } else {
4616+ // Compiz compatibility checks.
4617+ if ((results.flags & FLAG_GL_OES_EGL_IMAGE) &&
4618+ (results.flags & FLAG_EGL_KHR_IMAGE_PIXMAP) &&
4619+ (~results.flags & FLAG_SOFTWARE_RENDERING) &&
4620+ (~results.flags & FLAG_BLACKLISTED)) {
4621+ results.result = 0;
4622+ } else {
4623+ results.result = 1;
4624+ }
4625+ }
4626+ }
4627+#endif
4628 }
4629
4630 if (print == 1) {
4631@@ -596,8 +812,15 @@
4632
4633 if (vinfos != NULL)
4634 XFree (vinfos);
4635+#ifndef NUX_OPENGLES_20
4636 if (context != NULL)
4637 glXDestroyContext (display, context);
4638+#else
4639+ if (context == EGL_NO_CONTEXT)
4640+ eglDestroyContext (egl_dpy, context);
4641+ if (egl_dpy)
4642+ eglTerminate (egl_dpy);
4643+#endif
4644 if (display != NULL)
4645 XCloseDisplay (display);
4646 if (results.error != NULL)

Subscribers

People subscribed via source and target branches