add visualc solution

main
cosmonaut 2022-04-13 09:57:32 -07:00
parent fb56fe0397
commit a30c901173
7 changed files with 179 additions and 46 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.vscode
.vs
build
x64

View File

@ -9,17 +9,19 @@ Wellspring uses stb_truetype to rasterize and pack fonts quickly.
Dependencies
------------
Wellspring depends on the C runtime, but SDL2 can be optionally depended upon instead if your application prefers it.
Wellspring depends on the C runtime, but SDL2 can be optionally depended upon instead if your application prefers it by defining USE_SDL2.
Building Wellspring
-------------------
For *nix platforms, use Cmake:
For *nix platforms, use CMake:
$ mkdir build/
$ cd build
$ cmake ../
$ make
For Windows, see the 'visualc/' directory.
License
-------
Wellspring is licensed under the zlib license. See LICENSE for details.

View File

@ -142,47 +142,6 @@ WELLSPRINGAPI void Wellspring_GetBufferData(
WELLSPRINGAPI void Wellspring_DestroyTextBatch(Wellspring_TextBatch *textBatch);
WELLSPRINGAPI void Wellspring_DestroyPacker(Wellspring_Packer *packer);
/* Function defines */
#ifdef USE_SDL2
#define Wellspring_malloc SDL_malloc
#define Wellspring_realloc SDL_realloc
#define Wellspring_free SDL_free
#define Wellspring_memcpy SDL_memcpy
#define Wellspring_memset SDL_memset
#define Wellspring_ifloor(x) ((int) SDL_floorf(x))
#define Wellspring_iceil(x) ((int) SDL_ceilf(x))
#define Wellspring_sqrt SDL_sqrt
#define Wellspring_pow SDL_pow
#define Wellspring_fmod SDL_fmod
#define Wellspring_cos SDL_cos
#define Wellspring_acos SDL_acos
#define Wellspring_fabs SDL_fabs
#define Wellspring_assert SDL_assert
#define Wellspring_strlen SDL_strlen
#define Wellspring_sort SDL_qsort
#else
#define Wellspring_malloc malloc
#define Wellspring_realloc realloc
#define Wellspring_free free
#define Wellspring_memcpy memcpy
#define Wellspring_ifloor(x) ((int) floor(x))
#define Wellspring_iceil(x) ((int) ceil(x))
#define Wellspring_sqrt sqrt
#define Wellspring_pow pow
#define Wellspring_fmod fmod
#define Wellspring_cos cos
#define Wellspring_acos acos
#define Wellspring_fabs fabs
#define Wellspring_assert assert
#define Wellspring_strlen strlen
#define Wellspring_sort qsort
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -26,6 +26,57 @@
#include "Wellspring.h"
/* Function defines */
#ifdef USE_SDL2
#define Wellspring_malloc SDL_malloc
#define Wellspring_realloc SDL_realloc
#define Wellspring_free SDL_free
#define Wellspring_memcpy SDL_memcpy
#define Wellspring_memset SDL_memset
#define Wellspring_ifloor(x) ((int) SDL_floorf(x))
#define Wellspring_iceil(x) ((int) SDL_ceilf(x))
#define Wellspring_sqrt SDL_sqrt
#define Wellspring_pow SDL_pow
#define Wellspring_fmod SDL_fmod
#define Wellspring_cos SDL_cos
#define Wellspring_acos SDL_acos
#define Wellspring_fabs SDL_fabs
#define Wellspring_assert SDL_assert
#define Wellspring_strlen SDL_strlen
#define Wellspring_sort SDL_qsort
#else
#ifdef _MSC_VER
#include <assert.h>
#include <stdlib.h>
#include <search.h>
#include <math.h>
#include <string.h>
#endif
#define Wellspring_malloc malloc
#define Wellspring_realloc realloc
#define Wellspring_free free
#define Wellspring_memcpy memcpy
#define Wellspring_memset memset
#define Wellspring_ifloor(x) ((int) floor(x))
#define Wellspring_iceil(x) ((int) ceil(x))
#define Wellspring_sqrt sqrt
#define Wellspring_pow pow
#define Wellspring_fmod fmod
#define Wellspring_cos cos
#define Wellspring_acos acos
#define Wellspring_fabs fabs
#define Wellspring_assert assert
#define Wellspring_strlen strlen
#define Wellspring_sort qsort
#endif
#define STBTT_malloc(x,u) ((void)(u),Wellspring_malloc(x))
#define STBTT_free(x,u) ((void)(u),Wellspring_free(x))
#define STBTT_memcpy Wellspring_memcpy
@ -70,7 +121,7 @@ typedef int32_t stbtt_int32;
typedef struct CharRange
{
stbtt_packedchar *data;
int32_t firstCodepoint;
uint32_t firstCodepoint;
uint32_t charCount;
} CharRange;
@ -183,14 +234,14 @@ uint32_t Wellspring_PackFontRanges(
) {
Packer *myPacker = (Packer*) packer;
Wellspring_FontRange *currentFontRange;
stbtt_pack_range stbPackRanges[numRanges];
stbtt_pack_range* stbPackRanges = Wellspring_malloc(sizeof(stbtt_pack_range) * numRanges);
CharRange *currentCharRange;
uint32_t i;
for (i = 0; i < numRanges; i += 1)
{
currentFontRange = &ranges[i];
stbPackRanges[i].font_size = currentFontRange->fontSize;
stbPackRanges[i].font_size = (float) currentFontRange->fontSize;
stbPackRanges[i].first_unicode_codepoint_in_range = currentFontRange->firstCodepoint;
stbPackRanges[i].array_of_unicode_codepoints = NULL;
stbPackRanges[i].num_chars = currentFontRange->numChars;

31
visualc/Wellspring.sln Normal file
View File

@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wellspring", "Wellspring.vcxproj", "{6DB15344-E000-45CB-A48A-1D72F7D6E945}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
MinSizeRel|x64 = MinSizeRel|x64
Release|x64 = Release|x64
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.Debug|x64.ActiveCfg = Debug|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.Debug|x64.Build.0 = Debug|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.Release|x64.ActiveCfg = Release|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.Release|x64.Build.0 = Release|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{6DB15344-E000-45CB-A48A-1D72F7D6E945}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B2DB465-0A55-3811-9EF4-A520B47653D2}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<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>{6DB15344-E000-45CB-A48A-1D72F7D6E945}</ProjectGuid>
<RootNamespace>FNA3D</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>..\lib\;..\..\SDL2\include;..\include;$(IncludePath)</IncludePath>
<LibraryPath>..\..\SDL2\lib\$(PlatformShortName);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>USE_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>USE_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\Wellspring.c" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\lib\stb_rect_pack.h" />
<ClCompile Include="..\lib\stb_truetype.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\Wellspring.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>