Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 13 Mar 2012
Offline Last Active Jun 28 2015 11:26 AM

Topics I've Started

Angelscript on Raspberry Pi

09 November 2012 - 07:31 PM

Hi. I´ve been trying to build Angelscript on a Raspberry Pi computer (ARM processor). I made some modifications to the makefile and I´ve got mixed results.

First, after the

else ifeq($(TARGERPLATFORM), android)
	OBJ += $(OBJDIR)/as_callfunc_arm_gcc.o

I added:

	OBJ += $(OBJDIR)/as_callfunc_arm_gcc.o

Since the RPi is ARM based, and since I´m using gcc, this looked like the right thing to do.
I also had to add -DAS_NO_THREADS to avoid getting some "unreferences".

The Tutorial and Game examples build fine with this setup, but in the tutorial project I´ve found some problems. When running it, the program outputs this:

Received: 1000, 1000
System has been running for 1000 seconds.
The script function returned: 8.53973

So as you can see, the received values are wrong. (Interestingly enough, the value returned at the end is correct).

I have the same problem with an application I made. Everything seems to be working fine as long as I use ints or string within my scripts, but as soon as I use floats or doubles the values get corrupted. (I haven´t tested the game project enough, BTW).

If I build the library with -DAS_MAX_PORTABILITY then the tutorial project build ok and works as expected:

Received: 3.14159, 2.71828
System has been running for 3.89004e+06 seconds.
The script function returned: 8.53973

Any ideas on what could be the problem or what to look for in order to find a solution?


Segmentation fault - void asCScriptEngine::CallObjectMethod(...)

30 May 2012 - 12:20 PM

Hi, I'm getting a segmentation fault here:

void asCScriptEngine::CallObjectMethod(...)
.....f(obj, param);			  // <- line 3373 - causes segmentation fault

"f" comes out with some weird value.

This function is being called by the asCScriptEngine::WriteMessage(...). I'm registering my callback function like this:
void scriptInterface::setMessageCallback(asIScriptEngine* compiler)
compiler->SetMessageCallback( asMETHOD(scriptInterface,MessageCallback),this,asCALL_THISCALL );

virtual void scriptInterface::MessageCallback(const asSMessageInfo *msg)
// Implement a simple message callback function
const char *type = "ERR ";
if( msg->type == asMSGTYPE_WARNING )
type = "WARN";
else if( msg->type == asMSGTYPE_INFORMATION )
type = "INFO";

printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);

I have the feeling that the problem is here (file angelscript.h line 1024)

// Template specialization
template <>
struct asSMethodPtr<SINGLE_PTR_SIZE>
template<class M>
static asSFuncPtr Convert(M Mthd)
  asSFuncPtr p;
  asMemClear(&p, sizeof(p));
  asMemCopy(&p, &Mthd, SINGLE_PTR_SIZE); //<- after this, "f" (inside "p") gets wrong value
  // Mark this as a class method
  p.flag = 3;
  return p;

To make things even weirder, everything works as expected under Windows XP. I'm getting this error under Linux (Ubuntu) - using Code::Blocks as IDE.

Any ideas?


What to use if I wan to send a negative value to a script function?

29 May 2012 - 09:24 AM

What the title says.... The manual mentions:

int SetArgDWord(int arg, asDWORD value);
int SetArgQWord(int arg, asQWORD value);
int SetArgFloat(int arg, float value);
int SetArgDouble(int arg, double value);
int SetArgByte(int arg, asBYTE value);
int SetArgWord(int arg, asWORD value);

But all values are of unsigned type! How can I send a "-1" to my script?



Performance: global functions vs. object methods.

08 May 2012 - 02:40 PM

Hi. Is there any overhead when calling C++ member functions, compared to calling C++ global functions (from a script)?


Using one context per object for increased performance

13 March 2012 - 12:10 PM

Hi. I´ve been using Angelscript for some time now. It´s a great library, even though it took me some time to learn how to use it properly. Nice work!

To the point:

I´m developing an audio application. In it, I have a series of processing objects to manipulate some realtime audio signals. The objects get called one at a time, typically 44100 times per second. Some of these objects have scripting capabilities using.... you guessed! Angelscript! Every object has just one or two functions that are going to be called by the audio thread. Since performance is critical here the objects should do just what is needed to get the job done quickly.

With Angelscript, when calling a script function, what-is-needed is typically getting a context (from a pool), preparing it ( ctx->Prepare(func); ), setting the object pointer ( ctx->setObject(o); ), setting the corresponding arguments ( ctx->SetArgDWord(....) ) and then executing the call. And of course, all the stuff that the script function has to do. And then unpreparing the context.

Now, since the objects only have one or two functions that are going to be called (always the same functions for each object), wouldn´t it be better if each object had its own set of already prepared contexts ready to be called? That would reduce the process of calling the script function to just having to set arguments and execute the call. And of course the script function itself.

I can´t help thinking this could increase performance greatly for this kind of app. Are there any cons to this approach (other than the increased memory requirements)? How much of an increase in memory usage should I expect from this?

Thanks in advance for all your answers.