Nux

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

Proposed by Jay Taoko
Status: Merged
Approved by: Jay Taoko
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
Nux/WindowCompositor.cpp (+28/-5)
Nux/WindowCompositor.h (+3/-0)
NuxGraphics/GpuDevice.cpp (+48/-19)
NuxGraphics/GpuDevice.h (+3/-1)
NuxGraphics/GpuDeviceTexture.cpp (+46/-10)
NuxGraphics/GraphicsEngine.cpp (+15/-12)
NuxGraphics/IOpenGLFrameBufferObject.cpp (+30/-17)
NuxGraphics/IOpenGLFrameBufferObject.h (+1/-0)
To merge this branch: bzr merge lp:~unity-team/nux/nux.depth-texture-detection-support
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
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

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

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

Enable headless tests during build.

Approved by Didier Roche.

712. By Brandon Schaefer

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).

Revision history for this message
Tim Penhey (thumper) wrote :

Looks ok to me.

review: Approve
713. By Tim Penhey

- 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

 make check-headless should respect DEB_BUILD_OPTIONS=nocheck
.

Approved by Didier Roche.

715. By Brandon Schaefer

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

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

Approved by Brandon Schaefer.

717. By Michi Henning

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

Approved by Michi Henning.

718. By Albert Astals Cid

Make GetPosition const.

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

719. By Michi Henning

Added unit test for RandomColor().

Approved by .

720. By Brandon Schaefer

Fixes multi monitor issue with input area prox.

Approved by Andrea Azzarone.

721. By Marco Trevisan (Treviño)

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

Fix build when geis is located outside /usr.

Approved by Stephen M. Webb.

723. By Jay Taoko

* Merged with lp:nux

