aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-08-07 12:56:28 +0800
committerchai <chaifix@163.com>2018-08-07 12:56:28 +0800
commit35d0affb2b19a38ae43ac991021dd3c888dc3aa6 (patch)
tree378e1a6bf6fec56568dcec6aac15c4426f1f9375
parentdf24addf48a6de2c4ef4e1723ae7d9c1d261dabe (diff)
*update
-rw-r--r--build/.vs/libjin/v14/.suobin121856 -> 135168 bytes
-rw-r--r--build/02Audio/02Audio.vcxproj2
-rw-r--r--build/02Audio/02Audio.vcxproj.filters2
-rw-r--r--build/03Thread/03Thread.vcxproj3
-rw-r--r--build/03Thread/03Thread.vcxproj.filters5
-rw-r--r--build/03Thread/main.cpp154
-rw-r--r--build/04Network/04Network.vcxproj133
-rw-r--r--build/04Network/04Network.vcxproj.filters22
-rw-r--r--build/libjin.sln10
-rw-r--r--test/02Audio/main.cpp (renamed from test/02Audio/audiotest.cpp)0
-rw-r--r--test/03Thread/main.cpp (renamed from test/03Thread/threadtest.cpp)0
-rw-r--r--test/04Network/main.cpp83
12 files changed, 252 insertions, 162 deletions
diff --git a/build/.vs/libjin/v14/.suo b/build/.vs/libjin/v14/.suo
index cf42b3a..4ee2374 100644
--- a/build/.vs/libjin/v14/.suo
+++ b/build/.vs/libjin/v14/.suo
Binary files differ
diff --git a/build/02Audio/02Audio.vcxproj b/build/02Audio/02Audio.vcxproj
index a06df79..5aa3542 100644
--- a/build/02Audio/02Audio.vcxproj
+++ b/build/02Audio/02Audio.vcxproj
@@ -120,7 +120,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\..\test\02Audio\audiotest.cpp" />
+ <ClCompile Include="..\..\test\02Audio\main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\libjin\libjin.vcxproj">
diff --git a/build/02Audio/02Audio.vcxproj.filters b/build/02Audio/02Audio.vcxproj.filters
index 30ce2ab..29e09e3 100644
--- a/build/02Audio/02Audio.vcxproj.filters
+++ b/build/02Audio/02Audio.vcxproj.filters
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\test\02Audio\audiotest.cpp">
+ <ClCompile Include="..\..\test\02Audio\main.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
diff --git a/build/03Thread/03Thread.vcxproj b/build/03Thread/03Thread.vcxproj
index ddd8193..6cad582 100644
--- a/build/03Thread/03Thread.vcxproj
+++ b/build/03Thread/03Thread.vcxproj
@@ -125,8 +125,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\test\03Thread\threadtest.cpp" />
- <ClCompile Include="main.cpp" />
+ <ClCompile Include="..\..\test\03Thread\main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/build/03Thread/03Thread.vcxproj.filters b/build/03Thread/03Thread.vcxproj.filters
index d0d38cf..a9c0e02 100644
--- a/build/03Thread/03Thread.vcxproj.filters
+++ b/build/03Thread/03Thread.vcxproj.filters
@@ -15,10 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\test\03Thread\threadtest.cpp">
- <Filter>源文件</Filter>
- </ClCompile>
- <ClCompile Include="main.cpp">
+ <ClCompile Include="..\..\test\03Thread\main.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
diff --git a/build/03Thread/main.cpp b/build/03Thread/main.cpp
deleted file mode 100644
index ed12172..0000000
--- a/build/03Thread/main.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-//#include <SDL2/SDL.h>
-//#include <SDL2/SDL_thread.h>
-//#include <iostream>
-//#include <sstream>
-//#include <stdexcept>
-//
-//class SdlMutex
-//{
-//public:
-// SdlMutex()
-// {
-// mutex = SDL_CreateMutex();
-// if (!mutex) throw std::runtime_error("SDL_CreateMutex == NULL");
-// }
-//
-// ~SdlMutex()
-// {
-// SDL_DestroyMutex(mutex);
-// }
-//
-// void lock()
-// {
-// if (SDL_mutexP(mutex) == -1) throw std::runtime_error("SDL_mutexP == -1");
-// // Note:
-// // -1 does not mean it was already locked - it means there was an error in locking -
-// // if it was locked it will just block - see SDL_mutexP(3)
-// }
-//
-// void unlock()
-// {
-// if (SDL_mutexV(mutex) == -1) throw std::runtime_error("SDL_mutexV == -1");
-// }
-//
-// SDL_mutex* underlying()
-// {
-// return mutex;
-// }
-//private:
-// SDL_mutex* mutex;
-//};
-//
-//class SdlScopedLock
-//{
-//public:
-// SdlScopedLock(SdlMutex& mutex)
-// :
-// mutex(mutex)
-// {
-// mutex.lock();
-// }
-// ~SdlScopedLock()
-// {
-// try
-// {
-// this->unlock();
-// }
-// catch (const std::exception& e)
-// {
-// // Destructors should never throw ...
-// std::cerr << "SdlScopedLock::~SdlScopedLock - caught : " << e.what() << std::endl;
-// }
-// }
-// void unlock()
-// {
-// mutex.unlock();
-// }
-//private:
-// SdlMutex& mutex;
-//};
-//
-//class ThreadData
-//{
-//public:
-// ThreadData()
-// :
-// dataReady(false),
-// done(false)
-// {
-// condition = SDL_CreateCond();
-// }
-//
-// ~ThreadData()
-// {
-// SDL_DestroyCond(condition);
-// }
-//
-// // Using stringstream so I can just shift on integers...
-// std::stringstream data;
-// bool dataReady;
-// bool done;
-// SdlMutex mutex;
-// SDL_cond* condition;
-//};
-//
-//int threadFunction(void* data)
-//{
-// try
-// {
-// ThreadData* threadData = static_cast< ThreadData* >(data);
-//
-// for (size_t i = 0; i < 100; i++)
-// {
-// {
-// SdlScopedLock lock(threadData->mutex);
-// // Everything in this scope is now syncronized with the mutex
-// if (i != 0) threadData->data << ", ";
-// threadData->data << i;
-// threadData->dataReady = true;
-// } // threadData->mutex is automatically unlocked here
-// // Its important to note that condition should be signaled after mutex is unlocked
-// if (SDL_CondSignal(threadData->condition) == -1) throw std::runtime_error("Failed to signal");
-// }
-// {
-// SdlScopedLock lock(threadData->mutex);
-// threadData->done = true;
-// }
-// if (SDL_CondSignal(threadData->condition) == -1) throw std::runtime_error("Failed to signal");
-// return 0;
-// }
-// catch (const std::exception& e)
-// {
-// std::cerr << "Caught : " << e.what() << std::endl;
-// return 1;
-// }
-//}
-//
-//int main(int argc, char* argv[])
-//{
-// ThreadData threadData;
-// SDL_Thread* thread = SDL_CreateThread(threadFunction, "", &threadData);
-//
-// while (true)
-// {
-// SdlScopedLock lock(threadData.mutex);
-// while (threadData.dataReady == false && threadData.done == false)
-// {
-// // NOTE: must call condition wait with mutex already locked
-// if (SDL_CondWait(threadData.condition, threadData.mutex.underlying()) == -1) throw std::runtime_error("Failed to wait");
-// }
-// // once dataReady == true or threadData.done == true we get here
-// std::cout << "Got data = " << threadData.data.str() << std::endl;
-// threadData.data.str("");
-// threadData.dataReady = false;
-// if (threadData.done)
-// {
-// std::cout << "child done - ending" << std::endl;
-// break;
-// }
-// }
-//
-// int status = 99;
-// SDL_WaitThread(thread, &status);
-// std::cerr << "Thread completed with : " << status << std::endl;
-//} \ No newline at end of file
diff --git a/build/04Network/04Network.vcxproj b/build/04Network/04Network.vcxproj
new file mode 100644
index 0000000..b992a7a
--- /dev/null
+++ b/build/04Network/04Network.vcxproj
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{85071432-24B6-46D4-98D8-DAA63183093C}</ProjectGuid>
+ <RootNamespace>My04Network</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\libjin\;$(SolutionDir)\lib\SDL2-2.0.5\include\</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib\SDL2-2.0.5\lib\x86\</AdditionalLibraryDirectories>
+ <AdditionalDependencies>SDL2main.lib;SDL2.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\libjin\;$(SolutionDir)\lib\SDL2-2.0.5\include\</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib\SDL2-2.0.5\lib\x86\</AdditionalLibraryDirectories>
+ <AdditionalDependencies>SDL2main.lib;SDL2.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\test\04Network\main.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\libjin\libjin.vcxproj">
+ <Project>{407e9199-d39c-4460-b218-0c29ab42483b}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/build/04Network/04Network.vcxproj.filters b/build/04Network/04Network.vcxproj.filters
new file mode 100644
index 0000000..01aea0c
--- /dev/null
+++ b/build/04Network/04Network.vcxproj.filters
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="源文件">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="头文件">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;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="..\..\test\04Network\main.cpp">
+ <Filter>源文件</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/build/libjin.sln b/build/libjin.sln
index eb11a5f..7bdc3c3 100644
--- a/build/libjin.sln
+++ b/build/libjin.sln
@@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02Audio", "02Audio\02Audio.
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03Thread", "03Thread\03Thread.vcxproj", "{0E49D105-2032-4825-9FA1-54B1B94E3655}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "04Network", "04Network\04Network.vcxproj", "{85071432-24B6-46D4-98D8-DAA63183093C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -51,6 +53,14 @@ Global
{0E49D105-2032-4825-9FA1-54B1B94E3655}.Release|x64.Build.0 = Release|x64
{0E49D105-2032-4825-9FA1-54B1B94E3655}.Release|x86.ActiveCfg = Release|Win32
{0E49D105-2032-4825-9FA1-54B1B94E3655}.Release|x86.Build.0 = Release|Win32
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x64.ActiveCfg = Debug|x64
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x64.Build.0 = Debug|x64
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x86.ActiveCfg = Debug|Win32
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x86.Build.0 = Debug|Win32
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x64.ActiveCfg = Release|x64
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x64.Build.0 = Release|x64
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x86.ActiveCfg = Release|Win32
+ {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/test/02Audio/audiotest.cpp b/test/02Audio/main.cpp
index 4576cfa..4576cfa 100644
--- a/test/02Audio/audiotest.cpp
+++ b/test/02Audio/main.cpp
diff --git a/test/03Thread/threadtest.cpp b/test/03Thread/main.cpp
index a792e53..a792e53 100644
--- a/test/03Thread/threadtest.cpp
+++ b/test/03Thread/main.cpp
diff --git a/test/04Network/main.cpp b/test/04Network/main.cpp
new file mode 100644
index 0000000..a792e53
--- /dev/null
+++ b/test/04Network/main.cpp
@@ -0,0 +1,83 @@
+#include <iostream>
+#include <functional>
+#include "jin.h"
+
+using namespace std;
+using namespace jin::core;
+using namespace jin::graphics;
+using namespace jin::input;
+using namespace jin::audio;
+using namespace jin::time;
+using namespace jin::thread;
+
+Timers timers;
+
+void onEvent(jin::input::Event* e)
+{
+ static Game* game = Game::get();
+ if (e->type == EventType::QUIT)
+ game->stop();
+}
+
+void onUpdate(int ms)
+{
+ timers.update(ms);
+}
+
+void onDraw()
+{
+
+}
+
+void thread2Runner(Thread* t)
+{
+ int i = 0;
+ while (true)
+ {
+ if (i++ == 1000000000)
+ {
+ i = 0;
+ cout << (char*)(t->demand(1).pointer);
+ }
+ }
+}
+
+void sendFunc(void* p)
+{
+ Thread* t = (Thread*)p;
+ t->send(1, "hello_");
+}
+
+int main(int argc, char* argv[])
+{
+ Game* game = Game::get();
+ Game::Setting setting;
+ setting.eventHandler = onEvent;
+ setting.updater = onUpdate;
+ setting.drawer = onDraw;
+ setting.loader = nullptr;
+ game->init(&setting);
+
+ Window* wnd = Window::get();
+ Window::Setting wndSetting;
+ wndSetting.width = 600;
+ wndSetting.height = 512;
+ wndSetting.title = "test";
+ wndSetting.fps = 60;
+ wndSetting.vsync = false;
+ wndSetting.fullscreen = false;
+ wndSetting.resizable = false;
+ wnd->init(&wndSetting);
+
+ Thread t("Count", thread2Runner);
+
+ t.start();
+ timers.after(2000, sendFunc, &t);
+
+ game->run();
+
+ game->quit();
+ wnd->quit();
+
+ return 0;
+} \ No newline at end of file