port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "devmania2012invitro", "src\devmania2012invitro\devmania2012invitro.vcxproj", "{213903DE-E40A-4D23-9310-E520AC2B412E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Compress (Slow)|Win32 = Compress (Slow)|Win32
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{213903DE-E40A-4D23-9310-E520AC2B412E}.Compress (Slow)|Win32.ActiveCfg = Release|Win32
{213903DE-E40A-4D23-9310-E520AC2B412E}.Debug|Win32.ActiveCfg = Debug|Win32
{213903DE-E40A-4D23-9310-E520AC2B412E}.Debug|Win32.Build.0 = Debug|Win32
{213903DE-E40A-4D23-9310-E520AC2B412E}.Release|Win32.ActiveCfg = Release|Win32
{213903DE-E40A-4D23-9310-E520AC2B412E}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

View File

@@ -0,0 +1,20 @@
// some useful song defines for 4klang
#define SAMPLE_RATE 44100
#define BPM 100
#define MAX_INSTRUMENTS 9
#define MAX_PATTERNS 64
#define PATTERN_SIZE_SHIFT 4
#define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
#define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
#define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16))
#define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
#define POLYPHONY 1
#define FLOAT_32BIT
#define SAMPLE_TYPE float
// declaration of the external synth render function, you'll always need that
extern "C" void __stdcall _4klang_render(void*);
// declaration of the external envelope buffer. access only if you're song was exported with that option
extern "C" float _4klang_envelope_buffer;
// declaration of the external note buffer. access only if you're song was exported with that option
extern "C" int _4klang_note_buffer;

Binary file not shown.

View File

