Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualGrimshaw

Posted 30 March 2013 - 09:18 AM

Okay, then here is all the steps involved:

 

The script function:

 

 

 

void onRender(Renderer@ renderer)
{
     Color c;
     c.r = 255;
     c.g = 200;
     c.b  = 100;
     //c.alpha is by default 255, so we should be able to see a shape nevertheless, but c.alpha is a trashed low value inside     drawDebugQuad(), which causes us not to see anything
     renderer.drawDebugQuad(200,200,0,200,200, c);
}
 

 

The relevant function drawDebugQuad:

 

 

 

r = asEngine->RegisterObjectMethod("Renderer", "void drawDebugQuad(float,float,float,float,float,Color)", asMETHOD(Renderer, drawDebugQuad), asCALL_THISCALL);

Signature: void Renderer::drawDebugQuad(float x, float y, float angle, float width, float height, Color color)
 

 

 

The relevant Color type:

 

 

 asEngine->RegisterObjectType("Color", sizeof(Color), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
asEngine->RegisterObjectProperty("Color", "uint8 r", asOFFSET(Color, r));
asEngine->RegisterObjectProperty("Color", "uint8 g", asOFFSET(Color, g));
asEngine->RegisterObjectProperty("Color", "uint8 b", asOFFSET(Color, b));
asEngine->RegisterObjectProperty("Color", "uint8 a", asOFFSET(Color, a));
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ColorCTOR), asCALL_CDECL_OBJLAST);
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_CONSTRUCT, "void f(int, int, int)", asFUNCTION(ColorCTOR2), asCALL_CDECL_OBJLAST);
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(ColorDTOR), asCALL_CDECL_OBJLAST);
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_CONSTRUCT, "void f(const Color& in)", asFUNCTION(ObjectCopyConstructor<Color>), asCALL_CDECL_OBJLAST);
 

 

 

template<typename T>
void ObjectCopyConstructor(const T &in, void* address){
new(address) T(in);
}
 

 

 

 
Color class interface is simple:

 

Color();
Color(int byteRed, int byteGreen, int byteBlue, int byteAlpha = 255);
Uint8 r,g,b,a;

 

 

Also already tried using POD types to the same result. Im not sure whats wrong.

 

Note: If i register the Color type using generics it works as-is.


#1Grimshaw

Posted 30 March 2013 - 09:10 AM

Okay, then here is all the steps involved:

 

The script function:

 

 

 

void onRender(Renderer@ renderer)
{
     Color c;
     c.r = 255;
     c.g = 200;
     c.b  = 100;
     //c.alpha is by default 255, so we should be able to see a shape nevertheless, but c.alpha is a trashed low value inside     drawDebugQuad(), which causes us not to see anything
     renderer.drawDebugQuad(200,200,0,200,200, c);
}
 

 

The relevant function drawDebugQuad:

 

 

 

r = asEngine->RegisterObjectMethod("Renderer", "void drawDebugQuad(float,float,float,float,float,Color)", asMETHOD(Renderer, drawDebugQuad), asCALL_THISCALL);

Signature: void Renderer::drawDebugQuad(float x, float y, float angle, float width, float height, Color color)
 

 

 

The relevant Color type:

 

 

 asEngine->RegisterObjectType("Color", sizeof(Color), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
asEngine->RegisterObjectProperty("Color", "uint8 r", asOFFSET(Color, r));
asEngine->RegisterObjectProperty("Color", "uint8 g", asOFFSET(Color, g));
asEngine->RegisterObjectProperty("Color", "uint8 b", asOFFSET(Color, b));
asEngine->RegisterObjectProperty("Color", "uint8 a", asOFFSET(Color, a));
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ColorCTOR), asCALL_CDECL_OBJLAST);
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_CONSTRUCT, "void f(int, int, int)", asFUNCTION(ColorCTOR2), asCALL_CDECL_OBJLAST);
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(ColorDTOR), asCALL_CDECL_OBJLAST);
asEngine->RegisterObjectBehaviour("Color", asBEHAVE_CONSTRUCT, "void f(const Color& in)", asFUNCTION(ObjectCopyConstructor<Color>), asCALL_CDECL_OBJLAST);
 

 

 

template<typename T>
void ObjectCopyConstructor(const T &in, void* address){
new(address) T(in);
}
 

 

 

 
Color class interface is simple:

 

Color();
Color(int byteRed, int byteGreen, int byteBlue, int byteAlpha = 255);
Uint8 r,g,b,a;

 

 

Also already tried using POD types to the same result. Im not sure whats wrong.


PARTNERS