Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:58:50+00:00 2026-06-09T17:58:50+00:00

I am working on a 2D game engine at the moment and have hit

  • 0

I am working on a 2D game engine at the moment and have hit a stumbling block whilst implementing the LUA scripting / Interpreter.

I’m using SWIG and have got the basics all working fine.

In the engine I use the GLM (OpenGL Mathematics Libary http://glm.g-truc.net/) for all Vector and Matrix related areas.

I really need to expose glm (at a basic level) to the via SWIG to LUA so I can call methods in LUA like:

actor:GetPosition()  <- Which returns a glm::vec2

GLM is quite a complex library (possibly an understatement lol) and I do not require the whole thing exposed, that would be ridiculous amounts of work I assume. I simply want to be able to access the xy components of the glm::vec2 class.

I’m sure this must be easy as SWIG doesn’t require a full class definition and there must be a way to let SWIG just assume that the glm::vec2 class just has x,y params.

I’m not sure If using Proxy classes in SWIG is the way to do this ? or some other method ? I’m quite new to LUA integration and SWIG also.

One route I really don’t want to go down is ditching GLM and writing my own Vector/Matrix library which is much more simple, no templates etc and I can then simply wrap with SWIG, but I feel this would be a waste of time and I would ultimately end up with a less powerful Math Library :(.

Thanks in advance and I can provide more info if necessary.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:58:52+00:00Added an answer on June 9, 2026 at 5:58 pm

    A solution in luabind would look like this:

    #include <luabind/luabind.hpp>
    
    
    extern "C" int init(lua_State* L)
    {
        using namespace luabind;
        using namespace glm;
    
        open(L);
    
        module(L)
        [
            class_<dvec2>("dvec2")
                .def_readwrite("x", &dvec2::x)
                .def_readwrite("y", &dvec2::y)
        ];
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a game engine in C++ using Lua to define NPCs.
I'm working on a game engine in C++ using Lua for NPC behaviour. I
I'm working on a game engine in C++ and I have methods like setColour
I'm working on a toy game engine. I have never been thinking about coordinate
i am working on voxel based game engine, in which i need to have
Hi! I have a working prototype of a game engine and right now I'm
I am working on a debugger project for a game's scripting engine. I'm hoping
I am working on game engine prototype and have the following question: Right now
I'm currently working on a game/engine that uses OpenGL for rendering, and recently have
I'm working on a state based game engine and have something I'm happy with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.