Nux

Merge lp:~unity-team/nux/nux.fix-glsl-major-detection into lp:nux/2.0

Proposed by Jay Taoko
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 615
Merged at revision: 611
Proposed branch: lp:~unity-team/nux/nux.fix-glsl-major-detection
Merge into: lp:nux/2.0
Diff against target: 91 lines (+28/-30)
2 files modified
NuxGraphics/GpuDevice.cpp (+18/-30)
NuxGraphics/GraphicsEngine.cpp (+10/-0)
To merge this branch: bzr merge lp:~unity-team/nux/nux.fix-glsl-major-detection
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
Review via email: mp+101263@code.launchpad.net

Commit message

* Fixed detection of OpenGL major and minor version numbers.

Description of the change

* Fixed detection of OpenGL major and minor version numbers.
UNBLOCK

To post a comment you must log in.
611. By Jay Taoko

* Code cleanup.

612. By Jay Taoko

* Fix

613. By Jay Taoko

* Another fix

614. By Jay Taoko

* Fix

615. By Jay Taoko

* Cleanup.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

the string manipulation looks ok to me, approving then and I confirm it's now detected as OpenGL > 2 here and so I can get the gsls shader path and not the ARB ones. Thanks Jay!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NuxGraphics/GpuDevice.cpp'
2--- NuxGraphics/GpuDevice.cpp 2011-11-16 05:11:46 +0000
3+++ NuxGraphics/GpuDevice.cpp 2012-04-10 21:17:18 +0000
4@@ -327,8 +327,22 @@
5 #endif
6
7 #ifndef NUX_OPENGLES_20
8- CHECKGL(glGetIntegerv(GL_MAJOR_VERSION, &_opengl_major));
9- CHECKGL(glGetIntegerv(GL_MINOR_VERSION, &_opengl_minor));
10+ _glsl_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_VERSION)));
11+ CHECKGL_MSG(glGetString(GL_VERSION));
12+
13+ NString opengl_major;
14+ NString opengl_minor;
15+ char split = '.';
16+ _glsl_version_string.SplitAtFirstOccurenceOf(split, opengl_major, opengl_minor);
17+
18+ _opengl_major = (char)opengl_major.GetTCharPtr()[0] - '0';
19+ _opengl_minor = (char)opengl_minor.GetTCharPtr()[0] - '0';
20+
21+ if (_opengl_major >= 3)
22+ {
23+ CHECKGL(glGetIntegerv(GL_MAJOR_VERSION, &_opengl_major));
24+ CHECKGL(glGetIntegerv(GL_MINOR_VERSION, &_opengl_minor));
25+ }
26 #else
27 _opengl_major = 2;
28 _opengl_minor = 0;
29@@ -512,40 +526,14 @@
30 CHECKGL_MSG(glGetString(GL_RENDERER));
31 _openGL_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_VERSION)));
32 CHECKGL_MSG(glGetString(GL_VERSION));
33-#ifndef NUX_OPENGLES_20
34- if (GLEW_VERSION_2_0)
35-#else
36- if (1)
37-#endif
38- {
39- _glsl_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_SHADING_LANGUAGE_VERSION)));
40- CHECKGL_MSG(glGetString(GL_SHADING_LANGUAGE_VERSION));
41-
42- NString glsl_major;
43- NString glsl_minor;
44- char split = '.';
45- _glsl_version_string.SplitAtFirstOccurenceOf(split, glsl_major, glsl_minor);
46-
47- }
48
49 nuxDebugMsg("Gpu Vendor: %s", _board_vendor_string.GetTCharPtr());
50 nuxDebugMsg("Gpu Renderer: %s", _board_renderer_string.GetTCharPtr());
51 nuxDebugMsg("Gpu OpenGL Version: %s", _openGL_version_string.GetTCharPtr());
52+ nuxDebugMsg("Gpu OpenGL Major Version: %d", _opengl_major);
53+ nuxDebugMsg("Gpu OpenGL Minor Version: %d", _opengl_minor);
54 nuxDebugMsg("Gpu GLSL Version: %s", _glsl_version_string.GetTCharPtr());
55
56-#ifndef NUX_OPENGLES_20
57- // Get the version supported by the context that was set.
58- int new_opengl_major;
59- int new_opengl_minor;
60- CHECKGL(glGetIntegerv(GL_MAJOR_VERSION, &new_opengl_major));
61- CHECKGL(glGetIntegerv(GL_MINOR_VERSION, &new_opengl_minor));
62-
63- if ((new_opengl_major != _opengl_major) || (new_opengl_minor != _opengl_minor))
64- {
65- nuxDebugMsg("The Gpu supports OpenGL %d.%d but version %d.%d has been requested.", _opengl_major, _opengl_minor, new_opengl_major, new_opengl_minor);
66- }
67-#endif
68-
69 NString TempStr = (const char *) TCharToUpperCase(_board_vendor_string.GetTCharPtr());
70
71 if (TempStr.FindFirstOccurence("NVIDIA") != tstring::npos)
72
73=== modified file 'NuxGraphics/GraphicsEngine.cpp'
74--- NuxGraphics/GraphicsEngine.cpp 2012-02-09 05:39:28 +0000
75+++ NuxGraphics/GraphicsEngine.cpp 2012-04-10 21:17:18 +0000
76@@ -166,6 +166,16 @@
77 // Evaluate the features provided by the GPU.
78 EvaluateGpuCaps();
79
80+ if (UsingGLSLCodePath())
81+ {
82+ nuxDebugMsg("The GraphicsEngine is using the GLSL shader code path.");
83+ }
84+ else
85+ {
86+ nuxDebugMsg("The GraphicsEngine is using the assenbly shader code path.");
87+ }
88+
89+
90 GlWindow.m_GraphicsContext = this;
91 ResetStats();
92

Subscribers

People subscribed via source and target branches

to all changes: