From c741895e45968b50114a1b6ec0307503bce59783 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 3 Feb 2018 23:43:31 +0800 Subject: Fixed texture locking for sure this time. --- README.md | 2 +- examples/smelt_test.cpp | 2 +- extensions/smttfont.cpp | 2 -- smelt/glfw/gfx_glfw.cpp | 2 +- smelt/glfw_m/gfx_glfw.cpp | 2 +- smelt/sdl/gfx_sdl.cpp | 7 ++++--- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 031ab0f..4a71877 100644 --- a/README.md +++ b/README.md @@ -64,5 +64,5 @@ comments in the file for details. * Better documentation. * Sane way to build. * Unify OpenGL versions. -* D3D version. +* ~~D3D version.~~ * Better tools? diff --git a/examples/smelt_test.cpp b/examples/smelt_test.cpp index 8d0e41b..853d09b 100644 --- a/examples/smelt_test.cpp +++ b/examples/smelt_test.cpp @@ -185,7 +185,7 @@ int main() //initialize the indicator. ictest.init(100,5,0x80,tex,smTexRect(151,264,2,8)); //set the string of the truetype font renderer. - ttftest.updateString(L"truetype font test\nNow Playing: 稲田姫樣に叱られるから by ZUN"); + ttftest.updateString(L"truetype font test\nNow Playing: 稲田姫様に叱られるから by ZUN"); //play the bgm. sm->smSFXPlay(bgm,100,0,1.,true); //enter the main loop. diff --git a/extensions/smttfont.cpp b/extensions/smttfont.cpp index 02aa54a..566aab1 100644 --- a/extensions/smttfont.cpp +++ b/extensions/smttfont.cpp @@ -132,8 +132,6 @@ std::pair> smTTFont::_allocate_char(int rw,int rh) _smTexState* ptex=new _smTexState; ptex->cx=ptex->cy=ptex->mh=0; ptex->tex=sm->smTextureCreate(texw,texh); - DWORD* px=sm->smTextureLock(ptex->tex,0,0,texw,texh,false); - sm->smTexutreUnlock(ptex->tex); ret.first=ptex->tex; ret.second.first=ret.second.second=0; ptex->cx+=rw; diff --git a/smelt/glfw/gfx_glfw.cpp b/smelt/glfw/gfx_glfw.cpp index 485760d..5586112 100644 --- a/smelt/glfw/gfx_glfw.cpp +++ b/smelt/glfw/gfx_glfw.cpp @@ -538,7 +538,7 @@ void SMELT_IMPL::smTexutreUnlock(SMTEX tex) if(!ptex->locpx)return; if(!ptex->roloc) { - DWORD *src=ptex->locpx+ptex->locw*ptex->loch, + DWORD *src=ptex->locpx+ptex->locw*(ptex->loch-1), *dst=ptex->px+(((ptex->rh-ptex->locy-1)*ptex->rw)+ptex->locx); for(int i=0;iloch;++i) { diff --git a/smelt/glfw_m/gfx_glfw.cpp b/smelt/glfw_m/gfx_glfw.cpp index ebd24bf..41b4d7b 100644 --- a/smelt/glfw_m/gfx_glfw.cpp +++ b/smelt/glfw_m/gfx_glfw.cpp @@ -534,7 +534,7 @@ void SMELT_IMPL::smTexutreUnlock(SMTEX tex) if(!ptex->locpx)return; if(!ptex->roloc) { - DWORD *src=ptex->locpx+ptex->locw*ptex->loch, + DWORD *src=ptex->locpx+ptex->locw*(ptex->loch-1), *dst=ptex->px+(((ptex->rh-ptex->locy-1)*ptex->rw)+ptex->locx); for(int i=0;iloch;++i) { diff --git a/smelt/sdl/gfx_sdl.cpp b/smelt/sdl/gfx_sdl.cpp index ae50db2..875f103 100644 --- a/smelt/sdl/gfx_sdl.cpp +++ b/smelt/sdl/gfx_sdl.cpp @@ -538,11 +538,12 @@ void SMELT_IMPL::smTexutreUnlock(SMTEX tex) if(!ptex->locpx)return; if(!ptex->roloc) { - DWORD *src=ptex->locpx,*dst=ptex->px+((ptex->locy*ptex->rw)+ptex->locx); - for(int i=0;iloch;++i)//TODO: flip it... + DWORD *src=ptex->locpx+ptex->locw*(ptex->loch-1), + *dst=ptex->px+(((ptex->rh-ptex->locy-1)*ptex->rw)+ptex->locx); + for(int i=0;iloch;++i) { memcpy(dst,src,ptex->locw*sizeof(DWORD)); - dst+=ptex->rw;src+=ptex->locw; + dst-=ptex->rw;src-=ptex->locw; } if(ptex->lost)configTexture(ptex,ptex->rw,ptex->rh,ptex->px); else -- cgit v1.2.3