@@ -0,0 +1,242 @@
#ifdef _DEBUG
#include "Shaders.h"
PFNGLCREATESHADERPROC glCreateShader = NULL;
PFNGLSHADERSOURCEPROC glShaderSource = NULL;
PFNGLCOMPILESHADERPROC glCompileShader = NULL;
PFNGLGETSHADERIVPROC glGetShaderiv = NULL;
PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL;
PFNGLCREATEPROGRAMPROC glCreateProgram = NULL;
PFNGLATTACHSHADERPROC glAttachShader = NULL;
PFNGLLINKPROGRAMPROC glLinkProgram = NULL;
PFNGLUSEPROGRAMPROC glUseProgram = NULL;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = NULL;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = NULL;
void useProgram(GLhandleARB ah_Program)
{
glUseProgram(ah_Program);
}
void initShaders()
{
glCreateShader = (PFNGLCREATESHADERPROC)myGetProcAddress("glCreateShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)myGetProcAddress("glShaderSource");
glCompileShader = (PFNGLCOMPILESHADERPROC)myGetProcAddress("glCompileShader");
glGetShaderiv = (PFNGLGETSHADERIVPROC)myGetProcAddress("glGetShaderiv");
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)myGetProcAddress("glGetProgramiv");
glCreateProgram = (PFNGLCREATEPROGRAMPROC)myGetProcAddress("glCreateProgram");
glAttachShader = (PFNGLATTACHSHADERPROC)myGetProcAddress("glAttachShader");
glLinkProgram = (PFNGLLINKPROGRAMPROC)myGetProcAddress("glLinkProgram");
glUseProgram = (PFNGLUSEPROGRAMPROC)myGetProcAddress("glUseProgram");
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)myGetProcAddress("glGetShaderInfoLog");
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)myGetProcAddress("glGetProgramInfoLog");
if (!(glCreateShader && glShaderSource && glCompileShader && glGetShaderiv && glGetProgramiv && glCreateProgram && glAttachShader && glLinkProgram && glUseProgram && glGetShaderInfoLog && glGetProgramInfoLog))
{
std::cerr << "Some shader functions are not available!" << std::endl;
}
}
void PrintErrors()
{
GLenum lr_Error = GL_NO_ERROR;
int li_ErrorCount = 5;
do
{
lr_Error = glGetError();
if (lr_Error != GL_NO_ERROR)
{
li_ErrorCount--;
char* ls_ErrorString = (char*)gluErrorString(lr_Error);
if (ls_ErrorString != 0)
std::cout << "OPENGL :: ERROR " << ls_ErrorString << std::endl;
}
if (li_ErrorCount == 0)
{
std::cout << "OPENGL :: ERROR Too many errors!" << std::endl;
break;
}
} while (lr_Error != GL_NO_ERROR);
}
GLhandleARB createVertexShader(const char* as_ShaderSource)
{
GLhandleARB lh_Shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(lh_Shader, 1, &as_ShaderSource, NULL);
glCompileShader(lh_Shader);
int li_Status = 0;
glGetShaderiv(lh_Shader, GL_COMPILE_STATUS, &li_Status);
if (li_Status == GL_FALSE)
{
std::cerr << "Error compiling vertex shader!" << std::endl;
printShaderInfoLog(lh_Shader);
}
return lh_Shader;
}
GLhandleARB createFragmentShader(const char* as_FileName)
{
GLhandleARB lh_Shader = 0;
char* ls_ShaderSource = textFileRead(as_FileName);
if (ls_ShaderSource == NULL)
{
std::cerr << "Error reading file: " << as_FileName << std::endl;
return lh_Shader;
}
lh_Shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(lh_Shader, 1, (const char**)&ls_ShaderSource, NULL);
glCompileShader(lh_Shader);
int li_Status = 0;
glGetShaderiv(lh_Shader, GL_COMPILE_STATUS, &li_Status);
if (li_Status == GL_FALSE)
{
std::cerr << "Error compiling fragment shader: " << as_FileName << std::endl;
printShaderInfoLog(lh_Shader);
}
free(ls_ShaderSource);
return lh_Shader;
}
GLhandleARB createProgram(GLhandleARB ah_VertexShader, GLhandleARB ah_FragmentShader)
{
GLhandleARB lh_Program = 0;
if (ah_VertexShader + ah_FragmentShader <= 1)
{
std::cerr << "Cannot create program." << std::endl;
return lh_Program;
}
lh_Program = glCreateProgram();
glAttachShader(lh_Program, ah_VertexShader);
glAttachShader(lh_Program, ah_FragmentShader);
glLinkProgram(lh_Program);
int li_Status = 0;
glGetProgramiv(lh_Program, GL_LINK_STATUS, &li_Status);
if (li_Status == GL_FALSE)
{
std::cerr << "Error linking shaders." << std::endl;
printProgramInfoLog(lh_Program);
}
return lh_Program;
}
char* textFileRead(const char* as_FileName)
{
FILE* lh_File;
char* ls_Content = NULL;
size_t li_Count = 0;
if (as_FileName != NULL)
{
fopen_s(&lh_File, as_FileName, "rt");
if (lh_File != NULL)
{
fseek(lh_File, 0, SEEK_END);
li_Count = ftell(lh_File);
rewind(lh_File);
if (li_Count > 0)
{
ls_Content = (char*) malloc(sizeof(char) * (li_Count + 1));
li_Count = fread(ls_Content, sizeof(char), li_Count, lh_File);
ls_Content[li_Count] = '\0';
}
fclose(lh_File);
}
}
return ls_Content;
}
void printShaderInfoLog(GLhandleARB ah_Shader)
{
int li_InfologLength = 0;
int li_CharsWritten = 0;
char* li_InfoLog;
glGetShaderiv(ah_Shader, GL_INFO_LOG_LENGTH, &li_InfologLength);
if (li_InfologLength > 0)
{
li_InfoLog = (char*) malloc(li_InfologLength);
glGetShaderInfoLog(ah_Shader, li_InfologLength, &li_CharsWritten, li_InfoLog);
std::cerr << li_InfoLog << std::endl;
free(li_InfoLog);
}
}
void printProgramInfoLog(GLhandleARB ah_Program)
{
int li_InfologLength = 0;
int li_CharsWritten = 0;
char* ls_InfoLog;
glGetProgramiv(ah_Program, GL_INFO_LOG_LENGTH, &li_InfologLength);
if (li_InfologLength > 0)
{
ls_InfoLog = (char *)malloc(li_InfologLength);
glGetProgramInfoLog(ah_Program, li_InfologLength, &li_CharsWritten, ls_InfoLog);
std::cerr << ls_InfoLog << std::endl;
free(ls_InfoLog);
}
}
bool printShaderStatistics()
{
if (GL_VERSION_2_1) std::cout << "Supports OpenGL 2.1. " << std::endl;
else if (GL_VERSION_2_0) std::cout << "Supports OpenGL 2.0. " << std::endl;
else if (GL_VERSION_1_5) std::cout << "Supports OpenGL 1.5. " << std::endl;
else if (GL_VERSION_1_4) std::cout << "Supports OpenGL 1.4. " << std::endl;
else if (GL_VERSION_1_3) std::cout << "Supports OpenGL 1.3. " << std::endl;
else if (GL_VERSION_1_2) std::cout << "Supports OpenGL 1.2. " << std::endl;
else if (GL_VERSION_1_1) std::cout << "Supports OpenGL 1.1. " << std::endl;
if (GL_ARB_shader_objects && GL_ARB_vertex_shader && GL_ARB_fragment_shader)
{
std::cout << "Status: Using GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION_ARB) << std::endl;
}
else
{
std::cerr << "No GLSL support!" << std::endl;
return false;
}
return true;
}
#endif

View File

@@ -0,0 +1,19 @@
#pragma once
#include <windows.h>
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include "glext.h"
#define myGetProcAddress(name) wglGetProcAddress((LPCSTR)name)
void initShaders();
GLhandleARB createVertexShader(const char* as_FileName);
GLhandleARB createFragmentShader(const char* as_FileName);
GLhandleARB createProgram(GLhandleARB ah_VertexShader, GLhandleARB ah_FragmentShader);
void PrintErrors();
void useProgram(GLhandleARB ah_Program);
char* textFileRead(const char* as_FileName);
void printShaderInfoLog(GLhandleARB ah_Shader);
void printProgramInfoLog(GLhandleARB ah_Program);
bool printShaderStatistics();

View File