724. By Jay Taoko

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

Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Nux/WindowCompositor.cpp'
--- Nux/WindowCompositor.cpp 2012-11-22 00:48:56 +0000
+++ Nux/WindowCompositor.cpp 2012-11-28 15:20:28 +0000
@@ -61,6 +61,8 @@
61 on_menu_closure_continue_with_event_ = false;61 on_menu_closure_continue_with_event_ = false;
62 _mouse_position_on_owner = Point(0, 0);62 _mouse_position_on_owner = Point(0, 0);
6363
64 platform_support_for_depth_texture_ = GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer();
65
64 m_FrameBufferObject = GetGraphicsDisplay()->GetGpuDevice()->CreateFrameBufferObject();66 m_FrameBufferObject = GetGraphicsDisplay()->GetGpuDevice()->CreateFrameBufferObject();
65 // Do not leave the Fbo binded. Deactivate it.67 // Do not leave the Fbo binded. Deactivate it.
66 m_FrameBufferObject->Deactivate();68 m_FrameBufferObject->Deactivate();
@@ -68,7 +70,11 @@
68 // At this stage, the size of the window may not be known yet.70 // At this stage, the size of the window may not be known yet.
69 // FormatRenderTargets will be called the first time runtime gets into WindowThread::ExecutionLoop71 // FormatRenderTargets will be called the first time runtime gets into WindowThread::ExecutionLoop
70 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);72 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
71 m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);73
74 if (platform_support_for_depth_texture_)
75 {
76 m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
77 }
7278
73#if !defined(NUX_MINIMAL)79#if !defined(NUX_MINIMAL)
74 _mouse_over_menu_page = NULL;80 _mouse_over_menu_page = NULL;
@@ -1625,10 +1631,17 @@
1625 buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth();1631 buffer_width = window_thread_->GetGraphicsEngine().GetWindowWidth();
1626 buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight();1632 buffer_height = window_thread_->GetGraphicsEngine().GetWindowHeight();
16271633
1628 if ((!m_MainColorRT.IsValid()) || (!m_MainDepthRT.IsValid()) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height))1634 if ((!m_MainColorRT.IsValid()) || (m_MainColorRT->GetWidth() != buffer_width) || (m_MainColorRT->GetHeight() != buffer_height))
1629 {1635 {
1630 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);1636 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
1631 m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);1637 }
1638
1639 if (platform_support_for_depth_texture_)
1640 {
1641 if ((!m_MainDepthRT.IsValid()) || (m_MainDepthRT->GetWidth() != buffer_width) || (m_MainDepthRT->GetHeight() != buffer_height))
1642 {
1643 m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
1644 }
1632 }1645 }
16331646
1634 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);1647 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);
@@ -2050,7 +2063,10 @@
2050 nuxAssert(buffer_height >= 1);2063 nuxAssert(buffer_height >= 1);
20512064
2052 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);2065 m_MainColorRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
2053 m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);2066 if (platform_support_for_depth_texture_)
2067 {
2068 m_MainDepthRT = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
2069 }
20542070
2055 // Clear the buffer the first time...2071 // Clear the buffer the first time...
2056 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);2072 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);
@@ -2093,7 +2109,14 @@
2093 if ((rt.color_rt->GetWidth() != buffer_width) || (rt.color_rt->GetHeight() != buffer_height))2109 if ((rt.color_rt->GetWidth() != buffer_width) || (rt.color_rt->GetHeight() != buffer_height))
2094 {2110 {
2095 rt.color_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);2111 rt.color_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
2096 rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);2112 }
2113
2114 if (platform_support_for_depth_texture_)
2115 {
2116 if ((rt.depth_rt->GetWidth() != buffer_width) || (rt.depth_rt->GetHeight() != buffer_height))
2117 {
2118 rt.depth_rt = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(buffer_width, buffer_height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
2119 }
2097 }2120 }
20982121
2099 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);2122 m_FrameBufferObject->FormatFrameBufferObject(buffer_width, buffer_height, BITFMT_R8G8B8A8);
21002123
=== modified file 'Nux/WindowCompositor.h'
--- Nux/WindowCompositor.h 2012-11-20 22:13:38 +0000
+++ Nux/WindowCompositor.h 2012-11-28 15:20:28 +0000
@@ -536,6 +536,9 @@
536 unsigned int reference_fbo_;536 unsigned int reference_fbo_;
537 Geometry reference_fbo_geometry_;537 Geometry reference_fbo_geometry_;
538538
539 //! True if the platform has support for depth textures.
540 bool platform_support_for_depth_texture_;
541
539 //! Pointer grab stack.542 //! Pointer grab stack.
540 /*!543 /*!
541 The head of the list is the top of the stack.544 The head of the list is the top of the stack.
542545
=== modified file 'NuxGraphics/GpuDevice.cpp'
--- NuxGraphics/GpuDevice.cpp 2012-11-12 20:59:56 +0000
+++ NuxGraphics/GpuDevice.cpp 2012-11-28 15:20:28 +0000
@@ -187,26 +187,49 @@
187 STREAMSOURCE GpuDevice::_StreamSource[MAX_NUM_STREAM];187 STREAMSOURCE GpuDevice::_StreamSource[MAX_NUM_STREAM];
188188
189 GpuInfo::GpuInfo()189 GpuInfo::GpuInfo()
190 : _opengl_max_texture_size(0)190 : _support_opengl_version_11(false)
191 , _opengl_max_texture_units(0)191 , _support_opengl_version_12(false)
192 , _opengl_max_texture_coords(0)192 , _support_opengl_version_13(false)
193 , _opengl_max_texture_image_units(0)193 , _support_opengl_version_14(false)
194 , _opengl_max_fb_attachment(0)194 , _support_opengl_version_15(false)
195 , _opengl_max_vertex_attributes(0)195 , _support_opengl_version_20(false)
196 , _support_opengl_version_21(false)
197 , _support_opengl_version_30(false)
198 , _support_opengl_version_31(false)
199 , _support_opengl_version_32(false)
200 , _support_opengl_version_33(false)
201 , _support_opengl_version_40(false)
202 , _support_opengl_version_41(false)
203 , _opengl_max_texture_size(0)
204 , _opengl_max_texture_units(0)
205 , _opengl_max_texture_coords(0)
206 , _opengl_max_texture_image_units(0)
207 , _opengl_max_fb_attachment(0)
208 , _opengl_max_vertex_attributes(0)
209 , _support_ext_swap_control(false)
210 , _support_arb_vertex_program(false)
211 , _support_arb_fragment_program(false)
212 , _support_arb_shader_objects(false)
213 , _support_arb_vertex_shader(false)
214 , _support_arb_fragment_shader(false)
215 , _support_arb_vertex_buffer_object(false)
216 , _support_arb_texture_non_power_of_two(false)
217 , _support_ext_framebuffer_object(false)
218 , _support_ext_draw_range_elements(false)
219 , _support_ext_stencil_two_side(false)
220 , _support_ext_texture_rectangle(false)
221 , _support_arb_texture_rectangle(false)
222 , _support_nv_texture_rectangle(false)
223 , _support_arb_pixel_buffer_object(false)
224 , _support_ext_blend_equation_separate(false)
225 , _support_depth_buffer(false)
226#ifndef NUX_OPENGLES_20
227 , _support_ext_texture_srgb(false)
228 , _support_ext_texture_srgb_decode(false)
229 , _support_ext_framebuffer_srgb(false)
230 , _support_arb_framebuffer_srgb(false)
231#endif
196 {232 {
197 _support_opengl_version_11 = false;
198 _support_opengl_version_12 = false;
199 _support_opengl_version_13 = false;
200 _support_opengl_version_14 = false;
201 _support_opengl_version_15 = false;
202 _support_opengl_version_20 = false;
203 _support_opengl_version_21 = false;
204 _support_opengl_version_30 = false;
205 _support_opengl_version_31 = false;
206 _support_opengl_version_32 = false;
207 _support_opengl_version_33 = false;
208 _support_opengl_version_40 = false;
209 _support_opengl_version_41 = false;
210 }233 }
211234
212 void GpuInfo::Setup()235 void GpuInfo::Setup()
@@ -234,6 +257,7 @@
234 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &_opengl_max_texture_image_units));257 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &_opengl_max_texture_image_units));
235 CHECKGL(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &_opengl_max_vertex_attributes));258 CHECKGL(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &_opengl_max_vertex_attributes));
236 CHECKGL(glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &_opengl_max_fb_attachment));259 CHECKGL(glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &_opengl_max_fb_attachment));
260 _support_depth_buffer = true;
237#else261#else
238 // By opengl es 2.0 standard, GL_MAX_TEXTURE_SIZE should return a minimum of 64.262 // By opengl es 2.0 standard, GL_MAX_TEXTURE_SIZE should return a minimum of 64.
239 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_opengl_max_texture_size));263 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_opengl_max_texture_size));
@@ -242,6 +266,11 @@
242 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &_opengl_max_texture_image_units));266 CHECKGL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &_opengl_max_texture_image_units));
243 // GL_MAX_COLOR_ATTACHMENTS_EXT is not supported under opengl es 2.0.267 // GL_MAX_COLOR_ATTACHMENTS_EXT is not supported under opengl es 2.0.
244 _opengl_max_fb_attachment = 1;268 _opengl_max_fb_attachment = 1;
269
270 if (glGetString(GL_OES_depth_texture))
271 {
272 _support_depth_buffer = true;
273 }
245#endif274#endif
246275
247#if defined(NUX_OS_WINDOWS)276#if defined(NUX_OS_WINDOWS)
248277
=== modified file 'NuxGraphics/GpuDevice.h'
--- NuxGraphics/GpuDevice.h 2012-11-12 20:59:56 +0000
+++ NuxGraphics/GpuDevice.h 2012-11-28 15:20:28 +0000
@@ -84,8 +84,8 @@
84 bool SupportOpenGL21() const {return _support_opengl_version_21;}84 bool SupportOpenGL21() const {return _support_opengl_version_21;}
85 bool SupportOpenGL30() const {return _support_opengl_version_30;}85 bool SupportOpenGL30() const {return _support_opengl_version_30;}
86 bool SupportOpenGL31() const {return _support_opengl_version_31;}86 bool SupportOpenGL31() const {return _support_opengl_version_31;}
87 bool SupportOpenGL32() const {return _support_opengl_version_32;}
87 bool SupportOpenGL33() const {return _support_opengl_version_33;}88 bool SupportOpenGL33() const {return _support_opengl_version_33;}
88 bool SupportOpenGL32() const {return _support_opengl_version_32;}
89 bool SupportOpenGL40() const {return _support_opengl_version_40;}89 bool SupportOpenGL40() const {return _support_opengl_version_40;}
90 bool SupportOpenGL41() const {return _support_opengl_version_41;}90 bool SupportOpenGL41() const {return _support_opengl_version_41;}
9191
@@ -105,6 +105,7 @@
105 bool Support_NV_Texture_Rectangle() const {return _support_nv_texture_rectangle;}105 bool Support_NV_Texture_Rectangle() const {return _support_nv_texture_rectangle;}
106 bool Support_ARB_Pixel_Buffer_Object() const {return _support_arb_pixel_buffer_object;}106 bool Support_ARB_Pixel_Buffer_Object() const {return _support_arb_pixel_buffer_object;}
107 bool Support_EXT_Blend_Equation_Separate() const {return _support_ext_blend_equation_separate;}107 bool Support_EXT_Blend_Equation_Separate() const {return _support_ext_blend_equation_separate;}
108 bool Support_Depth_Buffer() const {return _support_depth_buffer;}
108109
109#ifndef NUX_OPENGLES_20110#ifndef NUX_OPENGLES_20
110 bool Support_EXT_Texture_sRGB() const {return _support_ext_texture_srgb;}111 bool Support_EXT_Texture_sRGB() const {return _support_ext_texture_srgb;}
@@ -157,6 +158,7 @@
157 bool _support_nv_texture_rectangle;158 bool _support_nv_texture_rectangle;
158 bool _support_arb_pixel_buffer_object;159 bool _support_arb_pixel_buffer_object;
159 bool _support_ext_blend_equation_separate;160 bool _support_ext_blend_equation_separate;
161 bool _support_depth_buffer;
160162
161#ifndef NUX_OPENGLES_20163#ifndef NUX_OPENGLES_20
162 bool _support_ext_texture_srgb;164 bool _support_ext_texture_srgb;
163165
=== modified file 'NuxGraphics/GpuDeviceTexture.cpp'
--- NuxGraphics/GpuDeviceTexture.cpp 2012-11-05 21:31:06 +0000
+++ NuxGraphics/GpuDeviceTexture.cpp 2012-11-28 15:20:28 +0000
@@ -36,9 +36,15 @@
36 int Width36 int Width
37 , int Height37 , int Height
38 , int Levels38 , int Levels
39 , BitmapFormat PixelFormat39 , BitmapFormat pixel_format
40 , NUX_FILE_LINE_DECL)40 , NUX_FILE_LINE_DECL)
41 {41 {
42 if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
43 {
44 // No support for depth buffers
45 return ObjectPtr<IOpenGLTexture2D>();
46 }
47
42 GpuInfo gpu_info = GetGpuInfo();48 GpuInfo gpu_info = GetGpuInfo();
43 int msz = gpu_info.GetMaxTextureSize();49 int msz = gpu_info.GetMaxTextureSize();
44 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)50 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
@@ -63,7 +69,7 @@
63 }69 }
6470
65 ObjectPtr<IOpenGLTexture2D> result;71 ObjectPtr<IOpenGLTexture2D> result;
66 result.Adopt(new IOpenGLTexture2D(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM));72 result.Adopt(new IOpenGLTexture2D(Width, Height, NumMipLevel, pixel_format, false, NUX_FILE_LINE_PARAM));
67 return result;73 return result;
68 }74 }
6975
@@ -74,6 +80,12 @@
74 , BitmapFormat pixel_format80 , BitmapFormat pixel_format
75 , NUX_FILE_LINE_DECL)81 , NUX_FILE_LINE_DECL)
76 {82 {
83 if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
84 {
85 // No support for depth buffers
86 return ObjectPtr<IOpenGLTexture2D>();
87 }
88
77 GpuInfo gpu_info = GetGpuInfo();89 GpuInfo gpu_info = GetGpuInfo();
78 int msz = gpu_info.GetMaxTextureSize();90 int msz = gpu_info.GetMaxTextureSize();
79 if(width <= 0 || height <=0 || width > msz || height > msz)91 if(width <= 0 || height <=0 || width > msz || height > msz)
@@ -90,9 +102,15 @@
90 int Width102 int Width
91 , int Height103 , int Height
92 , int Levels104 , int Levels
93 , BitmapFormat PixelFormat105 , BitmapFormat pixel_format
94 , NUX_FILE_LINE_DECL)106 , NUX_FILE_LINE_DECL)
95 {107 {
108 if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
109 {
110 // No support for depth buffers
111 return ObjectPtr<IOpenGLRectangleTexture>();
112 }
113
96 GpuInfo gpu_info = GetGpuInfo();114 GpuInfo gpu_info = GetGpuInfo();
97 int msz = gpu_info.GetMaxTextureSize();115 int msz = gpu_info.GetMaxTextureSize();
98 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)116 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
@@ -117,17 +135,23 @@
117 }135 }
118136
119 ObjectPtr<IOpenGLRectangleTexture> result;137 ObjectPtr<IOpenGLRectangleTexture> result;
120 result.Adopt(new IOpenGLRectangleTexture(Width, Height, NumMipLevel, PixelFormat, false, NUX_FILE_LINE_PARAM));138 result.Adopt(new IOpenGLRectangleTexture(Width, Height, NumMipLevel, pixel_format, false, NUX_FILE_LINE_PARAM));
121 return result;139 return result;
122 }140 }
123141
124 ObjectPtr<IOpenGLCubeTexture> GpuDevice::CreateCubeTexture(142 ObjectPtr<IOpenGLCubeTexture> GpuDevice::CreateCubeTexture(
125 int EdgeLength143 int EdgeLength
126 , int Levels144 , int Levels
127 , BitmapFormat PixelFormat145 , BitmapFormat pixel_format
128 , const char * /* __Nux_FileName__ */146 , const char * /* __Nux_FileName__ */
129 , int /* __Nux_LineNumber__ */)147 , int /* __Nux_LineNumber__ */)
130 {148 {
149 if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
150 {
151 // No support for depth buffers
152 return ObjectPtr<IOpenGLCubeTexture>();
153 }
154
131 unsigned int NumTotalMipLevel = 1 + floorf(Log2(EdgeLength));155 unsigned int NumTotalMipLevel = 1 + floorf(Log2(EdgeLength));
132 unsigned int NumMipLevel = 0;156 unsigned int NumMipLevel = 0;
133157
@@ -145,7 +169,7 @@
145 }169 }
146170
147 ObjectPtr<IOpenGLCubeTexture> result;171 ObjectPtr<IOpenGLCubeTexture> result;
148 result.Adopt(new IOpenGLCubeTexture(EdgeLength, NumMipLevel, PixelFormat));172 result.Adopt(new IOpenGLCubeTexture(EdgeLength, NumMipLevel, pixel_format));
149 return result;173 return result;
150 }174 }
151175
@@ -154,10 +178,16 @@
154 , int Height178 , int Height
155 , int Depth179 , int Depth
156 , int Levels180 , int Levels
157 , BitmapFormat PixelFormat181 , BitmapFormat pixel_format
158 , const char * /* __Nux_FileName__ */182 , const char * /* __Nux_FileName__ */
159 , int /* __Nux_LineNumber__ */)183 , int /* __Nux_LineNumber__ */)
160 {184 {
185 if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
186 {
187 // No support for depth buffers
188 return ObjectPtr<IOpenGLVolumeTexture>();
189 }
190
161 GpuInfo gpu_info = GetGpuInfo();191 GpuInfo gpu_info = GetGpuInfo();
162 int msz = gpu_info.GetMaxTextureSize();192 int msz = gpu_info.GetMaxTextureSize();
163 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)193 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
@@ -182,7 +212,7 @@
182 }212 }
183213
184 ObjectPtr<IOpenGLVolumeTexture> result;214 ObjectPtr<IOpenGLVolumeTexture> result;
185 result.Adopt(new IOpenGLVolumeTexture(Width, Height, Depth, NumMipLevel, PixelFormat));215 result.Adopt(new IOpenGLVolumeTexture(Width, Height, Depth, NumMipLevel, pixel_format));
186 return result;216 return result;
187 }217 }
188218
@@ -190,8 +220,14 @@
190 int Width220 int Width
191 , int Height221 , int Height
192 , int Depth222 , int Depth
193 , BitmapFormat PixelFormat)223 , BitmapFormat pixel_format)
194 {224 {
225 if ((pixel_format == BITFMT_D24S8) && (!GetGpuInfo().Support_Depth_Buffer()))
226 {
227 // No support for depth buffers
228 return ObjectPtr<IOpenGLAnimatedTexture>();
229 }
230
195 GpuInfo gpu_info = GetGpuInfo();231 GpuInfo gpu_info = GetGpuInfo();
196 int msz = gpu_info.GetMaxTextureSize();232 int msz = gpu_info.GetMaxTextureSize();
197 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)233 if(Width <= 0 || Height <= 0 || Width > msz || Height > msz)
@@ -200,7 +236,7 @@
200 }236 }
201237
202 ObjectPtr<IOpenGLAnimatedTexture> result;238 ObjectPtr<IOpenGLAnimatedTexture> result;
203 result.Adopt(new IOpenGLAnimatedTexture(Width, Height, Depth, PixelFormat));239 result.Adopt(new IOpenGLAnimatedTexture(Width, Height, Depth, pixel_format));
204 return result;240 return result;
205 }241 }
206242
207243
=== modified file 'NuxGraphics/GraphicsEngine.cpp'
--- NuxGraphics/GraphicsEngine.cpp 2012-11-20 22:13:38 +0000
+++ NuxGraphics/GraphicsEngine.cpp 2012-11-28 15:20:28 +0000
@@ -195,21 +195,23 @@
195 SetScissor(0, 0, _graphics_display.GetWindowWidth(), _graphics_display.GetWindowHeight());195 SetScissor(0, 0, _graphics_display.GetWindowWidth(), _graphics_display.GetWindowHeight());
196 EnableScissoring(true);196 EnableScissoring(true);
197197
198 GpuDevice* gpu_device = _graphics_display.GetGpuDevice();
199 const GpuInfo& gpu_info = gpu_device->GetGpuInfo();
200
198 if (create_rendering_data)201 if (create_rendering_data)
199 {202 {
200#ifndef NUX_OPENGLES_20203#ifndef NUX_OPENGLES_20
201 bool opengl_14_support = true;204 bool opengl_14_support = true;
202205 if ((gpu_device->GetOpenGLMajorVersion() == 1) &&
203 if ((_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion() == 1) &&206 (gpu_device->GetOpenGLMinorVersion() < 4))
204 (_graphics_display.GetGpuDevice()->GetOpenGLMinorVersion() < 4))
205 {207 {
206 // OpenGL version is less than OpenGL 1.4208 // OpenGL version is less than OpenGL 1.4
207 opengl_14_support = false;209 opengl_14_support = false;
208 }210 }
209 211
210 if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&212 if (gpu_info.Support_ARB_Fragment_Shader() &&
211 _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Program() &&213 gpu_info.Support_ARB_Vertex_Program() &&
212 opengl_14_support)214 opengl_14_support)
213 {215 {
214 InitAsmColorShader();216 InitAsmColorShader();
215 InitAsmTextureShader();217 InitAsmTextureShader();
@@ -229,8 +231,6 @@
229 }231 }
230#endif232#endif
231233
232 const GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo();
233
234 if ((gpu_info.Support_ARB_Vertex_Program() && gpu_info.Support_ARB_Fragment_Program())234 if ((gpu_info.Support_ARB_Vertex_Program() && gpu_info.Support_ARB_Fragment_Program())
235 || (gpu_info.Support_ARB_Vertex_Shader() && gpu_info.Support_ARB_Fragment_Shader()))235 || (gpu_info.Support_ARB_Vertex_Shader() && gpu_info.Support_ARB_Fragment_Shader()))
236 {236 {
@@ -238,7 +238,7 @@
238 }238 }
239239
240 if (gpu_info.Support_EXT_Framebuffer_Object())240 if (gpu_info.Support_EXT_Framebuffer_Object())
241 _offscreen_fbo = _graphics_display.GetGpuDevice()->CreateFrameBufferObject();241 _offscreen_fbo = gpu_device->CreateFrameBufferObject();
242242
243 _offscreen_color_rt0 = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);243 _offscreen_color_rt0 = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
244 _offscreen_color_rt1 = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);244 _offscreen_color_rt1 = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
@@ -1312,7 +1312,10 @@
1312 colorbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);1312 colorbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_R8G8B8A8, NUX_TRACKER_LOCATION);
1313 }1313 }
13141314
1315 if ((depthbuffer.IsValid()) && ((depthbuffer->GetWidth() != width) || (depthbuffer->GetHeight() != height)))1315 bool use_depth_buffer = _graphics_display.GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer();
1316 if (use_depth_buffer &&
1317 depthbuffer.IsValid() &&
1318 ((depthbuffer->GetWidth() != width) || (depthbuffer->GetHeight() != height)))
1316 {1319 {
1317 // Generate a new depth texture only if a valid one was passed to this function.1320 // Generate a new depth texture only if a valid one was passed to this function.
1318 depthbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION); 1321 depthbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_D24S8, NUX_TRACKER_LOCATION);
@@ -1321,7 +1324,7 @@
1321 fbo->FormatFrameBufferObject(width, height, BITFMT_R8G8B8A8);1324 fbo->FormatFrameBufferObject(width, height, BITFMT_R8G8B8A8);
1322 fbo->SetRenderTarget(0, colorbuffer->GetSurfaceLevel(0));1325 fbo->SetRenderTarget(0, colorbuffer->GetSurfaceLevel(0));
1323 1326
1324 if (depthbuffer.IsValid())1327 if (use_depth_buffer && depthbuffer.IsValid())
1325 fbo->SetDepthSurface(depthbuffer->GetSurfaceLevel(0));1328 fbo->SetDepthSurface(depthbuffer->GetSurfaceLevel(0));
1326 else1329 else
1327 fbo->SetDepthSurface(ObjectPtr<IOpenGLSurface>(NULL));1330 fbo->SetDepthSurface(ObjectPtr<IOpenGLSurface>(NULL));
13281331
=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.cpp'
--- NuxGraphics/IOpenGLFrameBufferObject.cpp 2012-11-17 21:44:54 +0000
+++ NuxGraphics/IOpenGLFrameBufferObject.cpp 2012-11-28 15:20:28 +0000
@@ -32,7 +32,8 @@
32 NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLFrameBufferObject);32 NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLFrameBufferObject);
3333
34 IOpenGLFrameBufferObject::IOpenGLFrameBufferObject(NUX_FILE_LINE_DECL)34 IOpenGLFrameBufferObject::IOpenGLFrameBufferObject(NUX_FILE_LINE_DECL)
35 : IOpenGLResource(RTFRAMEBUFFEROBJECT, NUX_FILE_LINE_PARAM)35 : IOpenGLResource(RTFRAMEBUFFEROBJECT, NUX_FILE_LINE_PARAM)
36 , platform_support_for_depth_texture_(false)
36 {37 {
37 attachment_width_ = 1;38 attachment_width_ = 1;
38 attachment_height_ = 1;39 attachment_height_ = 1;
@@ -45,6 +46,11 @@
45 surface_attachment_array_.push_back(ObjectPtr<IOpenGLSurface> (0));46 surface_attachment_array_.push_back(ObjectPtr<IOpenGLSurface> (0));
46 }47 }
4748
49 if (GetGraphicsDisplay()->GetGpuDevice() && GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().Support_Depth_Buffer())
50 {
51 platform_support_for_depth_texture_ = true;
52 }
53
48 FormatFrameBufferObject(attachment_width_, attachment_height_, _PixelFormat);54 FormatFrameBufferObject(attachment_width_, attachment_height_, _PixelFormat);
49 GRunTimeStats.Register(this);55 GRunTimeStats.Register(this);
50 }56 }
@@ -174,7 +180,10 @@
174180
175 int IOpenGLFrameBufferObject::SetDepthSurface(ObjectPtr<IOpenGLSurface> pDepthSurface)181 int IOpenGLFrameBufferObject::SetDepthSurface(ObjectPtr<IOpenGLSurface> pDepthSurface)
176 {182 {
177 //nuxAssert(pDepthSurface.IsValid());183 if (!platform_support_for_depth_texture_)
184 {
185 return 0;
186 }
178187
179 if (pDepthSurface.IsNull())188 if (pDepthSurface.IsNull())
180 {189 {
@@ -208,6 +217,11 @@
208217
209 int IOpenGLFrameBufferObject::SetDepthTextureAttachment(ObjectPtr<IOpenGLBaseTexture> depth_texture, int mip_level)218 int IOpenGLFrameBufferObject::SetDepthTextureAttachment(ObjectPtr<IOpenGLBaseTexture> depth_texture, int mip_level)
210 {219 {
220 if (!platform_support_for_depth_texture_)
221 {
222 return 0;
223 }
224
211 if (depth_texture.IsNull())225 if (depth_texture.IsNull())
212 {226 {
213 depth_surface_attachment_ = ObjectPtr<IOpenGLSurface> (0);227 depth_surface_attachment_ = ObjectPtr<IOpenGLSurface> (0);
@@ -289,27 +303,26 @@
289 }303 }
290 }304 }
291305
292 if (depth_surface_attachment_.IsValid())306 if (platform_support_for_depth_texture_)
293 {307 {
294 GLenum target = depth_surface_attachment_->GetSurfaceTarget();308 if (depth_surface_attachment_.IsValid())
295 GLenum glID = depth_surface_attachment_->GetOpenGLID();309 {
296 GLint level = depth_surface_attachment_->GetMipLevel();310 GLenum target = depth_surface_attachment_->GetSurfaceTarget();
297 CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, target, glID, level));311 GLenum glID = depth_surface_attachment_->GetOpenGLID();
312 GLint level = depth_surface_attachment_->GetMipLevel();
313 CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, target, glID, level));
314 }
315 else
316 {
317 CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
318 // On the PC you need to bing the same D24S8 surface to the depth and the stencil attachment.
319 }
298 }320 }
299 else321 else
300 {322 {
301 CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));323 CHECKGL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
302 // On the PC you need to bing the same D24S8 surface to the depth and the stencil attachment.
303 }324 }
304325
305// #ifndef NUX_OPENGLES_20
306// _Rbo.Set(GL_DEPTH_COMPONENT, attachment_width_, attachment_height_);
307// CHECKGL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
308// GL_DEPTH_ATTACHMENT_EXT,
309// GL_RENDERBUFFER_EXT,
310// _Rbo.GetId()));
311// #endif
312
313 nuxAssert( _Fbo.IsValid() == true );326 nuxAssert( _Fbo.IsValid() == true );
314327
315 if (GetGraphicsDisplay()->GetGraphicsEngine())328 if (GetGraphicsDisplay()->GetGraphicsEngine())
316329
=== modified file 'NuxGraphics/IOpenGLFrameBufferObject.h'
--- NuxGraphics/IOpenGLFrameBufferObject.h 2012-11-05 21:31:06 +0000
+++ NuxGraphics/IOpenGLFrameBufferObject.h 2012-11-28 15:20:28 +0000
@@ -105,6 +105,7 @@
105105
106 GLFramebufferObject _Fbo; // The framebuffer object used for rendering to the texture106 GLFramebufferObject _Fbo; // The framebuffer object used for rendering to the texture
107 GLRenderbuffer _Rbo;107 GLRenderbuffer _Rbo;
108 bool platform_support_for_depth_texture_;
108109
109 friend class GpuDevice;110 friend class GpuDevice;
110 };111 };

Subscribers

People subscribed via source and target branches