From d961ae306461e1606d37539f512a5d907490531b Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Tue, 17 May 2016 23:49:44 +0800 Subject: Fixed a bug in smColorRGBA. Fix and modify smMatrix::lookat. Allow disabling z-test in 3d mode. Add smvec4d. --- include/smcolor.hpp | 2 +- include/smelt.hpp | 2 +- include/smmath.hpp | 44 +++++++++++++++++++++++++++++++++++--------- smelt/sdl/gfx_sdl.cpp | 6 +++--- smelt/sdl/smelt_internal.hpp | 2 +- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/include/smcolor.hpp b/include/smcolor.hpp index 94ff4f3..a7feb65 100644 --- a/include/smcolor.hpp +++ b/include/smcolor.hpp @@ -27,7 +27,7 @@ public: friend smColorRGBA operator *(smColorRGBA a,float b){return smColorRGBA(b*a.r,b*a.g,b*a.b,b*a.a);} friend smColorRGBA operator /(smColorRGBA a,float b){return smColorRGBA(a.r/b,a.g/b,a.b/b,a.a/b);} void setHWColor(DWORD col){a=GETA(col)/255.;r=GETR(col)/255.;g=GETG(col)/255.;b=GETB(col)/255.;} - DWORD getHWColor(){clamp();return RGBA(r,g,b,a);} + DWORD getHWColor(){clamp();return RGBA(r*255.,g*255.,b*255.,a*255.);} }; class smColorHSVA { diff --git a/include/smelt.hpp b/include/smelt.hpp index e9caeb3..5c9b013 100644 --- a/include/smelt.hpp +++ b/include/smelt.hpp @@ -350,7 +350,7 @@ public: virtual bool smGetInpEvent(smInpEvent *e)=0; virtual bool smRenderBegin2D(bool ztest=0,SMTRG trg=0)=0; - virtual bool smRenderBegin3D(float fov,SMTRG trg=0)=0; + virtual bool smRenderBegin3D(float fov,bool ztest=0,SMTRG trg=0)=0; virtual bool smRenderEnd()=0; virtual void sm3DCamera6f2v(float *pos,float *rot)=0; virtual void sm2DCamera5f3v(float *pos,float *dpos,float *rot)=0; diff --git a/include/smmath.hpp b/include/smmath.hpp index b9763b7..84ef315 100644 --- a/include/smmath.hpp +++ b/include/smmath.hpp @@ -54,7 +54,7 @@ class smvec3d public: double x,y,z; smvec3d(double _x,double _y,double _z){x=_x;y=_y;z=_z;} - smvec3d(smvec2d a){x=a.x;y=a.y;z=.0;} + smvec3d(smvec2d a,double _z=.0){x=a.x;y=a.y;z=_z;} smvec3d(){x=y=z=.0;} double l(){return sqrt(sqr(x)+sqr(y)+sqr(z));} void normalize(){double L=l();if(Lhave_GL_EXT_framebuffer_object) pOpenGLDevice->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,(targ)?targ->frame:0); pOpenGLDevice->glDepthFunc(GL_LESS); - pOpenGLDevice->glEnable(GL_DEPTH_TEST); - zbufenabled=true; + ztest?pOpenGLDevice->glEnable(GL_DEPTH_TEST):pOpenGLDevice->glDisable(GL_DEPTH_TEST); + zbufenabled=ztest; if(targ) { pOpenGLDevice->glScissor(0,0,targ->w,targ->h); diff --git a/smelt/sdl/smelt_internal.hpp b/smelt/sdl/smelt_internal.hpp index f514c54..a14e151 100644 --- a/smelt/sdl/smelt_internal.hpp +++ b/smelt/sdl/smelt_internal.hpp @@ -144,7 +144,7 @@ public: virtual bool smGetInpEvent(smInpEvent *e); virtual bool smRenderBegin2D(bool ztest=0,SMTRG trg=0); - virtual bool smRenderBegin3D(float fov,SMTRG trg=0); + virtual bool smRenderBegin3D(float fov,bool ztest=0,SMTRG trg=0); virtual bool smRenderEnd(); virtual void sm3DCamera6f2v(float *pos,float *rot); virtual void sm2DCamera5f3v(float *pos,float *dpos,float *rot); -- cgit v1.2.3