From fd7ea15571b43dcacc7a88cf720fb7e103f19042 Mon Sep 17 00:00:00 2001 From: "chirs241097@gmail.com" Date: Mon, 17 Mar 2014 02:43:16 +0000 Subject: Partly revert r50, removing HGE::Gfx_SetTDRotate and fixing HGE::Gfx_SetTransform. 3D Rotate is blinking and not really working. However another method HGE::Gfx_SetTransform3D is planned. Switching between orthographic and perspective is also required. --- CHANGELOG.TXT | 3 +-- hge/graphics.cpp | 43 +++++++++++++------------------------------ hge/hge_impl.h | 3 +-- include/hge.h | 3 +-- 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 8ed37c6..bc2892b 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -9,8 +9,7 @@ Pre-Released versions: New level Supernova. New level (still unnamed). Add some additional tips. -Add HGE::Gfx_SetTDRotate(float,float,float,float), which is almost -a direct OpenGL call. It will be tested and ported to DX later. +Fix blinking of HGE::Gfx_SetTransform in OpenGL. Fix includes like " #include "../../include/..." " that would cause errors. Extend libcgh again. Adding operator ^ and method l(). diff --git a/hge/graphics.cpp b/hge/graphics.cpp index 9688024..6ee9578 100644 --- a/hge/graphics.cpp +++ b/hge/graphics.cpp @@ -230,43 +230,26 @@ void CALL HGE_Impl::Gfx_SetClipping(int x, int y, int w, int h) void CALL HGE_Impl::Gfx_SetTransform(float x, float y, float dx, float dy, float rot, float hscale, float vscale) { - if (!bTransforming) + if ((x == 0.0f) && (y == 0.0f) && (dx == 0.0f) && (dy == 0.0f) && (rot == 0.0f) && (hscale == 0.0f) && (vscale == 0.0f)) { - if ((x == 0.0f) && (y == 0.0f) && (dx == 0.0f) && (dy == 0.0f) && (rot == 0.0f) && (hscale == 1.0f) && (vscale == 1.0f)) - return; // nothing to do here, don't call into the GL. - } - - _render_batch(); - - bTransforming = true; - - // !!! FIXME: this math is probably wrong. Re-sync with the Direct3D code. - - pOpenGLDevice->glMatrixMode(GL_MODELVIEW); - if(vscale==0.0f) pOpenGLDevice->glLoadIdentity(); - else - { - pOpenGLDevice->glTranslatef(-x, -y, 0.0f); - //pOpenGLDevice->glScalef(1.0f, -1.0f, 1.0f); - pOpenGLDevice->glRotatef(-rot, 0.0f, 0.0f, -1.0f); - pOpenGLDevice->glTranslatef(x+dx, y+dy, 0.0f); - } -} - -void CALL HGE_Impl::Gfx_SetTDRotate(float ang, float x, float y, float z) -{ - if (!bTransforming) - { - if ((x == 0.0f) && (y == 0.0f) && (z == 0.0f) && (ang == 0.0f)) - return; // nothing to do here, don't call into the GL. + //reset everything + pOpenGLDevice->glMatrixMode(GL_MODELVIEW); + pOpenGLDevice->glLoadIdentity(); + bTransforming=false; + return; } _render_batch(); - bTransforming = true; pOpenGLDevice->glMatrixMode(GL_MODELVIEW); - pOpenGLDevice->glRotatef(ang, x, y, z); + //we have to reset the matrix in all cases. + //or this would cause insane transforming... + pOpenGLDevice->glLoadIdentity(); + pOpenGLDevice->glTranslatef(-x, -y, 0.0f); + pOpenGLDevice->glScalef(hscale, vscale, 1.0f); + pOpenGLDevice->glRotatef(rot, 0.0f, 0.0f, 1.0f); + pOpenGLDevice->glTranslatef(x+dx, y+dy, 0.0f); } bool CALL HGE_Impl::Gfx_BeginScene(HTARGET targ) diff --git a/hge/hge_impl.h b/hge/hge_impl.h index bcee956..e09a321 100644 --- a/hge/hge_impl.h +++ b/hge/hge_impl.h @@ -199,7 +199,7 @@ public: virtual bool CALL Input_KeyUp(int key); virtual bool CALL Input_GetKeyState(int key); virtual int CALL Input_GetKeyStateEx(int key); - virtual const char* CALL Input_GetKeyName(int key); + virtual const char* CALL Input_GetKeyName(int key); virtual int CALL Input_GetKey(); virtual int CALL Input_GetChar(); virtual bool CALL Input_GetEvent(hgeInputEvent *event); @@ -214,7 +214,6 @@ public: virtual void CALL Gfx_FinishBatch(int nprim); virtual void CALL Gfx_SetClipping(int x=0, int y=0, int w=0, int h=0); virtual void CALL Gfx_SetTransform(float x=0, float y=0, float dx=0, float dy=0, float rot=0, float hscale=0, float vscale=0); - virtual void CALL Gfx_SetTDRotate(float ang=0, float x=0, float y=0, float z=0); virtual HTARGET CALL Target_Create(int width, int height, bool zbuffer); virtual void CALL Target_Free(HTARGET target); diff --git a/include/hge.h b/include/hge.h index 1ccab9d..131cbbf 100644 --- a/include/hge.h +++ b/include/hge.h @@ -409,7 +409,7 @@ public: virtual bool CALL Input_KeyUp(int key) = 0; virtual bool CALL Input_GetKeyState(int key) = 0; virtual int CALL Input_GetKeyStateEx(int key) = 0; - virtual const char* CALL Input_GetKeyName(int key) = 0; + virtual const char* CALL Input_GetKeyName(int key) = 0; virtual int CALL Input_GetKey() = 0; virtual int CALL Input_GetChar() = 0; virtual bool CALL Input_GetEvent(hgeInputEvent *event) = 0; @@ -424,7 +424,6 @@ public: virtual void CALL Gfx_FinishBatch(int nprim) = 0; virtual void CALL Gfx_SetClipping(int x=0, int y=0, int w=0, int h=0) = 0; virtual void CALL Gfx_SetTransform(float x=0, float y=0, float dx=0, float dy=0, float rot=0, float hscale=0, float vscale=0) = 0; - virtual void CALL Gfx_SetTDRotate(float ang=0, float x=0, float y=0, float z=0) = 0; virtual HTARGET CALL Target_Create(int width, int height, bool zbuffer) = 0; virtual void CALL Target_Free(HTARGET target) = 0; -- cgit v1.2.3