@@ -0,0 +1,262 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="devmania2012invitro"
ProjectGUID="{213903DE-E40A-4D23-9310-E520AC2B412E}"
RootNamespace="devmania2012invitro"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)bin"
IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)_$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib winmm.lib glu32.lib"
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(ProjectDir)&quot;"
GenerateDebugInformation="true"
SubSystem="1"
EntryPointSymbol="main"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)bin"
IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)_$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="0"
DebugInformationFormat="3"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/CRINKLER /COMPMODE:INSTANT"
AdditionalDependencies="opengl32.lib winmm.lib libcmt.lib"
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
AdditionalLibraryDirectories="&quot;$(ProjectDir)&quot;"
GenerateManifest="false"
ManifestFile=""
GenerateDebugInformation="true"
SubSystem="2"
LinkTimeCodeGeneration="0"
EntryPointSymbol="main"
RandomizedBaseAddress="0"
DataExecutionPrevention="0"
TargetMachine="1"
ErrorReporting="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\Shaders.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\glext.h"
>
</File>
<File
RelativePath=".\release.h"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description=""
CommandLine=""
AdditionalDependencies=""
Outputs=""
/>
</FileConfiguration>
<FileConfiguration
Name="Compress (Slow)|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description=""
CommandLine=""
AdditionalDependencies=""
Outputs=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Shaders.h"
>
</File>
<File
RelativePath=".\small.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\4klang.obj"
>
</File>
<File
RelativePath=".\mark.fs"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,150 @@
<?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|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{213903DE-E40A-4D23-9310-E520AC2B412E}</ProjectGuid>
<RootNamespace>devmania2012invitro</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" 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>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)obj\$(ProjectName)_$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)obj\$(ProjectName)_$(Configuration)\</IntDir>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)_$(Configuration)</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)_$(Configuration)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<AdditionalDependencies>opengl32.lib;winmm.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
<AdditionalLibraryDirectories>$(ProjectDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EntryPointSymbol>main</EntryPointSymbol>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>
</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<AdditionalOptions>/CRINKLER /COMPMODE:INSTANT %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>opengl32.lib;winmm.lib;libcmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
<AdditionalLibraryDirectories>$(ProjectDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ManifestFile>
</ManifestFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
<EntryPointSymbol>main</EntryPointSymbol>
<RandomizedBaseAddress>
</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
<LinkErrorReporting>
</LinkErrorReporting>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="Shaders.cpp" />
<ClCompile Include="synth.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="4klang.h" />
<ClInclude Include="glext.h" />
<ClInclude Include="synth.h" />
<CustomBuild Include="release.h">
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Outputs)</Outputs>
</CustomBuild>
<ClInclude Include="Shaders.h" />
<ClInclude Include="small.h" />
</ItemGroup>
<ItemGroup>
<Object Include="4klang.obj" />
</ItemGroup>
<ItemGroup>
<None Include="frank.fs" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<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</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Shaders.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="synth.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="glext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Shaders.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="small.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="synth.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="4klang.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Object Include="4klang.obj" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="release.h">
<Filter>Header Files</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<None Include="frank.fs" />
</ItemGroup>
</Project>

View File

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

View File

@@ -0,0 +1,86 @@
varying vec4 Y;
vec2 wh = vec2(640, 480);
#define pi 3.14159265
#define R(p, a) p=cos(a)*p+sin(a)*vec2(p.y, -p.x)
#define hsv(h,s,v) mix(vec3(1.), clamp((abs(fract(h+vec3(3., 2., 1.)/3.)*6.-3.)-1.), 0., 1.), s)*v
float pn(vec3 p) {
vec3 i = floor(p);
vec4 a = dot(i, vec3(1., 57., 21.)) + vec4(0., 57., 21., 78.);
vec3 f = cos((p-i)*pi)*(-.5) + .5;
a = mix(sin(cos(a)*a), sin(cos(1.+a)*(1.+a)), f.x);
a.xy = mix(a.xz, a.yw, f.y);
return mix(a.x, a.y, f.z);
}
float fpn(vec3 p) {
return pn(p*.06125)*.5 + pn(p*.125)*.25 + pn(p*.25)*.125;
}
float sphere(vec3 p, float r) {
return length(p) - r;
}
float cyl(vec3 p, float r,float h) {
float d = length(p.xz)-r;
d = max(d,-p.y-h);
d = max(d,p.y-h);
return d;
}
float wave(float x)
{
return sin(x+cos(x))-sin(x)+0.2*sin(Y.x);
}
float ribbon(vec3 p, float b)
{
float a = wave(0.3*Y.x+(b*.5+.5)*length(p.xy)+2-0.1*dot(p.xy,p.xy));
//a = 0.2*a + sin(a*0.3*sin(Y.x));
R(p.xy, Y.x*0.1+0.5*a*b+0.5*b);
R(p.xz, 0.1*b*a);
return cyl(p, 0.05, (sin(Y.x)*.5+.5)*10.0);// + fpn(p*50.+Y.x*15.) * 0.05;
}
float ribbons(vec3 p, float b)
{
float d = 9;
for (float r = 0.3; r < 0.6; r += 0.05)
d = min(d, ribbon(p, r+b));
return d;
}
float f(vec3 p) {
p.z += 6.;
return min(ribbons(p+vec3(2,2,0), 0.75), ribbons(p-vec3(2,2,0), 1.25));
}
vec3 g(vec3 p) {
vec2 e = vec2(.0001, .0);
return normalize(vec3(f(p+e.xyy) - f(p-e.xyy),f(p+e.yxy) - f(p-e.yxy),f(p+e.yyx) - f(p-e.yyx)));
}
void main()
{
vec3 p = vec3(0, 0, 2.);
vec3 d = vec3((gl_FragCoord.xy/(0.5*wh)-1.)*vec2(wh.x/wh.y,1.0), 0.) - p;
d = normalize(d);
vec3 q=p;
float l,i;
for (i=0.;i<1.;i+=1.0/32)
{
l=abs(f(p));
p+=l*d*0.75;
if (l<0.001) break;
};
vec3 n = g(p);
l = max(0, -dot(n, d));
l = 0.5*l+pow(l, 16);
vec3 c = hsv(length(p-q), 0.5, 1.0) * l;
gl_FragColor = vec4(c, 1.0);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,145 @@
#ifdef _DEBUG
#include <time.h>
#include <io.h>
#include <process.h>
#include "Shaders.h"
#include "small.h"
#else
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "glext.h"
#include "small.h"
#endif
#include "release.h"
#include "synth.h"
#define USE_SOUND_THREAD // define this if you have a multicore cpu and can spare ~15 bytes for realtime playback
#pragma data_seg(".vertexshader")
static char* vsh = "varying vec4 Y;void main(){Y=gl_Color;gl_Position=gl_Vertex;}";
#pragma data_seg(".dms")
static DEVMODE dmScreenSettings={
"",0,0,sizeof(dmScreenSettings),0,DM_PELSWIDTH|DM_PELSHEIGHT,0,0,0,0,0,0,0,0,0,0,0,0,0,"",0,0,
640,480
//800,600
//1024,768
//1280,960
//1400,1050
//1280,720
//1920,1080
//1680,1050
//1920,1200
//1280,1024
};
#pragma data_seg(".pfd")
static const PIXELFORMATDESCRIPTOR pfd = {
0, 1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 8
};
#pragma data_seg(".glCreateProgram")
static char* glCreateProgram = "glCreateProgram";
#pragma data_seg(".glCreateShader")
static char* glCreateShader = "glCreateShader";
#pragma data_seg(".glShaderSource")
static char* glShaderSource = "glShaderSource";
#pragma data_seg(".glCompileShader")
static char* glCompileShader = "glCompileShader";
#pragma data_seg(".glAttachShader")
static char* glAttachShader = "glAttachShader";
#pragma data_seg(".glLinkProgram")
static char* glLinkProgram = "glLinkProgram";
#pragma data_seg(".glUseProgram")
static char* glUseProgram = "glUseProgram";
#pragma data_seg(".windowclass")
static const char* gs_WindowClass = "edit";
#pragma bss_seg(".mainbss")
static HDC gh_Dc;
static int gi_Program;
static int gi_FragmentShader;
static int gi_VertexShader;
HANDLE gh_ShaderCompileEvent;
static char** gs_LastShader_;
static __time64_t gi_ShaderChangedDate;
static unsigned int gi_ShaderProgram;
static unsigned int gi_LastShaderProgram;
static const char* gs_ShaderFile = "frank.fs";
DWORD WINAPI filemon(void* args)
{
while (true)
{
_finddata_t fdata;
long hfile = _findfirst(gs_ShaderFile, &fdata);
if (hfile != -1)
{
if (fdata.time_write != gi_ShaderChangedDate)
{
gi_ShaderChangedDate = fdata.time_write;
::SetEvent(gh_ShaderCompileEvent);
std::cout << "Shader loaded." << std::endl;
}
_findclose(hfile);
}
::Sleep(100);
}
return 0;
}
void _cdecl main()
{
HDC hDC = GetDC(CreateWindow("static", 0, WS_POPUP | WS_VISIBLE, 0, 0, dmScreenSettings.dmPelsWidth, dmScreenSettings.dmPelsHeight, 0, 0, 0, 0));
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
wglMakeCurrent(hDC, wglCreateContext(hDC));
ShowCursor(FALSE);
initShaders();
gh_ShaderCompileEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("WriteEvent"));
SetThreadPriority((HANDLE)CreateThread(0, 0, &filemon, 0, 0, 0), THREAD_PRIORITY_BELOW_NORMAL);
::Sleep(100);
if (::WaitForSingleObject(gh_ShaderCompileEvent, 0) == WAIT_OBJECT_0)
{
::Sleep(250);
gi_ShaderProgram = createProgram(createVertexShader(vsh), createFragmentShader(gs_ShaderFile));
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(gi_ShaderProgram);
PrintErrors();
}
glRects(-1, -1, 1, 1);
InitSound();
loop:
if (::WaitForSingleObject(gh_ShaderCompileEvent, 0) == WAIT_OBJECT_0)
{
::Sleep(250);
gi_ShaderProgram = createProgram(createVertexShader(vsh), createFragmentShader(gs_ShaderFile));
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(gi_ShaderProgram);
PrintErrors();
}
MSG lr_Message;
if (PeekMessage(&lr_Message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&lr_Message);
DispatchMessage(&lr_Message);
}
float time = get_Time();
glColor3f(time, 0, 0);
glRects(-1, -1, 1, 1);
SwapBuffers(hDC);
if (time < 150 && !GetAsyncKeyState(VK_ESCAPE)) goto loop;
ExitProcess(0);
}

View File

@@ -0,0 +1,232 @@
#pragma once
#pragma data_seg(".shaders")
static char* fsh =
"varying vec4 Y;" // Line 1
"vec4 u;" // Line 4
"vec3 x,w,A,z;" // Line 5
"float t,s,y,v=.0001;float a(float B){" // Line 6
"return clamp(B,.0,1.);}float b(float D,int C,int B){" // Line 8
"return (D-C)/(B-C);}vec3 c(vec3 B,float C){" // Line 9
"return vec3(" // Line 13
"cos(C)*B.x-sin(C)*B.z," // Line 14
"B.y," // Line 15
"sin(C)*B.x+cos(C)*B." // Line 16
"z" // Line 17
");}vec3 d(vec3 B,float C){" // Line 18
"return vec3(" // Line 23
"B.x," // Line 24
"B.y*cos(C)-B.z*sin(C)," // Line 25
"B.y*sin(C)+B.z*cos(C)" // Line 26
");}float e(vec2 C){" // Line 27
"int B=int(C.x*40+C.y*6400);" // Line 33
"B=(B<<13)^B;" // Line 34
"return 1-float((B*(B*B*15731+789221)+1376312589)&0x7fffffff)/1073741824;}float f(float B){" // Line 35
"return B*.5+.5;}float g(float C,float D,float B){" // Line 41
"return pow((" // Line 47
"f(sin(y*2*(C+D+Y.z*B)))+" // Line 48
"f(sin(y*(D-C-Y.z*B)))+" // Line 49
"f(sin(y*(D+Y.z*B)))+" // Line 50
"f(sin(y*3*(C-Y.z*B))))*.3,2.);}float h(vec2 D){" // Line 51
"D=mod(D,1000.);" // Line 57
"vec2 B=fract(D);" // Line 58
"D-=B;" // Line 59
"vec2 C=B*B*(3.-2.*B);" // Line 60
"return mix(" // Line 61
"mix(e(D+vec2(0)),e(D+vec2(1,0)),C.x)," // Line 62
"mix(e(D+vec2(0,1)),e(D+vec2(1)),C.x),C.y);}float i(vec2 D){" // Line 63
"float C=Y.z-s;" // Line 68
"float B=mix(1.,max(0.,u.w-u.y),1.-((C>0&&length(D-u.xz)<C)?1.:.0))/" // Line 69
"pow(1./max(0.,1.-length(u.xz-D)*.8),2.);" // Line 70
"D+=length(D-A.xy);" // Line 71
"D*=min(length(D-A.xy)*5,4.);" // Line 72
"return g(D.x+Y.z*.75,D.y*.5,.3)*.006+" // Line 74
"g(D.x*.1+Y.z*.2,D.y*.1,.02)*.125-" // Line 75
".15-B*2;}vec3 j(vec3 B){" // Line 76
"return normalize(vec3(" // Line 82
"g(B.x*160-12*cos(10*B.z),B.z*140,4.)," // Line 83
"8," // Line 84
"g(B.z*160-12*sin(10*B.x),B.x*140,4.))*2-1);}int k(vec3 H,vec3 G,float F,out float C){" // Line 85
"float D,E,B=0;" // Line 92
"for(float I=.1;I<F;I+=B)" // Line 94
"{" // Line 95
"H+=G*B;" // Line 97
"C=i(H.xz);" // Line 100
"if(H.y<=C)" // Line 102
"{" // Line 103
"C=I-B+B*(D-E)/(H.y-C+D-E);" // Line 106
"return 1;}" // Line 107
"D=C;" // Line 112
"E=H.y;" // Line 113
"B=.002+(I/(40*a(G.y+1)));}" // Line 117
"return 0;}vec3 l(vec3 B){" // Line 121
"return f(h(abs(B.xy*B.z+B.y*2)))*vec3(.15)+" // Line 127
"f(h(1.5*abs(B.xy*B.z+B.y+10)))*vec3(.15)+" // Line 128
"f(h(2.5*abs(B.xy*B.z+B.y+20)))*vec3(.15);}vec4 m(vec3 G,vec3 F){" // Line 129
"vec4 B=vec4(0);" // Line 135
"vec3 E=vec3(70,20,100);" // Line 137
"float C=dot(F,normalize(E-G))-.95;" // Line 138
"if(C>0)" // Line 139
"{" // Line 140
"C=length(E-G)-C*800;" // Line 141
"vec3 J=G+F*C;" // Line 142
"vec3 I=normalize(E-J);" // Line 143
"vec2 K=.5+.5*vec2(atan(I.z,I.x),acos(I.y))/y*vec2(5,50);" // Line 144
"B.rgb=max(0.,.2+dot(normalize(J-x),I))*" // Line 145
"(g(K.x*.5+Y.z*.1,K.y*.5,0.)+.5)*.15*vec3(1,0,1);" // Line 146
"B.a=1;}" // Line 147
"else C=t*99;" // Line 149
"vec3 D=vec3(-.96,.96,-.2);" // Line 152
"float H=dot(D,E-G)/dot(D,F);" // Line 153
"if(H>0&&H<C)" // Line 154
"{" // Line 155
"float I=length(E-(G+F*H));" // Line 156
"if(I>52&&I<80)" // Line 157
"B.rgb=mix(B.rgb,vec3(.8,.64,.4),H/200*f(sin((I-50)/30*h(vec2(I,3)))));" // Line 158
"B.a=B.a<1?3*length(B):B.a;}" // Line 159
"return vec4(max(vec3(0),B.xyz*.3)*clamp(dot(F,vec3(0,1,0))*8,0.,1.),B.a);}vec3 n(vec3 G,vec3 F,int B){" // Line 162
"vec3 D=max(vec3(0),(max(vec3(0),pow(dot(w,F),6.))*.7-F.y)*mix(vec3(1,.5,0),vec3(1),min(1.,w.y*1.5))+w.y*3);" // Line 168
"float E=atan(F.x,F.z);" // Line 170
"float H=acos(F.y/length(F));" // Line 171
"float C=smoothstep(.0,.5,f(.5*h(300*vec2(E,H)))+f(.75*h(500*vec2(E,H)))-1.25)*a(1.-w.y*5);" // Line 172
"if(B>0)" // Line 173
"{" // Line 174
"vec4 I=m(G,F);" // Line 176
"D+=C*a(1-I.a)+I.rgb;}" // Line 177
"F.xy+=G.xy*v;" // Line 181
"D+=(l(normalize(F+vec3(sin(Y.z*.1),0,cos(Y.z*.1))*.1)*3)+" // Line 182
"l(normalize(F+vec3(sin(Y.z*.1),0,cos(Y.z*.1))*.2)*5)*.1+" // Line 183
"l(normalize(F+vec3(sin(Y.z*.1),0,cos(Y.z*.1))*.4)*7)*.1-" // Line 184
"l(normalize(F+vec3(sin(Y.z*.2),0,0)*.5))*1.5)*a(F.y+.5);" // Line 185
"return D;}float o(vec3 C){" // Line 187
"int B=Y.z>80&&Y.z<112?1:0;" // Line 192
"C=d(c(d(c(C-u.xyz,3*Y.z),3*Y.z),B*sin(3*Y.z+3*C.y)),B*sin(3*Y.z+3*C.x));" // Line 193
"C*=4+10*max(0.,Y.z-s);" // Line 194
"return -.4+" // Line 196
"C.x*C.x*C.x*C.x*C.x*C.x*C.x*C.x+" // Line 197
"C.y*C.y*C.y*C.y*C.y*C.y*C.y*C.y+" // Line 198
"C.z*C.z*C.z*C.z*C.z*C.z*C.z*C.z;}float p(vec3 I,vec3 H,float G,float F,float J){" // Line 199
"float E,D,C,B=(F-G)/J;" // Line 205
"for(float K=G;K<F;K+=B)" // Line 207
"{" // Line 208
"vec3 M=I+K*H;" // Line 209
"float L=o(M);" // Line 210
"if(L<=0)" // Line 211
"{" // Line 212
"for(int N=0;N<9;N++)" // Line 213
"{" // Line 214
"C=(E+K)/2;" // Line 215
"if(o(I+C*H)<0)K=C;" // Line 216
"else E=C;}" // Line 217
"return C;}" // Line 219
"E=K;" // Line 222
"D=L;}" // Line 223
"return t;}void q(vec2 F,vec3 E,inout vec3 B){" // Line 226
"float C=length(F-u.xz);" // Line 231
"float D=Y.z-s;" // Line 232
"if(D>0&&C<D)" // Line 233
"{" // Line 234
"float G=D*.9;" // Line 235
"if(C<D-(D-G))" // Line 236
"{" // Line 237
"float H=a((C-G)/((D-(D-G)*2)-G));" // Line 238
"B*=(1-H*1.5);" // Line 239
"B+=(1-H*.8)*" // Line 240
"pow(f(E.x)+f(E.y)," // Line 241
"2*f(h(.4*Y.z+F*20))*" // Line 242
"f(h(10+F*5))+" // Line 243
"1." // Line 244
")*vec3(1.5,.75,.5);}" // Line 245
"if(C>D-(D-G)*2)" // Line 247
"B+=cos((C-G)/(D-G)*y*.5)*vec3(1.5,.75,.5);}}vec3 r(vec3 E,vec3 D){" // Line 248
"float F=(.1-E.y)/D.y;" // Line 255
"float C=200;" // Line 256
"vec3 B=n(E,D,1);" // Line 257
"if(D.y<-.01&&k(E+D*F,D,C,C)>0)" // Line 258
"{" // Line 259
"C+=F;" // Line 260
"vec3 H=E+D*C;" // Line 261
"vec3 G=normalize(normalize(" // Line 262
"vec3(" // Line 263
"i(H.xz-vec2(v,0))-i(H.xz+vec2(v,0))," // Line 264
"v*2," // Line 265
"i(H.xz-vec2(0,v))-i(H.xz+vec2(0,v))" // Line 266
")" // Line 267
")+" // Line 268
"(j(H*.2)*1.5+j(H*.1))*max(0.,1-C/t*7)" // Line 269
");" // Line 270
"B=max(0.,dot(G,w)" // Line 272
"+pow(max(0.,dot(G,normalize(w-D))),2.)" // Line 273
")*" // Line 274
"n(H,reflect(D,G),1);" // Line 275
"q(H.xz,G,B);" // Line 278
"B=mix(B," // Line 281
"n(E,D,0)," // Line 282
"a(C/t*1.6+a(dot(normalize(G+D*.2),D)))" // Line 283
");}" // Line 284
"return B;}void main(){" // Line 287
"t=9;" // Line 292
"s=127;" // Line 293
"y=3.1416;" // Line 294
"z=normalize(vec3(Y.xy-.5,1));" // Line 296
"u=vec4(10.,f(sin(Y.z*1+4)),13,0.);" // Line 297
"A=vec3(.0,.25,0.);" // Line 299
"float D=Y.z;" // Line 300
"if(D<16)" // Line 301
"{" // Line 302
"D=b(D,0,16);" // Line 303
"D=1-pow(1-D,2.);" // Line 304
"x=vec3(-400,100-D*450,1000);" // Line 305
"D=(D-1)*.7;" // Line 307
"z=d(z,-D);}" // Line 308
"else if(D<32)" // Line 310
"{" // Line 311
"D=b(D,16,32);" // Line 312
"D=1-pow(1-D,2.);" // Line 313
"x=vec3(-400,-350+D*600,1000);" // Line 314
"A.y-=D*.1;}" // Line 315
"else if(D<40)" // Line 317
"{" // Line 318
"x=vec3(-400,250,1000);" // Line 319
"A.y-=.1;}" // Line 320
"else if(D<64)" // Line 322
"{" // Line 323
"int E=int((D-40)/6.);" // Line 325
"if(E>=3)" // Line 326
"u.w=1.;" // Line 327
"x=vec3(-400,min(250.,f(e(vec2(E,2)))*400),1000);" // Line 328
"A.xz+=vec2(.1,20)*vec2(e(vec2(E,5)),e(vec2(E,7)));" // Line 331
"A=mix(" // Line 334
"A+vec3(.008)*abs(vec3(e(vec2(E,8)),0,e(vec2(E,10))))," // Line 335
"A+vec3(.75)*abs(vec3(e(vec2(E,11)),0,e(vec2(E,13))))," // Line 336
"D-40-E);" // Line 337
"A.y=.2;" // Line 338
"z=c(z,e(vec2(E,14))*y);}" // Line 339
"else " // Line 341
"{" // Line 342
"u.w=1.;" // Line 343
"x=vec3(-400,f(sin(D+10))*250,1000);" // Line 344
"float F=smoothstep(118.,120.,D);" // Line 345
"A.xz=u.xz+" // Line 346
"mix(vec2(sin(D*.6),cos(D*.6))*mix(sin(D*1.5+10)+2,2.,F)," // Line 347
"vec2(0,2+.75*(D-s))," // Line 348
"smoothstep(-1.,1.,D-s)" // Line 349
");" // Line 350
"A.y=mix(f(sin(D*3)*(1-F))*.3," // Line 351
".0," // Line 352
"smoothstep(-1.,1.,D-s)" // Line 353
")+.2;" // Line 354
"vec2 E=normalize(u.xz-A.xz);" // Line 355
"z=c(z,atan(E.y,E.x)-y/2);}" // Line 356
"w=normalize(x-A);" // Line 359
"float B=length(A-u.xyz)-1;" // Line 361
"float C=u.w==1?p(A,z,B,B+2,99.):t;" // Line 362
"if(C<t)" // Line 363
"{" // Line 364
"A+=C*z;" // Line 365
"vec3 E=normalize(vec3(" // Line 366
"o(vec3(A.x-v,A.y,A.z))-o(vec3(A.x+v,A.y,A.z))," // Line 367
"o(vec3(A.x,A.y-v,A.z))-o(vec3(A.x,A.y+v,A.z))," // Line 368
"o(vec3(A.x,A.y,A.z-v))-o(vec3(A.x,A.y,A.z+v))));" // Line 369
"z=reflect(z,E);}" // Line 370
"gl_FragColor=vec4(r(A,z)*clamp(sin((Y.z/150)*y)*10,.0,1.),1);}";

View File

@@ -0,0 +1,127 @@
#pragma once
#pragma code_seg("sm0")
DWORD x_Ftol(float af_Value)
{
DWORD ldw_RetVal;
__asm fld af_Value
__asm fistp ldw_RetVal
return ldw_RetVal;
}
#pragma code_seg("sm1")
__forceinline float x_Frac(float af_Value)
{
return af_Value - x_Ftol(af_Value);
}
#pragma code_seg("sm2")
__forceinline float x_Abs(float af_Value)
{
__asm fld af_Value
__asm fabs
}
#pragma code_seg("sm3")
float x_Sin(float af_Value)
{
__asm fld af_Value
__asm fsin
}
#pragma code_seg("sm4")
float x_Sign(float af_Value)
{
if (af_Value != 0)
return af_Value / x_Abs(af_Value);
return 1.0f;
}
#pragma code_seg("sm5")
float x_Sqrt(float af_Value)
{
__asm fld af_Value
__asm fsqrt
}
#pragma code_seg("sm7")
void x_MemCopy(void* av_Dest_, const void* av_Src_, size_t ai_Size)
{
__asm mov esi, av_Src_
__asm mov edi, av_Dest_
__asm mov ecx, ai_Size
__asm rep movsb
}
#pragma code_seg("sm8")
float x_Fmod(float x, float y)
{
__asm fld y
__asm fld x
__asm fprem
__asm fxch
__asm fstp x
}
#pragma data_seg("smA")
static unsigned long seed=0x12345678;
#pragma code_seg("sm9")
__forceinline void x_Randomize(unsigned long x)
{
seed = x;
}
#pragma code_seg("smB")
float x_Rand()
{
seed = seed * 0x76364873 + 1234567;
return (float)(seed & 0x7FFFFFFF) * (const float)(2.0f / (float)0x7FFFFFFF) - 1.0f;
}
#pragma code_seg("smS")
__forceinline GLsizei x_Strlen(const char* as_String)
{
GLsizei li_Length = 0;
while (*as_String++) ++li_Length;
return li_Length;
}
#pragma code_seg("smP")
float x_Pow(float x, float y){
float r;
__asm{
fld y
fld x
fyl2x
fld1
fld st(1)
fprem
f2xm1
faddp st(1),st
fscale
fxch st(1)
fstp st(0)
fstp r
}
return r;
}
extern "C"
{
int _fltused = 1;
}

View File

@@ -0,0 +1,96 @@
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include "windows.h"
#include "mmsystem.h"
#include "mmreg.h"
// define this if you have a multicore cpu and can spare ~10 bytes for realtime playback
// undef for sound precalc
#define USE_SOUND_THREAD
////////////////////////////////////////////////
// sound
////////////////////////////////////////////////
// some song information
#include "4klang.h"
// MAX_SAMPLES gives you the number of samples for the whole song. we always produce stereo samples, so times 2 for the buffer
SAMPLE_TYPE lpSoundBuffer[MAX_SAMPLES*2];
HWAVEOUT hWaveOut;
/////////////////////////////////////////////////////////////////////////////////
// initialized data
/////////////////////////////////////////////////////////////////////////////////
#pragma data_seg(".wavefmt")
WAVEFORMATEX WaveFMT =
{
#ifdef FLOAT_32BIT
WAVE_FORMAT_IEEE_FLOAT,
#else
WAVE_FORMAT_PCM,
#endif
2, // channels
SAMPLE_RATE, // samples per sec
SAMPLE_RATE*sizeof(SAMPLE_TYPE)*2, // bytes per sec
sizeof(SAMPLE_TYPE)*2, // block alignment;
sizeof(SAMPLE_TYPE)*8, // bits per sample
0 // extension not needed
};
#pragma data_seg(".wavehdr")
WAVEHDR WaveHDR =
{
(LPSTR)lpSoundBuffer,
MAX_SAMPLES*sizeof(SAMPLE_TYPE)*2, // MAX_SAMPLES*sizeof(float)*2(stereo)
0,
0,
0,
0,
0,
0
};
MMTIME MMTime =
{
TIME_SAMPLES,
0
};
/////////////////////////////////////////////////////////////////////////////////
// crt emulation
/////////////////////////////////////////////////////////////////////////////////
#ifndef _DEBUG
extern "C"
{
int _fltused = 1;
}
#endif
/////////////////////////////////////////////////////////////////////////////////
// Initialization
/////////////////////////////////////////////////////////////////////////////////
#pragma code_seg(".initsnd")
extern "C"
void InitSound()
{
#ifdef USE_SOUND_THREAD
// thx to xTr1m/blu-flame for providing a smarter and smaller way to create the thread :)
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)_4klang_render, lpSoundBuffer, 0, 0);
#else
_4klang_render(lpSoundBuffer);
#endif
waveOutOpen ( &hWaveOut, WAVE_MAPPER, &WaveFMT, NULL, 0, CALLBACK_NULL );
waveOutPrepareHeader( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
waveOutWrite ( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
}
#pragma code_seg(".getTime")
extern "C"
float get_Time()
{
waveOutGetPosition(hWaveOut, &MMTime, sizeof(MMTIME));
return float(MMTime.u.sample) / SAMPLE_RATE;
}

View File

@@ -0,0 +1,8 @@
#pragma once
extern "C"
{
__forceinline void InitSound();
//float get_Envelope(int instrument);
__forceinline float get_Time();
}