Browse Source

build: hide LolFx external declarations behind macros.

legacy
Sam Hocevar sam 12 years ago
parent
commit
3adf42b00c
11 changed files with 24 additions and 19 deletions
  1. +1
    -1
      build/autotools/common.am
  2. +5
    -0
      src/core.h
  3. +2
    -2
      src/easymesh/easymesh.cpp
  4. +2
    -2
      src/gradient.cpp
  5. +2
    -2
      src/scene.cpp
  6. +2
    -2
      tutorial/01_triangle.cpp
  7. +2
    -2
      tutorial/02_cube.cpp
  8. +2
    -2
      tutorial/03_noise.cpp
  9. +2
    -2
      tutorial/04_texture.cpp
  10. +2
    -2
      tutorial/08_fbo.cpp
  11. +2
    -2
      tutorial/11_fractal.cpp

+ 1
- 1
build/autotools/common.am View File

@@ -61,7 +61,7 @@ SUFFIXES += .lolfx
.lolfx.o: .lolfx.o:
$(lolfx_gen) $(lolfx_gen)
$(AM_V_at)(echo "char const *"; \ $(AM_V_at)(echo "char const *"; \
echo "lolfx_$(notdir $(basename $(filter %.lolfx, $^))) ="; \
echo "lolfx_resource_$(notdir $(basename $(filter %.lolfx, $^))) ="; \
$(SED) 's/"/\\"/g' $(filter %.lolfx, $^) | $(SED) 's/\([^\r]*\).*/"\1\\n"/'; \ $(SED) 's/"/\\"/g' $(filter %.lolfx, $^) | $(SED) 's/\([^\r]*\).*/"\1\\n"/'; \
echo ";") \ echo ";") \
| $(CXXCOMPILE) -xc++ -c - -o $@ | $(CXXCOMPILE) -xc++ -c - -o $@


+ 5
- 0
src/core.h View File

@@ -61,6 +61,11 @@ static inline int isnan(float f)
} }
#endif #endif


/* External declaration for LolFx files. */
#define LOLFX_RESOURCE_DECLARE(name) \
extern "C" char const *LOLFX_RESOURCE_NAME(name)
#define LOLFX_RESOURCE_NAME(name) lolfx_resource_##name

/* If using NaCl or Android, override main() with our version */ /* If using NaCl or Android, override main() with our version */
#if defined __native_client__ #if defined __native_client__
# define main lol_nacl_main # define main lol_nacl_main


+ 2
- 2
src/easymesh/easymesh.cpp View File

@@ -35,7 +35,7 @@
#include "core.h" #include "core.h"
#include "easymesh/easymesh-compiler.h" #include "easymesh/easymesh-compiler.h"


extern char const *lolfx_shiny;
LOLFX_RESOURCE_DECLARE(shiny);


