parent
1f54ee64e6
commit
db0b3d090e
|
@ -1,7 +1,7 @@
|
|||
--[[
|
||||
@Author : GGELUA
|
||||
@Date : 2020-11-27 10:05:41
|
||||
@LastEditTime : 2021-04-08 05:32:28
|
||||
@LastEditTime : 2021-04-09 18:10:23
|
||||
--]]
|
||||
|
||||
require("GGE")
|
||||
|
@ -23,7 +23,9 @@ function SDL窗口:SDL窗口(t)
|
|||
t.渲染器 = "opengl"
|
||||
SDL.SetHint("SDL_IOS_ORIENTATIONS", "LandscapeLeft LandscapeRight")--只能横向
|
||||
SDL.SetHint("SDL_ANDROID_BLOCK_ON_PAUSE", "0")--后台不停止
|
||||
flags = flags|0x00001000--SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||
if t.全屏 then
|
||||
flags = flags|0x00001000--SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||
end
|
||||
if SDL._win then
|
||||
return
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
--[[
|
||||
@Author : GGELUA
|
||||
@Date : 2021-02-11 11:49:09
|
||||
@LastEditTime : 2021-04-01 22:25:04
|
||||
@LastEditTime : 2021-04-08 08:15:12
|
||||
--]]
|
||||
|
||||
local _ENV = require("SDL")
|
||||
--local _REG = debug.getregistry()
|
||||
|
||||
local SDL读写 = class"SDL读写"
|
||||
|
||||
function SDL读写:SDL读写(file,mode)
|
||||
|
@ -15,8 +15,6 @@ function SDL读写:SDL读写(file,mode)
|
|||
else
|
||||
self._rw = RWFromFile(file,mode)
|
||||
end
|
||||
-- elseif type(file)=='userdata' then--_REG["FILE*"]
|
||||
-- self._rw = RWFromFP(file)
|
||||
elseif type(file)=='userdata' then
|
||||
self._rw = RWFromMem(file)
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "dep\SDL2\SDL2.vcxpr
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hidapi", "dep\hidapi\hidapi.vcxproj", "{654D6F15-267A-423D-8606-351C153C4E3D}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "main", "dep\main\main.vcxproj", "{B7F3A6F1-0359-4427-925D-4A6D1C979B61}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "dep\main\main.vcxproj", "{B7F3A6F1-0359-4427-925D-4A6D1C979B61}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ggelua", "lib\ggelua\ggelua.vcxproj", "{E35E2816-7594-4B05-B684-12B97E4BFD20}"
|
||||
EndProject
|
||||
|
@ -65,6 +65,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ghpsocket", "lib\ghpsocket\
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "socket", "lib\socket\socket.vcxproj", "{2B89BF02-C749-4CF4-8AAC-E9B5781C71D1}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQL", "SQL", "{A2F80EDF-0270-4A3F-B212-06C13557797E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
|
@ -510,13 +512,14 @@ Global
|
|||
{0B5CF24E-3D35-4D7C-A2C7-2808EF97C34B} = {FE064222-B64C-47DB-A2F1-BFF13D265624}
|
||||
{17883804-98A9-4F45-82E0-20A6CCBBF247} = {FE064222-B64C-47DB-A2F1-BFF13D265624}
|
||||
{7C56DFCA-4A87-47F4-9415-B096AF20337A} = {FE064222-B64C-47DB-A2F1-BFF13D265624}
|
||||
{46D15333-11AE-44E6-BB6A-5FD4E02FD048} = {49BE2731-DA8F-4041-8486-6C8188227CD7}
|
||||
{46D15333-11AE-44E6-BB6A-5FD4E02FD048} = {A2F80EDF-0270-4A3F-B212-06C13557797E}
|
||||
{B7E1564E-9354-4AFE-ABBC-227EFF02D4F9} = {49BE2731-DA8F-4041-8486-6C8188227CD7}
|
||||
{CF6B1309-8291-412D-A215-054222748E49} = {AB5005FC-E855-47D7-B43C-B15A427D193B}
|
||||
{F50F8B73-4BD2-4B79-B21E-F1AED6DBE6C2} = {AB5005FC-E855-47D7-B43C-B15A427D193B}
|
||||
{6494088E-28E3-4DC3-A744-0F9C742D116D} = {AB5005FC-E855-47D7-B43C-B15A427D193B}
|
||||
{4D03B2AF-4991-4561-BD96-4DF4A21B56ED} = {AB5005FC-E855-47D7-B43C-B15A427D193B}
|
||||
{2B89BF02-C749-4CF4-8AAC-E9B5781C71D1} = {AB5005FC-E855-47D7-B43C-B15A427D193B}
|
||||
{A2F80EDF-0270-4A3F-B212-06C13557797E} = {49BE2731-DA8F-4041-8486-6C8188227CD7}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {870A7F85-D65E-4927-8128-B095C513213E}
|
||||
|
|
|
@ -242,6 +242,7 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\dependent\SDL\src\main\android\SDL_android_main.c" />
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
<ClCompile Include="..\..\..\..\dependent\SDL\src\main\android\SDL_android_main.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -62,8 +62,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "dep\SDL\SDL.vcxproj
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "dep\SDLmain\SDLmain.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPSocketLIB4C", "dep\HPSocket\HPSocketLIB4C.vcxproj", "{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL_image", "dep\SDL_image\SDL_image.vcxproj", "{2BD5534E-00E2-4BEA-AC96-D9A92EA24696}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2_mixer", "dep\SDL_mixer\SDL_mixer.vcxproj", "{F7E944B3-0815-40CD-B3E4-90B2A15B0E33}"
|
||||
|
@ -100,10 +98,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mariadbclient", "dep\mariad
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpq", "dep\libpq\libpq.vcxproj", "{C34A78DF-68C8-4357-8E4E-7DE8154E3ABB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPSocketLIB", "dep\HPSocketLIB\HPSocketLIB.vcxproj", "{D73A44FF-8818-41EC-8A8E-C36280F0832C}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPSocket", "dep\HPSocketLIB\HPSocketLIB.vcxproj", "{D73A44FF-8818-41EC-8A8E-C36280F0832C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mongodb", "mongodb", "{A6CAF089-0523-49C5-8591-27BA52E5AE0D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQL", "SQL", "{5E056048-D632-4A94-B97F-AF92F34A84C0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -280,14 +280,6 @@ Global
|
|||
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|Win32.Build.0 = Release|Win32
|
||||
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.ActiveCfg = Release|x64
|
||||
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.Build.0 = Release|x64
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Debug|x64.Build.0 = Debug|x64
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Release|x64.ActiveCfg = Release|x64
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF}.Release|x64.Build.0 = Release|x64
|
||||
{2BD5534E-00E2-4BEA-AC96-D9A92EA24696}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2BD5534E-00E2-4BEA-AC96-D9A92EA24696}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2BD5534E-00E2-4BEA-AC96-D9A92EA24696}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -438,10 +430,9 @@ Global
|
|||
{E0E8A6E0-EC75-4078-8ED9-35A72C39444C} = {8286A76F-269C-4C17-B8AE-240AFCC1A0BC}
|
||||
{DD376932-B4BA-4C44-A146-C2E39A22F56D} = {178D2820-C8AE-4894-82A5-454A43F7AD21}
|
||||
{5FCA3894-FEB8-4C7F-B5FA-BAFF2E69F619} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{50D338F5-BC93-B42B-85CE-FDA8F14DF907} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{50D338F5-BC93-B42B-85CE-FDA8F14DF907} = {5E056048-D632-4A94-B97F-AF92F34A84C0}
|
||||
{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{54E670E2-9A44-4816-B4A4-1EC2C8F248AF} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{2BD5534E-00E2-4BEA-AC96-D9A92EA24696} = {C9B5FF09-339F-46B2-BEE1-4704283CEFAC}
|
||||
{F7E944B3-0815-40CD-B3E4-90B2A15B0E33} = {43E7C20B-0BE5-4774-930A-B875BB50A587}
|
||||
{DDDBD07D-DC76-4AF6-8D02-3E2DEB6EE255} = {4C3F0F90-CB04-4AC3-B49A-AD8CE115AC2A}
|
||||
|
@ -458,10 +449,11 @@ Global
|
|||
{65EBD877-099B-3F4E-9E5F-3D2EA6490307} = {A6CAF089-0523-49C5-8591-27BA52E5AE0D}
|
||||
{044F3BF3-94AD-3F0B-9E3C-AF4DA3F5258F} = {A6CAF089-0523-49C5-8591-27BA52E5AE0D}
|
||||
{641C5F36-32EE-4323-B740-992B651CF9D6} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{9FD3F0AA-0526-3BCD-BDA1-4017A83485D2} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{C34A78DF-68C8-4357-8E4E-7DE8154E3ABB} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{9FD3F0AA-0526-3BCD-BDA1-4017A83485D2} = {5E056048-D632-4A94-B97F-AF92F34A84C0}
|
||||
{C34A78DF-68C8-4357-8E4E-7DE8154E3ABB} = {5E056048-D632-4A94-B97F-AF92F34A84C0}
|
||||
{D73A44FF-8818-41EC-8A8E-C36280F0832C} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{A6CAF089-0523-49C5-8591-27BA52E5AE0D} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
{5E056048-D632-4A94-B97F-AF92F34A84C0} = {8B78C654-0550-43A0-B0B0-82304584AB3F}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E6EA96F6-C769-42B8-B9C2-DDF3F46F5FA9}
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
|
@ -146,7 +146,7 @@
|
|||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -162,9 +162,6 @@
|
|||
<ItemGroup>
|
||||
<None Include="logo.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
|
@ -185,6 +182,9 @@
|
|||
<Project>{0ffa55d6-c072-4ba9-a5ea-f08cffe7d641}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\GGELUAc\main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<ItemGroup>
|
||||
<ResourceCompile Include="GGELUA.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\GGELUAc\main.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,23 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -84,9 +84,9 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -103,8 +103,8 @@
|
|||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -119,11 +119,11 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DisableSpecificWarnings>5105</DisableSpecificWarnings>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<ImportLibrary>
|
||||
|
@ -145,11 +145,11 @@
|
|||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\dependent\zlib;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /y "$(OutDir)"$(TargetName).exe ..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</Command>
|
||||
|
@ -161,9 +161,6 @@
|
|||
<ItemGroup>
|
||||
<None Include="logo.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
|
@ -171,18 +168,9 @@
|
|||
<ProjectReference Include="..\..\dep\SDLmain\SDLmain.vcxproj">
|
||||
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\SDL\SDL.vcxproj">
|
||||
<Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\zlib\zlib.vcxproj">
|
||||
<Project>{5fca3894-feb8-4c7f-b5fa-baff2e69f619}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\ggelua\ggelua.vcxproj">
|
||||
<Project>{4f7b97f6-1b8f-416c-a987-8dba9b105f5d}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lua\lua.vcxproj">
|
||||
<Project>{0ffa55d6-c072-4ba9-a5ea-f08cffe7d641}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="logo.ico" />
|
||||
</ItemGroup>
|
||||
|
@ -12,4 +9,7 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,23 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerCommand>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>..\..\..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommand>$(SolutionDir)..\..\GGELUA\$(Configuration)$(PlatformArchitecture)\$(TargetName).exe</LocalDebuggerCommand>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
//#include "SDL_main.h"
|
||||
|
||||
//int main(int argc, char* argv[])
|
||||
//{
|
||||
// return 0;
|
||||
//}
|
|
@ -23,6 +23,7 @@
|
|||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>HPSocketLIB</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>HPSocket</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
</Command>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
|
@ -107,7 +107,7 @@
|
|||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
|
@ -125,7 +125,7 @@
|
|||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
|
@ -142,7 +142,7 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\dependent\sdl\include;..\..\..\..\source\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
|
@ -154,6 +154,20 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\dependent\sdl\src\main\windows\SDL_windows_main.c" />
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\main.c" />
|
||||
<ClCompile Include="..\..\..\..\source\app\ggelua\script.c" />
|
||||
<ClCompile Include="..\..\..\..\source\lib\ggelua\hash.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\ggelua\ggelua.vcxproj">
|
||||
<Project>{4f7b97f6-1b8f-416c-a987-8dba9b105f5d}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lua\lua.vcxproj">
|
||||
<Project>{0ffa55d6-c072-4ba9-a5ea-f08cffe7d641}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SDL\SDL.vcxproj">
|
||||
<Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\source\lib\ggelua\lbase64.c">
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
int luaopen_ggelua(lua_State* L);
|
||||
struct INFO {
|
||||
unsigned int signal;
|
||||
|
@ -57,11 +58,11 @@ static int GGE_LoadScript(lua_State *L)
|
|||
for (int i=0;i<l;i++)//到小写
|
||||
lpath[i] = SDL_tolower(path[i]);
|
||||
lpath[l] = 0;
|
||||
#ifdef _CONSOLE
|
||||
path = luaL_gsub(L, lpath, "ggeluac.exe", "ggelua.lua");
|
||||
#else
|
||||
path = luaL_gsub(L, lpath, "ggelua.exe", "ggelua.lua");
|
||||
#endif
|
||||
if (GetConsoleWindow() != NULL)
|
||||
path = luaL_gsub(L, lpath, "ggeluac.exe", "ggelua.lua");
|
||||
else
|
||||
path = luaL_gsub(L, lpath, "ggelua.exe", "ggelua.lua");
|
||||
|
||||
void* ggelua = SDL_LoadFile(path, (size_t*)&info.coresize);
|
||||
if (ggelua)
|
||||
{
|
||||
|
@ -79,24 +80,21 @@ static int GGE_LoadScript(lua_State *L)
|
|||
}
|
||||
|
||||
static int GGE_Error(lua_State* L) {
|
||||
#ifdef _CONSOLE
|
||||
printf("%s\n", lua_tostring(L, -1));
|
||||
#elif __ANDROID__
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "error", lua_tostring(L, -1), NULL);
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);//LOADED
|
||||
if (lua_getfield(L,-1,"SDL")!= LUA_TTABLE){
|
||||
if (lua_getfield(L, -1, "SDL") != LUA_TTABLE)
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "error", lua_tostring(L, -3), NULL);
|
||||
}else{
|
||||
else
|
||||
printf("%s\n", lua_tostring(L, -3));
|
||||
}
|
||||
#else
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "error", lua_tostring(L, -1), NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef _CONSOLE
|
||||
#ifdef _WIN32
|
||||
SetConsoleOutputCP(65001);
|
||||
#endif
|
||||
lua_State *L = luaL_newstate();
|
||||
|
@ -111,8 +109,8 @@ int SDL_main(int argc, char* argv[])
|
|||
}
|
||||
lua_setfield(L, -2, "arg");//gge.arg
|
||||
|
||||
#ifdef _CONSOLE
|
||||
lua_pushboolean(L, 1);
|
||||
#ifdef _WIN32
|
||||
lua_pushboolean(L, GetConsoleWindow()!=NULL);
|
||||
#else
|
||||
lua_pushboolean(L, 0);
|
||||
#endif
|
||||
|
@ -143,7 +141,7 @@ int SDL_main(int argc, char* argv[])
|
|||
lua_pushcfunction(L, luaopen_ggelua);
|
||||
lua_setfield(L, -2, "ggelua");
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
||||
if (lua_getfield(L, LUA_REGISTRYINDEX, "ggelua.lua")==LUA_TSTRING){
|
||||
size_t coresize;
|
||||
const char* ggelua = lua_tolstring(L, -1, &coresize);
|
||||
|
|
|
@ -52,9 +52,9 @@ static int LUA_UTF82ANSI(lua_State *L){
|
|||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GetRunPath(lua_State *L) {
|
||||
#ifdef __WIN32__
|
||||
static int LUA_GetRunPath(lua_State *L) {
|
||||
|
||||
luaL_Buffer b;
|
||||
char *p;
|
||||
DWORD n;
|
||||
|
@ -63,12 +63,11 @@ static int LUA_GetRunPath(lua_State *L) {
|
|||
p[n] = 0;
|
||||
luaL_pushresultsize(&b,strrchr(p, '\\')-p); /* close buffer */
|
||||
LUA_ANSI2UTF8(L);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GetCurPath(lua_State *L) {
|
||||
#ifdef __WIN32__
|
||||
luaL_Buffer b;
|
||||
char* p;
|
||||
DWORD n;
|
||||
|
@ -76,21 +75,19 @@ static int LUA_GetCurPath(lua_State *L) {
|
|||
n = GetCurrentDirectory(LUAL_BUFFERSIZE, p);
|
||||
luaL_pushresultsize(&b,n); /* close buffer */
|
||||
LUA_ANSI2UTF8(L);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_SetCurPath(lua_State *L) {
|
||||
#ifdef __WIN32__
|
||||
const char* str;
|
||||
LUA_UTF82ANSI(L);
|
||||
str = luaL_checkstring(L,-1);
|
||||
|
||||
lua_pushboolean(L,SetCurrentDirectory(str));
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
char* ggelua = NULL;//Æô¶¯½Å±¾
|
||||
size_t coresize;
|
||||
char* ggepack = NULL;//´ò°ü½Å±¾
|
||||
|
@ -143,7 +140,7 @@ static int LUA_StateThread(void * entry){
|
|||
lua_close(L);
|
||||
return 0;
|
||||
}
|
||||
//SDL
|
||||
//主要用于服务端创建
|
||||
static int LUA_NewState(lua_State *L) {
|
||||
const char*init = luaL_checkstring(L,1);
|
||||
if (lua_getfield(L, LUA_REGISTRYINDEX, "ggelua.lua") == LUA_TSTRING){
|
||||
|
@ -219,22 +216,24 @@ static int LUA_GetPlatform(lua_State *L){
|
|||
}
|
||||
|
||||
static const luaL_Reg fun_list[] = {
|
||||
{"ansitoutf8" , LUA_ANSI2UTF8} ,
|
||||
{"utf8toansi" , LUA_UTF82ANSI} ,
|
||||
{"getcurpath" , LUA_GetCurPath} ,
|
||||
{"setcurpath" , LUA_SetCurPath} ,
|
||||
{"getrunpath" , LUA_GetRunPath} ,
|
||||
{"newstate" , LUA_NewState} ,
|
||||
{"ansitoutf8" , LUA_ANSI2UTF8},
|
||||
{"utf8toansi" , LUA_UTF82ANSI},
|
||||
#ifdef __WIN32__
|
||||
{"getcurpath" , LUA_GetCurPath},
|
||||
{"setcurpath" , LUA_SetCurPath},
|
||||
{"getrunpath" , LUA_GetRunPath},
|
||||
#endif
|
||||
{"newstate" , LUA_NewState},
|
||||
|
||||
{"delay" , LUA_Delay} ,
|
||||
{"messagebox" , LUA_MessageBox} ,
|
||||
{"delay" , LUA_Delay},
|
||||
{"messagebox" , LUA_MessageBox},
|
||||
{"setclipboardtext", LUA_SetClipboardText},
|
||||
{"getclipboardtext", LUA_GetClipboardText},
|
||||
{"hasclipboardtext", LUA_HasClipboardText},
|
||||
{"getbasepath", LUA_GetBasePath},
|
||||
{"getprefpath", LUA_GetPrefPath},
|
||||
{"getplatform", LUA_GetPlatform},
|
||||
{NULL , NULL}
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static const luaL_Reg lib_list[] = {
|
||||
|
|
|
@ -34,7 +34,7 @@ static int LUA_GameControllerNumMappings(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerMappingForIndex(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
char* r = SDL_GameControllerMappingForIndex(index);
|
||||
if (r) {
|
||||
lua_pushstring(L, r);
|
||||
|
@ -71,7 +71,7 @@ static int LUA_GameControllerMapping(lua_State* L)
|
|||
|
||||
static int LUA_IsGameController(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
lua_pushboolean(L,SDL_IsGameController(index));
|
||||
|
||||
return 1;
|
||||
|
@ -79,7 +79,7 @@ static int LUA_IsGameController(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerNameForIndex(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
const char* r = SDL_GameControllerNameForIndex(index);
|
||||
if (r)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ static int LUA_GameControllerNameForIndex(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerTypeForIndex(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
SDL_GameControllerType r = SDL_GameControllerTypeForIndex(index);
|
||||
lua_pushinteger(L, r);
|
||||
return 1;
|
||||
|
@ -99,7 +99,7 @@ static int LUA_GameControllerTypeForIndex(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerMappingForDeviceIndex(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
char* r = SDL_GameControllerMappingForDeviceIndex(index);
|
||||
if (r)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ static int LUA_GameControllerMappingForDeviceIndex(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerOpen(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
SDL_GameController* gc = SDL_GameControllerOpen(index);
|
||||
if (gc) {
|
||||
SDL_GameController** ud = (SDL_GameController**)lua_newuserdata(L, sizeof(SDL_GameController*));
|
||||
|
@ -138,7 +138,7 @@ static int LUA_GameControllerFromInstanceID(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerFromPlayerIndex(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
SDL_GameController* gc = SDL_GameControllerFromPlayerIndex(index);
|
||||
if (gc) {
|
||||
SDL_GameController** ud = (SDL_GameController**)lua_newuserdata(L, sizeof(SDL_GameController*));
|
||||
|
@ -233,7 +233,7 @@ static int LUA_GameControllerGetJoystick(lua_State *L)
|
|||
|
||||
static int LUA_GameControllerEventState(lua_State *L)
|
||||
{
|
||||
int s = luaL_checkinteger(L, 1);//SDL_QUERY
|
||||
int s = (int)luaL_checkinteger(L, 1);//SDL_QUERY
|
||||
lua_pushinteger(L, SDL_GameControllerEventState(s));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
//TextureÈ¡ÏñËØ
|
||||
int GGE_GetTexturePixel(lua_State *L)
|
||||
{
|
||||
GGE_Texture * tex = (GGE_Texture*)luaL_checkudata(L, 1, "SDL_Texture");
|
||||
GGE_Texture * ud = (GGE_Texture*)luaL_checkudata(L, 1, "SDL_Texture");
|
||||
int x = (int)luaL_checkinteger(L,2);
|
||||
int y = (int)luaL_checkinteger(L,3);
|
||||
Uint32 format;
|
||||
int access, w, h;
|
||||
if (!tex->rect && SDL_QueryTexture(tex->tex , &format, &access, &w, &h)==0 &&
|
||||
if (!ud->rect && SDL_QueryTexture(ud->tex , &format, &access, &w, &h)==0 &&
|
||||
access==SDL_TEXTUREACCESS_STREAMING && x>=0 && y>=0 && x<w && y<h){
|
||||
if(!tex->locked){
|
||||
SDL_LockTexture(tex->tex,NULL,(void**)&tex->pixels,&tex->pitch);
|
||||
tex->locked = 1;
|
||||
if(!ud->locked){
|
||||
SDL_LockTexture(ud->tex,NULL,(void**)&ud->pixels,&ud->pitch);
|
||||
ud->locked = 1;
|
||||
}
|
||||
if (!tex->format)
|
||||
tex->format = SDL_AllocFormat(format);
|
||||
if (!ud->format)
|
||||
ud->format = SDL_AllocFormat(format);
|
||||
{
|
||||
Uint8 r,g,b,a;
|
||||
int bpp = tex->format->BytesPerPixel;
|
||||
Uint8 *p = (Uint8 *)tex->pixels + y * tex->pitch + x * bpp;
|
||||
int bpp = ud->format->BytesPerPixel;
|
||||
Uint8 *p = (Uint8 *)ud->pixels + y * ud->pitch + x * bpp;
|
||||
switch (bpp) {
|
||||
case 2:{
|
||||
SDL_GetRGBA(*(Uint16 *)p,tex->format,&r,&g,&b,&a);
|
||||
SDL_GetRGBA(*(Uint16 *)p,ud->format,&r,&g,&b,&a);
|
||||
lua_pushinteger(L,a);
|
||||
lua_pushinteger(L,r);
|
||||
lua_pushinteger(L,g);
|
||||
|
@ -32,7 +32,7 @@ int GGE_GetTexturePixel(lua_State *L)
|
|||
}
|
||||
case 3:{}
|
||||
case 4:{
|
||||
SDL_GetRGBA(*(Uint32 *)p,tex->format,&r,&g,&b,&a);
|
||||
SDL_GetRGBA(*(Uint32 *)p,ud->format,&r,&g,&b,&a);
|
||||
lua_pushinteger(L,a);
|
||||
lua_pushinteger(L,r);
|
||||
lua_pushinteger(L,g);
|
||||
|
@ -51,7 +51,7 @@ int GGE_GetTexturePixel(lua_State *L)
|
|||
//TextureÖÃÏñËØ
|
||||
int LUA_SetTexturePixel(lua_State *L)
|
||||
{
|
||||
GGE_Texture * tex = (GGE_Texture*)luaL_checkudata(L, 1, "SDL_Texture");
|
||||
GGE_Texture * ud = (GGE_Texture*)luaL_checkudata(L, 1, "SDL_Texture");
|
||||
int x = (int)luaL_checkinteger(L,2);
|
||||
int y = (int)luaL_checkinteger(L,3);
|
||||
int r = (int)luaL_optinteger(L,4,0);
|
||||
|
@ -61,24 +61,24 @@ int LUA_SetTexturePixel(lua_State *L)
|
|||
Uint32 format;
|
||||
int access, w, h;
|
||||
|
||||
if (!tex->rect && SDL_QueryTexture(tex->tex , &format, &access, &w, &h)==0 &&
|
||||
if (!ud->rect && SDL_QueryTexture(ud->tex , &format, &access, &w, &h)==0 &&
|
||||
access==SDL_TEXTUREACCESS_STREAMING && x>=0 && y>=0 && x<w && y<h){
|
||||
if(!tex->locked){
|
||||
SDL_LockTexture(tex->tex,NULL, (void**)&tex->pixels,&tex->pitch);
|
||||
tex->locked = 1;
|
||||
if(!ud->locked){
|
||||
SDL_LockTexture(ud->tex,NULL, (void**)&ud->pixels,&ud->pitch);
|
||||
ud->locked = 1;
|
||||
}
|
||||
if (!tex->format)
|
||||
tex->format = SDL_AllocFormat(format);
|
||||
if (!ud->format)
|
||||
ud->format = SDL_AllocFormat(format);
|
||||
|
||||
{
|
||||
int bpp = tex->format->BytesPerPixel;
|
||||
Uint8 *p = (Uint8 *)tex->pixels + y * tex->pitch + x * bpp;
|
||||
int bpp = ud->format->BytesPerPixel;
|
||||
Uint8 *p = (Uint8 *)ud->pixels + y * ud->pitch + x * bpp;
|
||||
switch (bpp) {
|
||||
case 2:
|
||||
*(Uint16 *)p = SDL_MapRGBA(tex->format,r,g,b,a);
|
||||
*(Uint16 *)p = SDL_MapRGBA(ud->format,r,g,b,a);
|
||||
case 3:{}
|
||||
case 4:
|
||||
*(Uint32 *)p = SDL_MapRGBA(tex->format,r,g,b,a);
|
||||
*(Uint32 *)p = SDL_MapRGBA(ud->format,r,g,b,a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,42 +88,42 @@ int LUA_SetTexturePixel(lua_State *L)
|
|||
//Texture»Ò¶È
|
||||
int GGE_TextureToGrayscale(lua_State *L)
|
||||
{
|
||||
GGE_Texture * tex = (GGE_Texture*)luaL_checkudata(L, 1, "SDL_Texture");
|
||||
GGE_Texture * ud = (GGE_Texture*)luaL_checkudata(L, 1, "SDL_Texture");
|
||||
Uint32 format;
|
||||
int access, w, h;
|
||||
|
||||
if (!tex->rect && SDL_QueryTexture(tex->tex , &format, &access, &w, &h)==0 && access==SDL_TEXTUREACCESS_STREAMING){
|
||||
if (!ud->rect && SDL_QueryTexture(ud->tex , &format, &access, &w, &h)==0 && access==SDL_TEXTUREACCESS_STREAMING){
|
||||
int i;
|
||||
Uint8 r,g,b,a,gray;
|
||||
if(!tex->locked)
|
||||
SDL_LockTexture(tex->tex,NULL,(void**)&tex->pixels,&tex->pitch);
|
||||
if (!tex->format)
|
||||
tex->format = SDL_AllocFormat(format);
|
||||
if(!ud->locked)
|
||||
SDL_LockTexture(ud->tex,NULL,(void**)&ud->pixels,&ud->pitch);
|
||||
if (!ud->format)
|
||||
ud->format = SDL_AllocFormat(format);
|
||||
//SDL_ConvertPixels
|
||||
switch (tex->format->BitsPerPixel) {
|
||||
switch (ud->format->BitsPerPixel) {
|
||||
case 16:{
|
||||
Uint16 *pixels16 = (Uint16 *)tex->pixels;
|
||||
Uint16 *pixels16 = (Uint16 *)ud->pixels;
|
||||
for (i=0;i<w*h;i++)
|
||||
{
|
||||
SDL_GetRGBA(pixels16[i],tex->format,&r,&g,&b,&a);
|
||||
SDL_GetRGBA(pixels16[i],ud->format,&r,&g,&b,&a);
|
||||
gray = (r + (g<<1) + b) >> 2;
|
||||
pixels16[i] = SDL_MapRGBA(tex->format,gray,gray,gray,a);
|
||||
pixels16[i] = SDL_MapRGBA(ud->format,gray,gray,gray,a);
|
||||
}
|
||||
}
|
||||
case 32:{
|
||||
Uint32 *pixels32 = (Uint32 *)tex->pixels;
|
||||
Uint32 *pixels32 = (Uint32 *)ud->pixels;
|
||||
for (i=0;i<w*h;i++)
|
||||
{
|
||||
SDL_GetRGBA(pixels32[i],tex->format,&r,&g,&b,&a);
|
||||
SDL_GetRGBA(pixels32[i],ud->format,&r,&g,&b,&a);
|
||||
gray = (r + (g<<1) + b) >> 2;
|
||||
pixels32[i] = SDL_MapRGBA(tex->format,gray,gray,gray,a);
|
||||
pixels32[i] = SDL_MapRGBA(ud->format,gray,gray,gray,a);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tex->format)
|
||||
SDL_FreeFormat(tex->format);
|
||||
tex->format = NULL;
|
||||
SDL_UnlockTexture(tex->tex);
|
||||
if (ud->format)
|
||||
SDL_FreeFormat(ud->format);
|
||||
ud->format = NULL;
|
||||
SDL_UnlockTexture(ud->tex);
|
||||
lua_pushboolean(L,1);
|
||||
}else
|
||||
lua_pushboolean(L,0);
|
||||
|
@ -269,6 +269,7 @@ int GGE_SetParent(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const luaL_Reg window_funcs[] = {
|
||||
#ifdef _WIN32
|
||||
{"SetParent",GGE_SetParent},
|
||||
|
|
|
@ -13,10 +13,16 @@ typedef struct
|
|||
SDL_Rect* rect;
|
||||
Uint8* pixels;
|
||||
int pitch;
|
||||
int nofree;
|
||||
int nofree;//RenderTarget
|
||||
SDL_PixelFormat *format;
|
||||
}GGE_Texture;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* ptr;
|
||||
size_t size;
|
||||
}GGE_Mem;
|
||||
|
||||
int bind_gge(lua_State* L);
|
||||
int bind_video(lua_State *L);
|
||||
int bind_renderer(lua_State *L);
|
||||
|
|
|
@ -102,10 +102,10 @@ static int LUA_StopTextInput(lua_State *L){
|
|||
|
||||
static int LUA_SetTextInputRect(lua_State *L){
|
||||
SDL_Rect rect;
|
||||
rect.x = luaL_checkinteger(L, 1);
|
||||
rect.y = luaL_checkinteger(L, 2);
|
||||
rect.w = luaL_checkinteger(L, 3);
|
||||
rect.h = luaL_checkinteger(L, 4);
|
||||
rect.x = (int)luaL_checkinteger(L, 1);
|
||||
rect.y = (int)luaL_checkinteger(L, 2);
|
||||
rect.w = (int)luaL_checkinteger(L, 3);
|
||||
rect.h = (int)luaL_checkinteger(L, 4);
|
||||
|
||||
SDL_SetTextInputRect(&rect);
|
||||
return 0;
|
||||
|
|
|
@ -145,7 +145,9 @@ static int LUA_PixelFormatIndex(lua_State *L)
|
|||
|
||||
if (SDL_strcmp(name, "format") == 0) {
|
||||
lua_pushinteger(L,pf->format);
|
||||
} else if (SDL_strcmp(name, "palette") == 0) {
|
||||
}else if (SDL_strcmp(name, "name") == 0) {
|
||||
lua_pushstring(L, SDL_GetPixelFormatName(pf->format));
|
||||
//} else if (SDL_strcmp(name, "palette") == 0) {
|
||||
|
||||
} else if (SDL_strcmp(name, "BitsPerPixel") == 0) {//λÉî
|
||||
lua_pushinteger(L,pf->BitsPerPixel);
|
||||
|
@ -189,12 +191,11 @@ static int LUA_PixelFormatIndex(lua_State *L)
|
|||
|
||||
static const luaL_Reg pixels_funcs[] = {
|
||||
{"__gc" , LUA_FreeFormat} ,
|
||||
{"__close" , LUA_FreeFormat} ,
|
||||
{"__close" , LUA_FreeFormat} ,
|
||||
{"GetRGB" , LUA_GetRGB} ,
|
||||
{"GetRGBA" , LUA_GetRGBA} ,
|
||||
{"MapRGB" , LUA_MapRGB} ,
|
||||
{"MapRGBA" , LUA_MapRGBA} ,
|
||||
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -202,7 +203,7 @@ static const luaL_Reg sdl_funcs[] = {
|
|||
{"AllocFormat" , LUA_AllocFormat} , //new SDL_PixelFormat
|
||||
{"AllocPalette" , LUA_AllocPalette} ,
|
||||
{"CalculateGammaRamp" , LUA_CalculateGammaRamp} ,
|
||||
{"FreePalette" , LUA_FreePalette} ,
|
||||
//{"FreePalette" , LUA_FreePalette} ,
|
||||
{"GetPixelFormatName" , LUA_GetPixelFormatName} ,
|
||||
|
||||
{"MasksToPixelFormatEnum" , LUA_MasksToPixelFormatEnum} ,
|
||||
|
|
|
@ -82,8 +82,8 @@ static int LUA_PointInRect(lua_State *L)
|
|||
{
|
||||
SDL_Rect * rect = (SDL_Rect*)luaL_checkudata(L, 1, "SDL_Rect");
|
||||
SDL_Point p;
|
||||
p.x = luaL_checkinteger(L,2);
|
||||
p.y = luaL_checkinteger(L,3);
|
||||
p.x = (int)luaL_checkinteger(L,2);
|
||||
p.y = (int)luaL_checkinteger(L,3);
|
||||
lua_pushboolean(L,SDL_PointInRect(&p, rect));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -802,8 +802,6 @@ static const luaL_Reg texture_funcs[] = {
|
|||
{"LockTextureToSurface" , LUA_LockTextureToSurface} ,
|
||||
{"UnlockTexture" , LUA_UnlockTexture} ,
|
||||
|
||||
//int LUA_UpdateTexture
|
||||
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ static int LUA_RWFromFile(lua_State *L)
|
|||
{
|
||||
const char *file = luaL_checkstring(L, 1);
|
||||
const char *mode = luaL_optstring(L, 2,"r");
|
||||
SDL_RWops *ops = SDL_RWFromFile(file, mode);
|
||||
if (ops){
|
||||
SDL_RWops *rwf = SDL_RWFromFile(file, mode);
|
||||
if (rwf){
|
||||
SDL_RWops **ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = ops;
|
||||
*ud = rwf;
|
||||
luaL_setmetatable(L, "SDL_RWops");
|
||||
return 1;
|
||||
}
|
||||
|
@ -17,14 +17,14 @@ static int LUA_RWFromFile(lua_State *L)
|
|||
|
||||
static int LUA_RWFromFP(lua_State *L)
|
||||
{
|
||||
luaL_Stream * p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
|
||||
if (p->f)
|
||||
luaL_Stream * ls = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
|
||||
if (ls->f)
|
||||
{
|
||||
SDL_RWops *ops = SDL_RWFromFP(p->f,SDL_FALSE);
|
||||
if (ops)
|
||||
SDL_RWops *rwf = SDL_RWFromFP(ls->f,SDL_FALSE);
|
||||
if (rwf)
|
||||
{
|
||||
SDL_RWops **ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = ops;
|
||||
*ud = rwf;
|
||||
luaL_setmetatable(L, "SDL_RWops");
|
||||
return 1;
|
||||
}
|
||||
|
@ -36,10 +36,11 @@ static int LUA_RWFromMem(lua_State *L)
|
|||
{
|
||||
void* mem = lua_touserdata(L,1);
|
||||
int size = (int)luaL_checkinteger(L,2);
|
||||
SDL_RWops *ops = SDL_RWFromMem(mem,size);
|
||||
if (ops){
|
||||
SDL_RWops *rwf = SDL_RWFromMem(mem,size);
|
||||
|
||||
if (rwf){
|
||||
SDL_RWops **ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = ops;
|
||||
*ud = rwf;
|
||||
luaL_setmetatable(L, "SDL_RWops");
|
||||
return 1;
|
||||
}
|
||||
|
@ -51,11 +52,11 @@ static int LUA_RWFromConstMem(lua_State *L)
|
|||
{
|
||||
const void * mem = lua_topointer(L,1);
|
||||
int size = (int)luaL_checkinteger(L,2);
|
||||
SDL_RWops *ops = SDL_RWFromConstMem(mem,size);
|
||||
SDL_RWops **ud;
|
||||
if (ops){
|
||||
ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = ops;
|
||||
SDL_RWops *rwf = SDL_RWFromConstMem(mem,size);
|
||||
|
||||
if (rwf){
|
||||
SDL_RWops** ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = rwf;
|
||||
luaL_setmetatable(L, "SDL_RWops");
|
||||
return 1;
|
||||
}
|
||||
|
@ -66,11 +67,11 @@ static int LUA_RWFromStr(lua_State *L)
|
|||
{
|
||||
size_t size;
|
||||
const void* mem = (void*)luaL_checklstring(L,1,&size);
|
||||
SDL_RWops *ops = SDL_RWFromConstMem(mem,(int)size);
|
||||
SDL_RWops **ud;
|
||||
if (ops){
|
||||
ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = ops;
|
||||
SDL_RWops *rwf = SDL_RWFromConstMem(mem,(int)size);
|
||||
|
||||
if (rwf){
|
||||
SDL_RWops** ud = (SDL_RWops**)lua_newuserdata(L, sizeof (SDL_RWops*));
|
||||
*ud = rwf;
|
||||
luaL_setmetatable(L, "SDL_RWops");
|
||||
return 1;
|
||||
}
|
||||
|
@ -80,11 +81,11 @@ static int LUA_RWFromStr(lua_State *L)
|
|||
|
||||
static int LUA_AllocRW(lua_State* L)
|
||||
{
|
||||
SDL_RWops* ops = SDL_AllocRW();
|
||||
SDL_RWops** ud;
|
||||
if (ops) {
|
||||
ud = (SDL_RWops**)lua_newuserdata(L, sizeof(SDL_RWops*));
|
||||
*ud = ops;
|
||||
SDL_RWops* rwf = SDL_AllocRW();
|
||||
|
||||
if (rwf) {
|
||||
SDL_RWops** ud = (SDL_RWops**)lua_newuserdata(L, sizeof(SDL_RWops*));
|
||||
*ud = rwf;
|
||||
luaL_setmetatable(L, "SDL_RWops");
|
||||
return 1;
|
||||
}
|
||||
|
@ -93,96 +94,98 @@ static int LUA_AllocRW(lua_State* L)
|
|||
|
||||
static int LUA_FreeRW(lua_State* L)
|
||||
{
|
||||
SDL_RWops* ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_FreeRW(ops);
|
||||
SDL_RWops* rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_FreeRW(rwf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_RWsize(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_RWops * rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
|
||||
lua_pushinteger(L,SDL_RWsize(ops));
|
||||
lua_pushinteger(L,SDL_RWsize(rwf));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_RWseek(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_RWops * rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
Sint64 offset = luaL_checkinteger(L, 2);
|
||||
int whence = (int)luaL_optinteger(L, 3, RW_SEEK_SET);
|
||||
|
||||
lua_pushboolean(L,SDL_RWseek(ops, offset, whence)!=-1);
|
||||
lua_pushboolean(L,SDL_RWseek(rwf, offset, whence)!=-1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_RWtell(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_RWops * rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
|
||||
lua_pushinteger(L,SDL_RWtell(ops));
|
||||
lua_pushinteger(L,SDL_RWtell(rwf));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_RWread(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_RWops * rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
size_t size = luaL_checkinteger(L, 2);
|
||||
luaL_Buffer b;
|
||||
char *ptr = luaL_buffinitsize(L, &b,size);
|
||||
size_t nr = SDL_RWread(ops,ptr,sizeof(char),size);
|
||||
size_t nr = SDL_RWread(rwf,ptr,sizeof(char),size);
|
||||
luaL_addsize(&b, nr);
|
||||
|
||||
luaL_pushresult(&b); /* close buffer */
|
||||
luaL_pushresult(&b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_RWwrite(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
SDL_RWops * rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
size_t size;
|
||||
const char *ptr = luaL_checklstring(L, 2, &size);
|
||||
|
||||
lua_pushinteger(L,SDL_RWwrite(ops, ptr, size, 1));
|
||||
lua_pushinteger(L,SDL_RWwrite(rwf, ptr, size, 1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_RWclose(lua_State *L)
|
||||
{
|
||||
SDL_RWops ** ops = (SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
if (*ops)
|
||||
SDL_RWops ** rwf = (SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
if (*rwf)
|
||||
{
|
||||
SDL_RWclose(*ops);
|
||||
*ops = NULL;
|
||||
SDL_RWclose(*rwf);
|
||||
*rwf = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LoadFile_RW(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
|
||||
|
||||
return 0;
|
||||
SDL_RWops * rwf = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
size_t datasize;
|
||||
void* data = SDL_LoadFile_RW(rwf, &datasize, 0);
|
||||
lua_pushlstring(L, data, datasize);
|
||||
SDL_free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_LoadFile(lua_State *L)
|
||||
{
|
||||
const char *file = luaL_checkstring(L, 1);
|
||||
SDL_RWops *ops = SDL_RWFromFile(file, "r");
|
||||
SDL_RWops *rwf = SDL_RWFromFile(file, "r");
|
||||
size_t nr;
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
do { /* read file in chunks of LUAL_BUFFERSIZE bytes */
|
||||
char *p = luaL_prepbuffer(&b);
|
||||
nr = SDL_RWread(ops,p,sizeof(char),LUAL_BUFFERSIZE);
|
||||
nr = SDL_RWread(rwf,p,sizeof(char),LUAL_BUFFERSIZE);
|
||||
luaL_addsize(&b, nr);
|
||||
} while (nr == LUAL_BUFFERSIZE);
|
||||
luaL_pushresult(&b); /* close buffer */
|
||||
SDL_RWclose(ops);
|
||||
SDL_RWclose(rwf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Read
|
||||
static int LUA_ReadU8(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
|
@ -238,7 +241,7 @@ static int LUA_ReadBE64(lua_State *L)
|
|||
lua_pushinteger(L,SDL_ReadBE64(ops));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Write
|
||||
static int LUA_WriteU8(lua_State *L)
|
||||
{
|
||||
SDL_RWops * ops = *(SDL_RWops**)luaL_checkudata(L, 1, "SDL_RWops");
|
||||
|
@ -310,6 +313,7 @@ static const luaL_Reg rwops_funcs[] = {
|
|||
{"RWtell" , LUA_RWtell} ,
|
||||
{"RWread" , LUA_RWread} ,
|
||||
{"RWwrite" , LUA_RWwrite} ,
|
||||
{"LoadFile" , LUA_LoadFile_RW} ,
|
||||
|
||||
{"ReadU8" , LUA_ReadU8} ,
|
||||
{"ReadBE16" , LUA_ReadBE16} ,
|
||||
|
@ -338,7 +342,7 @@ static const luaL_Reg sdl_funcs[] = {
|
|||
{"RWFromStr" , LUA_RWFromStr} ,
|
||||
{"AllocRW" , LUA_AllocRW} ,
|
||||
{"FreeRW" , LUA_FreeRW} ,
|
||||
{"LoadFile_RW" , LUA_LoadFile_RW} ,
|
||||
|
||||
{"LoadFile" , LUA_LoadFile} ,
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
|
|
@ -54,6 +54,7 @@ LUAMOD_API int luaopen_gsdl2(lua_State *L)
|
|||
luaL_newmetatable(L, "SDL_Surface"); lua_pop(L, 1);
|
||||
luaL_newmetatable(L, "SDL_Texture"); lua_pop(L, 1);
|
||||
luaL_newmetatable(L, "SDL_Renderer"); lua_pop(L, 1);
|
||||
|
||||
luaL_newlib(L,sdl_funcs);
|
||||
|
||||
bind_gge(L);
|
||||
|
|
|
@ -1,31 +1,92 @@
|
|||
#include "gge.h"
|
||||
|
||||
int LUA_malloc(lua_State *L)
|
||||
static int LUA_malloc(lua_State *L)
|
||||
{
|
||||
size_t size = luaL_checkinteger(L,1);
|
||||
void** ud = (void**)lua_newuserdata(L,sizeof(void*));
|
||||
*ud = SDL_malloc(size);
|
||||
luaL_setmetatable(L, "SDL_malloc");
|
||||
GGE_Mem* ud = (GGE_Mem*)lua_newuserdata(L, sizeof(GGE_Mem));
|
||||
|
||||
if (size>0)
|
||||
ud->ptr = (char*)SDL_malloc(size);
|
||||
else
|
||||
ud->ptr = 0;
|
||||
|
||||
ud->size = size;
|
||||
luaL_setmetatable(L, "SDL_mem");
|
||||
return 1;
|
||||
}
|
||||
int LUA_calloc(lua_State *L)
|
||||
|
||||
static int LUA_calloc(lua_State *L)
|
||||
{
|
||||
size_t nmemb = luaL_checkinteger(L,1);
|
||||
size_t size = luaL_checkinteger(L,2);
|
||||
lua_pushlightuserdata(L,SDL_calloc(nmemb,size));
|
||||
return 1;
|
||||
}
|
||||
//SDL_realloc
|
||||
int LUA_free(lua_State *L)
|
||||
{
|
||||
void** ud = (void**)luaL_checkudata(L, 1, "SDL_malloc");
|
||||
|
||||
SDL_free(*ud);
|
||||
if (nmemb>0 && size>0)
|
||||
{
|
||||
GGE_Mem* ud = (GGE_Mem*)lua_newuserdata(L, sizeof(GGE_Mem));
|
||||
ud->ptr = (char*)SDL_calloc(nmemb,size);
|
||||
ud->size = nmemb*size;
|
||||
luaL_setmetatable(L, "SDL_mem");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_realloc(lua_State* L)
|
||||
{
|
||||
GGE_Mem* ud = (GGE_Mem*)luaL_checkudata(L, 1, "SDL_mem");
|
||||
size_t size = luaL_checkinteger(L, 2);
|
||||
ud->ptr = SDL_realloc(ud->ptr, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_free(lua_State *L)
|
||||
{
|
||||
GGE_Mem* ud = (GGE_Mem*)luaL_checkudata(L, 1, "SDL_mem");
|
||||
if (ud->ptr)
|
||||
{
|
||||
SDL_free(ud->ptr);
|
||||
ud->ptr = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_getsize(lua_State* L)
|
||||
{
|
||||
GGE_Mem* ud = (GGE_Mem*)luaL_checkudata(L, 1, "SDL_mem");
|
||||
lua_pushinteger(L, ud->size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_getptr(lua_State* L)
|
||||
{
|
||||
GGE_Mem* ud = (GGE_Mem*)luaL_checkudata(L, 1, "SDL_mem");
|
||||
int offset = (int)luaL_optinteger(L, 2, 0);
|
||||
if (!ud->ptr)
|
||||
return 0;
|
||||
lua_pushlightuserdata(L, ud->ptr + offset);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg mem_funcs[] = {
|
||||
{ "realloc", LUA_realloc},
|
||||
{ "getsize", LUA_getsize},
|
||||
{ "getptr", LUA_getptr},
|
||||
{ "__gc", LUA_free}
|
||||
};
|
||||
|
||||
static const luaL_Reg sdl_funcs[] = {
|
||||
{ "malloc", LUA_malloc},
|
||||
{ "calloc", LUA_calloc},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
||||
int bind_stdinc(lua_State* L)
|
||||
{
|
||||
luaL_newmetatable(L, "SDL_mem");
|
||||
luaL_setfuncs(L, mem_funcs, 0);
|
||||
lua_pushvalue(L, -1);//Ö¸Ïò×Ô¼º
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_pop(L, 1);
|
||||
|
||||
luaL_setfuncs(L, sdl_funcs, 0);
|
||||
return 0;
|
||||
}
|
|
@ -457,7 +457,7 @@ static int LUA_GetYUVConversionModeForResolution(lua_State *L)
|
|||
static int LUA_SetSurfaceRef(lua_State* L)
|
||||
{
|
||||
SDL_Surface* sf = *(SDL_Surface**)luaL_checkudata(L, 1, "SDL_Surface");
|
||||
int ref = luaL_checkinteger(L, 2);
|
||||
int ref = (int)luaL_checkinteger(L, 2);
|
||||
sf->refcount = ref;
|
||||
return 0;
|
||||
}
|
||||
|
@ -473,6 +473,8 @@ static int LUA_SurfaceIndex(lua_State *L)
|
|||
*ud = sf->format;
|
||||
luaL_setmetatable(L, "SDL_PixelFormat");
|
||||
return 1;
|
||||
}else if (SDL_strcmp(key, "formatname") == 0) {
|
||||
lua_pushstring(L, SDL_GetPixelFormatName(sf->format->format));
|
||||
} else if (SDL_strcmp(key, "w") == 0) {
|
||||
lua_pushinteger(L,sf->w);
|
||||
} else if (SDL_strcmp(key, "h") == 0) {
|
||||
|
@ -522,9 +524,9 @@ static const luaL_Reg surface_funcs[] = {
|
|||
{"SoftStretch" , LUA_SoftStretch} ,
|
||||
{"UpperBlitScaled" , LUA_UpperBlitScaled} , //SDL_UpperBlitScaled
|
||||
{"LowerBlitScaled" , LUA_LowerBlitScaled} ,
|
||||
{"SetYUVConversionMode" , LUA_SetYUVConversionMode} ,
|
||||
{"GetYUVConversionMode" , LUA_GetYUVConversionMode} ,
|
||||
{"GetYUVConversionModeForResolution" , LUA_GetYUVConversionModeForResolution} ,
|
||||
//{"SetYUVConversionMode" , LUA_SetYUVConversionMode} ,
|
||||
//{"GetYUVConversionMode" , LUA_GetYUVConversionMode} ,
|
||||
//{"GetYUVConversionModeForResolution" , LUA_GetYUVConversionModeForResolution} ,
|
||||
|
||||
{"SetSurfaceRef" , LUA_SetSurfaceRef} ,
|
||||
{ NULL, NULL}
|
||||
|
|
Loading…
Reference in New Issue