Browse Source

MeshViewer cleanup + MessageService tweak for emscripten

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 11 years ago
parent
commit
34a59d25d4
4 changed files with 4 additions and 71 deletions
  1. +2
    -2
      src/messageservice.cpp
  2. +1
    -1
      test/Makefile.am
  3. +1
    -36
      test/meshviewer.cpp
  4. +0
    -32
      test/mviewer_em_test.lolfx

+ 2
- 2
src/messageservice.cpp View File

@@ -26,9 +26,9 @@ namespace lol
#if EMSCRIPTEN
extern "C"
{
bool C_Send(int id, const char* message)
int C_Send(int id, const char* message)
{
return MessageService::Send(id, message);
return (int)MessageService::Send(id, message);
}
//NOT IMPLEMENTED
//bool C_FetchFirst(int id, String& message);


+ 1
- 1
test/Makefile.am View File

@@ -58,7 +58,7 @@ nacl_phystest_DEPENDENCIES = @LOL_DEPS@
nacl_phystest_LDFLAGS = $(AM_LDFLAGS)

meshviewer_SOURCES = meshviewer.cpp \
shinymvtexture.lolfx shinyfur.lolfx mviewer_em_test.lolfx
shinymvtexture.lolfx shinyfur.lolfx
meshviewer_CPPFLAGS = $(AM_CPPFLAGS)
meshviewer_DEPENDENCIES = @LOL_DEPS@
meshviewer_LDFLAGS = $(AM_LDFLAGS)


+ 1
- 36
test/meshviewer.cpp View File

@@ -45,7 +45,6 @@ static int const TEXTURE_WIDTH = 256;
#define HST_CLAMP 1.f

#define WITH_TEXTURE 0
#define EM_TEST (1 && EMSCRIPTEN)

#define NO_NACL_EM (!__native_client__ && !EMSCRIPTEN)
#define NACL_EM (__native_client__ || EMSCRIPTEN)
@@ -85,38 +84,6 @@ enum MessageType
MSG_MAX
};

LOLFX_RESOURCE_DECLARE(mviewer_em_test);

class MVTestShaderData : public GpuShaderData
{
public:
//-----------------------------------------------------------------------------
MVTestShaderData()
{
m_render_mode = DebugRenderMode::Default;
m_vert_decl_flags = (1 << VertexUsage::Position) | (1 << VertexUsage::Color);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(mviewer_em_test));
SetupDefaultData(false);
}

//-----------------------------------------------------------------------------
void SetupDefaultData(bool with_UV)
{
AddUniform("in_ModelView");
AddUniform("in_Proj");
}

//-----------------------------------------------------------------------------
void SetupShaderDatas(mat4 const &model)
{
mat4 proj = g_scene->GetCamera()->GetProjection();
mat4 view = g_scene->GetCamera()->GetView();

m_shader->SetUniform(*GetUniform("in_ModelView"), view * model);
m_shader->SetUniform(*GetUniform("in_Proj"), proj);
}
};

class MeshViewer : public WorldEntity
{
public:
@@ -491,9 +458,7 @@ public:
{
if (m_meshes[i]->GetMeshState() == MeshRender::NeedConvert)
{
#if EM_TEST
m_meshes[i]->MeshConvert(new MVTestShaderData());
#elif WITH_TEXTURE
#if WITH_TEXTURE
m_meshes[i]->MeshConvert(new DefaultShaderData(((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
(1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)),
m_texture_shader, true));


+ 0
- 32
test/mviewer_em_test.lolfx View File

@@ -1,32 +0,0 @@

[vert.glsl]
#version 120

attribute vec3 in_Position;
attribute vec4 in_Color;

uniform mat4 in_ModelView;
uniform mat4 in_Proj;

varying vec4 pass_Color;

void main(void)
{
pass_Color = in_Color;

gl_Position = in_Proj * in_ModelView * vec4(in_Position, 1.0);
}

[frag.glsl]
#version 120

#if defined GL_ES
precision highp float;
#endif

varying vec4 pass_Color;

void main(void)
{
gl_FragColor = pass_Color;
}

Loading…
Cancel
Save