@@ -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 $@ | ||||
@@ -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 | ||||
@@ -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 | ||||
{ | { | ||||
@@ -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)); | ||||
@@ -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. | ||||
@@ -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)); | ||||
@@ -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", | ||||
@@ -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"); | ||||
@@ -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)); | ||||
@@ -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"); | ||||
@@ -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); | ||||