Skip to content

Commit

Permalink
[export] Fix macros failing to compile with luac due to libraries mis…
Browse files Browse the repository at this point in the history
…sing

[doc] Fix Shader doc
[plugin/liquidfun] Fix particle rendering and add size setting
[android] Fix crashes to due non reentrant mutex
[texturepacker] Add common shortcuts
  • Loading branch information
hgy29 committed Jan 15, 2018
1 parent 5487048 commit 63aa141
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 13 deletions.
6 changes: 4 additions & 2 deletions android/lib/jni/gideros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ class CThreadLock
void Unlock();
private:
pthread_mutex_t mutexlock;
pthread_mutexattr_t attr;
};

CThreadLock::CThreadLock()
{
// init lock here
pthread_mutex_init(&mutexlock, 0);
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mutexlock, &attr);
}

CThreadLock::~CThreadLock()
Expand Down
2 changes: 1 addition & 1 deletion docsrc/Shader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ sprite:setShader(shader)
<return type="string"><![CDATA[shader engine version]]></return>
</method>
<method name="Shader:getProperties" page="getProperties" shortdesc="get graphics engine properties" version="Gideros 2018.1"><![CDATA[Returns a table containing various characteristics of the graphics engine]]>
<return type="string"><![CDATA[graphics engine properties]]></return>
<return type="table"><![CDATA[graphics engine properties]]></return>
</method>
<method name="Shader:getShaderLanguage" page="getShaderLanguage" shortdesc="Get shader language" version="Gideros 2016.08"><![CDATA[Get shader language, returns string with values as: glsl or hlsl]]></method>
<example name="Shader example"><![CDATA[--Shaders are in vShader.glsl and fShader.glsl files
Expand Down
5 changes: 5 additions & 0 deletions lua/src/luac.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

#include "ldo.h"
#include "lfunc.h"
Expand Down Expand Up @@ -161,6 +162,10 @@ static int pmain(lua_State* L)
char** argv=s->argv;
const Proto* f;
int i;
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);

if (!lua_checkstack(L,argc)) fatal("too many input files");
for (i=0; i<argc; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/liquidfun/source/common/lqParticles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int Box2DBinder2::b2ParticleSystem_setTexture(lua_State *L)

b2ParticleSystemSprite* ps = static_cast<b2ParticleSystemSprite*>(static_cast<SpriteProxy *>(binder.getInstance("b2ParticleSystem", 1))->getContext());
TextureBase *textureBase = static_cast<TextureBase*>(binder.getInstance("TextureBase", 2));
ps->SetTexture(textureBase);
ps->SetTexture(textureBase,luaL_optnumber(L,3,0.0));

return 0;
}
Expand Down
23 changes: 16 additions & 7 deletions plugins/liquidfun/source/common/lqSprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,21 @@ b2ParticleSystemSprite::b2ParticleSystemSprite(LuaApplication* application,b2Par
world_=world;
application_=application;
texturebase_=NULL;
psize_=0;
proxy_=gtexture_get_spritefactory()->createProxy(application->getApplication(), this, b2PSS_Draw, b2PSS_Destroy);
}

void b2ParticleSystemSprite::SetTexture(TextureBase *texturebase)
void b2ParticleSystemSprite::SetTexture(TextureBase *texturebase,float psize)
{
TextureBase *originaltexturebase = texturebase_;
texturebase_ = texturebase;
texturebase_->ref();
if (texturebase)
{
texturebase_ = texturebase;
texturebase_->ref();
}
if (originaltexturebase)
originaltexturebase->unref();
psize_=psize;
}

b2ParticleSystemSprite::~b2ParticleSystemSprite()
Expand All @@ -277,11 +282,15 @@ void b2ParticleSystemSprite::doDraw(const CurrentTransform& , float _UNUSED(sx),
float physicsScale = application_->getPhysicsScale();

Matrix4 modelMat=gtexture_get_engine()->getModel();
Matrix4 scaledMat=modelMat;
scaledMat.scale(physicsScale,physicsScale,1);
float mc[16];
memcpy(mc,modelMat.get(),16*sizeof(float));
mc[0]*=physicsScale;
mc[5]*=physicsScale;
Matrix4 scaledMat;
scaledMat.set(mc);
gtexture_get_engine()->setModel(scaledMat);

ShaderProgram *p=proxy_->getShader(); //XXX get specific shader ???
ShaderProgram *p=proxy_->getShader();
if (!p)
p=gtexture_get_engine()->getDefault(ShaderEngine::STDP_PARTICLE);
if (p)
Expand All @@ -305,7 +314,7 @@ void b2ParticleSystemSprite::doDraw(const CurrentTransform& , float _UNUSED(sx),
sc = p->getSystemConstant(ShaderProgram::SysConst_ParticleSize);
if (sc>=0)
{
float rad=ps_->GetRadius()*2; //Point Size is width, e.q diameter
float rad=((psize_==0)?ps_->GetRadius():psize_)*2; //Point Size is width, e.q diameter
p->setConstant(sc,ShaderProgram::CFLOAT,1,&rad);
}
p->drawArrays(ShaderProgram::Point, 0, pc);
Expand Down
3 changes: 2 additions & 1 deletion plugins/liquidfun/source/common/lqSprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ class b2ParticleSystemSprite
virtual ~b2ParticleSystemSprite();
b2ParticleSystem* GetSystem() { return ps_; }
b2WorldED* GetWorld() { return world_; }
void SetTexture(TextureBase *texture);
void SetTexture(TextureBase *texture,float psize);
SpriteProxy *proxy_;
void doDraw(const CurrentTransform&, float sx, float sy, float ex, float ey);
private:
LuaApplication* application_;
b2ParticleSystem* ps_;
b2WorldED *world_;
TextureBase* texturebase_;
float psize_;
};


Expand Down
11 changes: 10 additions & 1 deletion texturepacker/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>20</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
Expand Down Expand Up @@ -73,6 +73,9 @@
<property name="text">
<string>Save Project</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionClose_Project">
<property name="text">
Expand All @@ -83,6 +86,9 @@
<property name="text">
<string>E&amp;xit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionProject1">
<property name="text">
Expand Down Expand Up @@ -113,6 +119,9 @@
<property name="text">
<string>Export Texture...</string>
</property>
<property name="shortcut">
<string>Ctrl+E</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down

0 comments on commit 63aa141

Please sign in to comment.