Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualandrew111

Posted 13 November 2012 - 05:09 PM

I'm not sure what LuaJIT is,


Well one thing you can do is use c code from within it.

I've just started looking at LuaJIT recently, and an idea I had apart from scripting world objects, was to use it to setup all the monotonous code, such geometry data (eg vertexarrayobjects, vertex buffers, attribute bindings, index buffers etc), shader programs, textures, texture samplers etc. Using luajit ffi to minimise the amount of cbindings necessary.

And then in your main program, load those 'resource files' into a table and just say:
load_resource("shader_program.lua");
lua_getfield(L,-1,"prog");
GLuint program = *((GLuint*)lua_touserdata(L,-1));
lua_pop(L,2);
..

glUseProgam(program);

A resource file might look like:
prog = CreateShaderProgram {
   {"vert",
	[[
	  attribute vec3 a_pos;
	  void main() {
	  ..
	  }
   ]]},

   {"frag",
	[[
	  void main() {
	  ..
	  }
	]]},
   {"attrib", "a_pos", 0}}

vao = CreateVertexArrayObject {
..
}

#4andrew111

Posted 13 November 2012 - 05:06 PM

I'm not sure what LuaJIT is,


Well one thing you can do is use c code from within it.

I've just started looking at LuaJIT recently, and an idea I had apart from scripting world objects, was to use it to setup all the monotonous code, such geometry data (eg vertexarrayobjects, vertex buffers, attribute bindings, index buffers etc), shader programs, textures, texture samplers etc. Using luajit ffi to minimise the amount of cbindings necessary.

And then in your main program, load those 'resource files' into a table and just say:
load_resource("shader_program.lua");
lua_getfield(L,-1,"prog");
GLuint program = *((GLuint*)lua_touserdata(L,-1));
lua_pop(L,2);
..

glUseProgam(program);

A resource file might look like:
prog = CreateShaderProgram {
   {"vert",
    [[
      attribute vec3 a_pos;
      void main() {
      ..
      }
   ]]},

   {"frag",
    [[
      void main() {
      ..
      }
    ]]},
   {"attrib", "a_pos", 0}}

#3andrew111

Posted 13 November 2012 - 05:06 PM

I'm not sure what LuaJIT is,


Well one thing you can do is use c code from within it.

I've just started looking at LuaJIT recently, and an idea I had apart from scripting world objects, was to use it to setup all the monotonous code, such geometry data (eg vertexarrayobjects, vertex buffers, attribute bindings, index buffers etc), shader programs, textures, texture samplers etc. Using luajit ffi to minimise the amount of cbindings necessary.

And then in your main program, load those 'resource files' into a table and just say:
load_resource("shader_program.lua");
lua_getfield(L,-1,"prog");
GLuint program = *((GLuint*)lua_touserdata(L,-1));
lua_pop(L,2);
..

glUseProgam(program);

A resource file might look like:
prog = CreateShaderProgram {
   {"vert",
    [[
      attribute vec3 a_pos;
      void main() {
      ..
      }
   ]]},

   {"frag",
    [[
      void main() {
      ..
      }
    ]]},
   {"attrib", "a_pos", 0}}

#2andrew111

Posted 13 November 2012 - 05:05 PM

I'm not sure what LuaJIT is,


Well one thing you can do is use c code from within it.

I've just started looking at LuaJIT recently, and an idea I had apart from scripting world objects, was to use it to setup all the monotonous code, such geometry data (eg vertexarrayobjects, vertex buffers, attribute bindings, index buffers etc), shader programs, textures, texture samplers etc. Using luajit ffi to minimise the amount of cbindings necessary.

And then in your main program, load those 'resource files' into a table and just say:
load_resource("shader_program.lua");
lua_getfield(L,-1,"prog");
GLuint program = *((GLuint*)lua_touserdata(L,-1));
lua_pop(L,2);
..

glUseProgam(program);

A resource file might look like:
]]},prog = CreateShaderProgram {
  {"vert", [[
   attribute vec3 a_pos;
   void main() {
   ..
   }
   ]]},

  {"frag", [[
   void main() {
   ..
  },
  {"attrib", "a_pos", 0},
   ]]},
}

#1andrew111

Posted 13 November 2012 - 05:01 PM

I'm not sure what LuaJIT is,


Well one thing you can do is use c code from within it.

I've just started looking at LuaJIT recently, and an idea I had apart from scripting world objects, was to use it to setup all the monotonous code, such geometry data (eg vertexarrayobjects, vertex buffers, attribute bindings, index buffers etc), shader programs, textures, texture samplers etc. Using luajit ffi to minimise the amount of cbindings necessary.

And then in your main program, load those 'resource files' into a table and just say:
load_resource("shader_program.lua");
lua_getfield(L,-1,"prog");
GLuint program = *((GLuint*)lua_touserdata(L,-1));

..

glUseProgam(program);

A resource file might look like:
prog = CreateShaderProgram {
  {"vert", [[
   attribute vec3 a_pos;
   void main() {
   ..
   }
   ]]},

  {"frag", [[
   void main() {
   ..
  },
  {"attrib", "a_pos", 0},
   ]]},
}

PARTNERS