namespace lol namespace lol
{ {
@@ -66,7 +66,7 @@ void EasyMesh::MeshConvert(Shader* provided_shader)
{ {
if(provided_shader == NULL) if(provided_shader == NULL)
{ {
m_gpu.shader = Shader::Create(lolfx_shiny);
m_gpu.shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny));
} }
else else
{ {


+ 2
- 2
src/gradient.cpp View File

@@ -17,7 +17,7 @@


using namespace std; using namespace std;


extern char const *lolfx_gradient;
LOLFX_RESOURCE_DECLARE(gradient);


namespace lol namespace lol
{ {
@@ -76,7 +76,7 @@ void Gradient::TickDraw(float seconds)


if (!data->shader) if (!data->shader)
{ {
data->shader = Shader::Create(lolfx_gradient);
data->shader = Shader::Create(LOLFX_RESOURCE_NAME(gradient));


data->m_vbo = new VertexBuffer(sizeof(vertex)); data->m_vbo = new VertexBuffer(sizeof(vertex));
data->m_cbo = new VertexBuffer(sizeof(color)); data->m_cbo = new VertexBuffer(sizeof(color));


+ 2
- 2
src/scene.cpp View File

@@ -22,7 +22,7 @@
#include "core.h" #include "core.h"
#include "lolgl.h" #include "lolgl.h"


extern char const *lolfx_tile;
LOLFX_RESOURCE_DECLARE(tile);


namespace lol namespace lol
{ {
@@ -156,7 +156,7 @@ void Scene::Render() // XXX: rename to Blit()
return; return;


if (!data->m_shader) if (!data->m_shader)
data->m_shader = Shader::Create(lolfx_tile);
data->m_shader = Shader::Create(LOLFX_RESOURCE_NAME(tile));


#if 0 #if 0
// Randomise, then sort. // Randomise, then sort.


+ 2
- 2
tutorial/01_triangle.cpp View File

@@ -18,7 +18,7 @@
using namespace std; using namespace std;
using namespace lol; using namespace lol;


extern char const *lolfx_01_triangle;
LOLFX_RESOURCE_DECLARE(01_triangle);


class Triangle : public WorldEntity class Triangle : public WorldEntity
{ {
@@ -37,7 +37,7 @@ public:


if (!m_ready) if (!m_ready)
{ {
m_shader = Shader::Create(lolfx_01_triangle);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(01_triangle));
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0);


m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position));


+ 2
- 2
tutorial/02_cube.cpp View File

@@ -18,7 +18,7 @@
using namespace std; using namespace std;
using namespace lol; using namespace lol;


extern char const *lolfx_02_cube;
LOLFX_RESOURCE_DECLARE(02_cube);


class Cube : public WorldEntity class Cube : public WorldEntity
{ {
@@ -74,7 +74,7 @@ public:


if (!m_ready) if (!m_ready)
{ {
m_shader = Shader::Create(lolfx_02_cube);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(02_cube));


m_mvp = m_shader->GetUniformLocation("in_Matrix"); m_mvp = m_shader->GetUniformLocation("in_Matrix");
m_coord = m_shader->GetAttribLocation("in_Vertex", m_coord = m_shader->GetAttribLocation("in_Vertex",


+ 2
- 2
tutorial/03_noise.cpp View File

@@ -18,7 +18,7 @@
using namespace std; using namespace std;
using namespace lol; using namespace lol;


extern char const *lolfx_03_noise;
LOLFX_RESOURCE_DECLARE(03_noise);


class NoiseDemo : public WorldEntity class NoiseDemo : public WorldEntity
{ {
@@ -44,7 +44,7 @@ public:


if (!m_ready) if (!m_ready)
{ {
m_shader = Shader::Create(lolfx_03_noise);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(03_noise));
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0);
m_time_uni = m_shader->GetUniformLocation("u_Time"); m_time_uni = m_shader->GetUniformLocation("u_Time");




+ 2
- 2
tutorial/04_texture.cpp View File

@@ -20,7 +20,7 @@ using namespace lol;


static int const TEXTURE_WIDTH = 256; static int const TEXTURE_WIDTH = 256;


extern char const *lolfx_04_texture;
LOLFX_RESOURCE_DECLARE(04_texture);


class TextureDemo : public WorldEntity class TextureDemo : public WorldEntity
{ {
@@ -74,7 +74,7 @@ public:
{ {
m_texture = new Texture(ivec2(TEXTURE_WIDTH, 1), PixelFormat::A8R8G8B8); m_texture = new Texture(ivec2(TEXTURE_WIDTH, 1), PixelFormat::A8R8G8B8);


m_shader = Shader::Create(lolfx_04_texture);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(04_texture));
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0);


m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position));


+ 2
- 2
tutorial/08_fbo.cpp View File

@@ -18,7 +18,7 @@
using namespace std; using namespace std;
using namespace lol; using namespace lol;


extern char const *lolfx_08_fbo;
LOLFX_RESOURCE_DECLARE(08_fbo);


class FBO : public WorldEntity class FBO : public WorldEntity
{ {
@@ -56,7 +56,7 @@ public:


if (!m_ready) if (!m_ready)
{ {
m_shader = Shader::Create(lolfx_08_fbo);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(08_fbo));
m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0);
m_uni_flag = m_shader->GetUniformLocation("in_Flag"); m_uni_flag = m_shader->GetUniformLocation("in_Flag");
m_uni_point = m_shader->GetUniformLocation("in_Point"); m_uni_point = m_shader->GetUniformLocation("in_Point");


+ 2
- 2
tutorial/11_fractal.cpp View File

@@ -20,7 +20,7 @@


using namespace lol; using namespace lol;


extern char const *lolfx_11_fractal;
LOLFX_RESOURCE_DECLARE(11_fractal);


class Fractal : public WorldEntity class Fractal : public WorldEntity
{ {
@@ -448,7 +448,7 @@ public:
* uploading subimages will not work. */ * uploading subimages will not work. */
m_texture->SetData(&m_pixels[0]); m_texture->SetData(&m_pixels[0]);


m_shader = Shader::Create(lolfx_11_fractal);
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(11_fractal));


m_vertexattrib = m_shader->GetAttribLocation("a_Vertex", VertexUsage::Position, 0); m_vertexattrib = m_shader->GetAttribLocation("a_Vertex", VertexUsage::Position, 0);
m_texattrib = m_shader->GetAttribLocation("a_TexCoord", VertexUsage::TexCoord, 0); m_texattrib = m_shader->GetAttribLocation("a_TexCoord", VertexUsage::TexCoord, 0);


Loading…
Cancel
Save