diff --git a/GGELUA/Release64/build.lua b/GGELUA/Release64/build.lua index 760cc8b..07bb9da 100644 --- a/GGELUA/Release64/build.lua +++ b/GGELUA/Release64/build.lua @@ -1,7 +1,7 @@ --[[ @Author : baidwwy @Date : 2021-02-08 15:51:46 - @LastEditTime : 2021-04-28 13:44:53 + @LastEditTime : 2021-05-06 12:49:29 --]] io.stdout:setvbuf('no',0) gge = package.loadlib("ggelua", "luaopen_ggelua")() @@ -60,7 +60,9 @@ function 创建目录(path,...) path = path:gsub('\\',dirsep) end path = 分割文本(path,dirsep) - table.remove(path) + if #path>1 then + table.remove(path) + end for i,v in ipairs(path) do lfs.mkdir(table.concat(path, dirsep,1,i)) end @@ -209,18 +211,24 @@ function 写出Windows(path,c) end end end - print("写出失败") + error("写出失败",2) return false end -function 写出Android() - -- local file = io.open("assets\\ggescript","wb") - -- if file then - -- local data = getscript() - -- file:write(core) - -- file:write(data) - -- file:write(string.pack(" = io.open("ggescript","wb") + if file then + local data = getscript() + file:write(core) + file:write(data) + file:write(string.pack("self.高度 then--横屏 + self._rd:RenderSetLogicalSize(math.floor(w/(h/self.高度)),self.高度) + else + self._rd:RenderSetLogicalSize(self.宽度,math.floor(w/(h/self.宽度))) + end + end + -- for i=0,SDL.GetNumRenderDrivers()-1 do--CreateRenderer第1参数来启用相应的渲染器,(-1)第1个 -- print(i,SDL.GetRenderDriverInfo(i).name) -- end @@ -38,8 +51,8 @@ function SDL渲染:SDL渲染(t) -- print(string.format( "%s,%s",k,v )) -- end - --print(self._rd:GetRendererOutputSize()) - --print(self._rd:RenderGetLogicalSize()) + -- SDL.Log("OutputSize %d,%d",self._rd:GetRendererOutputSize()) + -- SDL.Log("LogicalSize %d,%d",self._rd:RenderGetLogicalSize()) --print(self._rd:RenderGetIntegerScale()) --print(SDL.GetPixelFormatName(self._win:GetWindowPixelFormat())) @@ -89,8 +102,10 @@ function SDL渲染:渲染清除(r,g,b,a) end end -function SDL渲染:创建渲染区() - +function SDL渲染:创建渲染区(w,h) + if self._rd then + return self._rd:CreateTexture(w,h)--SDL_PIXELFORMAT_ARGB8888,SDL_TEXTUREACCESS_TARGET + end end function SDL渲染:置渲染区(tex) diff --git a/GGELUA/Release64/lua/SDL/窗口.lua b/GGELUA/Release64/lua/SDL/窗口.lua index 1620296..7a0a847 100644 --- a/GGELUA/Release64/lua/SDL/窗口.lua +++ b/GGELUA/Release64/lua/SDL/窗口.lua @@ -1,7 +1,7 @@ --[[ @Author : GGELUA @Date : 2020-11-27 10:05:41 - @LastEditTime : 2021-05-03 19:54:40 + @LastEditTime : 2021-05-06 17:13:05 --]] require("GGE") local type = type @@ -21,21 +21,6 @@ function SDL窗口:SDL窗口(t) self[k] = v end end - local flags = 0x00000004--SDL_WINDOW_SHOWN - local platform = SDL.GetPlatform() - if platform == 'Android' or platform == 'iOS' then - t.全屏 = t.全屏~=false - t.渲染器 = "opengl" - SDL.SetHint("SDL_IOS_ORIENTATIONS", "LandscapeLeft LandscapeRight")--只能横向 - SDL.SetHint("SDL_ANDROID_BLOCK_ON_PAUSE", "0")--后台不停止 - if t.全屏 then - flags = flags|0x00001000--SDL_WINDOW_FULLSCREEN_DESKTOP - end - if SDL._win then - return - end - end - self.标题 = t.标题 or "GGELUA Game Engine" self.原始标题 = self.标题 self.宽度 = t.宽度 or 800 @@ -47,6 +32,27 @@ function SDL窗口:SDL窗口(t) self.x = 0 self.y = 0 + local flags = 0x00000004--SDL_WINDOW_SHOWN + local platform = SDL.GetPlatform() + if platform == 'Android' or platform == 'iOS' then + self.是否全屏 = t.全屏~=false + t.渲染器 = "opengl" + + if self.宽度>self.高度 then--横向 + SDL.SetHint("SDL_IOS_ORIENTATIONS", "LandscapeLeft LandscapeRight") + else + SDL.SetHint("SDL_IOS_ORIENTATIONS", "Portrait") + end + + SDL.SetHint("SDL_ANDROID_BLOCK_ON_PAUSE", "0")--后台不停止 + if self.是否全屏 then + flags = flags|0x00001000--SDL_WINDOW_FULLSCREEN_DESKTOP + end + if SDL._win then + return + end + end + if type(t.渲染器)=='string' then SDL.SetHint('SDL_RENDER_DRIVER',t.渲染器) if t.渲染器=='opengl' then @@ -54,7 +60,7 @@ function SDL窗口:SDL窗口(t) end end - if t.全屏 then + if self.是否全屏 then flags = flags|0x00000001--SDL_WINDOW_FULLSCREEN end if t.无边框 then--隐藏边框 diff --git a/GGELUA/Release64/lua/SDL/精灵.lua b/GGELUA/Release64/lua/SDL/精灵.lua index b0914bf..5a2d615 100644 --- a/GGELUA/Release64/lua/SDL/精灵.lua +++ b/GGELUA/Release64/lua/SDL/精灵.lua @@ -1,7 +1,7 @@ --[[ @Author : GGELUA @Date : 2020-10-11 11:55:41 - @LastEditTime : 2021-05-03 14:23:16 + @LastEditTime : 2021-05-06 13:10:24 --]] local _ENV = require("SDL") IMG_Init() @@ -83,7 +83,7 @@ function SDL精灵:显示(x,y) --tex:SetTextureAlphaMod(self._a) --tex:SetTextureBlendMode(self._blend) - if self._f or self._deg then--高级 + if self._f or self._deg then--src,dst,旋转,翻转,翻转中心 self._win:显示纹理(tex,self._sr,self._dr,self._deg,self._f,self._ax,self._ay); if self._hl then--高亮 tex:SetTextureBlendMode(BLENDMODE_ADD)--FIXME diff --git a/project/android-vs/app/GGELUA/GGELUA.androidproj.user b/project/android-vs/app/GGELUA/GGELUA.androidproj.user index 721ccd8..390273d 100644 --- a/project/android-vs/app/GGELUA/GGELUA.androidproj.user +++ b/project/android-vs/app/GGELUA/GGELUA.androidproj.user @@ -2,12 +2,11 @@ AndroidDebugger - emulator-5554;api26 - com.GGELUA.game.ggemain + emulator-####;api26 - emulator-5554;api26 AndroidDebugger + emulator-####;api26 AndroidDebugger @@ -15,17 +14,22 @@ AndroidDebugger + com.GGELUA.game.ggemain AndroidDebugger + com.GGELUA.game.ggemain AndroidDebugger + com.GGELUA.game.ggemain AndroidDebugger + emulator-####;api26 AndroidDebugger + emulator-####;api26 \ No newline at end of file