Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
cbc5fe16
Commit
cbc5fe16
authored
Mar 28, 2013
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] proper lighting (zoom-invariant) for the template module
parent
476081cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
src/core/graphicsEngine/shaders/shaders/WGELighting-vertex.glsl
...re/graphicsEngine/shaders/shaders/WGELighting-vertex.glsl
+7
-1
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+14
-0
src/modules/template/WMTemplate.h
src/modules/template/WMTemplate.h
+6
-0
No files found.
src/core/graphicsEngine/shaders/shaders/WGELighting-vertex.glsl
View file @
cbc5fe16
...
...
@@ -34,7 +34,13 @@ void main()
// prepare light
v_normal
=
gl_NormalMatrix
*
gl_Normal
;
gl_FrontColor
=
gl_Color
;
#ifdef USE_MATERIAL_DIFFUSE
vec4
color
=
gl_FrontMaterial
.
diffuse
;
#else
vec4
color
=
gl_Color
;
#endif
gl_FrontColor
=
color
;
gl_BackColor
=
color
;
gl_Position
=
ftransform
();
}
src/modules/template/WMTemplate.cpp
View file @
cbc5fe16
...
...
@@ -436,6 +436,16 @@ void WMTemplate::moduleMain()
waitRestored
();
// This always returns if you manually add your module and no project file loader or something similar has to restore any values.
// Before we begin, we finally create a shader object which shades the graphics we create in this module. You can use your own shaders or a
// global one, like WGELighting. When creating a shader, you need to specify its name and an optional search path. When developing modules,
// this search path should be you module's local resource path.
m_shader
=
new
WGEShader
(
"WGELighting"
,
m_localPath
);
// Later in the code, we show how we use a property to modify the graphics color. There, we use the OpenGL material mechanism. So we need to
// switch the shader to this mode by setting a compile-time switch:
m_shader
->
setDefine
(
"USE_MATERIAL_DIFFUSE"
);
// There are multiple ways to set uniforms and defines automatically by binding them to properties. But this is not the topic of this module.
// Normally, you will have a loop which runs as long as the module should not shutdown. In this loop you can react on changing data on input
// connectors or on changed in your properties.
debugLog
()
<<
"Entering main loop"
;
...
...
@@ -587,6 +597,10 @@ void WMTemplate::moduleMain()
// right? Setting the color can be done in such an update callback. See in the header file, how this class is defined.
m_geode
->
addUpdateCallback
(
new
SafeUpdateCallback
(
this
)
);
// The default lighting is not very pretty. We can bind a default shader provided by OpenWalnut to this geode to have nice per-pixel
// Phong shading. We earlier created this shader object. Now, we need to apply it:
m_shader
->
apply
(
m_geode
);
// And insert the new node
m_rootNode
->
insert
(
m_geode
);
}
...
...
src/modules/template/WMTemplate.h
View file @
cbc5fe16
...
...
@@ -33,6 +33,7 @@
#include "core/common/WItemSelector.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/graphicsEngine/shaders/WGEShader.h"
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleInputData.h"
...
...
@@ -302,6 +303,11 @@ private:
*/
void
hideButtonPressed
();
/**
* We want some nice shading effects, so we need a nice shader.
*/
WGEShader
::
RefPtr
m_shader
;
/**
* Node callback to change the color of the shapes inside the root node. For more details on this class, refer to the documentation in
* moduleMain().
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment