Browse Source

Added tweak to 05_EZMesh to show how custom shader setting works.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 11 years ago
parent
commit
a8f0081deb
1 changed files with 24 additions and 1 deletions
  1. +24
    -1
      demos/tutorial/05_easymesh.cpp

+ 24
- 1
demos/tutorial/05_easymesh.cpp View File

@@ -18,6 +18,11 @@
using namespace std; using namespace std;
using namespace lol; using namespace lol;


#define USE_CUSTOM_SHADER 1
#if USE_CUSTOM_SHADER
LOLFX_RESOURCE_DECLARE(shiny);
#endif //USE_CUSTOM_SHADER

class EasyMeshTutorial : public WorldEntity class EasyMeshTutorial : public WorldEntity
{ {
public: public:
@@ -113,10 +118,27 @@ public:


if (!m_ready) if (!m_ready)
{ {
g_renderer->SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
#if USE_CUSTOM_SHADER
//Custom Shader: Init the shader
m_custom_shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny));
// any other shader stuf here (Get uniform, mostly, and set texture)
#endif //USE_CUSTOM_SHADER


g_renderer->SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
for (int i = 0; i < m_gears.Count(); i++) for (int i = 0; i < m_gears.Count(); i++)
{
#if USE_CUSTOM_SHADER
//Custom shader, Convert by setuping a shaderData with the vertex useage.
//DefaultShaderData is only a basic class, if needed, don't hesitate to create your own
m_gears[i].m1.MeshConvert(new DefaultShaderData(
((1 << VertexUsage::Position) |
(1 << VertexUsage::Normal) |
(1 << VertexUsage::Color)),
m_custom_shader, false));
#else //USE_CUSTOM_SHADER
m_gears[i].m1.MeshConvert(); m_gears[i].m1.MeshConvert();
#endif //USE_CUSTOM_SHADER
}
m_ready = true; m_ready = true;
} }


@@ -125,6 +147,7 @@ public:
} }


private: private:
Shader* m_custom_shader;
Array<EasyMesh, mat4, float> m_gears; Array<EasyMesh, mat4, float> m_gears;
float m_angle; float m_angle;
mat4 m_mat; mat4 m_mat;


Loading…
Cancel
Save