Merge lp:~unity-team/nux/nux.depth-texture-detection-support into lp:nux

Proposed by Jay Taoko on 2012-11-16
Status: Merged
Approved by: Jay Taoko on 2012-11-29
Approved revision: 724
Merged at revision: 726
Proposed branch: lp:~unity-team/nux/nux.depth-texture-detection-support
Merge into: lp:nux
Diff against target: 535 lines (+174/-64) 8 files modified
To merge this branch: bzr merge lp:~unity-team/nux/nux.depth-texture-detection-support
Reviewer Review Type Date Requested Status
Tim Penhey (community) 2012-11-16 Approve on 2012-11-20
PS Jenkins bot continuous-integration Pending
Review via email: mp+134729@code.launchpad.net

Commit Message

* Added depth texture support detection.
* Disable use of depth textures if support not available.

Description of the Change

* Added depth texture support detection.
* Disable use of depth textures if support not available.

To post a comment you must log in.
709. By MC Return on 2012-11-18

Performance:
Check for emptiness instead of calculating the size as this might be inefficient.
xxxx.size() can take linear time while xxxx.empty() is guaranteed to take constant time.

Approved by Michi Henning.

710. By MC Return on 2012-11-18

Performance: Do not create unnecessary string copies by converting const char* to std::string, instead use those directly.

Approved by Michi Henning.

711. By Michael Terry on 2012-11-19

Enable headless tests during build.

Approved by Didier Roche.

712. By Brandon Schaefer on 2012-11-20

Adds a input area proximity class which takes an input area and the proximity.

It has 3 signals, mouse_near, mouse_approaching, and mouse_beyond. They depend on the CheckMousePosition function. The default function expands each side of the InputArea by the proximity and checks if the mouse is within that geo. If true then emit mouse_near, if the mouse then is moved from that geo mouse_beyond will emit. (Some what like enter/leave). If the mouse is near, but not yet inside the input area then the mouse_approaching signal emits the mouses position and the distance to the input area. Fixes: https://bugs.launchpad.net/bugs/608124.

Approved by Jay Taoko, Marco Trevisan (Treviño).

Tim Penhey (thumper) wrote :

Looks ok to me.

review: Approve
713. By Tim Penhey on 2012-11-21

- Introducing improvements for ARM build.
- Resolved build failures
- Added --enable-x-support option
- Added --enable-minimal-build option

[Tests] Covered by existing tests.

Approved by Brandon Schaefer, Jay Taoko.

714. By Ricardo Salveti on 2012-11-21

 make check-headless should respect DEB_BUILD_OPTIONS=nocheck
.

Approved by Didier Roche.

715. By Brandon Schaefer on 2012-11-22

Check the position of mouse events for InputAreaProximities if an event type is NUX_WINDOW_MOUSE_LEAVE.

Approved by Jay Taoko.

716. By Tim Penhey on 2012-11-22

Make tests/gtest-nuxcore only depend on NuxCore libs.

Approved by Brandon Schaefer.

717. By Michi Henning on 2012-11-23

Fixes random color generation (which left the green component always at zero) in RandomColorINT().

Approved by Michi Henning.

718. By Albert Astals Cid on 2012-11-23

Make GetPosition const.

Approved by Marco Trevisan (Treviño), Neil J. Patel.

719. By Michi Henning on 2012-11-24

Added unit test for RandomColor().

Approved by .

720. By Brandon Schaefer on 2012-11-24

Fixes multi monitor issue with input area prox.

Approved by Andrea Azzarone.

721. By Marco Trevisan (Treviño) on 2012-11-27

AnimationValue: add Reverse and CurrentTimePosition methods

The first allow to revert the "direction" of an animation, while the second returns the current elapsed time since the animation has started.

Approved by Tim Penhey.

722. By Daniel d'Andrada on 2012-11-27

Fix build when geis is located outside /usr.

Approved by Stephen M. Webb.

723. By Jay Taoko on 2012-11-27

* Merged with lp:nux

724. By Jay Taoko on 2012-11-28

* Fixed ARM build error [-Werror=unused-but-set-variable]

Sean Feole (sfeole) wrote :

Last night I successfully installed and tested nux4.0 and unity 6.12 built by Lucasz (sil2100) in the unity-team/ppa targeted for Quantal. All of the packages appeared to work as expected.

If Jay is rebasing this patch to the nux trunk and I would be happy to retest once that finishes.

Preview Diff

1=== modified file 'Nux/WindowCompositor.cpp'
2--- Nux/WindowCompositor.cpp 2012-11-22 00:48:56 +0000
3+++ Nux/WindowCompositor.cpp 2012-11-28 15:20:28 +0000
4@@ -61,6 +61,8 @@
5 on_menu_closure_continue_with_event_ = false;
6 _mouse_position_on_owner = Point(0, 0);
7
8+ platform_support_for_depth_texture_ = GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer();
9+
10 m_FrameBufferObject = GetGraphicsDisplay()->GetGpuDevice()->CreateFrameBufferObject();
11 // Do not leave the Fbo binded. Deactivate it.
12 m_FrameBufferObject->Deactivate();
13@@ -68,7 +70,11 @@
14 // At this stage, the size of the window may not be known yet.
15 // FormatRenderTargets will be called the first time runtime gets into WindowThread::ExecutionLoop
16 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
17- m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
18+
19+ if (platform_support_for_depth_texture_)
20+ {
21+ m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
22+ }
23
24 #if !defined(NUX_MINIMAL)
25 _mouse_over_menu_page = NULL;
26@@ -1625,10 +1631,17 @@
27 buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth();
28 buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight();
29
30- if ((!m_MainColorRT.IsValid()) || (!m_MainDepthRT.IsValid()) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height))
31+ if ((!m_MainColorRT.IsValid()) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height))
32 {
33 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
34- m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
35+ }
36+
37+ if (platform_support_for_depth_texture_)
38+ {
39+ if ((!m_MainDepthRT.IsValid()) || (m_MainDepthRT->GetWidth() != buffer_width) || (m_MainDepthRT->GetHeight() != buffer_height))
40+ {
41+ m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
42+ }
43 }
44
45 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);
46@@ -2050,7 +2063,10 @@
47 nuxAssert(buffer_height >= 1);
48
49 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
50- m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
51+ if (platform_support_for_depth_texture_)
52+ {
53+ m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
54+ }
55
56 // Clear the buffer the first time...
57 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);
58@@ -2093,7 +2109,14 @@
59 if ((rt.color_rt->GetWidth() != buffer_width) || (rt.color_rt->GetHeight() != buffer_height))
60 {
61 rt.color_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
62- rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
63+ }
64+
65+ if (platform_support_for_depth_texture_)
66+ {
67+ if ((rt.depth_rt->GetWidth() != buffer_width) || (rt.depth_rt->GetHeight() != buffer_height))
68+ {
69+ rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
70+ }
71 }
72
73 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);
74
75=== modified file 'Nux/WindowCompositor.h'
76--- Nux/WindowCompositor.h 2012-11-20 22:13:38 +0000
77+++ Nux/WindowCompositor.h 2012-11-28 15:20:28 +0000
78@@ -536,6 +536,9 @@
79 unsigned int reference_fbo_;
80 Geometry reference_fbo_geometry_;
81
82+ //! True if the platform has support for depth textures.
83+ bool platform_support_for_depth_texture_;
84+
85 //! Pointer grab stack.
86 /*!
87 The head of the list is the top of the stack.
88
89=== modified file 'NuxGraphics/GpuDevice.cpp'
90--- NuxGraphics/GpuDevice.cpp 2012-11-12 20:59:56 +0000
91+++ NuxGraphics/GpuDevice.cpp 2012-11-28 15:20:28 +0000
92@@ -187,26 +187,49 @@
93 STREAMSOURCE GpuDevice::_StreamSource[MAX_NUM_STREAM];
94
95 GpuInfo::GpuInfo()
96- : _opengl_max_texture_size(0)
97- , _opengl_max_texture_units(0)
98- , _opengl_max_texture_coords(0)
99- , _opengl_max_texture_image_units(0)
100- , _opengl_max_fb_attachment(0)
101- , _opengl_max_vertex_attributes(0)
102+ : _support_opengl_version_11(false)
103+ , _support_opengl_version_12(false)
104+ , _support_opengl_version_13(false)
105+ , _support_opengl_version_14(false)
106+ , _support_opengl_version_15(false)
107+ , _support_opengl_version_20(false)
108+ , _support_opengl_version_21(false)
109+ , _support_opengl_version_30(false)
110+ , _support_opengl_version_31(false)
111+ , _support_opengl_version_32(false)
112+ , _support_opengl_version_33(false)
113+ , _support_opengl_version_40(false)
114+ , _support_opengl_version_41(false)
115+ , _opengl_max_texture_size(0)
116+ , _opengl_max_texture_units(0)
117+ , _opengl_max_texture_coords(0)
118+ , _opengl_max_texture_image_units(0)
119+ , _opengl_max_fb_attachment(0)
120+ , _opengl_max_vertex_attributes(0)
121+ , _support_ext_swap_control(false)
122+ , _support_arb_vertex_program(false)
123+ , _support_arb_fragment_program(false)
124+ , _support_arb_shader_objects(false)
125+ , _support_arb_vertex_shader(false)
126+ , _support_arb_fragment_shader(false)
127+ , _support_arb_vertex_buffer_object(false)
128+ , _support_arb_texture_non_power_of_two(false)
129+ , _support_ext_framebuffer_object(false)
130+ , _support_ext_draw_range_elements(false)
131+ , _support_ext_stencil_two_side(false)
132+ , _support_ext_texture_rectangle(false)
133+ , _support_arb_texture_rectangle(false)
134+ , _support_nv_texture_rectangle(false)
135+ , _support_arb_pixel_buffer_object(false)
136+ , _support_ext_blend_equation_separate(false)
137+ , _support_depth_buffer(false)
138+#ifndef NUX_OPENGLES_20
139+ , _support_ext_texture_srgb(false)
140+ , _support_ext_texture_srgb_decode(false)
141+ , _support_ext_framebuffer_srgb(false)
142+ , _support_arb_framebuffer_srgb(false)
143+#endif
144 {
145- _support_opengl_version_11 = false;
146- _support_opengl_version_12 = false;
147- _support_opengl_version_13 = false;
148- _support_opengl_version_14 = false;
149- _support_opengl_version_15 = false;
150- _support_opengl_version_20 = false;
151- _support_opengl_version_21 = false;
152- _support_opengl_version_30 = false;
153- _support_opengl_version_31 = false;
154- _support_opengl_version_32 = false;
155- _support_opengl_version_33 = false;
156- _support_opengl_version_40 = false;
157- _support_opengl_version_41 = false;
158 }
159
160 void GpuInfo::Setup()
161@@ -234,6 +257,7 @@
162 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &_opengl_max_texture_image_units));
163 CHECKGL(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &_opengl_max_vertex_attributes));
164 CHECKGL(glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &_opengl_max_fb_attachment));
165+ _support_depth_buffer = true;
166 #else
167 // By opengl es 2.0 standard, GL_MAX_TEXTURE_SIZE should return a minimum of 64.
168 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_opengl_max_texture_size));
169@@ -242,6 +266,11 @@
170 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &_opengl_max_texture_image_units));
171 // GL_MAX_COLOR_ATTACHMENTS_EXT is not supported under opengl es 2.0.
172 _opengl_max_fb_attachment = 1;
173+
174+ if (glGetString(GL_OES_depth_texture))
175+ {
176+ _support_depth_buffer = true;
177+ }
178 #endif
179
180 #if defined(NUX_OS_WINDOWS)
181
182=== modified file 'NuxGraphics/GpuDevice.h'
183--- NuxGraphics/GpuDevice.h 2012-11-12 20:59:56 +0000
184+++ NuxGraphics/GpuDevice.h 2012-11-28 15:20:28 +0000
185@@ -84,8 +84,8 @@
186 bool SupportOpenGL21() const {return _support_opengl_version_21;}
187 bool SupportOpenGL30() const {return _support_opengl_version_30;}
188 bool SupportOpenGL31() const {return _support_opengl_version_31;}
189+ bool SupportOpenGL32() const {return _support_opengl_version_32;}
190 bool SupportOpenGL33() const {return _support_opengl_version_33;}
191- bool SupportOpenGL32() const {return _support_opengl_version_32;}
192 bool SupportOpenGL40() const {return _support_opengl_version_40;}
193 bool SupportOpenGL41() const {return _support_opengl_version_41;}
194
195@@ -105,6 +105,7 @@
196 bool Support_NV_Texture_Rectangle() const {return _support_nv_texture_rectangle;}
197 bool Support_ARB_Pixel_Buffer_Object() const {return _support_arb_pixel_buffer_object;}
198 bool Support_EXT_Blend_Equation_Separate() const {return _support_ext_blend_equation_separate;}
199+ bool Support_Depth_Buffer() const {return _support_depth_buffer;}
200
201 #ifndef NUX_OPENGLES_20
202 bool Support_EXT_Texture_sRGB() const {return _support_ext_texture_srgb;}
203@@ -157,6 +158,7 @@
204 bool _support_nv_texture_rectangle;
205 bool _support_arb_pixel_buffer_object;
206 bool _support_ext_blend_equation_separate;
207+ bool _support_depth_buffer;
208
209 #ifndef NUX_OPENGLES_20
210 bool _support_ext_texture_srgb;
211
212=== modified file 'NuxGraphics/GpuDeviceTexture.cpp'
213--- NuxGraphics/GpuDeviceTexture.cpp 2012-11-05 21:31:06 +0000
214+++ NuxGraphics/GpuDeviceTexture.cpp 2012-11-28 15:20:28 +0000
215@@ -36,9 +36,15 @@
216 int Width
217 , int Height
218 , int Levels
219- , BitmapFormat PixelFormat
220+ , BitmapFormat pixel_format
221 , NUX_FILE_LINE_DECL)
222 {
223+ if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
224+ {
225+ // No support for depth buffers
226+ return ObjectPtr<IOpenGLTexture2D>();
227+ }
228+
229 GpuInfo gpu_info = GetGpuInfo();
230 int msz = gpu_info.GetMaxTextureSize();
231 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
232@@ -63,7 +69,7 @@
233 }
234
235 ObjectPtr<IOpenGLTexture2D> result;
236- result.Adopt(new IOpenGLTexture2D(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM));
237+ result.Adopt(new IOpenGLTexture2D(Width, Height, NumMipLevel, pixel_format, false, NUX_FILE_LINE_PARAM));
238 return result;
239 }
240
241@@ -74,6 +80,12 @@
242 , BitmapFormat pixel_format
243 , NUX_FILE_LINE_DECL)
244 {
245+ if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
246+ {
247+ // No support for depth buffers
248+ return ObjectPtr<IOpenGLTexture2D>();
249+ }
250+
251 GpuInfo gpu_info = GetGpuInfo();
252 int msz = gpu_info.GetMaxTextureSize();
253 if(width <= 0 || height <=0 || width > msz || height > msz)
254@@ -90,9 +102,15 @@
255 int Width
256 , int Height
257 , int Levels
258- , BitmapFormat PixelFormat
259+ , BitmapFormat pixel_format
260 , NUX_FILE_LINE_DECL)
261 {
262+ if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
263+ {
264+ // No support for depth buffers
265+ return ObjectPtr<IOpenGLRectangleTexture>();
266+ }
267+
268 GpuInfo gpu_info = GetGpuInfo();
269 int msz = gpu_info.GetMaxTextureSize();
270 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
271@@ -117,17 +135,23 @@
272 }
273
274 ObjectPtr<IOpenGLRectangleTexture> result;
275- result.Adopt(new IOpenGLRectangleTexture(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM));
276+ result.Adopt(new IOpenGLRectangleTexture(Width, Height, NumMipLevel, pixel_format, false, NUX_FILE_LINE_PARAM));
277 return result;
278 }
279
280 ObjectPtr<IOpenGLCubeTexture> GpuDevice::CreateCubeTexture(
281 int EdgeLength
282 , int Levels
283- , BitmapFormat PixelFormat
284+ , BitmapFormat pixel_format
285 , const char * /* __Nux_FileName__ */
286 , int /* __Nux_LineNumber__ */)
287 {
288+ if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
289+ {
290+ // No support for depth buffers
291+ return ObjectPtr<IOpenGLCubeTexture>();
292+ }
293+
294 unsigned int NumTotalMipLevel = 1 + floorf(Log2(EdgeLength));
295 unsigned int NumMipLevel = 0;
296
297@@ -145,7 +169,7 @@
298 }
299
300 ObjectPtr<IOpenGLCubeTexture> result;
301- result.Adopt(new IOpenGLCubeTexture(EdgeLength, NumMipLevel, PixelFormat));
302+ result.Adopt(new IOpenGLCubeTexture(EdgeLength, NumMipLevel, pixel_format));
303 return result;
304 }
305
306@@ -154,10 +178,16 @@
307 , int Height
308 , int Depth
309 , int Levels
310- , BitmapFormat PixelFormat
311+ , BitmapFormat pixel_format
312 , const char * /* __Nux_FileName__ */
313 , int /* __Nux_LineNumber__ */)
314 {
315+ if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
316+ {
317+ // No support for depth buffers
318+ return ObjectPtr<IOpenGLVolumeTexture>();
319+ }
320+
321 GpuInfo gpu_info = GetGpuInfo();
322 int msz = gpu_info.GetMaxTextureSize();
323 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
324@@ -182,7 +212,7 @@
325 }
326
327 ObjectPtr<IOpenGLVolumeTexture> result;
328- result.Adopt(new IOpenGLVolumeTexture(Width, Height, Depth, NumMipLevel, PixelFormat));
329+ result.Adopt(new IOpenGLVolumeTexture(Width, Height, Depth, NumMipLevel, pixel_format));
330 return result;
331 }
332
333@@ -190,8 +220,14 @@
334 int Width
335 , int Height
336 , int Depth
337- , BitmapFormat PixelFormat)
338+ , BitmapFormat pixel_format)
339 {
340+ if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
341+ {
342+ // No support for depth buffers
343+ return ObjectPtr<IOpenGLAnimatedTexture>();
344+ }
345+
346 GpuInfo gpu_info = GetGpuInfo();
347 int msz = gpu_info.GetMaxTextureSize();
348 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
349@@ -200,7 +236,7 @@
350 }
351
352 ObjectPtr<IOpenGLAnimatedTexture> result;
353- result.Adopt(new IOpenGLAnimatedTexture(Width, Height, Depth, PixelFormat));
354+ result.Adopt(new IOpenGLAnimatedTexture(Width, Height, Depth, pixel_format));
355 return result;
356 }
357
358
359=== modified file 'NuxGraphics/GraphicsEngine.cpp'
360--- NuxGraphics/GraphicsEngine.cpp 2012-11-20 22:13:38 +0000
361+++ NuxGraphics/GraphicsEngine.cpp 2012-11-28 15:20:28 +0000
362@@ -195,21 +195,23 @@
363 SetScissor(0, 0, _graphics_display.GetWindowWidth(), _graphics_display.GetWindowHeight());
364 EnableScissoring(true);
365
366+ GpuDevice* gpu_device = _graphics_display.GetGpuDevice();
367+ const GpuInfo& gpu_info = gpu_device->GetGpuInfo();
368+
369 if (create_rendering_data)
370 {
371 #ifndef NUX_OPENGLES_20
372 bool opengl_14_support = true;
373-
374- if ((_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion() == 1) &&
375- (_graphics_display.GetGpuDevice()->GetOpenGLMinorVersion() < 4))
376+ if ((gpu_device->GetOpenGLMajorVersion() == 1) &&
377+ (gpu_device->GetOpenGLMinorVersion() < 4))
378 {
379 // OpenGL version is less than OpenGL 1.4
380 opengl_14_support = false;
381 }
382-
383- if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
384- _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Program() &&
385- opengl_14_support)
386+
387+ if (gpu_info.Support_ARB_Fragment_Shader() &&
388+ gpu_info.Support_ARB_Vertex_Program() &&
389+ opengl_14_support)
390 {
391 InitAsmColorShader();
392 InitAsmTextureShader();
393@@ -229,8 +231,6 @@
394 }
395 #endif
396
397- const GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo();
398-
399 if ((gpu_info.Support_ARB_Vertex_Program() && gpu_info.Support_ARB_Fragment_Program())
400 || (gpu_info.Support_ARB_Vertex_Shader() && gpu_info.Support_ARB_Fragment_Shader()))
401 {
402@@ -238,7 +238,7 @@
403 }
404
405 if (gpu_info.Support_EXT_Framebuffer_Object())
406- _offscreen_fbo = _graphics_display.GetGpuDevice()->CreateFrameBufferObject();
407+ _offscreen_fbo = gpu_device->CreateFrameBufferObject();
408
409 _offscreen_color_rt0 = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
410 _offscreen_color_rt1 = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
411@@ -1312,7 +1312,10 @@
412 colorbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
413 }
414
415- if ((depthbuffer.IsValid()) && ((depthbuffer->GetWidth() != width) || (depthbuffer->GetHeight() != height)))
416+ bool use_depth_buffer = _graphics_display.GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer();
417+ if (use_depth_buffer &&
418+ depthbuffer.IsValid() &&
419+ ((depthbuffer->GetWidth() != width) || (depthbuffer->GetHeight() != height)))
420 {
421 // Generate a new depth texture only if a valid one was passed to this function.
422 depthbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
423@@ -1321,7 +1324,7 @@
424 fbo->FormatFrameBufferObject(width, height, BITFMT_R8G8B8A8);
425 fbo->SetRenderTarget(0, colorbuffer->GetSurfaceLevel(0));
426
427- if (depthbuffer.IsValid())
428+ if (use_depth_buffer && depthbuffer.IsValid())
429 fbo->SetDepthSurface(depthbuffer->GetSurfaceLevel(0));
430 else
431 fbo->SetDepthSurface(ObjectPtr<IOpenGLSurface>(NULL));
432
433=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.cpp'
434--- NuxGraphics/IOpenGLFrameBufferObject.cpp 2012-11-17 21:44:54 +0000
435+++ NuxGraphics/IOpenGLFrameBufferObject.cpp 2012-11-28 15:20:28 +0000
436@@ -32,7 +32,8 @@
437 NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLFrameBufferObject);
438
439 IOpenGLFrameBufferObject::IOpenGLFrameBufferObject(NUX_FILE_LINE_DECL)
440- : IOpenGLResource(RTFRAMEBUFFEROBJECT, NUX_FILE_LINE_PARAM)
441+ : IOpenGLResource(RTFRAMEBUFFEROBJECT, NUX_FILE_LINE_PARAM)
442+ , platform_support_for_depth_texture_(false)
443 {
444 attachment_width_ = 1;
445 attachment_height_ = 1;
446@@ -45,6 +46,11 @@
447 surface_attachment_array_.push_back(ObjectPtr<IOpenGLSurface> (0));
448 }
449
450+ if (GetGraphicsDisplay()->GetGpuDevice() && GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer())
451+ {
452+ platform_support_for_depth_texture_ = true;
453+ }
454+
455 FormatFrameBufferObject(attachment_width_, attachment_height_, _PixelFormat);
456 GRunTimeStats.Register(this);
457 }
458@@ -174,7 +180,10 @@
459
460 int IOpenGLFrameBufferObject::SetDepthSurface(ObjectPtr<IOpenGLSurface> pDepthSurface)
461 {
462- //nuxAssert(pDepthSurface.IsValid());
463+ if (!platform_support_for_depth_texture_)
464+ {
465+ return 0;
466+ }
467
468 if (pDepthSurface.IsNull())
469 {
470@@ -208,6 +217,11 @@
471
472 int IOpenGLFrameBufferObject::SetDepthTextureAttachment(ObjectPtr<IOpenGLBaseTexture> depth_texture, int mip_level)
473 {
474+ if (!platform_support_for_depth_texture_)
475+ {
476+ return 0;
477+ }
478+
479 if (depth_texture.IsNull())
480 {
481 depth_surface_attachment_ = ObjectPtr<IOpenGLSurface> (0);
482@@ -289,27 +303,26 @@
483 }
484 }
485
486- if (depth_surface_attachment_.IsValid())
487+ if (platform_support_for_depth_texture_)
488 {
489- GLenum target = depth_surface_attachment_->GetSurfaceTarget();
490- GLenum glID = depth_surface_attachment_->GetOpenGLID();
491- GLint level = depth_surface_attachment_->GetMipLevel();
492- CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, target, glID, level));
493+ if (depth_surface_attachment_.IsValid())
494+ {
495+ GLenum target = depth_surface_attachment_->GetSurfaceTarget();
496+ GLenum glID = depth_surface_attachment_->GetOpenGLID();
497+ GLint level = depth_surface_attachment_->GetMipLevel();
498+ CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, target, glID, level));
499+ }
500+ else
501+ {
502+ CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
503+ // On the PC you need to bing the same D24S8 surface to the depth and the stencil attachment.
504+ }
505 }
506 else
507 {
508- CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
509- // On the PC you need to bing the same D24S8 surface to the depth and the stencil attachment.
510+ CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
511 }
512
513-// #ifndef NUX_OPENGLES_20
514-// _Rbo.Set(GL_DEPTH_COMPONENT, attachment_width_, attachment_height_);
515-// CHECKGL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
516-// GL_DEPTH_ATTACHMENT_EXT,
517-// GL_RENDERBUFFER_EXT,
518-// _Rbo.GetId()));
519-// #endif
520-
521 nuxAssert( _Fbo.IsValid() == true );
522
523 if (GetGraphicsDisplay()->GetGraphicsEngine())
524
525=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.h'
526--- NuxGraphics/IOpenGLFrameBufferObject.h 2012-11-05 21:31:06 +0000
527+++ NuxGraphics/IOpenGLFrameBufferObject.h 2012-11-28 15:20:28 +0000
528@@ -105,6 +105,7 @@
529
530 GLFramebufferObject _Fbo; // The framebuffer object used for rendering to the texture
531 GLRenderbuffer _Rbo;
532+ bool platform_support_for_depth_texture_;
533
534 friend class GpuDevice;
535 };

Subscribers

People subscribed via source and target branches