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

0
.gitignore vendored Normal file
View File

23
4kgfx/4k.sln Normal file
View File

@@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4k", "src\4k.vcproj", "{478863DD-1156-47FF-8AE2-F7A923BB3998}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Crinkler|Win32 = Crinkler|Win32
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Crinkler|Win32.ActiveCfg = Crinkler|Win32
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Crinkler|Win32.Build.0 = Crinkler|Win32
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Debug|Win32.ActiveCfg = Debug|Win32
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Debug|Win32.Build.0 = Debug|Win32
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Release|Win32.ActiveCfg = Release|Win32
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

23
4kgfx/4kgfx.sln Normal file
View File

@@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4kgfx", "4kgfx.vcxproj", "{27D5C038-72A5-4FCE-84C5-F02BCA628E50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Crinkler|Win32 = Crinkler|Win32
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{27D5C038-72A5-4FCE-84C5-F02BCA628E50}.Crinkler|Win32.ActiveCfg = Crinkler|Win32
{27D5C038-72A5-4FCE-84C5-F02BCA628E50}.Crinkler|Win32.Build.0 = Crinkler|Win32
{27D5C038-72A5-4FCE-84C5-F02BCA628E50}.Debug|Win32.ActiveCfg = Debug|Win32
{27D5C038-72A5-4FCE-84C5-F02BCA628E50}.Debug|Win32.Build.0 = Debug|Win32
{27D5C038-72A5-4FCE-84C5-F02BCA628E50}.Release|Win32.ActiveCfg = Release|Win32
{27D5C038-72A5-4FCE-84C5-F02BCA628E50}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
4kgfx/4kgfx.suo Normal file

Binary file not shown.

166
4kgfx/4kgfx.vcxproj Normal file
View File

@@ -0,0 +1,166 @@
<?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="Crinkler|Win32">
<Configuration>Crinkler</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<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>{27D5C038-72A5-4FCE-84C5-F02BCA628E50}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>My4kgfx</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Crinkler|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</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 Condition="'$(Configuration)|$(Platform)'=='Crinkler|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 Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Crinkler|Win32'">
<LinkIncremental>false</LinkIncremental>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ShowIncludes>true</ShowIncludes>
<OmitDefaultLibName>true</OmitDefaultLibName>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>opengl32.lib;kernel32.lib;user32.lib;gdi32.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>main</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MinSpace</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ShowIncludes>true</ShowIncludes>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointExceptions>false</FloatingPointExceptions>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>false</OpenMPSupport>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>opengl32.lib;kernel32.lib;user32.lib;gdi32.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>main</EntryPointSymbol>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Crinkler|Win32'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MinSpace</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ShowIncludes>true</ShowIncludes>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointExceptions>false</FloatingPointExceptions>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<OpenMPSupport>false</OpenMPSupport>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>opengl32.lib;kernel32.lib;user32.lib;gdi32.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>main</EntryPointSymbol>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<AdditionalOptions>/CRINKLER /COMPMODE:SLOW /PROGRESSGUI /ORDERTRIES:3000 /HASHSIZE:300 /RANGE:opengl32 /TRANSFORM:CALLS /REPORT:Report.html %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="mesh.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Crinkler|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="vecmath.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="glext.h" />
<ClInclude Include="mesh.h" />
<ClInclude Include="ogl3.h" />
<ClInclude Include="small.h" />
<ClInclude Include="smallwin.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="vecmath.h" />
<ClInclude Include="wglext.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,57 @@
<?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;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="vecmath.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mesh.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="small.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="glext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="smallwin.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wglext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ogl3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mesh.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="vecmath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

3
4kgfx/4kgfx.vcxproj.user Normal file
View File

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

BIN
4kgfx/Crinkler/4kgfx.exe Normal file

Binary file not shown.

View File

@@ -0,0 +1,2 @@
#v4.0:v100:false
Crinkler|Win32|E:\Private\Frank\Code\blu-flame.org\4kgfx\|

109
4kgfx/Crinkler/4kgfx.log Normal file
View File

@@ -0,0 +1,109 @@
Build started 2011-04-12 22:49:00.
1>Project "E:\Private\Frank\Code\blu-flame.org\4kgfx\4kgfx.vcxproj" on node 2 (build target(s)).
1>InitializeBuildStatus:
Touching "Crinkler\4kgfx.unsuccessfulbuild".
ClCompile:
All outputs are up-to-date.
D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /Zi /nologo /W0 /WX- /O1 /Os /Oy /GT /D WIN32 /D NDEBUG /D _CONSOLE /Gm- /MD /GS- /Gy- /fp:precise /fp:except- /Zc:wchar_t /Zc:forScope /GR- /openmp- /Yu"StdAfx.h" /Fp"Crinkler\4kgfx.pch" /FAs /Fa"Crinkler\\" /Fo"Crinkler\\" /Fd"Crinkler\vc100.pdb" /Gd /TP /showIncludes /analyze- /errorReport:prompt main.cpp
main.cpp
Link:
E:\Private\Frank\Code\blu-flame.org\4kgfx\link.exe /ERRORREPORT:PROMPT /OUT:"E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.exe" /INCREMENTAL:NO /NOLOGO opengl32.lib kernel32.lib user32.lib gdi32.lib /NODEFAULTLIB /MANIFEST:NO /PDB:"E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /ENTRY:"main" /DYNAMICBASE /NXCOMPAT /IMPLIB:"E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.lib" /MACHINE:X86 Crinkler\main.obj
Crinkler\mesh.obj
Crinkler\stdafx.obj
Crinkler\vecmath.obj /CRINKLER /COMPMODE:SLOW /PROGRESSGUI /ORDERTRIES:3000 /HASHSIZE:300 /RANGE:opengl32 /TRANSFORM:CALLS /REPORT:Report.html
Crinkler 1.3 (Mar 5 2011) (c) 2005-2011 Aske Simon Christensen & Rune Stubbe
Ignoring unknown argument '/ERRORREPORT:PROMPT'
Ignoring unknown argument '/INCREMENTAL:NO'
Ignoring unknown argument '/NOLOGO'
Ignoring unknown argument '/NODEFAULTLIB'
Ignoring unknown argument '/MANIFEST:NO'
Ignoring unknown argument '/PDB:E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.pdb'
Ignoring unknown argument '/TLBID:1'
Ignoring unknown argument '/DYNAMICBASE'
Ignoring unknown argument '/NXCOMPAT'
Ignoring unknown argument '/IMPLIB:E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.lib'
Ignoring unknown argument '/MACHINE:X86'
Target: E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.exe
Subsystem type: CONSOLE
Compression mode: SLOW
Hash size: 300 MB
Hash tries: 20
Order tries: 3000
Report: Report.html
Transforms: CALLS
Replace DLLs: NONE
Range DLLs: opengl32
loading:
opengl32.lib kernel32.lib user32.lib gdi32.lib
Crinkler\main.obj Crinkler\mesh.obj Crinkler\stdafx.obj Crinkler\vecmath.obj
Calls transformed: 147
Uncompressed size of code: 11496
Uncompressed size of data: 440
|-- Estimating models for code ----------------------------|
............................................................ 1m16s
Ideal compressed size: 4607
|-- Estimating models for data ----------------------------|
............................................................ 0m00s
Ideal compressed size: 131
Estimated ideal compressed total size: 4739
Reordering sections...
Iteration: 0 Size: 4746.16
Iteration: 1 Size: 4744.91
Iteration: 32 Size: 4744.05
Iteration: 47 Size: 4743.70
Iteration: 57 Size: 4742.23
Iteration: 61 Size: 4740.29
Iteration: 66 Size: 4736.51
Iteration: 144 Size: 4736.33
Iteration: 198 Size: 4735.81
Iteration: 248 Size: 4735.76
Iteration: 514 Size: 4735.73
Iteration: 516 Size: 4735.55
Iteration: 561 Size: 4735.52
Iteration: 916 Size: 4735.20
Iteration: 1671 Size: 4735.17
Iteration: 1996 Size: 4735.00
Iteration: 2291 Size: 4734.95
Iteration: 2541 Size: 4734.45
Iteration: 2861 Size: 4733.36
Time spent: 1m36s
Calls transformed: 147
|-- Reestimating models for code --------------------------|
............................................................ 1m53s
Ideal compressed size: 4554
|-- Reestimating models for data --------------------------|
............................................................ 0m01s
Ideal compressed size: 127
Reestimated ideal compressed total size: 4682
|-- Optimizing hash table size ----------------------------|
............................................................ 0m03s
Real compressed total size: 4701
Bytes lost to hashing: 19
Final file size: 5096
time spent: 4m53s
4kgfx.vcxproj -> E:\Private\Frank\Code\blu-flame.org\4kgfx\Crinkler\4kgfx.exe
FinalizeBuildStatus:
Deleting file "Crinkler\4kgfx.unsuccessfulbuild".
Touching "Crinkler\4kgfx.lastbuildstate".
1>Done Building Project "E:\Private\Frank\Code\blu-flame.org\4kgfx\4kgfx.vcxproj" (build target(s)).
Build succeeded.
Time Elapsed 00:04:53.29

BIN
4kgfx/Crinkler/4kgfx.pch Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@

Binary file not shown.

218
4kgfx/Crinkler/main.asm Normal file
View File

@@ -0,0 +1,218 @@
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01
TITLE E:\Private\Frank\Code\blu-flame.org\4kgfx\main.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB MSVCRT
INCLUDELIB OLDNAMES
CONST SEGMENT
_pfd DW 00H
DW 01H
DD 021H
DB 00H
DB 020H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 00H
DB 08H
ORG $+17
_attribs DD 02091H
DD 03H
DD 02092H
DD 03H
DD 02094H
DD 02H
DD 00H
CONST ENDS
screenSettings SEGMENT
_screenSettings DB 00H
ORG $+31
DW 00H
DW 00H
DW 07cH
DW 00H
DD 01c0000H
DW 00H
ORG $+14
DW 00H
DW 00H
DW 00H
DW 00H
DW 00H
DB 00H
ORG $+31
DW 00H
DD 020H
DD 0500H
DD 02d0H
DD 00H
DD 00H
screenSettings ENDS
PUBLIC ??_C@_0BL@PDDHMPGF@wglCreateContextAttribsARB?$AA@ ; `string'
PUBLIC ??_C@_06GGHJAEBN@static?$AA@ ; `string'
PUBLIC _main
EXTRN __imp__ExitProcess@4:PROC
EXTRN __imp__GetAsyncKeyState@4:PROC
EXTRN __imp__SwapBuffers@4:PROC
EXTRN ?Render@Mesh@@QAEXXZ:PROC ; Mesh::Render
EXTRN __imp__wglGetProcAddress@4:PROC
EXTRN __imp__wglMakeCurrent@8:PROC
EXTRN __imp__wglCreateContext@4:PROC
EXTRN __imp__SetPixelFormat@12:PROC
EXTRN __imp__ChoosePixelFormat@8:PROC
EXTRN __imp__GetDC@4:PROC
EXTRN __imp__CreateWindowExA@48:PROC
EXTRN __imp__ShowCursor@4:PROC
EXTRN __imp__ChangeDisplaySettingsA@8:PROC
; COMDAT ??_C@_0BL@PDDHMPGF@wglCreateContextAttribsARB?$AA@
; File e:\private\frank\code\blu-flame.org\4kgfx\main.cpp
CONST SEGMENT
??_C@_0BL@PDDHMPGF@wglCreateContextAttribsARB?$AA@ DB 'wglCreateContextAt'
DB 'tribsARB', 00H ; `string'
CONST ENDS
; COMDAT ??_C@_06GGHJAEBN@static?$AA@
CONST SEGMENT
??_C@_06GGHJAEBN@static?$AA@ DB 'static', 00H ; `string'
; Function compile flags: /Ogspy
CONST ENDS
func_main SEGMENT
_main PROC
; 8 : {
push ebx
push esi
push edi
; 9 : #ifndef _DEBUG
; 10 : ChangeDisplaySettingsA(&screenSettings, CDS_FULLSCREEN);
push 4
push OFFSET _screenSettings
call DWORD PTR __imp__ChangeDisplaySettingsA@8
; 11 : ShowCursor(0);
xor edi, edi
push edi
call DWORD PTR __imp__ShowCursor@4
; 12 : #endif
; 13 : HDC hDC=GetDC(CreateWindowExA(0, "static", 0,WS_VISIBLE|WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,0,0,XRES,YRES,0,0,0,0));
push edi
push edi
push edi
push edi
push 720 ; 000002d0H
push 1280 ; 00000500H
push edi
push edi
push -1778384896 ; 96000000H
push edi
push OFFSET ??_C@_06GGHJAEBN@static?$AA@
push edi
call DWORD PTR __imp__CreateWindowExA@48
push eax
call DWORD PTR __imp__GetDC@4
mov esi, eax
; 14 : SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
mov eax, OFFSET _pfd
push eax
push eax
push esi
call DWORD PTR __imp__ChoosePixelFormat@8
push eax
push esi
call DWORD PTR __imp__SetPixelFormat@12
; 15 : wglMakeCurrent(hDC, wglCreateContext(hDC));
push esi
call DWORD PTR __imp__wglCreateContext@4
mov ebx, DWORD PTR __imp__wglMakeCurrent@8
push eax
push esi
call ebx
; 16 : wglMakeCurrent(hDC, ((PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"))(hDC, 0, attribs));
push OFFSET _attribs
push edi
push esi
push OFFSET ??_C@_0BL@PDDHMPGF@wglCreateContextAttribsARB?$AA@
call DWORD PTR __imp__wglGetProcAddress@4
call eax
push eax
push esi
call ebx
; 17 :
; 18 : #ifdef _DEBUG
; 19 : ((PFNGLDEBUGMESSAGECALLBACKAMDPROC)wglGetProcAddress("glDebugMessageCallbackAMD"))(glDebugOutputAMD, 0);
; 20 : #endif
; 21 :
; 22 : cube.Render();
mov ecx, OFFSET _cube
call ?Render@Mesh@@QAEXXZ ; Mesh::Render
; 23 : SwapBuffers(hDC);
push esi
call DWORD PTR __imp__SwapBuffers@4
$LL2@main:
; 24 :
; 25 : while (!GetAsyncKeyState(27));
push 27 ; 0000001bH
call DWORD PTR __imp__GetAsyncKeyState@4
test ax, ax
je SHORT $LL2@main
; 26 : ExitProcess(0);
push edi
call DWORD PTR __imp__ExitProcess@4
pop edi
pop esi
pop ebx
$LN7@main:
$LN6@main:
_main ENDP
func_main ENDS
EXTRN ??0Mesh@@QAE@XZ:PROC ; Mesh::Mesh
; Function compile flags: /Ogspy
; COMDAT ??__Ecube@@YAXXZ
compile SEGMENT
??__Ecube@@YAXXZ PROC ; `dynamic initializer for 'cube'', COMDAT
; 4 : static Mesh cube;
mov ecx, OFFSET _cube
jmp ??0Mesh@@QAE@XZ ; Mesh::Mesh
??__Ecube@@YAXXZ ENDP ; `dynamic initializer for 'cube''
compile ENDS
_BSS SEGMENT
_cube DB 0488040H DUP (?)
_BSS ENDS
CRT$XCU SEGMENT
_cube$initializer$ DD FLAT:??__Ecube@@YAXXZ
CRT$XCU ENDS
END

BIN
4kgfx/Crinkler/main.obj Normal file

Binary file not shown.

2978
4kgfx/Crinkler/mesh.asm Normal file

File diff suppressed because it is too large Load Diff

BIN
4kgfx/Crinkler/mesh.obj Normal file

Binary file not shown.

176
4kgfx/Crinkler/stdafx.asm Normal file
View File

@@ -0,0 +1,176 @@
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01
TITLE E:\Private\Frank\Code\blu-flame.org\4kgfx\stdafx.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB MSVCRT
INCLUDELIB OLDNAMES
PUBLIC ?glShaderSource@@3P6GXIHPAPBDPBH@ZA ; glShaderSource
PUBLIC ?glCreateProgram@@3P6GIXZA ; glCreateProgram
PUBLIC ?glGenBuffers@@3P6GXHPAI@ZA ; glGenBuffers
PUBLIC ?glUseProgram@@3P6GXI@ZA ; glUseProgram
PUBLIC ?glBindBuffer@@3P6GXII@ZA ; glBindBuffer
PUBLIC ?glLinkProgram@@3P6GXI@ZA ; glLinkProgram
PUBLIC ?glVertexAttribPointer@@3P6GXIHIEHPBX@ZA ; glVertexAttribPointer
PUBLIC ?glCreateShader@@3P6GII@ZA ; glCreateShader
PUBLIC ?glEnableVertexAttribArray@@3P6GXI@ZA ; glEnableVertexAttribArray
PUBLIC ?glBindVertexArray@@3P6GXI@ZA ; glBindVertexArray
PUBLIC ?glMapBuffer@@3P6GPAXII@ZA ; glMapBuffer
PUBLIC ?glCompileShader@@3P6GXI@ZA ; glCompileShader
PUBLIC ?glUnmapBuffer@@3P6GEI@ZA ; glUnmapBuffer
PUBLIC ?glGetAttribLocation@@3P6GHIPBD@ZA ; glGetAttribLocation
PUBLIC ?glAttachShader@@3P6GXII@ZA ; glAttachShader
PUBLIC ?glBufferData@@3P6GXI_JPBXI@ZA ; glBufferData
PUBLIC ?glGenVertexArrays@@3P6GXHPAI@ZA ; glGenVertexArrays
PUBLIC ?currentProgramId@@3IA ; currentProgramId
PUBLIC ?MaxVertexBuffer@Mesh@@2HB ; Mesh::MaxVertexBuffer
PUBLIC ?MaxIndexBuffer@Mesh@@2HB ; Mesh::MaxIndexBuffer
_BSS SEGMENT
?glShaderSource@@3P6GXIHPAPBDPBH@ZA DD 01H DUP (?) ; glShaderSource
?glCreateProgram@@3P6GIXZA DD 01H DUP (?) ; glCreateProgram
?glGenBuffers@@3P6GXHPAI@ZA DD 01H DUP (?) ; glGenBuffers
?glUseProgram@@3P6GXI@ZA DD 01H DUP (?) ; glUseProgram
?glBindBuffer@@3P6GXII@ZA DD 01H DUP (?) ; glBindBuffer
?glLinkProgram@@3P6GXI@ZA DD 01H DUP (?) ; glLinkProgram
?glVertexAttribPointer@@3P6GXIHIEHPBX@ZA DD 01H DUP (?) ; glVertexAttribPointer
?glCreateShader@@3P6GII@ZA DD 01H DUP (?) ; glCreateShader
?glEnableVertexAttribArray@@3P6GXI@ZA DD 01H DUP (?) ; glEnableVertexAttribArray
?glBindVertexArray@@3P6GXI@ZA DD 01H DUP (?) ; glBindVertexArray
?glMapBuffer@@3P6GPAXII@ZA DD 01H DUP (?) ; glMapBuffer
?glCompileShader@@3P6GXI@ZA DD 01H DUP (?) ; glCompileShader
?glUnmapBuffer@@3P6GEI@ZA DD 01H DUP (?) ; glUnmapBuffer
?glGetAttribLocation@@3P6GHIPBD@ZA DD 01H DUP (?) ; glGetAttribLocation
?glAttachShader@@3P6GXII@ZA DD 01H DUP (?) ; glAttachShader
?glBufferData@@3P6GXI_JPBXI@ZA DD 01H DUP (?) ; glBufferData
?glGenVertexArrays@@3P6GXHPAI@ZA DD 01H DUP (?) ; glGenVertexArrays
?currentProgramId@@3IA DD 01H DUP (?) ; currentProgramId
_BSS ENDS
; COMDAT ?MaxIndexBuffer@Mesh@@2HB
CONST SEGMENT
?MaxIndexBuffer@Mesh@@2HB DD 048000H ; Mesh::MaxIndexBuffer
CONST ENDS
; COMDAT ?MaxVertexBuffer@Mesh@@2HB
CONST SEGMENT
?MaxVertexBuffer@Mesh@@2HB DD 010000H ; Mesh::MaxVertexBuffer
CONST ENDS
screenSettings SEGMENT
_screenSettings DB 00H
ORG $+31
DW 00H
DW 00H
DW 07cH
DW 00H
DD 01c0000H
DW 00H
ORG $+14
DW 00H
DW 00H
DW 00H
DW 00H
DW 00H
DB 00H
ORG $+31
DW 00H
DD 020H
DD 0500H
DD 02d0H
DD 00H
DD 00H
screenSettings ENDS
PUBLIC ?compileShader@@YAIPBD0@Z ; compileShader
; Function compile flags: /Ogspy
; File e:\private\frank\code\blu-flame.org\4kgfx\ogl3.h
compile SEGMENT
_vsh$ = 8 ; size = 4
_fsh$ = 12 ; size = 4
?compileShader@@YAIPBD0@Z PROC ; compileShader
; 36 : {
push esi
push edi
; 37 : GLuint s,p;
; 38 : p = glCreateProgram();
call DWORD PTR ?glCreateProgram@@3P6GIXZA ; glCreateProgram
; 39 : s = glCreateShader(GL_VERTEX_SHADER);
push 35633 ; 00008b31H
mov esi, eax
call DWORD PTR ?glCreateShader@@3P6GII@ZA ; glCreateShader
mov edi, eax
; 40 : glShaderSource(s, 1, &vsh, NULL);
push 0
lea eax, DWORD PTR _vsh$[esp+8]
push eax
push 1
push edi
call DWORD PTR ?glShaderSource@@3P6GXIHPAPBDPBH@ZA ; glShaderSource
; 41 : glCompileShader(s);
push edi
call DWORD PTR ?glCompileShader@@3P6GXI@ZA ; glCompileShader
; 42 : glAttachShader(p, s);
push edi
push esi
call DWORD PTR ?glAttachShader@@3P6GXII@ZA ; glAttachShader
; 43 : s = glCreateShader(GL_FRAGMENT_SHADER);
push 35632 ; 00008b30H
call DWORD PTR ?glCreateShader@@3P6GII@ZA ; glCreateShader
mov edi, eax
; 44 : glShaderSource(s, 1, &fsh, NULL);
push 0
lea eax, DWORD PTR _fsh$[esp+8]
push eax
push 1
push edi
call DWORD PTR ?glShaderSource@@3P6GXIHPAPBDPBH@ZA ; glShaderSource
; 45 : glCompileShader(s);
push edi
call DWORD PTR ?glCompileShader@@3P6GXI@ZA ; glCompileShader
; 46 : glAttachShader(p, s);
push edi
push esi
call DWORD PTR ?glAttachShader@@3P6GXII@ZA ; glAttachShader
; 47 : glLinkProgram(p);
push esi
call DWORD PTR ?glLinkProgram@@3P6GXI@ZA ; glLinkProgram
; 48 : glUseProgram(p);
push esi
call DWORD PTR ?glUseProgram@@3P6GXI@ZA ; glUseProgram
pop edi
; 49 : return p;
mov eax, esi
pop esi
; 50 : };
ret 0
?compileShader@@YAIPBD0@Z ENDP ; compileShader
compile ENDS
END

BIN
4kgfx/Crinkler/stdafx.obj Normal file

Binary file not shown.

BIN
4kgfx/Crinkler/vc100.pdb Normal file

Binary file not shown.

4155
4kgfx/Crinkler/vecmath.asm Normal file

File diff suppressed because it is too large Load Diff

BIN
4kgfx/Crinkler/vecmath.obj Normal file

Binary file not shown.

11022
4kgfx/glext.h Normal file

File diff suppressed because it is too large Load Diff

BIN
4kgfx/link.exe Normal file

Binary file not shown.

27
4kgfx/main.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "stdafx.h"
#pragma data_seg(".cube")
static Mesh cube;
#pragma code_seg(".func_main")
void __cdecl main(void)
{
#ifndef _DEBUG
ChangeDisplaySettingsA(&screenSettings, CDS_FULLSCREEN);
ShowCursor(0);
#endif
HDC hDC=GetDC(CreateWindowExA(0, "static", 0,WS_VISIBLE|WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,0,0,XRES,YRES,0,0,0,0));
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
wglMakeCurrent(hDC, wglCreateContext(hDC));
wglMakeCurrent(hDC, ((PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"))(hDC, 0, attribs));
#ifdef _DEBUG
((PFNGLDEBUGMESSAGECALLBACKAMDPROC)wglGetProcAddress("glDebugMessageCallbackAMD"))(glDebugOutputAMD, 0);
#endif
cube.Render();
SwapBuffers(hDC);
while (!GetAsyncKeyState(27));
ExitProcess(0);
}

465
4kgfx/mesh.cpp Normal file
View File

@@ -0,0 +1,465 @@
#include "stdafx.h"
Mesh::Mesh()
: IndexCount(0)
, VertexCount(0)
{
glGenVertexArrays(1, &VertexArrayObject);
glBindVertexArray(VertexArrayObject);
glGenBuffers(1, &VertexArrayBuffer);
glBindBuffer(GL_ARRAY_BUFFER, VertexArrayBuffer);
glBufferData(GL_ARRAY_BUFFER, MaxVertexBuffer * sizeof(MeshVertex), 0, GL_STATIC_DRAW);
glGenBuffers(1, &IndexBufferObject);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBufferObject);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, MaxIndexBuffer * sizeof(unsigned short), NULL, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void Mesh::Render()
{
glBindVertexArray(VertexArrayObject);
unsigned int positionId = glGetAttribLocation(currentProgramId, "inPosition");
unsigned int normalId = glGetAttribLocation(currentProgramId, "inNormal");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBufferObject);
glBindBuffer(GL_ARRAY_BUFFER, VertexArrayBuffer);
glEnableVertexAttribArray(positionId);
glVertexAttribPointer(positionId, 4, GL_FLOAT, GL_FALSE, sizeof(MeshVertex), (const GLvoid*)0);
glEnableVertexAttribArray(normalId);
glVertexAttribPointer(normalId, 4, GL_FLOAT, GL_FALSE, sizeof(MeshVertex), (const GLvoid*)16);
glDrawElements(GL_TRIANGLES, IndexCount, GL_UNSIGNED_SHORT, 0);
glBindVertexArray(0);
}
void Mesh::Lock()
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBufferObject);
glBindBuffer(GL_ARRAY_BUFFER, VertexArrayBuffer);
IndexBuffer = (unsigned short*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_WRITE);
VertexBuffer = (MeshVertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
}
void Mesh::Unlock()
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
}
void Mesh::GenerateNormals()
{
for (int i = 0; i < VertexCount; ++i)
{
VertexBuffer[i].Normal = vec4(0, 0, 0, 1);
}
for (int i = 0; i < IndexCount; )
{
int count = IndexBuffer[i];
++i;
for (int j = 0; j < count; ++j)
{
int index = IndexBuffer[i + j];
int indexPrev = IndexBuffer[i + ((j + count - 1) % count)];
int indexNext = IndexBuffer[i + ((j + 1) % count)];
vec4 p1(VertexBuffer[indexPrev].Position - VertexBuffer[index].Position);
vec4 p2(VertexBuffer[indexNext].Position - VertexBuffer[index].Position);
VertexBuffer[index].Normal += cross(p1, p2);
}
i += count;
}
}
void Mesh::NormalizeNormals()
{
for (int i = 0; i < VertexCount; ++i)
{
VertexBuffer[i].Normal = normalize(VertexBuffer[i].Normal);
}
}
void Mesh::Triangulate() // Converts polygons into triangle fans
{
OP.Reset();
OP.NextVertexCount = 0;
OP.NextFaceCount = 0;
for (int i = 0; i < IndexCount;)
{
int count = IndexBuffer[i++];
int firstVertex = IndexBuffer[i++];
int secondVertex = IndexBuffer[i++];
int j = 0;
do
{
OP.NextIB[OP.NextIndexCount++] = firstVertex;
OP.NextIB[OP.NextIndexCount++] = secondVertex;
OP.NextIB[OP.NextIndexCount++] = IndexBuffer[i + j];
OP.NextFaceCount++;
secondVertex = IndexBuffer[i + j++];
} while (j < count - 2);
i += count - 2;
}
memcpy(IndexBuffer, OP.NextIB, MaxIndexBuffer * sizeof(unsigned short));
IndexCount = OP.NextIndexCount;
FaceCount = OP.NextFaceCount;
}
void Mesh::CatmullClarkSubdivide()
{
if (IndexCount >= MaxIndexBuffer / 4 || VertexCount >= MaxVertexBuffer * 9 / 4)
{
return;
}
// neuer VB ist so:
// alter VB bzw. verschobene Originalpunkte
// ein Vertex pro Face (FacePunkte)
// ein Vertex pro Edge (EdgePunkte)
//neuer IB ist so:
// 4 / alte Ecke0 / EdgePunkt / FaceFacePunkt / EdgePunkt
// 4 / alte Ecke1 / EdgePunkt / FaceFacePunkt / EdgePunkt
//...
// 4 / alte EckeN / EdgePunkt / FaceFacePunkt / EdgePunkt (N = = Vertexcount)
//beim kopieren dann ueberall noch 4
OP.Reset();
OP.NextVertexCount = VertexCount + FaceCount; //Basis Vertices sind die alte Ecken und die neuen FacePunkte
int face = 0;
for (int i = 0; i < IndexCount;)
{
int count = IndexBuffer[i++];
vec4& fp = OP.NextVB[VertexCount + face].Position;
unsigned short int* ib = OP.NextIB + OP.NextIndexCount;
for (int j = 0; j < count; ++j)
{
int index = IndexBuffer[i + j];
fp += VertexBuffer[index].Position;
ib[j * 5] = 4;
ib[j * 5 + 1] = index;
ib[j * 5 + 3] = VertexCount + face; // erste Haelfte IB fertig
}
fp /= (float)count; // jetzt ist der FacePunkt fertig
for (int j = 0; j < count; ++j)
{
int index = IndexBuffer[i + j];
int indexNext = IndexBuffer[i + ((j + 1) % count)];
int Edge = OP.MakeEdgeID(index, indexNext);
OP.NextVB[OP.EdgeID[Edge]].Position += fp; // Summe aller FacePunkte zu dieser Ecke sind hier
ib[j * 5 + 2] = OP.EdgeID[Edge];
ib[(j * 5 + 9) % (count * 5)] = OP.EdgeID[Edge]; // IB fertig!
OP.NextVB[index].Position += fp; //Summe aller FacePunkte die an diesen Originalpunkt grenzen
}
i += count;
face++;
OP.NextIndexCount += count * 5;
OP.NextFaceCount += count;
}
// Originalpunkte verschieben
for (int i = 0; i < VertexCount; ++i)
{
bool openEdges = false; // gab es offene Kanten (d.h. einseitig benutze?)
vec4 edgesVector(0,0,0,0);
vec4 openEdgesVector(0,0,0,0);
int edgeCount = 0;
int openEdgeCount = 0;
for (int j = 0; j < OP.EdgeCount; ++j)
{
int V1 = (OP.EdgeConfiguration[j] & 0x0000ffff);
int V2 = (OP.EdgeConfiguration[j] & 0xffff0000) >> 16;
if (V1 == i || V2 == i)
{
vec4 mid = VertexBuffer[V1].Position + VertexBuffer[V2].Position;
if (OP.EdgeUsage[j] == 1)
{
openEdges = true;
openEdgeCount++;
openEdgesVector += mid;
}
edgeCount++;
edgesVector += mid;
}
}
if (openEdges)
{
OP.NextVB[i].Position = openEdgesVector / (float)(openEdgeCount * 4) + VertexBuffer[i].Position * 0.5f;
}
else
{
OP.NextVB[i].Position =
OP.NextVB[i].Position / (float)edgeCount +
edgesVector / (float)edgeCount +
VertexBuffer[i].Position * (float)(edgeCount - 3);
OP.NextVB[i].Position /= (float)edgeCount;
}
}
//EdgePunkte anpassen
for (int j = 0; j < OP.EdgeCount; ++j)
{
int V1 = (OP.EdgeConfiguration[j] & 0x0000ffff);
int V2 = (OP.EdgeConfiguration[j] & 0xffff0000) >> 16;
if (OP.EdgeUsage[j] < 2)
{
OP.NextVB[OP.EdgeID[j]].Position = vec4(0,0,0,0);
OP.EdgeUsage[j] = 0;
}
OP.NextVB[OP.EdgeID[j]].Position += VertexBuffer[V1].Position;
OP.NextVB[OP.EdgeID[j]].Position += VertexBuffer[V2].Position;
OP.NextVB[OP.EdgeID[j]].Position /= (float)(OP.EdgeUsage[j] + 2);
}
memcpy(VertexBuffer, OP.NextVB, MaxVertexBuffer * sizeof(MeshVertex));
memcpy(IndexBuffer, OP.NextIB, MaxIndexBuffer * sizeof(unsigned short));
VertexCount = OP.NextVertexCount;
IndexCount = OP.NextIndexCount;
FaceCount = OP.NextFaceCount;
}
void Mesh::Extrude(float fExtend)
{
OP.Reset();
for (int i = 0; i < IndexCount;)
{
int count = IndexBuffer[i];
IndexBuffer[i + IndexCount] = count;
++i;
for (int j = 0; j < count; ++j)
{
int index = IndexBuffer[i + j];
int indexNext = IndexBuffer[i + ((j + 1) % count)];
int ID = OP.MakeEdgeID(index, indexNext);
if (index > indexNext)
{
OP.EdgeUsage[ID] += 0x80;
}
IndexBuffer[i + IndexCount + count - j - 1] = index + VertexCount;
}
i += count;
}
for (int i = 0; i < VertexCount; ++i)
{
VertexBuffer[i + VertexCount].Position = VertexBuffer[i].Position;
VertexBuffer[i].Position.z -= fExtend;
VertexBuffer[i + VertexCount].Position.z += fExtend;
}
IndexCount *= 2;
FaceCount *= 2;
for (int i = 0; i < OP.EdgeCount; ++i)
{
if ((OP.EdgeUsage[i] & 0x7f) == 1)
{
int iAdd = OP.EdgeUsage[i] == 1 ? 0 : VertexCount;
int V1 = (OP.EdgeConfiguration[i] & 0x0000ffff);
int V2 = (OP.EdgeConfiguration[i] & 0xffff0000) >> 16;
IndexBuffer[IndexCount++] = 4;
IndexBuffer[IndexCount++] = V1 + iAdd;
iAdd = VertexCount - iAdd;
IndexBuffer[IndexCount++] = V1 + iAdd;
IndexBuffer[IndexCount++] = V2 + iAdd;
iAdd = VertexCount - iAdd;
IndexBuffer[IndexCount++] = V2 + iAdd;
FaceCount += 1;
}
}
VertexCount *= 2;
}
void Mesh::OpInfo::Reset()
{
memclear(NextVB, sizeof (NextVB));
memclear(NextIB, sizeof (NextIB));
memclear(EdgeConfiguration, sizeof (EdgeConfiguration));
memclear(EdgeUsage, sizeof (EdgeUsage));
memclear(EdgeID, sizeof (EdgeID));
NextVertexCount = 0;
NextIndexCount = 0;
NextFaceCount = 0;
EdgeCount = 0;
}
int Mesh::OpInfo::MakeEdgeID (unsigned short VertexA, unsigned short VertexB)
{
unsigned int edgeConfiguration = VertexA > VertexB ? (VertexA << 16 | VertexB) : (VertexB << 16 | VertexA);
for (int i = 0; i < EdgeCount; ++i)
{
if (EdgeConfiguration[i] == edgeConfiguration)
{
EdgeUsage[i]++;
return i;
}
}
EdgeConfiguration[EdgeCount] = edgeConfiguration;
EdgeUsage[EdgeCount]++;
EdgeID[EdgeCount] = NextVertexCount;
NextVertexCount++;
return EdgeCount++;
}
void Mesh::StandardSubdivide()
{
OP.Reset();
memcpy(OP.NextVB, VertexBuffer, VertexCount * sizeof(MeshVertex));
OP.NextVertexCount = VertexCount;
int face = 0;
for (int i = 0; i < IndexCount; ++face)
{
int count = IndexBuffer[i++];
for (int j = 0; j < count; ++j)
{
int prevIndex = j - 1;
if (prevIndex < 0)
prevIndex += count;
prevIndex = IndexBuffer[i + prevIndex];
int index = IndexBuffer[i + j];
int nextIndex = IndexBuffer[i + ((j + 1) % count)];
int prevEdgeID = OP.EdgeID[OP.MakeEdgeID(prevIndex, index)];
int nextEdgeID = OP.EdgeID[OP.MakeEdgeID(index, nextIndex)];
OP.NextVB[prevEdgeID].Position = (VertexBuffer[prevIndex].Position + VertexBuffer[index].Position) / 2;
OP.NextVB[nextEdgeID].Position = (VertexBuffer[nextIndex].Position + VertexBuffer[index].Position) / 2;
OP.NextIB[OP.NextIndexCount + 0] = 4;
OP.NextIB[OP.NextIndexCount + 1] = 0; // will be set later (face offset)
OP.NextIB[OP.NextIndexCount + 2] = prevEdgeID;
OP.NextIB[OP.NextIndexCount + 3] = index;
OP.NextIB[OP.NextIndexCount + 4] = nextEdgeID;
OP.NextIndexCount += 5;
++OP.NextFaceCount;
}
i += count;
}
int vbFaceOffset = OP.NextVertexCount;
int ibIndex = 1;
face = 0;
for (int i = 0; i < IndexCount; ++face)
{
int count = IndexBuffer[i++];
vec4 fp;
for (int j = 0; j < count; ++j)
{
fp += VertexBuffer[IndexBuffer[i + j]].Position;
OP.NextIB[ibIndex] = vbFaceOffset + face;
ibIndex += 5;
}
OP.NextVB[vbFaceOffset + face].Position = fp / (float)count;
++OP.NextVertexCount;
i += count;
}
memcpy(VertexBuffer, OP.NextVB, MaxVertexBuffer * sizeof(MeshVertex));
memcpy(IndexBuffer, OP.NextIB, MaxIndexBuffer * sizeof(unsigned short));
VertexCount = OP.NextVertexCount;
IndexCount = OP.NextIndexCount;
FaceCount = OP.NextFaceCount;
}
void Mesh::CreateCube()
{
Lock();
VertexBuffer[0].Position = vec4(-2, -1, 0, 1);
VertexBuffer[1].Position = vec4(-2, 1, 0, 1);
VertexBuffer[2].Position = vec4(2, 1, 0, 1);
VertexBuffer[3].Position = vec4(2, -1, 0, 1);
VertexCount = 4;
IndexBuffer[0] = 4;
IndexBuffer[1] = 0;
IndexBuffer[2] = 1;
IndexBuffer[3] = 2;
IndexBuffer[4] = 3;
IndexCount = 5;
FaceCount = 1;
Extrude(1.0f);
GenerateNormals();
Triangulate();
Homogenize();
Unlock();
}
void Mesh::CreateSphere(unsigned int lod)
{
Lock();
VertexBuffer[0].Position = vec4(-1, -1, 0, 1);
VertexBuffer[1].Position = vec4(-1, 1, 0, 1);
VertexBuffer[2].Position = vec4(1, 1, 0, 1);
VertexBuffer[3].Position = vec4(1, -1, 0, 1);
VertexCount = 4;
IndexBuffer[0] = 4;
IndexBuffer[1] = 0;
IndexBuffer[2] = 1;
IndexBuffer[3] = 2;
IndexBuffer[4] = 3;
IndexCount = 5;
FaceCount = 1;
Extrude(1.0f);
for (unsigned int i = 0; i < lod; ++i)
CatmullClarkSubdivide();
GenerateNormals();
Triangulate();
Homogenize();
Unlock();
}
void Mesh::Homogenize()
{
for (int i = 0; i < VertexCount; ++i)
VertexBuffer[i].Position.w = 1;
}
void Mesh::Transform(const Matrix& transform)
{
Lock();
for (int i = 0; i < VertexCount; ++i)
{
VertexBuffer[i].Position = transform * VertexBuffer[i].Position;
}
Unlock();
}

92
4kgfx/mesh.h Normal file
View File

@@ -0,0 +1,92 @@
#pragma once
struct MeshVertex
{
vec4 Position;
vec4 Normal;
};
struct Instance
{
Matrix transform;
};
class Mesh
{
public:
Mesh();
struct VertexInfo
{
int Pos;
int Normal;
int UV;
bool operator < (const VertexInfo& v) const
{
if (Pos == v.Pos)
{
if (Normal == v.Normal)
{
return UV < v.UV;
}
return Normal < v.Normal;
}
return Pos < v.Pos;
}
};
int VertexCount;
int IndexCount;
int FaceCount;
static const int MaxVertexBuffer = 65536;
static const int MaxIndexBuffer = 65536 * 9 / 2;
MeshVertex* VertexBuffer;
unsigned short* IndexBuffer;
struct OpInfo
{
void Reset();
MeshVertex NextVB[Mesh::MaxVertexBuffer];
unsigned short int NextIB[Mesh::MaxIndexBuffer];
int NextVertexCount;
int NextIndexCount;
int NextFaceCount;
int EdgeCount;
unsigned int EdgeConfiguration[Mesh::MaxIndexBuffer];
unsigned char EdgeUsage[Mesh::MaxIndexBuffer];
int MakeEdgeID(unsigned short VertexA, unsigned short VertexB);
unsigned short int EdgeID[Mesh::MaxIndexBuffer];
};
OpInfo OP;
unsigned int VertexArrayObject;
unsigned int VertexArrayBuffer;
unsigned int IndexBufferObject;
void Render();
void Lock();
void Unlock();
void Transform(const Matrix& transform);
void CreateCube();
void CreateSphere(unsigned int lod);
private:
void Homogenize();
void GenerateNormals();
void NormalizeNormals();
void CatmullClarkSubdivide();
void StandardSubdivide();
void Extrude(float extend);
void Bevel(float extend, float minAngle);
void Triangulate();
};

102
4kgfx/ogl3.h Normal file
View File

@@ -0,0 +1,102 @@
#pragma once
#define XRES 1280
#define YRES 720
typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
typedef void (WINAPI *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
typedef void (WINAPI *PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam);
PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLCREATESHADERPROC glCreateShader;
PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLATTACHSHADERPROC glAttachShader;
PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLUSEPROGRAMPROC glUseProgram;
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
PFNGLGENBUFFERSPROC glGenBuffers;
PFNGLBUFFERDATAPROC glBufferData;
PFNGLMAPBUFFERPROC glMapBuffer;
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
PFNGLBINDBUFFERPROC glBindBuffer;
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
#pragma data_seg(".screenSettings")
static DEVMODE screenSettings = {{0}, 0, 0, sizeof(DEVMODE), 0, 0x001c0000, {0}, 0, 0, 0, 0, 0, {0}, 0, 32, XRES, YRES, {0}, 0};
#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 code_seg(".compile")
unsigned int __cdecl compileShader(const char* vsh, const char* fsh)
{
GLuint s,p;
p = glCreateProgram();
s = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(s, 1, &vsh, NULL);
glCompileShader(s);
glAttachShader(p, s);
s = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(s, 1, &fsh, NULL);
glCompileShader(s);
glAttachShader(p, s);
glLinkProgram(p);
glUseProgram(p);
return p;
};
#ifdef _DEBUG
void APIENTRY glDebugOutputAMD(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam)
{
OutputDebugStringA("[");
if (severity == GL_DEBUG_SEVERITY_HIGH_AMD)
OutputDebugStringA("high");
else if (severity == GL_DEBUG_SEVERITY_MEDIUM_AMD)
OutputDebugStringA("medium");
else if (severity == GL_DEBUG_SEVERITY_LOW_AMD)
OutputDebugStringA("low");
OutputDebugStringA("] ");
if (category == GL_DEBUG_CATEGORY_API_ERROR_AMD)
OutputDebugStringA("api error");
else if (category == GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD)
OutputDebugStringA("window system");
else if (category == GL_DEBUG_CATEGORY_DEPRECATION_AMD)
OutputDebugStringA("deprecation");
else if (category == GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD)
OutputDebugStringA("undefined behavior");
else if (category == GL_DEBUG_CATEGORY_PERFORMANCE_AMD)
OutputDebugStringA("performance");
else if (category == GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD)
OutputDebugStringA("shader compiler");
else if (category == GL_DEBUG_CATEGORY_APPLICATION_AMD)
OutputDebugStringA("application");
else if (category == GL_DEBUG_CATEGORY_OTHER_AMD)
OutputDebugStringA("other");
OutputDebugStringA(": ");
OutputDebugStringA(message);
OutputDebugStringA("\n");
DebugBreak();
}
#endif
#pragma data_seg(".attribs")
static const int attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
#ifdef _DEBUG
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB,
#else
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
#endif
0
};

128
4kgfx/small.h Normal file
View File

@@ -0,0 +1,128 @@
#pragma once
#pragma code_seg("pi")
__forceinline float pi()
{
__asm fldpi
}
#pragma code_seg("sm0")
unsigned long ftol(float Value)
{
unsigned long RetVal;
__asm fld Value
__asm fistp RetVal
return RetVal;
}
#pragma code_seg("sm1")
float frac(float Value)
{
return Value - ftol(Value);
}
#pragma code_seg("sm2")
float abs(float Value)
{
__asm fld Value
__asm fabs
}
#pragma code_seg("sm3")
float sin(float Value)
{
__asm fld Value
__asm fsin
}
#pragma code_seg("sm4")
float sign(float Value)
{
if (Value != 0)
return Value / abs(Value);
return 1.0f;
}
#pragma code_seg("sm5")
float sqrt(float Value)
{
__asm fld Value
__asm fsqrt
}
#pragma code_seg("sm7")
void* memcpy(void* Dest, const void* Src, size_t destSize)
{
__asm mov esi, Src
__asm mov edi, Dest
__asm mov ecx, destSize
__asm rep movsb
}
#pragma code_seg("sm8")
float 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 randomize(unsigned long x)
{
seed = x;
}
#pragma code_seg("smB")
float rand()
{
seed = seed * 0x76364873 + 1234567;
return (float)(seed & 0x7FFFFFFF) * (const float)(2.0f / (float)0x7FFFFFFF) - 1.0f;
}
#pragma code_seg("smS")
__forceinline size_t strlen(const char* String)
{
size_t Length = 0;
while (*String++) ++Length;
return Length;
}
#pragma code_seg("smP")
float 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;
}

188
4kgfx/smallwin.h Normal file
View File

@@ -0,0 +1,188 @@
#pragma once
extern "C"
{
#define HANDLE void*
#define DECLARE_HANDLE(name) typedef HANDLE name
#define WINGDIAPI __declspec(dllimport)
#define WINUSERAPI __declspec(dllimport)
#define WINBASEAPI __declspec(dllimport)
#define WINAPI __stdcall
#define NULL 0
#define APIENTRY WINAPI
#define PFD_DOUBLEBUFFER 0x00000001
#define PFD_STEREO 0x00000002
#define PFD_DRAW_TO_WINDOW 0x00000004
#define PFD_DRAW_TO_BITMAP 0x00000008
#define PFD_SUPPORT_GDI 0x00000010
#define PFD_SUPPORT_OPENGL 0x00000020
#define PFD_GENERIC_FORMAT 0x00000040
#define PFD_NEED_PALETTE 0x00000080
#define PFD_NEED_SYSTEM_PALETTE 0x00000100
#define PFD_SWAP_EXCHANGE 0x00000200
#define PFD_SWAP_COPY 0x00000400
#define PFD_SWAP_LAYER_BUFFERS 0x00000800
#define PFD_GENERIC_ACCELERATED 0x00001000
#define PFD_SUPPORT_DIRECTDRAW 0x00002000
#define PFD_DIRECT3D_ACCELERATED 0x00004000
#define PFD_SUPPORT_COMPOSITION 0x00008000
#define PFD_TYPE_RGBA 0
#define PFD_TYPE_COLORINDEX 1
#define WS_OVERLAPPED 0x00000000L
#define WS_POPUP 0x80000000L
#define WS_CHILD 0x40000000L
#define WS_MINIMIZE 0x20000000L
#define WS_VISIBLE 0x10000000L
#define WS_DISABLED 0x08000000L
#define WS_CLIPSIBLINGS 0x04000000L
#define WS_CLIPCHILDREN 0x02000000L
#define WS_MAXIMIZE 0x01000000L
#define WS_CAPTION 0x00C00000L
#define WS_BORDER 0x00800000L
#define WS_DLGFRAME 0x00400000L
#define WS_VSCROLL 0x00200000L
#define WS_HSCROLL 0x00100000L
#define WS_SYSMENU 0x00080000L
#define WS_THICKFRAME 0x00040000L
#define WS_GROUP 0x00020000L
#define WS_TABSTOP 0x00010000L
#define CDS_UPDATEREGISTRY 0x00000001
#define CDS_TEST 0x00000002
#define CDS_FULLSCREEN 0x00000004
#define CDS_GLOBAL 0x00000008
#define CDS_SET_PRIMARY 0x00000010
#define CDS_VIDEOPARAMETERS 0x00000020
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
typedef int (WINAPI *PROC)();
typedef unsigned long DWORD;
typedef unsigned short WORD;
typedef unsigned short USHORT;
typedef unsigned char BYTE;
typedef char CHAR;
typedef unsigned int UINT;
typedef long LONG;
typedef const char* LPCSTR;
typedef void VOID;
typedef float FLOAT;
typedef __int64 INT64;
typedef int INT;
typedef int INT32;
typedef long BOOL;
typedef void *HDC;
typedef void *HGLRC;
typedef void *HWND;
typedef void *HMENU;
typedef void *HINSTANCE;
typedef void *LPVOID;
typedef struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
typedef struct _POINTL
{
long x;
long y;
} POINTL, *PPOINTL;
typedef struct _devicemodeA {
BYTE dmDeviceName[32];
WORD dmSpecVersion;
WORD dmDriverVersion;
WORD dmSize;
WORD dmDriverExtra;
DWORD dmFields;
union {
struct {
short dmOrientation;
short dmPaperSize;
short dmPaperLength;
short dmPaperWidth;
short dmScale;
short dmCopies;
short dmDefaultSource;
short dmPrintQuality;
} a;
struct {
POINTL dmPosition;
DWORD dmDisplayOrientation;
DWORD dmDisplayFixedOutput;
} b;
} c;
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
BYTE dmFormName[32];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
union {
DWORD dmDisplayFlags;
DWORD dmNup;
};
DWORD dmDisplayFrequency;
} DEVMODE;
typedef struct tagPIXELFORMATDESCRIPTOR
{
WORD nSize;
WORD nVersion;
DWORD dwFlags;
BYTE iPixelType;
BYTE cColorBits;
BYTE cRedBits;
BYTE cRedShift;
BYTE cGreenBits;
BYTE cGreenShift;
BYTE cBlueBits;
BYTE cBlueShift;
BYTE cAlphaBits;
BYTE cAlphaShift;
BYTE cAccumBits;
BYTE cAccumRedBits;
BYTE cAccumGreenBits;
BYTE cAccumBlueBits;
BYTE cAccumAlphaBits;
BYTE cDepthBits;
BYTE cStencilBits;
BYTE cAuxBuffers;
BYTE iLayerType;
BYTE bReserved;
DWORD dwLayerMask;
DWORD dwVisibleMask;
DWORD dwDamageMask;
} PIXELFORMATDESCRIPTOR;
__declspec(dllimport) int WINAPI wglGetProcAddress(LPCSTR);
__declspec(dllimport) HGLRC WINAPI wglCreateContext(HDC);
__declspec(dllimport) long WINAPI wglMakeCurrent(HDC, HGLRC);
__declspec(dllimport) HDC WINAPI GetDC(HWND hWnd);
__declspec(dllimport) HWND WINAPI CreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
__declspec(dllimport) long WINAPI SetPixelFormat(HDC hdc, int format, const PIXELFORMATDESCRIPTOR * ppfd);
__declspec(dllimport) int WINAPI ChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd);
__declspec(dllimport) int WINAPI ShowCursor(long bShow);
__declspec(dllimport) long WINAPI SwapBuffers(HDC);
__declspec(dllimport) short WINAPI GetAsyncKeyState(int vKey);
__declspec(dllimport) __declspec(noreturn) void WINAPI ExitProcess(unsigned int uExitCode);
__declspec(dllimport) long WINAPI ChangeDisplaySettingsA(DEVMODE* lpDevMode, DWORD dwFlags);
__declspec(dllimport) void WINAPI OutputDebugStringA(LPCSTR lpOutputString);
__declspec(dllimport) void WINAPI DebugBreak(VOID);
}

292
4kgfx/src/4k.vcproj Normal file
View File

@@ -0,0 +1,292 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="4k"
ProjectGUID="{478863DD-1156-47FF-8AE2-F7A923BB3998}"
RootNamespace="My4k"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)bin"
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
Description="Compiling shaders..."
CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
Description=""
CommandLine=""
Outputs=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
FavorSizeOrSpeed="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="0"
SmallerTypeCheck="true"
RuntimeLibrary="3"
EnableEnhancedInstructionSet="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib"
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
ProgramDatabaseFile="$(IntDir)\$(TargetName).pdb"
SubSystem="2"
EntryPointSymbol="main"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
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\$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
OmitFramePointers="true"
ExceptionHandling="0"
RuntimeLibrary="0"
StructMemberAlignment="5"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
RuntimeTypeInfo="false"
DebugInformationFormat="0"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
GenerateManifest="false"
GenerateDebugInformation="false"
SubSystem="2"
EntryPointSymbol="main"
RandomizedBaseAddress="0"
DataExecutionPrevention="0"
ErrorReporting="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Crinkler|Win32"
OutputDirectory="$(SolutionDir)bin"
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
ExceptionHandling="0"
RuntimeLibrary="0"
StructMemberAlignment="5"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="false"
WarningLevel="0"
DebugInformationFormat="0"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/CRINKLER /COMPMODE:SLOW /PROGRESSGUI /REPORT:Report.html /HASHSIZE:200 /ORDERTRIES:2000"
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
GenerateManifest="false"
GenerateDebugInformation="false"
SubSystem="2"
EntryPointSymbol="main"
RandomizedBaseAddress="0"
DataExecutionPrevention="0"
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>
<File
RelativePath=".\4kcpu.cpp"
>
</File>
<File
RelativePath=".\intro.h"
>
</File>
<File
RelativePath=".\lib.h"
>
</File>
<File
RelativePath=".\objects.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

94
4kgfx/src/4kcpu.cpp Normal file
View File

@@ -0,0 +1,94 @@
#define XRES 640
#define YRES 480
#define MAX_OBJECTS 64
#define MEMORY 65536
#define BLOCKSIZE 64
#include <windows.h>
#include <process.h>
#include "intro.h"
#pragma bss_seg(".zero")
static int colorBuffer[XRES * YRES];
static __declspec(align(16)) char memoryBuffer[MEMORY];
static char* freeMemory;
#pragma data_seg(".blockindex")
static __declspec(align(32)) volatile LONG currentPixel = -1;
#pragma data_seg(".aspectratio")
static const float aspectRatio = 1.33f;
#ifdef _DEBUG
static int gi_MemoryRemaining = MEMORY;
#endif
#pragma data_seg(".bitmapinfo")
static BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), XRES, -YRES, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, {0, 0, 0, 0}};
#pragma data_seg(".devmode")
static DEVMODE screenSettings = {{0}, 0, 0, 156, 0, 0x001c0000, {0}, 0, 0, 0, 0, 0, {0}, 0, 32, XRES, YRES, {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#pragma code_seg(".operator_new")
void* __cdecl operator new(unsigned int ai_Size)
{
#ifdef _DEBUG
if (gi_MemoryRemaining - (int)ai_Size < 0)
{
*((char*)0) = 0; // another way to crash
}
gi_MemoryRemaining -= ai_Size;
#endif
_asm push freeMemory
_asm mov eax, freeMemory
_asm add eax, ai_Size
_asm mov freeMemory, eax
_asm pop eax
}
#pragma code_seg(".func_intro_render")
DWORD intro_render(LPVOID av_Param_)
{
int myPixel;
do
{
myPixel = ::InterlockedIncrement(&currentPixel);
int x = myPixel % XRES;
int y = YRES - myPixel / XRES;
vec d = normalize(_vec((2.0f * x / XRES - 1.0f) * aspectRatio, 2.0f * y / YRES - 1.0f, -1.0f));
vec o = _vec(0.0f, 0.0f, 5.0f);
vec color = intro_render(o, d);
*(colorBuffer + myPixel) = clamp(color, 0.0f, 1.0f).ToInt32();
} while (currentPixel < XRES*YRES);
return 0;
}
#pragma code_seg(".func_main")
void _cdecl main(void)
{
//ChangeDisplaySettings(&screenSettings, CDS_FULLSCREEN); ShowCursor(0);
HDC hDC=GetDC(CreateWindowEx(0,"static",0,WS_VISIBLE|WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,0,0,XRES,YRES,0,0,0,0));
freeMemory = memoryBuffer;
intro_init();
SYSTEM_INFO lr_SysInfo;
::GetSystemInfo(&lr_SysInfo);
do
{
::CreateThread(0, 0, intro_render, 0, 0, 0);
} while (--lr_SysInfo.dwNumberOfProcessors);
do
{
::StretchDIBits(hDC,0,0,XRES,YRES,0,0,XRES,YRES,colorBuffer,&bmi,DIB_RGB_COLORS,SRCCOPY);
} while(!GetAsyncKeyState(VK_ESCAPE));
::ExitProcess(0);
}
// /CRINKLER /COMPMODE:SLOW /PROGRESSGUI /ORDERTRIES:1000 /HASHSIZE:200 /REPORT:Report.html
// /CRINKLER /COMPMODE:FAST /PROGRESSGUI /ORDERTRIES:100 /HASHSIZE:200 /REPORT:Report.html

96
4kgfx/src/intro.h Normal file
View File

@@ -0,0 +1,96 @@
#pragma once
#include "lib.h"
#include "objects.h"
#pragma bss_seg(".introzero")
static r_Object* gr_Objects_[255];
static vec vectorZero;
#pragma data_seg(".introcolors")
float colorGray[] = {0.5f, 0.5f, 0.5f, 0.0f};
float colorLightBlue[] = {0.4f, 0.5f, 0.8f, 0.0f};
float colorLightGray[] = {0.8f, 0.8f, 0.8f, 0.0f};
float colorLightRed[] = {0.8f, 0.5f, 0.4f, 0.0f};
float colorBrown[] = {0.4f, 0.3f, 0.2f, 0.0f};
#pragma data_seg(".introvectors")
float vectorCylinder[] = {1.0f, 0.0f, 1.0f, 0.0f};
float vectorPlane1[] = {0.0f, 1.0f, 0.4f, 0.0f};
float vectorPlane2[] = {0.4f, -0.3f, 0.9f, 0.0f};
#pragma data_seg(".intropositions")
float positionCylinder[] = {0.0f, -1.0f, 0.5f, 0.0f};
float positionPlane1[] = {0.0f, -3.0f, 0.0f, 0.0f};
float positionPlane2[] = {0.0f, 0.0f, -10.0f, 0.0f};
#pragma data_seg(".introvalues")
float sphereRadius = 2.0f;
float cylinderRadius = 0.5f;
float specularValue = 16.0f;
#pragma code_seg(".intro_init")
__forceinline void intro_init()
{
gr_Objects_[0] = new r_Sphere(new _vec(vectorZero), sphereRadius, new r_Material(new _vec(colorGray), new _vec(colorLightBlue), new _vec(colorLightGray), specularValue));
gr_Objects_[1] = new r_Cylinder(new _vec(normalize(_vec(vectorCylinder))), new _vec(positionCylinder), cylinderRadius, new r_Material(new _vec(colorGray), new _vec(colorLightRed), new _vec(colorLightGray), specularValue));
gr_Objects_[2] = new r_Plane(new _vec(normalize(_vec(vectorPlane1))), new _vec(positionPlane1), new r_Material(new _vec(colorGray), new _vec(colorBrown), new _vec(colorGray), specularValue));
gr_Objects_[3] = new r_Plane(new _vec(normalize(_vec(vectorPlane2))), new _vec(positionPlane2), new r_Material(new _vec(colorGray), new _vec(colorBrown), new _vec(colorGray), specularValue));
}
#pragma code_seg(".get_NearestObject")
void get_NearestObject(_vec& p, r_Object** ar_Object__, float* af_Distance)
{
r_Object** lr_Object__ = gr_Objects_;
r_Object* lr_NearestObject_ = NULL;
float lf_MinDistance = 1024.0f;
// Evaluate distance field:
while (*lr_Object__)
{
*af_Distance = (*lr_Object__)->get_Distance(p);
if (*af_Distance < lf_MinDistance)
{
lr_NearestObject_ = *lr_Object__;
lf_MinDistance = *af_Distance;
}
++lr_Object__;
}
*af_Distance = lf_MinDistance;
*ar_Object__ = lr_NearestObject_;
}
#pragma code_seg(".get_HitObject")
void get_HitObject(_vec& ro, _vec& rd, _vec* hitpoint, r_Object** ar_Object__)
{
float lf_Distance;
vec p = ro;
int li_Iterations = 1024;
// Raymarch:
do
{
get_NearestObject(p, ar_Object__, &lf_Distance);
p += rd * lf_Distance;
} while (lf_Distance > 0.001f && li_Iterations--);
if (lf_Distance > 0.001f)
*ar_Object__ = NULL;
else
*hitpoint = p;
}
#pragma code_seg(".intro_render")
__forceinline vec intro_render(_vec& ro, _vec& rd)
{
r_Object* lr_HitObject_ = NULL;
vec hitPoint;
get_HitObject(ro, rd, &hitPoint, &lr_HitObject_);
if (lr_HitObject_ == NULL)
return _vec(1,1,1);
return *lr_HitObject_->mr_Material_->mr_Diffuse_ * dot(-lr_HitObject_->get_Normal(hitPoint), rd);
}

400
4kgfx/src/lib.h Normal file
View File

@@ -0,0 +1,400 @@
#pragma once
#include <intrin.h>
#pragma data_seg(".const_eps")
static const float eps = 0.001f;
#pragma code_seg(".func_pow")
float 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;
}
#pragma code_seg(".func_sqrt")
__inline float sqrt(float x)
{
__asm fld x
__asm fsqrt
}
#pragma code_seg(".func_sin")
__inline float sin(float x)
{
__asm fld x
__asm fsin
}
#pragma code_seg(".func_cos")
__inline float cos(float x)
{
__asm fld x
__asm fcos
}
#pragma code_seg(".func_fabs")
__inline float fabs(float x)
{
__asm fld x
__asm fabs
}
#pragma code_seg(".func_smoothstep")
float smoothstep(float x, float a, float b)
{
if (x<a) return 0.0f;
if (x>b) return 1.0f;
x = (x-a)/(b-a);
return x*x*(3.0f-2.0f*x);
}
#pragma code_seg(".func_memcopy")
void 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(".func_pi")
float pi()
{
__asm fldpi
}
#pragma code_seg(".func_exp2")
float exp2(float f)
{
_asm fld dword ptr [f]
_asm fld1
_asm fld st(1)
_asm fprem
_asm f2xm1
_asm faddp st(1), st
_asm fscale
_asm fstp st(1)
_asm fstp dword ptr [f]
return f;
}
#pragma code_seg(".func_floor")
int ftol(float x)
{
x -= 0.5f;
int t;
_asm fld x
_asm fistp t
return t;
}
#pragma code_seg(".struct_vec")
#define vec __declspec(align(16)) _vec
struct vec
{
union
{
struct __declspec(align(16))
{
float x;
float y;
float z;
float w;
};
__declspec(align(16)) float m[4];
};
vec():x(0),y(0),z(0),w(0){};
vec(const _vec& arg):x(arg.x),y(arg.y),z(arg.z),w(arg.w){};
vec(float X, float Y, float Z, float W = 0.0f):x(X),y(Y),z(Z),w(W){};
vec(float a):x(a),y(a),z(a),w(0){};
vec(const float* arg){memcopy(m, arg, 16);};
vec(const __m128& arg){_mm_store_ps(m, arg);};
int ToInt32() const
{
return (((ftol(255 * x) << 8) + ftol(255 * y)) << 8) + ftol(255 * z);
}
operator __m128() const
{
return _mm_load_ps(m);
}
vec operator + (const _vec& arg) const
{
return _mm_add_ps(_mm_load_ps(m), _mm_load_ps(arg.m));
}
vec operator + (float arg) const
{
return *this + _mm_set_ps1(arg);
}
void operator += (const _vec& arg)
{
_mm_store_ps(m, _mm_add_ps(*this, arg));
}
void operator += (float arg)
{
*this += _mm_set_ps1(arg);
}
vec operator - (const _vec& arg) const
{
return _mm_sub_ps(*this, arg);
}
vec operator - (float arg) const
{
return *this - _mm_set_ps1(arg);
}
void operator -= (const _vec& arg)
{
_mm_store_ps(m, _mm_sub_ps(*this, arg));
}
void operator -= (float arg)
{
*this -= _mm_set_ps1(arg);
}
vec operator * (const _vec& arg) const
{
return _mm_mul_ps(*this, arg);
}
vec operator * (float arg) const
{
return *this * _mm_set_ps1(arg);
}
void operator *= (const _vec& arg)
{
_mm_store_ps(m, _mm_mul_ps(*this, arg));
}
void operator *= (float arg)
{
*this *= _mm_set_ps1(arg);
}
vec operator / (float arg) const
{
return *this * _mm_set_ps1(1.0f / arg);
}
void operator /= (float arg)
{
*this *= _mm_set_ps1(1.0f / arg);
}
vec operator -() const
{
return *this * -1.0f;
}
};
#pragma code_seg(".align")
__inline vec align(_vec& arg)
{
return arg;
};
#pragma code_seg(".struct_material")
struct r_Material
{
r_Material() {};
r_Material(_vec* ar_Ambient_, _vec* ar_Diffuse_, _vec* ar_Specular_, float af_Shininess)
: mr_Ambient_(ar_Ambient_)
, mr_Diffuse_(ar_Diffuse_)
, mr_Specular_(ar_Specular_)
, mf_Shininess(af_Shininess)
{
}
vec* mr_Ambient_;
vec* mr_Diffuse_;
vec* mr_Specular_;
float mf_Shininess;
};
#pragma code_seg(".func_dot")
float dot(const _vec& arg1, const _vec& arg2)
{
__m128 temp = _mm_mul_ps(arg1, arg2);
temp = _mm_hadd_ps(temp, temp);
temp = _mm_hadd_ps(temp, temp);
return temp.m128_f32[0];
}
#pragma code_seg(".func_length")
float length(_vec& arg)
{
return sqrt(dot(arg, arg));
}
#pragma code_seg(".func_normalize")
vec normalize(_vec& arg)
{
return arg * _mm_rsqrt_ss(_mm_set_ps1(dot(arg,arg))).m128_f32[0];
}
#pragma code_seg(".func_mix")
vec mix(_vec& arg1, _vec& arg2, float t)
{
return arg1 * (1.0f - t) + arg2 * t;
}
#pragma code_seg(".func_clamp1")
vec clamp(_vec& arg, float lo, float hi)
{
return _mm_max_ps(_mm_min_ps(arg, _mm_set_ps1(hi)), _mm_set_ps1(lo));
}
#pragma code_seg(".func_clamp2")
float clamp(float arg, float lo, float hi)
{
return max(min(arg, hi), lo);
}
#pragma code_seg(".func_reflect")
vec reflect(_vec& arg1, _vec& arg2)
{
return arg1 - arg2 * 2.0f * dot(arg2, arg1);
}
#pragma data_seg(".struct_mat")
#define mat __declspec(align(16)) _mat
//struct mat
//{
// union
// {
// struct __declspec(align(16))
// {
// vec r1;
// vec r2;
// vec r3;
// vec r4;
// };
// __declspec(align(16)) float m[16];
// };
//
// mat():r1(1,0,0,0),r2(0,1,0,0),r3(0,0,1,0),r4(0,0,0,1){};
// mat(const _mat& arg):r1(arg.r1),r2(arg.r2),r3(arg.r3),r4(arg.r4){};
// mat(const _vec& R1, const _vec& R2, const _vec& R3, const _vec& R4):r1(R1),r2(R2),r3(R3),r4(R4){};
//
// vec operator * (const _vec& arg) const
// {
// return _vec(dot(r1, arg), dot(r2, arg), dot(r3, arg), dot(r4, arg));
// }
//
// mat operator * (const _mat& arg) const
// {
// return _mat(
// *this * arg.r1,
// *this * arg.r2,
// *this * arg.r3,
// *this * arg.r4);
// }
//
// void operator *= (const _mat& arg)
// {
// r1 = *this * arg.r1;
// r2 = *this * arg.r2;
// r3 = *this * arg.r3;
// r4 = *this * arg.r4;
// }
//
// static mat rotateX(float af_Rad)
// {
// float s = sin(af_Rad);
// float c = cos(af_Rad);
// return _mat(
// _vec(1,0,0,0),
// _vec(0,c,-s,0),
// _vec(0,s,c,0),
// _vec(0,0,0,1));
// }
//
// static mat rotateY(float af_Rad)
// {
// float s = sin(af_Rad);
// float c = cos(af_Rad);
// return _mat(
// _vec(c,0,s,0),
// _vec(0,1,0,0),
// _vec(-s,0,c,0),
// _vec(0,0,0,1));
// }
//
// static mat rotateZ(float af_Rad)
// {
// float s = sin(af_Rad);
// float c = cos(af_Rad);
// return _mat(
// _vec(c,-s,0,0),
// _vec(s,c,0,0),
// _vec(0,0,1,0),
// _vec(0,0,0,1));
// }
//
// static mat scale(float s)
// {
// return _mat(
// _vec(s,0,0,0),
// _vec(0,s,0,0),
// _vec(0,0,s,0),
// _vec(0,0,0,1));
// }
//
// mat transpose(const _mat& arg) const
// {
// return _mat(
// _vec(arg.r1.x, arg.r2.x, arg.r3.x, arg.r4.x),
// _vec(arg.r1.y, arg.r2.y, arg.r3.y, arg.r4.y),
// _vec(arg.r1.z, arg.r2.z, arg.r3.z, arg.r4.z),
// _vec(arg.r1.w, arg.r2.w, arg.r3.w, arg.r4.w));
// }
//};
//
#pragma data_seg(".seed")
static unsigned long seed=0x80808080;
#pragma code_seg(".randseed")
void randseed(unsigned long x)
{
seed = x;
}
#pragma code_seg(".frand")
float frand()
{
seed=seed*0x76364873+1234567;
return (float)(seed&0x7FFFFFFF)*(const float)(2.0f/(float)0x7FFFFFFF)-1.0f;
}

107
4kgfx/src/objects.h Normal file
View File

@@ -0,0 +1,107 @@
#pragma once
#pragma data_seg(".struct_object")
struct r_Object
{
r_Material* mr_Material_;
r_Object(r_Material* ar_Material_)
: mr_Material_(ar_Material_)
{
}
virtual float get_Distance(const _vec& ar_Point) = 0;
virtual vec get_Normal(const _vec& ar_Point) = 0;
virtual vec get_AltNormal(const _vec& ar_Point)
{
vec e1,e2,e3;
e1.x=e2.y=e3.z=eps;
return normalize(_vec(
get_Distance(ar_Point+e1) - get_Distance(ar_Point-e1),
get_Distance(ar_Point+e2) - get_Distance(ar_Point-e2),
get_Distance(ar_Point+e3) - get_Distance(ar_Point-e3)));
}
};
#pragma data_seg(".struct_sphere")
struct r_Sphere : r_Object
{
vec* mr_Center_;
float mf_Radius;
r_Sphere(_vec* ar_Center_, float af_Radius, r_Material* ar_Material_)
: r_Object(ar_Material_)
, mr_Center_(ar_Center_)
, mf_Radius(af_Radius)
{
};
virtual float get_Distance(const _vec& ar_Point)
{
return length(*mr_Center_ - ar_Point) - mf_Radius;
}
virtual vec get_Normal(const _vec& ar_Point)
{
return normalize(ar_Point - *mr_Center_);
}
};
#pragma data_seg(".struct_plane")
struct r_Plane : r_Object
{
vec* mr_Normal_;
vec* mr_Origin_;
r_Plane(_vec* ar_Normal_, _vec* ar_Origin_, r_Material* ar_Material_)
: r_Object(ar_Material_)
, mr_Normal_(ar_Normal_)
, mr_Origin_(ar_Origin_)
{
*mr_Normal_ = normalize(*mr_Normal_);
};
virtual float get_Distance(const _vec& ar_Point)
{
return dot(*mr_Normal_, ar_Point - *mr_Origin_);
}
virtual vec get_Normal(const _vec& ar_Point)
{
return *mr_Normal_;
}
};
#pragma data_seg(".struct_cylinder")
struct r_Cylinder : r_Object
{
vec* mr_Direction_;
vec* mr_Center_;
float mf_Radius;
r_Cylinder(_vec* ar_Direction_, _vec* ar_Center_, float af_Radius, r_Material* ar_Material_)
: r_Object(ar_Material_)
, mr_Direction_(ar_Direction_)
, mr_Center_(ar_Center_)
, mf_Radius(af_Radius)
{
*ar_Direction_ = normalize(*ar_Direction_);
};
virtual float get_Distance(const _vec& ar_Point)
{
vec bP = *mr_Center_ + *mr_Direction_ * dot(ar_Point - *mr_Center_, *mr_Direction_);
return length(ar_Point - bP) - mf_Radius;
}
virtual vec get_Normal(const _vec& ar_Point)
{
vec bP = *mr_Center_ + *mr_Direction_ * dot(ar_Point - *mr_Center_, *mr_Direction_);
return normalize(ar_Point - bP);
}
};

3
4kgfx/stdafx.cpp Normal file
View File

@@ -0,0 +1,3 @@
#include "stdafx.h"
unsigned int currentProgramId;

10
4kgfx/stdafx.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#include "smallwin.h"
#include <GL/gl.h>
#include "glext.h"
#include "vecmath.h"
#include "ogl3.h"
#include "mesh.h"
extern unsigned int currentProgramId;

663
4kgfx/vecmath.cpp Normal file
View File

@@ -0,0 +1,663 @@
#include "stdafx.h"
extern "C"
{
float pi()
{
__asm fldpi
}
void memclear(void* dest, size_t _size)
{
__asm
{
xor eax, eax
mov edi, dest
mov ecx, _size
rep stosb
}
}
void* memcpy(void* dest, const void* source, size_t _size)
{
__asm
{
mov esi, source
mov edi, dest
mov ecx, _size
rep movsb
}
}
size_t strlen(const char* string)
{
__asm
{
xor ecx, ecx
mov edi, string
not ecx
xor al, al
cld
repne scasb
not ecx
lea eax, [ecx-1]
}
}
float 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;
}
float sqrt(float x)
{
__asm fld x
__asm fsqrt
}
float sin(float x)
{
__asm fld x
__asm fsin
}
float cos(float x)
{
__asm fld x
__asm fcos
}
float fabs(float x)
{
__asm fld x
__asm fabs
}
float tan(float f)
{
return sin(f) / cos(f);
}
float smoothstep(float x, float a, float b)
{
if (x<a) return 0.0f;
if (x>b) return 1.0f;
x = (x-a)/(b-a);
return x*x*(3.0f-2.0f*x);
}
float exp2(float f)
{
_asm fld dword ptr [f]
_asm fld1
_asm fld st(1)
_asm fprem
_asm f2xm1
_asm faddp st(1), st
_asm fscale
_asm fstp st(1)
_asm fstp dword ptr [f]
return f;
}
unsigned long ftol(float x)
{
int t;
_asm fld x
_asm fistp t
return t;
}
long _ftol2_sse(float x)
{
*((char*)0) = 0; // If it breaks here, it's because you have a cast to (int) somewhere. Use ftol for float-to-int casts.
return ftol(x);
}
float min(float a, float b)
{
if (a < b) return a;
return b;
}
float max(float a, float b)
{
if (a > b) return a;
return b;
}
int _fltused = 1;
}
vec4::vec4():x(0),y(0),z(0),w(0){};
vec4::vec4(const vec4& arg):x(arg.x),y(arg.y),z(arg.z),w(arg.w){};
vec4::vec4(float X, float Y, float Z, float W):x(X),y(Y),z(Z),w(W){};
vec4::vec4(float a):x(a),y(a),z(a),w(0){};
vec4::vec4(const float* arg){memcpy(m, arg, 16);};
vec4::vec4(const __m128& arg){_mm_store_ps(m, arg);};
int vec4::ToInt32() const
{
return (((ftol(255 * x) << 8) + ftol(255 * y)) << 8) + ftol(255 * z);
}
vec4::operator __m128() const
{
return _mm_load_ps(m);
}
float& vec4::operator[](int i)
{
return m[i];
}
vec4 vec4::operator + (const vec4& arg) const
{
return _mm_add_ps(_mm_load_ps(m), _mm_load_ps(arg.m));
}
vec4 vec4::operator + (float arg) const
{
return *this + _mm_set_ps1(arg);
}
void vec4::operator += (const vec4& arg)
{
_mm_store_ps(m, _mm_add_ps(*this, arg));
}
void vec4::operator += (float arg)
{
*this += _mm_set_ps1(arg);
}
vec4 vec4::operator - (const vec4& arg) const
{
return _mm_sub_ps(*this, arg);
}
vec4 vec4::operator - (float arg) const
{
return *this - _mm_set_ps1(arg);
}
void vec4::operator -= (const vec4& arg)
{
_mm_store_ps(m, _mm_sub_ps(*this, arg));
}
void vec4::operator -= (float arg)
{
*this -= _mm_set_ps1(arg);
}
vec4 vec4::operator * (const vec4& arg) const
{
return _mm_mul_ps(*this, arg);
}
vec4 vec4::operator * (float arg) const
{
return *this * _mm_set_ps1(arg);
}
void vec4::operator *= (const vec4& arg)
{
_mm_store_ps(m, _mm_mul_ps(*this, arg));
}
void vec4::operator *= (float arg)
{
*this *= _mm_set_ps1(arg);
}
vec4 vec4::operator / (float arg) const
{
return *this * _mm_set_ps1(1.0f / arg);
}
void vec4::operator /= (float arg)
{
*this *= _mm_set_ps1(1.0f / arg);
}
vec4 vec4::operator -() const
{
return *this * -1.0f;
}
__inline vec4 align(vec4& arg)
{
return arg;
};
float dot(const vec4& arg1, const vec4& arg2)
{
__m128 temp = _mm_mul_ps(arg1, arg2);
temp = _mm_hadd_ps(temp, temp);
temp = _mm_hadd_ps(temp, temp);
return temp.m128_f32[0];
}
float length(vec4& arg)
{
return sqrt(dot(arg, arg));
}
vec4 normalize(vec4 const& arg)
{
return arg * _mm_rsqrt_ss(_mm_set_ps1(dot(arg,arg))).m128_f32[0];
}
vec4 mix(vec4& arg1, vec4& arg2, float t)
{
return arg1 * (1.0f - t) + arg2 * t;
}
vec4 clamp(vec4& arg, float lo, float hi)
{
return _mm_max_ps(_mm_min_ps(arg, _mm_set_ps1(hi)), _mm_set_ps1(lo));
}
float clamp(float arg, float lo, float hi)
{
return max(min(arg, hi), lo);
}
vec4 reflect(vec4& arg1, vec4& arg2)
{
return arg1 - arg2 * 2.0f * dot(arg2, arg1);
}
vec4 cross(vec4& va, vec4& vb)
{
__m128 a = va;
__m128 b = vb;
__m128 ea = _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 0, 2, 1));
__m128 eb = _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 1, 0, 2));
__m128 xa = _mm_mul_ps(ea, eb);
a = _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 1, 0, 2));
b = _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 0, 2, 1));
__m128 xb = _mm_mul_ps(a, b);
return _mm_sub_ps(xa, xb);
}
Quaternion::Quaternion()
: x(0)
, y(0)
, z(0)
, w(1)
{
};
Quaternion::Quaternion(const Quaternion& arg)
: x(arg.x)
, y(arg.y)
, z(arg.z)
, w(arg.w)
{
};
Quaternion::Quaternion(const float* M)
{
memcpy(m, M, 4 * sizeof(float));
};
Quaternion::operator __m128() const
{
return _mm_load_ps(m);
}
Quaternion::Quaternion(float X, float Y, float Z, float W, bool ab_Rotation)
: x(X)
, y(Y)
, z(Z)
, w(W)
{
if (ab_Rotation)
{
W *= pi();
W /= 180.0;
w = 0.0f;
normalize();
_mm_store_ps(m, _mm_mul_ps(*this, _mm_set_ps1(sin(W / 2.0f))));
w = cos(W / 2.0f);
}
};
Quaternion::Quaternion(const __m128& arg)
{
_mm_store_ps(m, arg);
};
Quaternion::operator float*()
{
return m;
}
Quaternion Quaternion::operator * (const Quaternion& arg) const
{
return _mm_set_ps(
x * -arg.x - y * arg.y - z * arg.z * w * arg.w,
x * -arg.y + y * arg.x + z * arg.w - w * arg.z,
x * -arg.z - y * arg.w + z * arg.x + w * arg.y,
x * -arg.w + y * arg.z - z * arg.y + w * arg.x);
}
Quaternion Quaternion::operator -() const
{
return _mm_set_ps(-x, -y, -z, -w);
}
void Quaternion::operator *= (const Quaternion& arg)
{
_mm_store_ps(m, *this * arg);
}
void Quaternion::operator += (const Quaternion& arg)
{
_mm_store_ps(m, _mm_add_ps(*this, arg));
}
void Quaternion::rotate (const Quaternion& arg)
{
_mm_store_ps(m, -arg * *this * arg);
}
float Quaternion::lengthSquared() const
{
__m128 temp = _mm_mul_ps(*this, *this);
temp = _mm_hadd_ps(temp, temp);
temp = _mm_hadd_ps(temp, temp);
return temp.m128_f32[0];
}
float Quaternion::length() const
{
return sqrt(lengthSquared());
}
void Quaternion::normalize()
{
_mm_store_ps(m, _mm_mul_ps(*this, _mm_set_ps1(_mm_rsqrt_ss(_mm_set_ps1(lengthSquared())).m128_f32[0])));
}
Matrix::Matrix()
: r1(1, 0, 0, 0)
, r2(0, 1, 0, 0)
, r3(0, 0, 1, 0)
, r4(0, 0, 0, 1)
{
};
Matrix::Matrix(const Matrix& arg)
: r1(arg.r1)
, r2(arg.r2)
, r3(arg.r3)
, r4(arg.r4)
{
};
Matrix::Matrix(const vec4& R1, const vec4& R2, const vec4& R3, const vec4& R4)
: r1(R1)
, r2(R2)
, r3(R3)
, r4(R4)
{
};
Matrix::Matrix(const float* M)
: r1(&M[0])
, r2(&M[4])
, r3(&M[8])
, r4(&M[12])
{
};
Matrix::Matrix(const Quaternion& aQuaternion)
{
Quaternion lQuaterion(aQuaternion);
float lf_Length2 = lQuaterion.lengthSquared();
if (lf_Length2 != 1.0 && lf_Length2 != 0.0)
{
lQuaterion.normalize();
}
float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
x2 = lQuaterion.m[0] + lQuaterion.m[0];
y2 = lQuaterion.m[1] + lQuaterion.m[1];
z2 = lQuaterion.m[2] + lQuaterion.m[2];
xx = lQuaterion.m[0] * x2;
xy = lQuaterion.m[0] * y2;
xz = lQuaterion.m[0] * z2;
yy = lQuaterion.m[1] * y2;
yz = lQuaterion.m[1] * z2;
zz = lQuaterion.m[2] * z2;
wx = lQuaterion.m[3] * x2;
wy = lQuaterion.m[3] * y2;
wz = lQuaterion.m[3] * z2;
r1 = vec4(1.0f - (yy + zz), xy - wz, xz + wy, 0.0f);
r2 = vec4(xy + wz, 1.0f - (xx + zz), yz - wx, 0.0f);
r3 = vec4(xz - wy, yz + wx, 1.0f - (xx + yy), 0.0f);
r4 = vec4(0.0f, 0.0f, 0.0f, 1.0f);
};
float& Matrix::operator[](int i)
{
return m[i];
}
vec4 Matrix::operator * (const vec4& arg) const
{
return vec4(dot(r1, arg), dot(r2, arg), dot(r3, arg), dot(r4, arg));
}
Matrix Matrix::operator * (const Matrix& arg) const
{
Matrix temp;
for (int i = 0; i < 4; ++i) // zeile
{
for (int j = 0; j < 4; ++j) // spalte
{
float value = 0;
for (int k = 0; k < 4; ++k)
{
value += m[i*4+k] * arg.m[k*4+j];
}
temp.m[i*4+j] = value;
}
}
return temp;
}
void Matrix::operator *= (const Matrix& arg)
{
Matrix lTemp = *this;
r1 = lTemp * arg.r1;
r2 = lTemp * arg.r2;
r3 = lTemp * arg.r3;
r4 = lTemp * arg.r4;
}
Matrix Matrix::rotateX(float af_Rad)
{
float s = sin(af_Rad);
float c = cos(af_Rad);
return Matrix(
vec4(1,0,0,0),
vec4(0,c,-s,0),
vec4(0,s,c,0),
vec4(0,0,0,1));
}
Matrix Matrix::rotateY(float af_Rad)
{
float s = sin(af_Rad);
float c = cos(af_Rad);
return Matrix(
vec4(c,0,s,0),
vec4(0,1,0,0),
vec4(-s,0,c,0),
vec4(0,0,0,1));
}
Matrix Matrix::rotateZ(float af_Rad)
{
float s = sin(af_Rad);
float c = cos(af_Rad);
return Matrix(
vec4(c,-s,0,0),
vec4(s,c,0,0),
vec4(0,0,1,0),
vec4(0,0,0,1));
}
Matrix Matrix::scale(float s)
{
return Matrix(
vec4(s,0,0,0),
vec4(0,s,0,0),
vec4(0,0,s,0),
vec4(0,0,0,1));
}
Matrix Matrix::scale(const vec4& s)
{
return Matrix(
vec4(s.x,0,0,0),
vec4(0,s.y,0,0),
vec4(0,0,s.z,0),
vec4(0,0,0,1));
}
Matrix Matrix::translate(const vec4& aTranslation)
{
return Matrix(
vec4(1,0,0,aTranslation.x),
vec4(0,1,0,aTranslation.y),
vec4(0,0,1,aTranslation.z),
vec4(0,0,0,1));
}
void Matrix::transpose()
{
Matrix lTemp(
vec4(r1.x, r2.x, r3.x, r4.x),
vec4(r1.y, r2.y, r3.y, r4.y),
vec4(r1.z, r2.z, r3.z, r4.z),
vec4(r1.w, r2.w, r3.w, r4.w));
r1 = lTemp.r1;
r2 = lTemp.r2;
r3 = lTemp.r3;
r4 = lTemp.r4;
}
float Matrix::Determinante2x2(float a1, float a2, float b1, float b2)
{
return a1 * b2 - b1 * a2;
}
float Matrix::Determinante3x3( float a1, float a2, float a3,
float b1, float b2, float b3,
float c1, float c2, float c3)
{
return a1 * Determinante2x2( b2, b3, c2, c3 ) - b1 * Determinante2x2( a2, a3, c2, c3 ) + c1 * Determinante2x2( a2, a3, b2, b3 );
}
void Matrix::inverse()
{
Matrix lResult;
lResult.m[0] = Determinante3x3( m[5], m[9], m[13], m[6], m[10], m[14], m[7], m[11], m[15] );
lResult.m[4] = -Determinante3x3( m[4], m[8], m[12], m[6], m[10], m[14], m[7], m[11], m[15] );
lResult.m[8] = Determinante3x3( m[4], m[8], m[12], m[5], m[9], m[13], m[7], m[11], m[15] );
lResult.m[12] = -Determinante3x3( m[4], m[8], m[12], m[5], m[9], m[13], m[6], m[10], m[14] );
lResult.m[1] = -Determinante3x3( m[1], m[9], m[13], m[2], m[10], m[14], m[3], m[11], m[15] );
lResult.m[5] = Determinante3x3( m[0], m[8], m[12], m[2], m[10], m[14], m[3], m[11], m[15] );
lResult.m[9] = -Determinante3x3( m[0], m[8], m[12], m[1], m[9], m[13], m[3], m[11], m[15] );
lResult.m[13] = Determinante3x3( m[0], m[8], m[12], m[1], m[9], m[13], m[2], m[10], m[14] );
lResult.m[2] = Determinante3x3( m[1], m[5], m[13], m[2], m[6], m[14], m[3], m[7], m[15] );
lResult.m[6] = -Determinante3x3( m[0], m[4], m[12], m[2], m[6], m[14], m[3], m[7], m[15] );
lResult.m[10] = Determinante3x3( m[0], m[4], m[12], m[1], m[5], m[13], m[3], m[7], m[15] );
lResult.m[14] = -Determinante3x3( m[0], m[4], m[12], m[1], m[5], m[13], m[2], m[6], m[14] );
lResult.m[3] = -Determinante3x3( m[1], m[5], m[9], m[2], m[6], m[10], m[3], m[7], m[11] );
lResult.m[7] = Determinante3x3( m[0], m[4], m[8], m[2], m[6], m[10], m[3], m[7], m[11] );
lResult.m[11] = -Determinante3x3( m[0], m[4], m[8], m[1], m[5], m[9], m[3], m[7], m[11] );
lResult.m[15] = Determinante3x3( m[0], m[4], m[8], m[1], m[5], m[9], m[2], m[6], m[10] );
float lf_Det = (m[0] * lResult.m[0]) + (m[1] * lResult.m[4]) + (m[2] * lResult.m[8]) + (m[3] * lResult.m[12]);
if (lf_Det == 0.0f)
return; // matrix is singular
lf_Det = 1.0f / lf_Det;
*this = lResult;
m[0] *= lf_Det;
m[4] *= lf_Det;
m[8] *= lf_Det;
m[12] *= lf_Det;
m[1] *= lf_Det;
m[5] *= lf_Det;
m[9] *= lf_Det;
m[13] *= lf_Det;
m[2] *= lf_Det;
m[6] *= lf_Det;
m[10] *= lf_Det;
m[14] *= lf_Det;
m[3] *= lf_Det;
m[7] *= lf_Det;
m[11] *= lf_Det;
m[15] *= lf_Det;
}
Matrix Matrix::Perspective(float fov, float aspectRatio, float zNear, float zFar)
{
float f = 1.0f / tan(fov / 2.0f);
float m = zNear - zFar;
Matrix M(
vec4(f / aspectRatio, 0, 0, 0),
vec4(0, f, 0, 0),
vec4(0, 0, (zFar + zNear) / m, (2 * zFar * zNear) / m),
vec4(0, 0, -1, 0));
return M;
}
Matrix Matrix::LookAt(vec4& eye, vec4& center, vec4& up)
{
vec4 f = normalize(center - eye);
vec4 u = normalize(up);
vec4 s = cross(f, u);
u = cross(s, f);
s[3] = u[3] = f[3] = 0;
Matrix M(s, u, -f, vec4(0, 0, 0, 1));
//M.transpose();
M *= Matrix::translate(-eye);
return M;
}

147
4kgfx/vecmath.h Normal file
View File

@@ -0,0 +1,147 @@
#pragma once
#include <intrin.h>
extern "C"
{
float pi();
void* memcpy(void* dest, const void* source, size_t size);
void memclear(void* dest, size_t size);
size_t strlen(const char* string);
float pow(float x, float y);
float sqrt(float x);
float sin(float x);
float cos(float x);
float fabs(float x);
float smoothstep(float x, float a, float b);
float exp2(float f);
float tan(float f);
unsigned long ftol(float x);
long _ftol2_sse(float x);
float min(float a, float b);
float max(float a, float b);
}
struct __declspec(align(16)) vec4
{
union
{
struct __declspec(align(16))
{
float x;
float y;
float z;
float w;
};
__declspec(align(16)) float m[4];
};
vec4();
vec4(const vec4& arg);
vec4(float X, float Y, float Z, float W = 0.0f);
vec4(float a);
vec4(const float* arg);
vec4(const __m128& arg);
int ToInt32() const;
operator __m128() const;
float& operator[](int i);
vec4 operator + (const vec4& arg) const;
vec4 operator + (float arg) const;
void operator += (const vec4& arg);
void operator += (float arg);
vec4 operator - (const vec4& arg) const;
vec4 operator - (float arg) const;
void operator -= (const vec4& arg);
void operator -= (float arg);
vec4 operator * (const vec4& arg) const;
vec4 operator * (float arg) const;
void operator *= (const vec4& arg);
void operator *= (float arg);
vec4 operator / (float arg) const;
void operator /= (float arg);
vec4 operator -() const;
};
struct __declspec(align(16)) Quaternion
{
union
{
struct __declspec(align(16))
{
float x;
float y;
float z;
float w;
};
__declspec(align(16)) float m[4];
};
Quaternion();
Quaternion(const Quaternion& arg);
Quaternion(const float* M);
operator __m128() const;
Quaternion(float X, float Y, float Z, float W, bool ab_Rotation = false);
Quaternion(const __m128& arg);
operator float*();
Quaternion operator * (const Quaternion& arg) const;
Quaternion operator -() const;
void operator *= (const Quaternion& arg);
void operator += (const Quaternion& arg);
void rotate (const Quaternion& arg);
float lengthSquared() const;
float length() const;
void normalize();
};
struct __declspec(align(16)) Matrix
{
union
{
struct __declspec(align(16))
{
vec4 r1;
vec4 r2;
vec4 r3;
vec4 r4;
};
__declspec(align(16)) float m[16];
};
Matrix();
Matrix(const Matrix& arg);
Matrix(const vec4& R1, const vec4& R2, const vec4& R3, const vec4& R4);
Matrix(const float* M);
Matrix(const Quaternion& aQuaternion);
float& operator[](int i);
vec4 operator * (const vec4& arg) const;
Matrix operator * (const Matrix& arg) const;
void operator *= (const Matrix& arg);
static Matrix rotateX(float af_Rad);
static Matrix rotateY(float af_Rad);
static Matrix rotateZ(float af_Rad);
static Matrix scale(float s);
static Matrix scale(const vec4& s);
static Matrix translate(const vec4& aTranslation);
static Matrix Perspective(float fov, float aspect, float near, float far);
static Matrix LookAt(vec4& eye, vec4& center, vec4& up);
void transpose();
float Determinante2x2(float a1, float a2, float b1, float b2);
float Determinante3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3);
void inverse();
};
__inline vec4 align(vec4& arg);
__inline Quaternion align(Quaternion& arg);
__inline Matrix align(Matrix& arg);
float dot(const vec4& arg1, const vec4& arg2);
float length(vec4& arg);
vec4 normalize(vec4 const& arg);
vec4 mix(vec4& arg1, vec4& arg2, float t);
vec4 clamp(vec4& arg, float lo, float hi);
float clamp(float arg, float lo, float hi);
vec4 reflect(vec4& arg1, vec4& arg2);
vec4 cross(vec4& a, vec4& b);

897
4kgfx/wglext.h Normal file
View File

@@ -0,0 +1,897 @@
#ifndef __wglext_h_
#define __wglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2010 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Function declaration macros - to move into glplatform.h */
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/*************************************************************/
/* Header file version number */
/* wglext.h last updated 2010/08/06 */
/* Current version at http://www.opengl.org/registry/ */
#define WGL_WGLEXT_VERSION 22
#ifndef WGL_ARB_buffer_region
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
#endif
#ifndef WGL_ARB_multisample
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif
#ifndef WGL_ARB_extensions_string
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#endif
#ifndef WGL_ARB_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
#endif
#ifndef WGL_ARB_render_texture
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
#define WGL_TEXTURE_FORMAT_ARB 0x2072
#define WGL_TEXTURE_TARGET_ARB 0x2073
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
#define WGL_TEXTURE_RGB_ARB 0x2075
#define WGL_TEXTURE_RGBA_ARB 0x2076
#define WGL_NO_TEXTURE_ARB 0x2077
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
#define WGL_TEXTURE_1D_ARB 0x2079
#define WGL_TEXTURE_2D_ARB 0x207A
#define WGL_MIPMAP_LEVEL_ARB 0x207B
#define WGL_CUBE_MAP_FACE_ARB 0x207C
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
#define WGL_FRONT_LEFT_ARB 0x2083
#define WGL_FRONT_RIGHT_ARB 0x2084
#define WGL_BACK_LEFT_ARB 0x2085
#define WGL_BACK_RIGHT_ARB 0x2086
#define WGL_AUX0_ARB 0x2087
#define WGL_AUX1_ARB 0x2088
#define WGL_AUX2_ARB 0x2089
#define WGL_AUX3_ARB 0x208A
#define WGL_AUX4_ARB 0x208B
#define WGL_AUX5_ARB 0x208C
#define WGL_AUX6_ARB 0x208D
#define WGL_AUX7_ARB 0x208E
#define WGL_AUX8_ARB 0x208F
#define WGL_AUX9_ARB 0x2090
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif
#ifndef WGL_ARB_create_context
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define ERROR_INVALID_VERSION_ARB 0x2095
#endif
#ifndef WGL_ARB_create_context_profile
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define ERROR_INVALID_PROFILE_ARB 0x2096
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
#endif
#ifndef WGL_EXT_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
#define WGL_ACCELERATION_EXT 0x2003
#define WGL_NEED_PALETTE_EXT 0x2004
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
#define WGL_SWAP_METHOD_EXT 0x2007
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
#define WGL_TRANSPARENT_EXT 0x200A
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
#define WGL_SHARE_DEPTH_EXT 0x200C
#define WGL_SHARE_STENCIL_EXT 0x200D
#define WGL_SHARE_ACCUM_EXT 0x200E
#define WGL_SUPPORT_GDI_EXT 0x200F
#define WGL_SUPPORT_OPENGL_EXT 0x2010
#define WGL_DOUBLE_BUFFER_EXT 0x2011
#define WGL_STEREO_EXT 0x2012
#define WGL_PIXEL_TYPE_EXT 0x2013
#define WGL_COLOR_BITS_EXT 0x2014
#define WGL_RED_BITS_EXT 0x2015
#define WGL_RED_SHIFT_EXT 0x2016
#define WGL_GREEN_BITS_EXT 0x2017
#define WGL_GREEN_SHIFT_EXT 0x2018
#define WGL_BLUE_BITS_EXT 0x2019
#define WGL_BLUE_SHIFT_EXT 0x201A
#define WGL_ALPHA_BITS_EXT 0x201B
#define WGL_ALPHA_SHIFT_EXT 0x201C
#define WGL_ACCUM_BITS_EXT 0x201D
#define WGL_ACCUM_RED_BITS_EXT 0x201E
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
#define WGL_DEPTH_BITS_EXT 0x2022
#define WGL_STENCIL_BITS_EXT 0x2023
#define WGL_AUX_BUFFERS_EXT 0x2024
#define WGL_NO_ACCELERATION_EXT 0x2025
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
#define WGL_FULL_ACCELERATION_EXT 0x2027
#define WGL_SWAP_EXCHANGE_EXT 0x2028
#define WGL_SWAP_COPY_EXT 0x2029
#define WGL_SWAP_UNDEFINED_EXT 0x202A
#define WGL_TYPE_RGBA_EXT 0x202B
#define WGL_TYPE_COLORINDEX_EXT 0x202C
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
#define WGL_PBUFFER_LARGEST_EXT 0x2033
#define WGL_PBUFFER_WIDTH_EXT 0x2034
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
#endif
#ifndef WGL_EXT_depth_float
#define WGL_DEPTH_FLOAT_EXT 0x2040
#endif
#ifndef WGL_3DFX_multisample
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
#define WGL_SAMPLES_3DFX 0x2061
#endif
#ifndef WGL_EXT_multisample
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
#define WGL_SAMPLES_EXT 0x2042
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
#endif
#ifndef WGL_I3D_gamma
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
#endif
#ifndef WGL_I3D_genlock
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
#endif
#ifndef WGL_I3D_swap_frame_lock
#endif
#ifndef WGL_NV_render_depth_texture
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
#define WGL_DEPTH_COMPONENT_NV 0x20A7
#endif
#ifndef WGL_NV_render_texture_rectangle
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
#endif
#ifndef WGL_NV_float_buffer
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
#endif
#ifndef WGL_NV_present_video
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
#endif
#ifndef WGL_NV_video_out
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
#define WGL_VIDEO_OUT_FRAME 0x20C8
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
#endif
#ifndef WGL_NV_swap_group
#endif
#ifndef WGL_NV_gpu_affinity
#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
#endif
#ifndef WGL_AMD_gpu_association
#define WGL_GPU_VENDOR_AMD 0x1F00
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
#define WGL_GPU_RAM_AMD 0x21A3
#define WGL_GPU_CLOCK_AMD 0x21A4
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
#define WGL_GPU_NUM_RB_AMD 0x21A7
#define WGL_GPU_NUM_SPI_AMD 0x21A8
#endif
#ifndef WGL_NV_video_capture
#define WGL_UNIQUE_ID_NV 0x20CE
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
#endif
#ifndef WGL_NV_copy_image
#endif
#ifndef WGL_NV_multisample_coverage
#define WGL_COVERAGE_SAMPLES_NV 0x2042
#define WGL_COLOR_SAMPLES_NV 0x20B9
#endif
#ifndef WGL_EXT_create_context_es2_profile
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
#endif
/*************************************************************/
#ifndef WGL_ARB_pbuffer
DECLARE_HANDLE(HPBUFFERARB);
#endif
#ifndef WGL_EXT_pbuffer
DECLARE_HANDLE(HPBUFFEREXT);
#endif
#ifndef WGL_NV_present_video
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
#endif
#ifndef WGL_NV_video_output
DECLARE_HANDLE(HPVIDEODEV);
#endif
#ifndef WGL_NV_gpu_affinity
DECLARE_HANDLE(HPGPUNV);
DECLARE_HANDLE(HGPUNV);
typedef struct _GPU_DEVICE {
DWORD cb;
CHAR DeviceName[32];
CHAR DeviceString[128];
DWORD Flags;
RECT rcVirtualScreen;
} GPU_DEVICE, *PGPU_DEVICE;
#endif
#ifndef WGL_NV_video_capture
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
#endif
#ifndef WGL_ARB_buffer_region
#define WGL_ARB_buffer_region 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif
#ifndef WGL_ARB_multisample
#define WGL_ARB_multisample 1
#endif
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_ARB_make_current_read
#define WGL_ARB_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
extern HDC WINAPI wglGetCurrentReadDCARB (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_ARB_render_texture
#define WGL_ARB_render_texture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_ARB_pixel_format_float 1
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_ARB_framebuffer_sRGB 1
#endif
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif
#ifndef WGL_ARB_create_context_profile
#define WGL_ARB_create_context_profile 1
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_ARB_create_context_robustness 1
#endif
#ifndef WGL_EXT_display_color_table
#define WGL_EXT_display_color_table 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
#endif
#ifndef WGL_EXT_extensions_string
#define WGL_EXT_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
#endif
#ifndef WGL_EXT_make_current_read
#define WGL_EXT_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
extern HDC WINAPI wglGetCurrentReadDCEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_EXT_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_EXT_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_EXT_swap_control
#define WGL_EXT_swap_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSwapIntervalEXT (int interval);
extern int WINAPI wglGetSwapIntervalEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
#endif
#ifndef WGL_EXT_depth_float
#define WGL_EXT_depth_float 1
#endif
#ifndef WGL_NV_vertex_array_range
#define WGL_NV_vertex_array_range 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
extern void WINAPI wglFreeMemoryNV (void *pointer);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
#endif
#ifndef WGL_3DFX_multisample
#define WGL_3DFX_multisample 1
#endif
#ifndef WGL_EXT_multisample
#define WGL_EXT_multisample 1
#endif
#ifndef WGL_OML_sync_control
#define WGL_OML_sync_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_I3D_digital_video_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
#endif
#ifndef WGL_I3D_gamma
#define WGL_I3D_gamma 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif
#ifndef WGL_I3D_genlock
#define WGL_I3D_genlock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_I3D_image_buffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
#endif
#ifndef WGL_I3D_swap_frame_lock
#define WGL_I3D_swap_frame_lock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableFrameLockI3D (void);
extern BOOL WINAPI wglDisableFrameLockI3D (void);
extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
#endif
#ifndef WGL_I3D_swap_frame_usage
#define WGL_I3D_swap_frame_usage 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
extern BOOL WINAPI wglEndFrameTrackingI3D (void);
extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_ATI_pixel_format_float 1
#endif
#ifndef WGL_NV_float_buffer
#define WGL_NV_float_buffer 1
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_3DL_stereo_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_EXT_pixel_format_packed_float 1
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_EXT_framebuffer_sRGB 1
#endif
#ifndef WGL_NV_present_video
#define WGL_NV_present_video 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
#endif
#ifndef WGL_NV_video_output
#define WGL_NV_video_output 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#ifndef WGL_NV_swap_group
#define WGL_NV_swap_group 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
extern BOOL WINAPI wglResetFrameCountNV (HDC hDC);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
#endif
#ifndef WGL_NV_gpu_affinity
#define WGL_NV_gpu_affinity 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
extern BOOL WINAPI wglDeleteDCNV (HDC hdc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
#endif
#ifndef WGL_AMD_gpu_association
#define WGL_AMD_gpu_association 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
#ifndef WGL_NV_video_capture
#define WGL_NV_video_capture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif
#ifndef WGL_NV_copy_image
#define WGL_NV_copy_image 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef WGL_NV_multisample_coverage
#define WGL_NV_multisample_coverage 1
#endif
extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
#ifdef __cplusplus
}
#endif
#endif

62
8kode/8kode.sln Normal file
View File

@@ -0,0 +1,62 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "intro", "src\intro\intro.vcxproj", "{EC001821-5569-4BB5-87B3-20CB8FF9137B}"
ProjectSection(ProjectDependencies) = postProject
{6D00EB12-7129-482A-8011-F187F20345DF} = {6D00EB12-7129-482A-8011-F187F20345DF}
{930621BA-75BE-49FE-80DE-E75E7DC06931} = {930621BA-75BE-49FE-80DE-E75E7DC06931}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tool", "src\tool\tool.csproj", "{6D00EB12-7129-482A-8011-F187F20345DF}"
ProjectSection(ProjectDependencies) = postProject
{930621BA-75BE-49FE-80DE-E75E7DC06931} = {930621BA-75BE-49FE-80DE-E75E7DC06931}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shc", "src\shc\shc.csproj", "{930621BA-75BE-49FE-80DE-E75E7DC06931}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Authoring|Mixed Platforms = Authoring|Mixed Platforms
Compress|Mixed Platforms = Compress|Mixed Platforms
Release|Mixed Platforms = Release|Mixed Platforms
ShaderDebug|Mixed Platforms = ShaderDebug|Mixed Platforms
Video|Mixed Platforms = Video|Mixed Platforms
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Authoring|Mixed Platforms.ActiveCfg = Authoring|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Authoring|Mixed Platforms.Build.0 = Authoring|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Compress|Mixed Platforms.ActiveCfg = Compress|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Compress|Mixed Platforms.Build.0 = Compress|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Release|Mixed Platforms.Build.0 = Release|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.ShaderDebug|Mixed Platforms.ActiveCfg = ShaderDebug|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.ShaderDebug|Mixed Platforms.Build.0 = ShaderDebug|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Video|Mixed Platforms.ActiveCfg = Video|Win32
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Video|Mixed Platforms.Build.0 = Video|Win32
{6D00EB12-7129-482A-8011-F187F20345DF}.Authoring|Mixed Platforms.ActiveCfg = Authoring|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Authoring|Mixed Platforms.Build.0 = Authoring|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Compress|Mixed Platforms.ActiveCfg = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Compress|Mixed Platforms.Build.0 = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Release|Mixed Platforms.ActiveCfg = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Release|Mixed Platforms.Build.0 = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.ShaderDebug|Mixed Platforms.ActiveCfg = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.ShaderDebug|Mixed Platforms.Build.0 = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Video|Mixed Platforms.ActiveCfg = Void|Any CPU
{6D00EB12-7129-482A-8011-F187F20345DF}.Video|Mixed Platforms.Build.0 = Void|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Authoring|Mixed Platforms.ActiveCfg = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Authoring|Mixed Platforms.Build.0 = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Compress|Mixed Platforms.ActiveCfg = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Compress|Mixed Platforms.Build.0 = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.ShaderDebug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.ShaderDebug|Mixed Platforms.Build.0 = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Video|Mixed Platforms.ActiveCfg = Debug|Any CPU
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Video|Mixed Platforms.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
8kode/8kode.v12.suo Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>AvalonEdit</id>
<version>5.0.2</version>
<authors>Daniel Grunwald</authors>
<owners>Daniel Grunwald</owners>
<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>
<projectUrl>http://www.avalonedit.net/</projectUrl>
<iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>AvalonEdit is the WPF-based text editor used in SharpDevelop. There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and one that targets .NET 3.5.</description>
<summary>AvalonEdit is the WPF-based text editor used in SharpDevelop</summary>
<releaseNotes>* License changed from LGPL to MIT
* New Feature: Hide mouse cursor while typing (enabled by default)
* New Feature: Highlight current line (disabled by default)
* New Feature: Overstrike mode (disabled by default)
* New Feature: 'underline' attribute in syntax highlighting definitions
* AvalonEdit now raises the WPF DataObject attached events on clipboard and drag'n'drop operations.
* Encoding detection now distinguishes between UTF-8 with BOM and UTF-8 without BOM. This prevents AvalonEdit from adding the BOM to existing UTF-8 files.
* Improved handling of grapheme clusters. A base character followed by a combining mark is now treated as a single character by the caret movement logic.
* Added RichText, RichTextModel and RichTextColorizer.
* Renamed the VB highlighting mode from "VBNET" to "VB"
* Changed IHighlighter API in order to support SharpDevelop's semantic C# highlighter
* The regex-based highlighting engine was moved into its own class (HighlightingEngine) to be separated from the state-tracking logic in DocumentHighlighter.
* Add FileName property to TextDocument class.
* DocumentChangeEventArgs.RemovedText/InsertedText are now of type ITextSource instead of string.
* The error-tolerant XML parser included with AvalonEdit was removed. An improved version of this parser is part of the NRefactory 5 project.
* Removed some obsolete APIs.</releaseNotes>
<language>en-US</language>
<tags>WPF Text Editor SharpDevelop AvalonEdit</tags>
</metadata>
</package>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\src\tool\packages.config" />
</repositories>

58
8kode/readme.txt Normal file
View File

@@ -0,0 +1,58 @@
Alcatraz 8kode
=========
A framework for developing 8k intros.
Initial setup:
1) Start Visual Studio 2013 and open 8kode.sln
2) Right click your solution and choose "Set StartUp Projects..."
3) Under Common Properties -> Startup Project, choose "Multiple startup projects"
4) Set both "intro" and "tool" to Start.
5) Click "OK"
6) Set your build configuration to "Authoring"
7) Hit F5 and enjoy.
Interface:
8kode's interface is very similar to Blender 2.5.
If you're unfamiliar with it, please have a look at http://vimeo.com/19628478 starting from 1:59
You can set up multiple views of the same data, and you can split, resize and merge views as you need.
Layouts can be saved and loaded using the Layouts menu.
Intro navigation:
You can move through time by clicking and dragging in the Audio view.
The seek positions snap to intro "scenes".
A scene is defined by SOUND_TICKS_PER_SCENE * SAMPLES_PER_TICK samples.
The preconfigured SOUND_TICKS_PER_SCENE is 64 ticks and SAMPLES_PER_TICK is provided by 4klang.h
File and folder structure:
The intro coder musn't take care of the src\intro\framework folder.
Shaders are inside src\intro\shaders, intro code is inside src\intro\intro.
Put your intro init code in src\intro\intro\init.h and your per-frame code in src\intro\intro\update.h.
Variables and such can be put in src\intro\intro\data.h
Shader compiler tool (shc):
8kode comes with a shader preprocessor. It has 2 main purposes:
1) Resolve all #includes, so that Ctrl+Alt+Test's shader minifier can minify everything together
2) Automatically generate C++ code with ready-to-use DirectX shader pointers
In order to have autogenerated shader pointers, you can use an [EntryPoint(foo)] attribute on your HLSL function.
This will signal shc that this function is an entry point, and it will create a corresponding IID3D11FooShader* pointer.
Obviously you should replace foo with the correct shader profile name (e.g. vs, ps, cs).
Example:
[numthreads(16, 16, 1)]
[entrypoint(cs)]
void colorPattern(uint3 id:SV_DispatchThreadID)
{
float2 resolution;
out0.GetDimensions(resolution.x, resolution.y);
out0[id.xy] = float4(id.xy / resolution, 0.5, 1.0);
}
When compiling with shc, it will generate corresponding code and provide a ID3D11ComputeShader* cs_colorPattern pointer.
The coder can use that pointer immediately in the intro code.
8kode's authoring tool allows instant shader compilation with the shortcut Ctrl+Enter. It invokes shc, which in turn:
1) generates intro\framework\shaders_shc.h, containing all entry point shader pointers and compile code for the intro
2) runs Ctrl+Alt+Test's shader minifier and outputs the minified shader to intro\framework\intro_hlsl.h
3) recompiles every entry point that was present at the last intro compile time. If entry points changed, a tool restart is required.
All shader compilation errors are marked in the code view as line decorations. Hovering over marked lines will display a tooltip
with the errors in that line.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
// some useful song defines for 4klang
#define SAMPLE_RATE 44100
#define BPM 174.170609
#define MAX_INSTRUMENTS 10
#define MAX_PATTERNS 132
#define PATTERN_SIZE_SHIFT 4
#define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
#define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
#define SAMPLES_PER_TICK 3798
#define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
#define POLYPHONY 1
#define FLOAT_32BIT
#define SAMPLE_TYPE float
#define WINDOWS_OBJECT
// 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;

View File

@@ -0,0 +1,942 @@
%macro export_func 1
global _%1
_%1:
%endmacro
%define USE_SECTIONS
%define SAMPLE_RATE 44100
%define MAX_INSTRUMENTS 10
%define MAX_VOICES 1
%define HLD 1
%define BPM 174.170609
%define MAX_PATTERNS 132
%define PATTERN_SIZE_SHIFT 4
%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
%define SAMPLES_PER_TICK 3798
%define DEF_LFO_NORMALIZE 0.0000658241
%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
;%define GO4K_USE_16BIT_OUTPUT
;%define GO4K_USE_GROOVE_PATTERN
;%define GO4K_USE_ENVELOPE_RECORDINGS
;%define GO4K_USE_NOTE_RECORDINGS
%define GO4K_CLIP_OUTPUT
%define GO4K_USE_DST
%define GO4K_USE_DLL
%define GO4K_USE_PAN
%define GO4K_USE_GLOBAL_DLL
%define GO4K_USE_FSTG
%define GO4K_USE_ENV_CHECK
%define GO4K_USE_ENV_MOD_GM
%define GO4K_USE_VCO_CHECK
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCO_GATE
%define GO4K_USE_VCO_MOD_FM
%define GO4K_USE_VCO_MOD_TM
%define GO4K_USE_VCO_MOD_GM
%define GO4K_USE_VCO_MOD_SM
%define GO4K_USE_VCF_CHECK
%define GO4K_USE_VCF_MOD_FM
%define GO4K_USE_VCF_HIGH
%define GO4K_USE_VCF_BAND
%define GO4K_USE_VCF_PEAK
%define GO4K_USE_DST_CHECK
%define GO4K_USE_DST_SH
%define GO4K_USE_DLL_CHORUS_CLAMP
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_FSTG_CHECK
%define GO4K_USE_OUT_MOD_GM
%define GO4K_USE_WAVESHAPER_CLIP
%define MAX_DELAY 65536
%define MAX_UNITS 48
%define MAX_UNIT_SLOTS 9
%define GO4K_BEGIN_CMDDEF(def_name)
%define GO4K_END_CMDDEF db 0
%define GO4K_BEGIN_PARAMDEF(def_name)
%define GO4K_END_PARAMDEF
GO4K_ENV_ID equ 1
%macro GO4K_ENV 5
db %1
db %2
db %3
db %4
db %5
%endmacro
%define ATTAC(val) val
%define DECAY(val) val
%define SUSTAIN(val) val
%define RELEASE(val) val
%define GAIN(val) val
struc go4kENV_val
.attac resd 1
.decay resd 1
.sustain resd 1
.release resd 1
.gain resd 1
.size
endstruc
struc go4kENV_wrk
.state resd 1
.level resd 1
.gm resd 1
.am resd 1
.dm resd 1
.sm resd 1
.rm resd 1
.size
endstruc
%define ENV_STATE_ATTAC 0
%define ENV_STATE_DECAY 1
%define ENV_STATE_SUSTAIN 2
%define ENV_STATE_RELEASE 3
%define ENV_STATE_OFF 4
GO4K_VCO_ID equ 2
%macro GO4K_VCO 8
db %1
db %2
%ifdef GO4K_USE_VCO_PHASE_OFFSET
db %3
%endif
%ifdef GO4K_USE_VCO_GATE
db %4
%endif
db %5
%ifdef GO4K_USE_VCO_SHAPE
db %6
%endif
db %7
db %8
%endmacro
%define TRANSPOSE(val) val
%define DETUNE(val) val
%define PHASE(val) val
%define GATES(val) val
%define COLOR(val) val
%define SHAPE(val) val
%define FLAGS(val) val
%define SINE 0x01
%define TRISAW 0x02
%define PULSE 0x04
%define NOISE 0x08
%define LFO 0x10
%define GATE 0x20
%define VCO_STEREO 0x40
struc go4kVCO_val
.transpose resd 1
.detune resd 1
%ifdef GO4K_USE_VCO_PHASE_OFFSET
.phaseofs resd 1
%endif
%ifdef GO4K_USE_VCO_GATE
.gate resd 1
%endif
.color resd 1
%ifdef GO4K_USE_VCO_SHAPE
.shape resd 1
%endif
.gain resd 1
.flags resd 1
.size
endstruc
struc go4kVCO_wrk
.phase resd 1
.tm resd 1
.dm resd 1
.fm resd 1
.pm resd 1
.cm resd 1
.sm resd 1
.gm resd 1
.phase2 resd 1
.size
endstruc
GO4K_VCF_ID equ 3
%macro GO4K_VCF 3
db %1
db %2
db %3
%endmacro
%define LOWPASS 0x1
%define HIGHPASS 0x2
%define BANDPASS 0x4
%define BANDSTOP 0x3
%define ALLPASS 0x7
%define PEAK 0x8
%define STEREO 0x10
%define FREQUENCY(val) val
%define RESONANCE(val) val
%define VCFTYPE(val) val
struc go4kVCF_val
.freq resd 1
.res resd 1
.type resd 1
.size
endstruc
struc go4kVCF_wrk
.low resd 1
.high resd 1
.band resd 1
.freq resd 1
.fm resd 1
.rm resd 1
.low2 resd 1
.high2 resd 1
.band2 resd 1
.size
endstruc
GO4K_DST_ID equ 4
%macro GO4K_DST 3
db %1
%ifdef GO4K_USE_DST_SH
db %2
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%else
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%endif
%endmacro
%define DRIVE(val) val
%define SNHFREQ(val) val
%define FLAGS(val) val
struc go4kDST_val
.drive resd 1
%ifdef GO4K_USE_DST_SH
.snhfreq resd 1
%endif
.flags resd 1
.size
endstruc
struc go4kDST_wrk
.out resd 1
.snhphase resd 1
.dm resd 1
.sm resd 1
.out2 resd 1
.size
endstruc
GO4K_DLL_ID equ 5
%macro GO4K_DLL 8
db %1
db %2
db %3
%ifdef GO4K_USE_DLL_DAMP
db %4
%endif
%ifdef GO4K_USE_DLL_CHORUS
db %5
db %6
%endif
db %7
db %8
%endmacro
%define PREGAIN(val) val
%define DRY(val) val
%define FEEDBACK(val) val
%define DEPTH(val) val
%define DAMP(val) val
%define DELAY(val) val
%define COUNT(val) val
struc go4kDLL_val
.pregain resd 1
.dry resd 1
.feedback resd 1
%ifdef GO4K_USE_DLL_DAMP
.damp resd 1
%endif
%ifdef GO4K_USE_DLL_CHORUS
.freq resd 1
.depth
%endif
.delay resd 1
.count resd 1
.size
endstruc
struc go4kDLL_wrk
.index resd 1
.store resd 1
.dcin resd 1
.dcout resd 1
%ifdef GO4K_USE_DLL_CHORUS
.phase resd 1
%endif
.buffer resd MAX_DELAY
.size
endstruc
struc go4kDLL_wrk2
.pm resd 1
.fm resd 1
.im resd 1
.dm resd 1
.sm resd 1
.am resd 1
.size
endstruc
GO4K_FOP_ID equ 6
%macro GO4K_FOP 1
db %1
%endmacro
%define OP(val) val
%define FOP_POP 0x1
%define FOP_ADDP 0x2
%define FOP_MULP 0x3
%define FOP_PUSH 0x4
%define FOP_XCH 0x5
%define FOP_MUL 0x6
%define FOP_ADDP2 0x7
struc go4kFOP_val
.flags resd 1
.size
endstruc
struc go4kFOP_wrk
.size
endstruc
GO4K_FST_ID equ 7
%macro GO4K_FST 2
db %1
dw %2
%endmacro
%define AMOUNT(val) val
%define DEST(val) val
%define FST_SET 0x0000
%define FST_ADD 0x4000
%define FST_POP 0x8000
struc go4kFST_val
.amount resd 1
.op1 resd 1
.size
endstruc
struc go4kFST_wrk
.size
endstruc
GO4K_PAN_ID equ 8
%macro GO4K_PAN 1
%ifdef GO4K_USE_PAN
db %1
%endif
%endmacro
%define PANNING(val) val
struc go4kPAN_val
%ifdef GO4K_USE_PAN
.panning resd 1
%endif
.size
endstruc
struc go4kPAN_wrk
.pm resd 1
.size
endstruc
GO4K_OUT_ID equ 9
%macro GO4K_OUT 2
db %1
%ifdef GO4K_USE_GLOBAL_DLL
db %2
%endif
%endmacro
%define AUXSEND(val) val
struc go4kOUT_val
.gain resd 1
%ifdef GO4K_USE_GLOBAL_DLL
.auxsend resd 1
%endif
.size
endstruc
struc go4kOUT_wrk
.am resd 1
.gm resd 1
.size
endstruc
GO4K_ACC_ID equ 10
%macro GO4K_ACC 1
db %1
%endmacro
%define OUTPUT 0
%define AUX 8
%define ACCTYPE(val) val
struc go4kACC_val
.acctype resd 1
.size
endstruc
struc go4kACC_wrk
.size
endstruc
%ifdef GO4K_USE_FLD
GO4K_FLD_ID equ 11
%macro GO4K_FLD 1
db %1
%endmacro
%define VALUE(val) val
struc go4kFLD_val
.value resd 1
.size
endstruc
struc go4kFLD_wrk
.vm resd 1
.size
endstruc
%endif
%ifdef GO4K_USE_FSTG
GO4K_FSTG_ID equ 12
%macro GO4K_FSTG 2
db %1
dw %2
%endmacro
struc go4kFSTG_val
.amount resd 1
.op1 resd 1
.size
endstruc
struc go4kFSTG_wrk
.size
endstruc
%endif
struc go4k_instrument
.release resd 1
.note resd 1
.workspace resd MAX_UNITS*MAX_UNIT_SLOTS
.dlloutl resd 1
.dlloutr resd 1
.outl resd 1
.outr resd 1
.size
endstruc
struc go4k_synth
.instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES
.global resb go4k_instrument.size * MAX_VOICES
.size
endstruc
%ifdef USE_SECTIONS
section .g4kmuc1 data align=1
%else
section .data align=1
%endif
go4k_patterns
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
db 0, 0, 0, 0, 0, 0, 84, HLD, HLD, HLD, HLD, HLD, 76, HLD, HLD, HLD,
db 77, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 64, HLD, 69, HLD,
db 81, HLD, 93, HLD, HLD, HLD, 84, HLD, HLD, HLD, HLD, HLD, 76, HLD, HLD, HLD,
db HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 64, HLD, 69, HLD,
db 77, HLD, 76, HLD, 77, HLD, 74, HLD, HLD, HLD, 77, HLD, 81, HLD, HLD, HLD,
db 74, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 88, HLD, 89, HLD, HLD, HLD,
db 86, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 79, HLD, 78, HLD, 79, HLD, 76, HLD, HLD, HLD, 79, HLD, 83, HLD, HLD, HLD,
db 76, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 90, HLD, 91, HLD, HLD, HLD,
db 88, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 84, HLD, 83, HLD, 84, HLD, 81, HLD, HLD, HLD, 84, HLD, 88, HLD, HLD, HLD,
db 81, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 95, HLD, 96, HLD, HLD, HLD,
db 93, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 81, HLD, 79, HLD, 81, HLD, 78, HLD, HLD, HLD, 81, HLD, 84, HLD, HLD, HLD,
db 78, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 91, HLD, 93, HLD, HLD, HLD,
db 90, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 76, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 90, HLD, 91, HLD, 69, HLD,
db 88, HLD, 86, HLD, 88, HLD, 84, HLD, HLD, HLD, 88, HLD, 91, HLD, HLD, HLD,
db 84, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 98, HLD, 100, HLD, HLD, HLD,
db 96, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 83, HLD, 81, HLD, 83, HLD, 79, HLD, HLD, HLD, 83, HLD, 86, HLD, HLD, HLD,
db 79, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 93, HLD, 95, HLD, HLD, HLD,
db 91, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 76, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 57, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 62, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 59, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 60, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 48, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 67, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 55, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 66, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 69, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 71, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 83, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 75, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 72, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 84, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 87, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, HLD, HLD, HLD,
db 0, 0, 0, 0, 0, 0, 0, 0, 60, HLD, 60, HLD, HLD, HLD, 60, HLD,
db HLD, HLD, HLD, HLD, HLD, HLD, 60, HLD, 60, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 60, HLD, 60, HLD, HLD, HLD, 60, HLD,
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, HLD, HLD, HLD,
db 60, HLD, HLD, HLD, HLD, HLD, 60, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 60, HLD, HLD, HLD, HLD, HLD, 60, HLD, HLD, HLD, HLD, HLD, 60, HLD, HLD, HLD,
db 50, HLD, HLD, HLD, 38, HLD, HLD, HLD, 38, HLD, HLD, HLD, 50, HLD, HLD, HLD,
db 38, HLD, HLD, HLD, 38, HLD, HLD, HLD, 50, HLD, 62, HLD, 50, HLD, HLD, HLD,
db 38, HLD, HLD, HLD, 50, HLD, HLD, HLD, 50, HLD, HLD, HLD, 38, HLD, HLD, HLD,
db 38, HLD, HLD, HLD, 50, HLD, HLD, HLD, 62, HLD, 50, HLD, 38, HLD, HLD, HLD,
db 52, HLD, HLD, HLD, 40, HLD, HLD, HLD, 40, HLD, HLD, HLD, 52, HLD, HLD, HLD,
db 40, HLD, HLD, HLD, 40, HLD, HLD, HLD, 52, HLD, 64, HLD, 52, HLD, HLD, HLD,
db 40, HLD, HLD, HLD, 52, HLD, HLD, HLD, 52, HLD, HLD, HLD, 40, HLD, HLD, HLD,
db 40, HLD, HLD, HLD, 52, HLD, HLD, HLD, 64, HLD, 52, HLD, 40, HLD, HLD, HLD,
db 57, HLD, HLD, HLD, 45, HLD, HLD, HLD, 45, HLD, HLD, HLD, 57, HLD, HLD, HLD,
db 45, HLD, HLD, HLD, 45, HLD, HLD, HLD, 57, HLD, 69, HLD, 57, HLD, HLD, HLD,
db 45, HLD, HLD, HLD, 57, HLD, HLD, HLD, 57, HLD, HLD, HLD, 45, HLD, HLD, HLD,
db 45, HLD, HLD, HLD, 57, HLD, HLD, HLD, 69, HLD, 57, HLD, 45, HLD, HLD, HLD,
db 59, HLD, HLD, HLD, 47, HLD, HLD, HLD, 47, HLD, HLD, HLD, 59, HLD, HLD, HLD,
db 47, HLD, HLD, HLD, 47, HLD, HLD, HLD, 59, HLD, 71, HLD, 59, HLD, HLD, HLD,
db 47, HLD, HLD, HLD, 59, HLD, HLD, HLD, 59, HLD, HLD, HLD, 47, HLD, HLD, HLD,
db 47, HLD, HLD, HLD, 59, HLD, HLD, HLD, 71, HLD, 59, HLD, 47, HLD, HLD, HLD,
db 40, HLD, HLD, HLD, 40, HLD, HLD, HLD, 52, HLD, 40, HLD, 52, HLD, HLD, HLD,
db 40, HLD, HLD, HLD, 52, HLD, HLD, HLD, 40, HLD, 52, HLD, 40, HLD, HLD, HLD,
db 48, HLD, HLD, HLD, 36, HLD, HLD, HLD, 36, HLD, HLD, HLD, 48, HLD, HLD, HLD,
db 36, HLD, HLD, HLD, 36, HLD, HLD, HLD, 48, HLD, 60, HLD, 48, HLD, HLD, HLD,
db 48, HLD, HLD, HLD, 60, HLD, HLD, HLD, 60, HLD, HLD, HLD, 48, HLD, HLD, HLD,
db 48, HLD, HLD, HLD, 60, HLD, HLD, HLD, 72, HLD, 60, HLD, 48, HLD, HLD, HLD,
db 55, HLD, HLD, HLD, 43, HLD, HLD, HLD, 43, HLD, HLD, HLD, 55, HLD, HLD, HLD,
db 43, HLD, HLD, HLD, 43, HLD, HLD, HLD, 55, HLD, 67, HLD, 55, HLD, HLD, HLD,
db 43, HLD, HLD, HLD, 55, HLD, HLD, HLD, 55, HLD, HLD, HLD, 43, HLD, HLD, HLD,
db 43, HLD, HLD, HLD, 55, HLD, HLD, HLD, 67, HLD, 55, HLD, 43, HLD, HLD, HLD,
db 40, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 81, 0, 83, 0, 84, 0, 86, 0, 2, HLD, 88, HLD, HLD, HLD, HLD, HLD,
db 0, 0, 0, 0, 0, 0, 0, 0, 84, HLD, HLD, HLD, 0, 0, 0, 0,
db 83, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, 79, 0, 81, 0,
db 76, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
db 79, 0, 81, HLD, HLD, HLD, 83, HLD, 0, 0, 79, HLD, 0, 0, 0, 0,
db 78, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 0, 0, 0, 0, 79, 0, 81, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 0, 0, 0, 0, 0, 0, 0, 0, 81, 0, 83, 0, 84, 0, 81, 0,
db 83, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0,
db 81, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
db 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, 79, 0, 81, 0, 79, 0,
db 52, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0,
db 52, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 91, 0, 90, 0, 88, 0, 86, 0,
db 88, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 90, 0,
db 88, 0, 90, HLD, 0, 0, 91, HLD, 0, 0, 100, HLD, 0, 0, 0, 0,
db 98, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 93, 0,
db 95, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
db 91, 0, 93, HLD, 0, 0, 95, HLD, 0, 0, 103, HLD, 0, 0, 0, 0,
db 102, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0,
db 90, 0, 91, HLD, 0, 0, 93, HLD, 0, 0, 96, HLD, 0, 0, 0, 0,
db 95, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 93, 0,
db 0, 0, 0, 0, 0, 0, 0, 0, 91, 0, 90, 0, 88, 0, 86, 0,
db 88, 0, 90, HLD, 0, 0, 91, HLD, 0, 0, 88, HLD, 0, 0, 0, 0,
db 86, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 81, 0,
db 79, 0, 81, HLD, 0, 0, 83, HLD, 0, 0, 91, HLD, 0, 0, 0, 0,
db 90, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 88, 0,
db 0, 0, 0, 0, 0, 0, 0, 0, 83, HLD, HLD, HLD, 0, 0, 0, 0,
go4k_patterns_end
%ifdef USE_SECTIONS
section .g4kmuc2 data align=1
%else
section .data
%endif
go4k_pattern_lists
Instrument0List db 1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 7, 8, 9, 8, 10, 5, 6, 5, 7, 8, 9, 8, 10, 11, 12, 11, 13, 8, 9, 8, 10, 14, 15, 14, 16, 8, 9, 8, 10, 11, 12, 11, 13, 8, 9, 8, 10, 14, 15, 14, 16, 8, 9, 8, 10, 8, 17, 8, 10, 8, 17, 8, 10, 8, 17, 8, 10, 8, 17, 8, 10, 18, 19, 18, 20, 21, 22, 21, 23, 14, 15, 14, 16, 8, 9, 8, 10, 18, 19, 18, 20, 21, 22, 21, 23, 14, 15, 14, 16, 8, 9, 8, 10, 8, 9, 8, 10, 8, 9, 8, 10, 8, 24, 24, 25,
Instrument1List db 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 27, 25, 25, 25, 28, 25, 25, 25, 27, 25, 25, 25, 28, 25, 25, 25, 26, 25, 25, 25, 28, 25, 25, 25, 29, 25, 25, 25, 28, 25, 25, 25, 26, 25, 25, 25, 28, 25, 25, 25, 29, 25, 25, 25, 28, 25, 25, 25, 28, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 30, 25, 31, 30, 32, 25, 32, 33, 29, 25, 34, 29, 28, 25, 32, 33, 30, 25, 31, 30, 32, 25, 32, 33, 29, 25, 34, 29, 28, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0,
Instrument2List db 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 35, 25, 25, 25, 36, 25, 25, 25, 35, 25, 25, 25, 36, 25, 25, 25, 24, 25, 25, 25, 37, 25, 25, 25, 38, 25, 25, 25, 37, 25, 25, 25, 24, 25, 25, 25, 37, 25, 25, 25, 38, 25, 25, 25, 37, 25, 25, 25, 36, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 39, 40, 25, 25, 37, 25, 25, 25, 38, 25, 25, 25, 37, 25, 25, 25, 39, 40, 25, 25, 37, 25, 25, 25, 38, 41, 25, 25, 37, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0,
Instrument3List db 0, 0, 0, 0, 0, 0, 39, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Instrument4List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 44, 45, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0,
Instrument5List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 30, 47, 30, 48, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0,
Instrument6List db 30, 25, 25, 25, 25, 25, 0, 46, 25, 25, 25, 25, 25, 25, 0, 46, 25, 25, 25, 25, 25, 25, 0, 46, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 30, 25, 25, 25, 25, 25, 0, 0, 30, 25, 25, 25, 25, 25, 0, 46, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0,
Instrument7List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 50, 51, 52, 53, 54, 55, 56, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 53, 54, 55, 56, 61, 62, 63, 64, 53, 54, 55, 56, 57, 58, 59, 60, 53, 54, 55, 56, 61, 62, 63, 64, 53, 54, 55, 56, 53, 65, 55, 66, 53, 65, 55, 66, 53, 65, 55, 66, 53, 65, 55, 66, 67, 68, 69, 70, 71, 72, 73, 74, 61, 62, 63, 64, 53, 54, 73, 74, 67, 68, 69, 70, 71, 72, 73, 74, 61, 62, 63, 64, 53, 54, 55, 56, 53, 54, 55, 56, 53, 54, 55, 56, 53, 54, 75, 25,
Instrument8List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 25, 25, 25, 25, 25, 25, 25, 31, 25, 25, 25, 25, 25, 25, 25, 31, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 31, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Instrument9List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 77, 78, 79, 0, 80, 81, 82, 0, 83, 84, 79, 0, 80, 85, 76, 0, 77, 78, 79, 0, 80, 81, 82, 0, 86, 24, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 88, 89, 23, 0, 90, 91, 92, 0, 93, 94, 92, 0, 95, 96, 23, 0, 97, 89, 23, 0, 98, 99, 37, 0, 100, 101, 41, 0, 102, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
go4k_pattern_lists_end
%ifdef USE_SECTIONS
section .g4kmuc3 data align=1
%else
section .data
%endif
go4k_synth_instructions
GO4K_BEGIN_CMDDEF(Instrument0)
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_PAN_ID
db GO4K_DLL_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument1)
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_DST_ID
db GO4K_VCF_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument2)
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_VCF_ID
db GO4K_FST_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DST_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument3)
db GO4K_ENV_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FOP_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument4)
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_ENV_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument5)
db GO4K_ENV_ID
db GO4K_FST_ID
db GO4K_ENV_ID
db GO4K_DST_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument6)
db GO4K_ENV_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FOP_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument7)
db GO4K_ENV_ID
db GO4K_FST_ID
db GO4K_FST_ID
db GO4K_ENV_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DST_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument8)
db GO4K_ENV_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Instrument9)
db GO4K_ENV_ID
db GO4K_ENV_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_FST_ID
db GO4K_FST_ID
db GO4K_FST_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_VCO_ID
db GO4K_FOP_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DST_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_PAN_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
GO4K_BEGIN_CMDDEF(Global)
db GO4K_ACC_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_DLL_ID
db GO4K_ACC_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FSTG_ID
db GO4K_FSTG_ID
db GO4K_FOP_ID
db GO4K_VCO_ID
db GO4K_FSTG_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_FOP_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_VCF_ID
db GO4K_OUT_ID
GO4K_END_CMDDEF
go4k_synth_instructions_end
%ifdef USE_SECTIONS
section .g4kmuc4 data align=1
%else
section .data
%endif
go4k_synth_parameter_values
GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_ENV ATTAC(16),DECAY(68),SUSTAIN(0),RELEASE(32),GAIN(72)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(64),GATES(0),COLOR(32),SHAPE(96),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(16),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_DLL PREGAIN(64),DRY(96),FEEDBACK(16),DAMP(64),FREQUENCY(64),DEPTH(0),DELAY(17),COUNT(1)
GO4K_PAN PANNING(0)
GO4K_DLL PREGAIN(128),DRY(64),FEEDBACK(0),DAMP(128),FREQUENCY(0),DEPTH(128),DELAY(18),COUNT(1)
GO4K_OUT GAIN(48), AUXSEND(32)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument1)
GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(64),GAIN(128)
GO4K_VCO TRANSPOSE(52),DETUNE(60),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(8),FLAGS(SINE)
GO4K_FST AMOUNT(68),DEST(4*MAX_UNIT_SLOTS+3+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(48),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(96),GAIN(128),FLAGS(TRISAW|LFO)
GO4K_DST DRIVE(112), SNHFREQ(64), FLAGS(0)
GO4K_VCF FREQUENCY(32),RESONANCE(64),VCFTYPE(LOWPASS)
GO4K_VCO TRANSPOSE(52),DETUNE(68),PHASE(64),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(8),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_VCF FREQUENCY(16),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_PAN PANNING(40)
GO4K_OUT GAIN(32), AUXSEND(24)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument2)
GO4K_ENV ATTAC(80),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(24),FLAGS(NOISE)
GO4K_VCF FREQUENCY(2),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_FST AMOUNT(65),DEST(7*MAX_UNIT_SLOTS+3+FST_SET)
GO4K_FST AMOUNT(63),DEST(6*MAX_UNIT_SLOTS+3+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(0),GATES(0),COLOR(32),SHAPE(112),GAIN(24),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(52),DETUNE(62),PHASE(32),GATES(0),COLOR(80),SHAPE(40),GAIN(48),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(60),DETUNE(68),PHASE(64),GATES(0),COLOR(48),SHAPE(88),GAIN(32),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(48),DETUNE(66),PHASE(96),GATES(0),COLOR(96),SHAPE(16),GAIN(32),FLAGS(TRISAW)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_ADDP)
GO4K_VCF FREQUENCY(64),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_DST DRIVE(64), SNHFREQ(96), FLAGS(0)
GO4K_VCF FREQUENCY(72),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_VCF FREQUENCY(8),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_VCF FREQUENCY(16),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_DLL PREGAIN(64),DRY(64),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(19),COUNT(1)
GO4K_PAN PANNING(96)
GO4K_OUT GAIN(16), AUXSEND(48)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument3)
GO4K_ENV ATTAC(112),DECAY(128),SUSTAIN(128),RELEASE(112),GAIN(128)
GO4K_FSTG AMOUNT(100),DEST((0*go4k_instrument.size*MAX_VOICES/4)+(3*MAX_UNIT_SLOTS+4)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(100),DEST((1*go4k_instrument.size*MAX_VOICES/4)+(11*MAX_UNIT_SLOTS+4)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(100),DEST((2*go4k_instrument.size*MAX_VOICES/4)+(18*MAX_UNIT_SLOTS+4)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(80),DEST((9*go4k_instrument.size*MAX_VOICES/4)+(23*MAX_UNIT_SLOTS+1)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(80),DEST((8*go4k_instrument.size*MAX_VOICES/4)+(2*MAX_UNIT_SLOTS+7)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(112),DEST((7*go4k_instrument.size*MAX_VOICES/4)+(13*MAX_UNIT_SLOTS+4)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(88),DEST((7*go4k_instrument.size*MAX_VOICES/4)+(15*MAX_UNIT_SLOTS+1)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument4)
GO4K_ENV ATTAC(0),DECAY(70),SUSTAIN(0),RELEASE(0),GAIN(128)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(NOISE)
GO4K_VCF FREQUENCY(24),RESONANCE(128),VCFTYPE(BANDPASS)
GO4K_FOP OP(FOP_MULP)
GO4K_ENV ATTAC(0),DECAY(48),SUSTAIN(0),RELEASE(64),GAIN(96)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(24),FLAGS(NOISE)
GO4K_VCF FREQUENCY(96),RESONANCE(128),VCFTYPE(BANDSTOP)
GO4K_FOP OP(FOP_MULP)
GO4K_ENV ATTAC(0),DECAY(72),SUSTAIN(64),RELEASE(64),GAIN(16)
GO4K_FST AMOUNT(66),DEST(12*MAX_UNIT_SLOTS+3+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_ENV ATTAC(0),DECAY(68),SUSTAIN(0),RELEASE(64),GAIN(128)
GO4K_VCO TRANSPOSE(0),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(32),FLAGS(SINE|LFO)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_PUSH)
GO4K_FOP OP(FOP_ADDP)
GO4K_PAN PANNING(56)
GO4K_OUT GAIN(64), AUXSEND(32)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument5)
GO4K_ENV ATTAC(0),DECAY(76),SUSTAIN(0),RELEASE(64),GAIN(128)
GO4K_FST AMOUNT(96),DEST(0*MAX_UNIT_SLOTS+2+FST_SET)
GO4K_ENV ATTAC(0),DECAY(72),SUSTAIN(0),RELEASE(0),GAIN(128)
GO4K_DST DRIVE(32), SNHFREQ(128), FLAGS(0)
GO4K_FST AMOUNT(80),DEST(6*MAX_UNIT_SLOTS+1+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(40),DETUNE(64),PHASE(0),GATES(85),COLOR(64),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_MULP)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(48), AUXSEND(8)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument6)
GO4K_ENV ATTAC(90),DECAY(128),SUSTAIN(128),RELEASE(90),GAIN(128)
GO4K_FSTG AMOUNT(112),DEST((1*go4k_instrument.size*MAX_VOICES/4)+(10*MAX_UNIT_SLOTS+4)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(112),DEST((2*go4k_instrument.size*MAX_VOICES/4)+(17*MAX_UNIT_SLOTS+4)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument7)
GO4K_ENV ATTAC(32),DECAY(72),SUSTAIN(0),RELEASE(32),GAIN(88)
GO4K_FST AMOUNT(108),DEST(0*MAX_UNIT_SLOTS+2+FST_SET)
GO4K_FST AMOUNT(88),DEST(11*MAX_UNIT_SLOTS+4+FST_SET)
GO4K_ENV ATTAC(0),DECAY(60),SUSTAIN(0),RELEASE(0),GAIN(128)
GO4K_FST AMOUNT(52),DEST(7*MAX_UNIT_SLOTS+6+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(64),DETUNE(70),PHASE(32),GATES(85),COLOR(128),SHAPE(80),GAIN(64),FLAGS(SINE)
GO4K_VCO TRANSPOSE(64),DETUNE(48),PHASE(48),GATES(85),COLOR(128),SHAPE(96),GAIN(64),FLAGS(SINE)
GO4K_FOP OP(FOP_ADDP)
GO4K_VCF FREQUENCY(32),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_DST DRIVE(112), SNHFREQ(128), FLAGS(0)
GO4K_VCF FREQUENCY(32),RESONANCE(128),VCFTYPE(ALLPASS)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(24),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_PAN PANNING(96)
GO4K_OUT GAIN(4), AUXSEND(8)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument8)
GO4K_ENV ATTAC(0),DECAY(128),SUSTAIN(128),RELEASE(0),GAIN(128)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(1),COLOR(3),SHAPE(64),GAIN(128),FLAGS(GATE|LFO)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(32),FLAGS(NOISE)
GO4K_VCF FREQUENCY(112),RESONANCE(128),VCFTYPE(BANDPASS)
GO4K_VCF FREQUENCY(112),RESONANCE(128),VCFTYPE(LOWPASS)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_MULP)
GO4K_PAN PANNING(80)
GO4K_OUT GAIN(12), AUXSEND(8)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument9)
GO4K_ENV ATTAC(48),DECAY(64),SUSTAIN(64),RELEASE(88),GAIN(128)
GO4K_ENV ATTAC(80),DECAY(128),SUSTAIN(128),RELEASE(128),GAIN(128)
GO4K_FOP OP(FOP_PUSH)
GO4K_FOP OP(FOP_MULP)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(8),FLAGS(SINE|LFO)
GO4K_FOP OP(FOP_MULP)
GO4K_FST AMOUNT(66),DEST(10*MAX_UNIT_SLOTS+1+FST_SET)
GO4K_FST AMOUNT(66),DEST(11*MAX_UNIT_SLOTS+1+FST_SET)
GO4K_FST AMOUNT(66),DEST(12*MAX_UNIT_SLOTS+1+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(64),DETUNE(62),PHASE(0),GATES(0),COLOR(32),SHAPE(64),GAIN(64),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(64),DETUNE(66),PHASE(48),GATES(0),COLOR(64),SHAPE(64),GAIN(64),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(96),GATES(0),COLOR(128),SHAPE(96),GAIN(64),FLAGS(SINE)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_ADDP)
GO4K_VCF FREQUENCY(8),RESONANCE(128),VCFTYPE(HIGHPASS)
GO4K_DST DRIVE(80), SNHFREQ(96), FLAGS(0)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(96),RESONANCE(0),VCFTYPE(BANDSTOP)
GO4K_VCF FREQUENCY(64),RESONANCE(0),VCFTYPE(BANDSTOP)
GO4K_VCF FREQUENCY(32),RESONANCE(0),VCFTYPE(BANDSTOP)
GO4K_DLL PREGAIN(96),DRY(96),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(19),COUNT(1)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(32), AUXSEND(24)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Global)
GO4K_ACC ACCTYPE(AUX)
GO4K_VCF FREQUENCY(32),RESONANCE(64),VCFTYPE(HIGHPASS)
GO4K_DLL PREGAIN(64),DRY(0),FEEDBACK(112),DAMP(32),FREQUENCY(128),DEPTH(0),DELAY(1),COUNT(8)
GO4K_FOP OP(FOP_XCH)
GO4K_VCF FREQUENCY(32),RESONANCE(64),VCFTYPE(HIGHPASS)
GO4K_DLL PREGAIN(64),DRY(0),FEEDBACK(112),DAMP(32),FREQUENCY(128),DEPTH(0),DELAY(9),COUNT(8)
GO4K_ACC ACCTYPE(OUTPUT)
GO4K_FOP OP(FOP_ADDP2)
GO4K_VCO TRANSPOSE(40),DETUNE(64),PHASE(32),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FSTG AMOUNT(80),DEST((0*go4k_instrument.size*MAX_VOICES/4)+(1*MAX_UNIT_SLOTS+7)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FSTG AMOUNT(65),DEST((1*go4k_instrument.size*MAX_VOICES/4)+(1*MAX_UNIT_SLOTS+7)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(52),DETUNE(64),PHASE(33),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FSTG AMOUNT(88),DEST((8*go4k_instrument.size*MAX_VOICES/4)+(2*MAX_UNIT_SLOTS+7)+(go4k_instrument.workspace/4)+FST_SET)
GO4K_FOP OP(FOP_POP)
GO4K_VCF FREQUENCY(72),RESONANCE(32),VCFTYPE(ALLPASS)
GO4K_VCF FREQUENCY(96),RESONANCE(64),VCFTYPE(ALLPASS)
GO4K_VCF FREQUENCY(48),RESONANCE(128),VCFTYPE(PEAK)
GO4K_FOP OP(FOP_XCH)
GO4K_VCF FREQUENCY(72),RESONANCE(32),VCFTYPE(ALLPASS)
GO4K_VCF FREQUENCY(96),RESONANCE(64),VCFTYPE(ALLPASS)
GO4K_VCF FREQUENCY(48),RESONANCE(128),VCFTYPE(PEAK)
GO4K_OUT GAIN(64), AUXSEND(0)
GO4K_END_PARAMDEF
go4k_synth_parameter_values_end
%ifdef USE_SECTIONS
section .g4kmuc5 data align=1
%else
section .data
%endif
%ifdef GO4K_USE_DLL
global _go4k_delay_times
_go4k_delay_times
dw 0
dw 1116
dw 1188
dw 1276
dw 1356
dw 1422
dw 1492
dw 1556
dw 1618
dw 1140
dw 1212
dw 1300
dw 1380
dw 1446
dw 1516
dw 1580
dw 1642
dw 30384
dw 512
dw 15192
%endif

View File

@@ -0,0 +1,577 @@
#pragma once
#include <Shlwapi.h>
#include "mutexlock.h"
static HANDLE shaderCompileEvent;
struct SharedMemoryToolType
{
int WindowLeft;
int WindowTop;
int WindowWidth;
int WindowHeight;
int MaxSamples;
int SampleSize;
int SamplesPerTick;
int TicksPerScene;
float IntroPosition;
int AudioRenderPosition;
int SeekToScene;
bool KeepAlive;
HWND introHandle;
HWND analysisHandle;
bool UseMinifiedShader;
};
static D3D11_TEXTURE1D_DESC histogramTextureDesc =
{
256,
1,
1,
DXGI_FORMAT_R32G32B32A32_FLOAT,
D3D11_USAGE_DEFAULT,
D3D11_BIND_UNORDERED_ACCESS,
0,
0
};
static D3D11_TEXTURE1D_DESC histogramStagingTextureDesc =
{
256,
1,
1,
DXGI_FORMAT_R32G32B32A32_FLOAT,
D3D11_USAGE_STAGING,
0,
D3D11_CPU_ACCESS_READ,
0
};
static D3D11_TEXTURE1D_DESC histogramBucketTextureDesc =
{
257,
1,
1,
DXGI_FORMAT_R32_UINT,
D3D11_USAGE_DEFAULT,
D3D11_BIND_UNORDERED_ACCESS,
0,
0
};
static D3D11_TEXTURE2D_DESC paradeVectorScopeBucketTextureDesc =
{
257,
256,
1,
1,
DXGI_FORMAT_R32_UINT,
{ 1, 0 },
D3D11_USAGE_DEFAULT,
D3D11_BIND_UNORDERED_ACCESS,
0,
0
};
static D3D11_TEXTURE2D_DESC paradeTextureDesc =
{
256,
256,
1,
1,
DXGI_FORMAT_R8G8B8A8_UINT,
{ 1, 0 },
D3D11_USAGE_DEFAULT,
D3D11_BIND_UNORDERED_ACCESS,
0,
0
};
static D3D11_TEXTURE2D_DESC paradeStagingTextureDesc =
{
256,
256,
1,
1,
DXGI_FORMAT_R8G8B8A8_UINT,
{ 1, 0 },
D3D11_USAGE_STAGING,
0,
D3D11_CPU_ACCESS_READ,
0
};
static D3D11_TEXTURE2D_DESC vectorScopeTextureDesc =
{
256,
256,
1,
1,
DXGI_FORMAT_R8G8B8A8_UINT,
{ 1, 0 },
D3D11_USAGE_DEFAULT,
D3D11_BIND_UNORDERED_ACCESS,
0,
0
};
static D3D11_TEXTURE2D_DESC vectorScopeStagingTextureDesc =
{
256,
256,
1,
1,
DXGI_FORMAT_R8G8B8A8_UINT,
{ 1, 0 },
D3D11_USAGE_STAGING,
0,
D3D11_CPU_ACCESS_READ,
0
};
static D3D11_UNORDERED_ACCESS_VIEW_DESC histogramUAVdesc =
{
DXGI_FORMAT_R32G32B32A32_FLOAT,
D3D11_UAV_DIMENSION_TEXTURE1D,
{ 0 }
};
static D3D11_UNORDERED_ACCESS_VIEW_DESC histogramBucketUAVdesc =
{
DXGI_FORMAT_R32_UINT,
D3D11_UAV_DIMENSION_TEXTURE1D,
{ 0 }
};
static D3D11_UNORDERED_ACCESS_VIEW_DESC paradeUAVdesc =
{
DXGI_FORMAT_R8G8B8A8_UINT,
D3D11_UAV_DIMENSION_TEXTURE2D,
{ 0, 1 }
};
static D3D11_UNORDERED_ACCESS_VIEW_DESC paradeVectorScopeBucketUAVdesc =
{
DXGI_FORMAT_R32_UINT,
D3D11_UAV_DIMENSION_TEXTURE2D,
{ 0, 1 }
};
static D3D11_UNORDERED_ACCESS_VIEW_DESC vectorScopeUAVdesc =
{
DXGI_FORMAT_R8G8B8A8_UINT,
D3D11_UAV_DIMENSION_TEXTURE2D,
{ 0, 1 }
};
static D3D11_SHADER_RESOURCE_VIEW_DESC analysisSRVdesc =
{
DXGI_FORMAT_R8G8B8A8_UNORM,
D3D11_SRV_DIMENSION_TEXTURE2D,
{ 0, 1 }
};
static SharedMemoryToolType* SharedMemoryTool;
static char* SharedImage;
static HANDLE AudioFileMapping;
static HANDLE ImageFileMapping;
static HANDLE HistogramFileMapping;
static HANDLE ParadeFileMapping;
static HANDLE VectorscopeFileMapping;
static HANDLE SharedMemoryFileMapping;
static bool playMusic;
static long musicStartOffset;
static HANDLE SharedMemoryMutex;
static D3D11_TEXTURE2D_DESC analysisDesc;
static ID3D11Texture2D* resolvedTexture;
static ID3D11Texture2D* stagingTexture;
static ID3D11Texture1D* histogramTexture;
static ID3D11Texture1D* histogramRedBucketTexture;
static ID3D11Texture1D* histogramGreenBucketTexture;
static ID3D11Texture1D* histogramBlueBucketTexture;
static ID3D11Texture1D* histogramStagingTexture;
static ID3D11Texture2D* paradeRedBucketTexture;
static ID3D11Texture2D* paradeGreenBucketTexture;
static ID3D11Texture2D* paradeBlueBucketTexture;
static ID3D11Texture2D* paradeAlphaBucketTexture;
static ID3D11Texture2D* paradeTexture;
static ID3D11Texture2D* paradeStagingTexture;
static ID3D11Texture2D* vectorScopeBucketTexture;
static ID3D11Texture2D* vectorScopeTexture;
static ID3D11Texture2D* vectorScopeStagingTexture;
static ID3D11ComputeShader* csHistogramGather;
static ID3D11ComputeShader* csHistogramMaximum;
static ID3D11ComputeShader* csHistogramSpread;
static ID3D11ComputeShader* csParadeVectorscopeGather;
static ID3D11ComputeShader* csParadeVectorscopeMaximum;
static ID3D11ComputeShader* csParadeVectorscopeSpread;
static ID3D11UnorderedAccessView* histogramUAV;
static ID3D11UnorderedAccessView* histogramRedBucketUAV;
static ID3D11UnorderedAccessView* histogramGreenBucketUAV;
static ID3D11UnorderedAccessView* histogramBlueBucketUAV;
static ID3D11UnorderedAccessView* paradeUAV;
static ID3D11UnorderedAccessView* paradeRedBucketUAV;
static ID3D11UnorderedAccessView* paradeGreenBucketUAV;
static ID3D11UnorderedAccessView* paradeBlueBucketUAV;
static ID3D11UnorderedAccessView* paradeAlphaBucketUAV;
static ID3D11UnorderedAccessView* vectorScopeUAV;
static ID3D11UnorderedAccessView* vectorScopeBucketUAV;
static ID3D11ShaderResourceView* analysisSRV;
static D3D11_MAPPED_SUBRESOURCE mappedResource;
static float* histogram;
static float* parade;
static float* vectorscope;
static HANDLE hShaderErrorPipe;
extern "C" int _4klang_current_tick;
float AuthoringGetIntroPosition()
{
float time = SoundGetIntroPosition();
return time + musicStartOffset / (float)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE);
}
void ReadFile(char* path, char** content, size_t* length)
{
FILE* shaderFile;
auto error = fopen_s(&shaderFile, path, "rb");
fseek(shaderFile, 0, SEEK_END);
*length = ftell(shaderFile);
*content = new char[*length];
fseek(shaderFile, 0, SEEK_SET);
fread_s(*content, *length, sizeof(char), *length, shaderFile);
fclose(shaderFile);
}
void AuthoringInit()
{
MutexLock("IntroAuthorMutex");
Log("IntroInit");
SharedMemoryFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(SharedMemoryToolType), "IntroAuthor");
AudioFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(SAMPLE_TYPE)* MAX_SAMPLES * 2, "IntroAudio");
ImageFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * SCREENWIDTH * SCREENHEIGHT, "IntroImage");
HistogramFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * 4 * 256, "IntroHistogram");
ParadeFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * 256 * 256, "IntroParade");
VectorscopeFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * 256 * 256, "IntroVectorscope");
SharedMemoryTool = (SharedMemoryToolType*)MapViewOfFile(SharedMemoryFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SharedMemoryToolType));
soundBuffer = (SAMPLE_TYPE*)MapViewOfFile(AudioFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SAMPLE_TYPE)* MAX_SAMPLES * 2);
SharedImage = (char*)MapViewOfFile(ImageFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * SCREENWIDTH * SCREENHEIGHT);
histogram = (float*)MapViewOfFile(HistogramFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * 4 * 256);
parade = (float*)MapViewOfFile(ParadeFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * 256 * 256);
vectorscope = (float*)MapViewOfFile(VectorscopeFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * 256 * 256);
WaveHDR.lpData = (LPSTR)soundBuffer;
RECT rect;
GetWindowRect(windowHandle, &rect);
SharedMemoryTool->WindowLeft = rect.left;
SharedMemoryTool->WindowTop = rect.top;
SharedMemoryTool->WindowWidth = rect.right - rect.left - 16;
SharedMemoryTool->WindowHeight = rect.bottom - rect.top - 39;
SharedMemoryTool->MaxSamples = MAX_SAMPLES;
SharedMemoryTool->SampleSize = sizeof(SAMPLE_TYPE);
SharedMemoryTool->SamplesPerTick = SAMPLES_PER_TICK;
SharedMemoryTool->TicksPerScene = SOUND_TICKS_PER_SCENE;
SharedMemoryTool->SeekToScene = -1;
SharedMemoryTool->KeepAlive = true;
SharedMemoryTool->UseMinifiedShader = true;
backBufferTexture->GetDesc(&analysisDesc);
analysisDesc.Usage = D3D11_USAGE_DEFAULT;
analysisDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
analysisDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
analysisDesc.SampleDesc.Count = 1;
device->CreateTexture2D(&analysisDesc, NULL, &resolvedTexture);
analysisDesc.Usage = D3D11_USAGE_STAGING;
analysisDesc.BindFlags = 0;
analysisDesc.CPUAccessFlags |= D3D11_CPU_ACCESS_READ;
device->CreateTexture2D(&analysisDesc, NULL, &stagingTexture);
device->CreateShaderResourceView(resolvedTexture, &analysisSRVdesc, &analysisSRV);
device->CreateTexture1D(&histogramTextureDesc, NULL, &histogramTexture);
device->CreateTexture1D(&histogramBucketTextureDesc, NULL, &histogramRedBucketTexture);
device->CreateTexture1D(&histogramBucketTextureDesc, NULL, &histogramGreenBucketTexture);
device->CreateTexture1D(&histogramBucketTextureDesc, NULL, &histogramBlueBucketTexture);
device->CreateUnorderedAccessView(histogramTexture, &histogramUAVdesc, &histogramUAV);
device->CreateUnorderedAccessView(histogramRedBucketTexture, &histogramBucketUAVdesc, &histogramRedBucketUAV);
device->CreateUnorderedAccessView(histogramGreenBucketTexture, &histogramBucketUAVdesc, &histogramGreenBucketUAV);
device->CreateUnorderedAccessView(histogramBlueBucketTexture, &histogramBucketUAVdesc, &histogramBlueBucketUAV);
device->CreateTexture1D(&histogramStagingTextureDesc, NULL, &histogramStagingTexture);
device->CreateTexture2D(&paradeVectorScopeBucketTextureDesc, NULL, &paradeRedBucketTexture);
device->CreateTexture2D(&paradeVectorScopeBucketTextureDesc, NULL, &paradeGreenBucketTexture);
device->CreateTexture2D(&paradeVectorScopeBucketTextureDesc, NULL, &paradeBlueBucketTexture);
device->CreateTexture2D(&paradeVectorScopeBucketTextureDesc, NULL, &paradeAlphaBucketTexture);
device->CreateTexture2D(&paradeVectorScopeBucketTextureDesc, NULL, &vectorScopeBucketTexture);
device->CreateTexture2D(&paradeTextureDesc, NULL, &paradeTexture);
device->CreateTexture2D(&paradeStagingTextureDesc, NULL, &paradeStagingTexture);
device->CreateTexture2D(&vectorScopeTextureDesc, NULL, &vectorScopeTexture);
device->CreateTexture2D(&vectorScopeStagingTextureDesc, NULL, &vectorScopeStagingTexture);
device->CreateUnorderedAccessView(paradeRedBucketTexture, &paradeVectorScopeBucketUAVdesc, &paradeRedBucketUAV);
device->CreateUnorderedAccessView(paradeGreenBucketTexture, &paradeVectorScopeBucketUAVdesc, &paradeGreenBucketUAV);
device->CreateUnorderedAccessView(paradeBlueBucketTexture, &paradeVectorScopeBucketUAVdesc, &paradeBlueBucketUAV);
device->CreateUnorderedAccessView(paradeAlphaBucketTexture, &paradeVectorScopeBucketUAVdesc, &paradeAlphaBucketUAV);
device->CreateUnorderedAccessView(vectorScopeBucketTexture, &paradeVectorScopeBucketUAVdesc, &vectorScopeBucketUAV);
device->CreateUnorderedAccessView(vectorScopeTexture, &vectorScopeUAVdesc, &vectorScopeUAV);
device->CreateUnorderedAccessView(paradeTexture, &paradeUAVdesc, &paradeUAV);
static char shaderPath[MAX_PATH];
static char exePath[MAX_PATH];
static char* shaderCode;
static size_t shaderLength;
GetModuleFileName(NULL, exePath, MAX_PATH);
PathRemoveFileSpec(exePath);
PathCombine(shaderPath, exePath, "histogramGather.cso");
ReadFile(shaderPath, &shaderCode, &shaderLength);
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csHistogramGather);
PathCombine(shaderPath, exePath, "histogramMaximum.cso");
ReadFile(shaderPath, &shaderCode, &shaderLength);
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csHistogramMaximum);
PathCombine(shaderPath, exePath, "histogramSpread.cso");
ReadFile(shaderPath, &shaderCode, &shaderLength);
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csHistogramSpread);
PathCombine(shaderPath, exePath, "paradeVectorscopeGather.cso");
ReadFile(shaderPath, &shaderCode, &shaderLength);
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csParadeVectorscopeGather);
PathCombine(shaderPath, exePath, "paradeVectorscopeMaximum.cso");
ReadFile(shaderPath, &shaderCode, &shaderLength);
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csParadeVectorscopeMaximum);
PathCombine(shaderPath, exePath, "paradeVectorscopeSpread.cso");
ReadFile(shaderPath, &shaderCode, &shaderLength);
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csParadeVectorscopeSpread);
while (1)
{
auto pipeName = "\\\\.\\pipe\\8kode";
hShaderErrorPipe = CreateFileA(
pipeName, // pipe name
GENERIC_WRITE |
GENERIC_WRITE, // read/write access
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
// Break if the pipe handle is valid.
if (hShaderErrorPipe != INVALID_HANDLE_VALUE)
break;
// Exit if an error other than ERROR_PIPE_BUSY occurs.
DWORD error;
if (error = GetLastError() != ERROR_PIPE_BUSY)
{
Error("Could not open pipe");
}
// All pipe instances are busy, so wait for 2 seconds.
if (WaitNamedPipe(pipeName, 2000))
{
printf("Could not open pipe: 2 second wait timed out.");
break;
}
}
}
bool audio_IsPaused = false;
void SoundSeekToRow(void *d, int row)
{
if (row < 0)
row = 0;
musicStartOffset = row * (long)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE) / SYNC_ROWS_PER_SCENE;
WaveHDR.lpData = (LPSTR)(float*)(soundBuffer + musicStartOffset * 2);
WaveHDR.dwBufferLength = (MAX_SAMPLES - musicStartOffset) * sizeof(SAMPLE_TYPE) * 2;
//send buffer to waveOut
waveOutReset(hWaveOut);
waveOutPrepareHeader(hWaveOut, &WaveHDR, sizeof(WaveHDR));
waveOutWrite(hWaveOut, &WaveHDR, sizeof(WaveHDR));
//put on pause
if (audio_IsPaused)
waveOutPause(hWaveOut);
}
void SoundSeekToScene(void *d, int scene)
{
SoundSeekToRow(d, scene * SYNC_ROWS_PER_SCENE);
}
void SoundPause(void *d, int iPause)
{
// Check if there is change of current play/pause state?
if (audio_IsPaused != (bool)iPause)
{
// Assign new state
audio_IsPaused = (bool)iPause;
// Change audio play state
if (audio_IsPaused)
waveOutPause(hWaveOut);
else
waveOutRestart(hWaveOut);
}
}
int SoundIsPlaying(void *d)
{
return (int)!audio_IsPaused;
}
struct sync_cb usync_cb =
{
SoundPause,
SoundSeekToRow,
SoundIsPlaying
};
void *usync_data = NULL;
bool AuthoringUpdate()
{
SharedMemoryTool->IntroPosition = AuthoringGetIntroPosition();
SharedMemoryTool->AudioRenderPosition = _4klang_current_tick * SAMPLES_PER_TICK;
SetWindowPos(windowHandle, 0, SharedMemoryTool->WindowLeft, SharedMemoryTool->WindowTop, SharedMemoryTool->WindowWidth + 16, SharedMemoryTool->WindowHeight + 39, 0);
static ID3D11Buffer* empty[16];
context->CSSetConstantBuffers(0, 8, empty);
context->VSSetConstantBuffers(0, 8, empty);
context->GSSetConstantBuffers(0, 8, empty);
context->HSSetConstantBuffers(0, 8, empty);
context->DSSetConstantBuffers(0, 8, empty);
context->PSSetConstantBuffers(0, 8, empty);
context->ResolveSubresource(resolvedTexture, 0, backBufferTexture, 0, analysisDesc.Format);
context->CopyResource(stagingTexture, resolvedTexture);
context->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
memcpy(SharedImage, mappedResource.pData, 4 * SCREENWIDTH * SCREENHEIGHT);
context->Unmap(stagingTexture, 0);
static ID3D11UnorderedAccessView* histogramUAVs[] =
{
backBufferUAV,
histogramRedBucketUAV,
histogramGreenBucketUAV,
histogramBlueBucketUAV,
histogramUAV,
0,
0,
0,
0
};
static ID3D11UnorderedAccessView* paradeVectorscopeUAVs[] =
{
backBufferUAV,
paradeRedBucketUAV,
paradeGreenBucketUAV,
paradeBlueBucketUAV,
paradeAlphaBucketUAV,
vectorScopeBucketUAV,
paradeUAV,
vectorScopeUAV
};
static UINT zero[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
context->ClearUnorderedAccessViewUint(histogramRedBucketUAV, zero);
context->ClearUnorderedAccessViewUint(histogramGreenBucketUAV, zero);
context->ClearUnorderedAccessViewUint(histogramBlueBucketUAV, zero);
context->ClearUnorderedAccessViewUint(vectorScopeBucketUAV, zero);
context->ClearUnorderedAccessViewUint(paradeRedBucketUAV, zero);
context->ClearUnorderedAccessViewUint(paradeGreenBucketUAV, zero);
context->ClearUnorderedAccessViewUint(paradeBlueBucketUAV, zero);
context->ClearUnorderedAccessViewUint(paradeAlphaBucketUAV, zero);
context->CSSetShaderResources(0, 1, &analysisSRV);
context->OMSetRenderTargets(1, (ID3D11RenderTargetView* const *)zero, NULL);
context->CSSetUnorderedAccessViews(0, 8, histogramUAVs, NULL);
context->CSSetShader(csHistogramGather, NULL, 0);
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
context->CSSetShader(csHistogramMaximum, NULL, 0);
context->Dispatch(16, 1, 1);
context->CSSetShader(csHistogramSpread, NULL, 0);
context->Dispatch(16, 1, 1);
context->CSSetUnorderedAccessViews(0, 8, paradeVectorscopeUAVs, NULL);
context->CSSetShader(csParadeVectorscopeGather, NULL, 0);
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
context->CSSetShader(csParadeVectorscopeMaximum, NULL, 0);
context->Dispatch(16, 16, 1);
context->CSSetShader(csParadeVectorscopeSpread, NULL, 0);
context->Dispatch(16, 16, 1);
context->CSSetShaderResources(0, 1, (ID3D11ShaderResourceView* const*)zero);
context->CSSetUnorderedAccessViews(0, 8, (ID3D11UnorderedAccessView* const *)zero, NULL);
context->CopyResource(histogramStagingTexture, histogramTexture);
context->Map(histogramStagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
memcpy(histogram, mappedResource.pData, 4 * 4 * 256);
context->Unmap(histogramStagingTexture, 0);
context->CopyResource(paradeStagingTexture, paradeTexture);
context->Map(paradeStagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
memcpy(parade, mappedResource.pData, 4 * 256 * 256);
context->Unmap(paradeStagingTexture, 0);
context->CopyResource(vectorScopeStagingTexture, vectorScopeTexture);
context->Map(vectorScopeStagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
memcpy(vectorscope, mappedResource.pData, 4 * 256 * 256);
context->Unmap(vectorScopeStagingTexture, 0);
if (::WaitForSingleObject(shaderCompileEvent, 0) == WAIT_OBJECT_0)
{
::Sleep(100);
FrameworkShadersCompile();
}
if (SharedMemoryTool->SeekToScene != -1)
{
auto scene = SharedMemoryTool->SeekToScene;
SharedMemoryTool->SeekToScene = -1;
SoundSeekToScene(NULL, scene);
}
return true;
}
void AuthoringDispose()
{
usync_export();
Log("AuthoringDispose");
UnmapViewOfFile(SharedMemoryTool);
UnmapViewOfFile(soundBuffer);
UnmapViewOfFile(SharedImage);
UnmapViewOfFile(histogram);
UnmapViewOfFile(parade);
UnmapViewOfFile(vectorscope);
CloseHandle(SharedMemoryFileMapping);
CloseHandle(AudioFileMapping);
CloseHandle(ImageFileMapping);
CloseHandle(HistogramFileMapping);
CloseHandle(ParadeFileMapping);
CloseHandle(VectorscopeFileMapping);
CloseHandle(SharedMemoryMutex);
}

View File

@@ -0,0 +1,91 @@
#pragma once
#include <d3d11.h>
//#define DEPTH_STENCIL
#ifndef RELEASE
#define D3D_DEVICE_FLAGS D3D11_CREATE_DEVICE_DEBUG
#else
#define D3D_DEVICE_FLAGS 0
#endif
#pragma bss_seg(".directxBss")
static ID3D11Device* device;
static ID3D11DeviceContext* context;
static IDXGISwapChain* swapChain;
static ID3D11Texture2D* backBufferTexture;
static ID3D11UnorderedAccessView* backBufferUAV;
static ID3D11RenderTargetView* backBufferRTV;
#ifdef DEPTH_STENCIL
static ID3D11Texture2D* depthStencilBuffer;
static ID3D11DepthStencilState* depthStencilState;
static ID3D11DepthStencilView* depthStencilView;
static ID3D11ShaderResourceView* depthStencilSRV;
#endif
#pragma data_seg(".backBufferUAVdesc")
static D3D11_UNORDERED_ACCESS_VIEW_DESC backBufferUAVdesc =
{
DXGI_FORMAT_R8G8B8A8_UNORM,
D3D11_UAV_DIMENSION_TEXTURE2D,
{ 0 }
};
#pragma data_seg(".backBufferRTVdesc")
static D3D11_RENDER_TARGET_VIEW_DESC backBufferRTVdesc =
{
DXGI_FORMAT_R8G8B8A8_UNORM,
D3D11_RTV_DIMENSION_TEXTURE2D,
{ 0 }
};
#pragma data_seg(".directxFeatureLevel")
static D3D_FEATURE_LEVEL featureLevel[] = { D3D_FEATURE_LEVEL_11_0 };
#pragma data_seg(".directxSwapChainDesc")
static DXGI_SWAP_CHAIN_DESC swapChainDesc =
{
{
SCREENWIDTH,
SCREENHEIGHT,
{
0, 1
},
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED,
DXGI_MODE_SCALING_UNSPECIFIED
},
{
1, 0
},
DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS,
1,
0,
WINDOWED,
DXGI_SWAP_EFFECT_DISCARD,
0
};
#pragma data_seg(".swapChainViewport")
static D3D11_VIEWPORT swapChainViewport =
{
0.0f,
0.0f,
SCREENWIDTH,
SCREENHEIGHT,
0.0f,
1.0f,
};
#pragma code_seg(".directxInit")
INLINE void DirectXInit()
{
Log("DirectXInit");
swapChainDesc.OutputWindow = windowHandle;
CHECK(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D_DEVICE_FLAGS, featureLevel, 1, D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, NULL, &context));
CHECK(swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferTexture));
CHECK(device->CreateUnorderedAccessView(backBufferTexture, &backBufferUAVdesc, &backBufferUAV));
CHECK(device->CreateRenderTargetView(backBufferTexture, &backBufferRTVdesc, &backBufferRTV));
}

View File

@@ -0,0 +1,128 @@
#pragma once
#ifndef _DEBUG
#define INLINE __forceinline
#else
#define INLINE
#endif
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "log.h"
#include "window.h"
#include "directx.h"
#include "4klang.h"
#include "sound.h"
#include "video.h"
#pragma bss_seg(".shadersbss")
static void* shaderCode;
static size_t shaderSize;
#ifdef AUTHORING
bool CompileShader_Authoring(char* entryPoint, char* profile);
#define CompileShader(entryPoint, profile) { if (!CompileShader_Authoring(entryPoint, profile)) return; }
#else
void CompileShader_Release(char* entryPoint, char* profile);
#define CompileShader(entryPoint, profile) CompileShader_Release(entryPoint, profile)
#endif
#include "sync/usync.h"
#include "shaders_shc.h"
#pragma code_seg(".introforward")
void IntroInit();
void IntroUpdate(float _introPosition);
#ifdef AUTHORING
#include "authoring.h"
#endif
#include "shaders.h"
INLINE void FrameworkInit()
{
Log("FrameworkInit");
WindowInit();
DirectXInit();
ShadersInit();
SyncInit();
#ifdef AUTHORING
AuthoringInit();
#endif
FrameworkShadersCompile();
IntroInit();
SoundInit();
#ifdef AUTHORING
SoundPause(NULL, (int)true);
#endif
#ifdef VIDEO
VideoInit();
#endif
}
INLINE float FrameworkGetIntroPosition()
{
#ifdef AUTHORING
return AuthoringGetIntroPosition();
#elif VIDEO
return VideoGetPosition();
#else
return SoundGetIntroPosition();
#endif
}
INLINE void FrameworkUpdate()
{
#ifdef VIDEO
float t = VideoGetPosition();
#else
float t = FrameworkGetIntroPosition();
#endif
SyncUpdate(t);
#ifdef AUTHORING
if (AuthoringUpdate())
{
IntroUpdate(t);
}
#else
IntroUpdate(t);
#endif
#ifdef VIDEO
VideoUpdate();
#endif
}
INLINE void FrameworkDispose()
{
Log("FrameworkDispose");
#ifdef AUTHORING
AuthoringDispose();
#endif
#ifdef VIDEO
VideoDispose();
#endif
}
static const float introLength = (float)MAX_SAMPLES / (float)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE);
INLINE bool FrameworkContinueExecuting()
{
#ifndef AUTHORING
if (FrameworkGetIntroPosition() >= introLength)
return false;
return !GetAsyncKeyState(VK_ESCAPE);
#else
return SharedMemoryTool->KeepAlive;
#endif
}

View File

@@ -0,0 +1,19 @@
/* File generated with Shader Minifier 1.1.3
* http://www.ctrl-alt-test.fr
*/
#ifndef INTRO_HLSL_H_
# define INTRO_HLSL_H_
# define VAR_O2D0 "f"
char merged_hlsl[] = "#define _ [numthreads(16,16,1)]\n"
"RWTexture2D<float4> f:register(u0);"
"_ "
"void cs_Sample(int3 i:SV_DispatchThreadID)"
"{"
"float2 u;"
"f.GetDimensions(u.x,u.y);"
"float2 x=(i.xy+.500000)/u;"
"f[i.xy]=float4(x,.500000,1.000000);"
"}";
#endif // INTRO_HLSL_H_

View File

@@ -0,0 +1,65 @@
#pragma once
#ifdef _DEBUG
#include <stdio.h>
#include <stdarg.h>
void Log(char* _text, ...)
{
va_list args;
va_start(args, _text);
vprintf(_text, args);
va_end(args);
printf("\n");
}
void Warn(char* _text)
{
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hstdout, &csbi);
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
OutputDebugString("WARNING: ");
OutputDebugString(_text);
OutputDebugString("\n");
Log(_text);
SetConsoleTextAttribute(hstdout, csbi.wAttributes);
}
void Error(char* _text)
{
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hstdout, &csbi);
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
OutputDebugString("ERROR: ");
OutputDebugString(_text);
OutputDebugString("\n");
Log(_text);
SetConsoleTextAttribute(hstdout, csbi.wAttributes);
}
void CHECK(HRESULT _hResult)
{
if (_hResult != S_OK)
{
HLOCAL pBuffer;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, _hResult, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&pBuffer, 512, NULL);
Error((char*)pBuffer);
DebugBreak();
}
}
#else
#define Log(text)
#define Warn(text)
#define Error(text)
#define CHECK(hresult) hresult
#endif

View File

@@ -0,0 +1,11 @@
RWTexture2D<float4> o2d0 : register(u0); /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|1)*/
/*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|2)*/
[numthreads(16,16,1)] /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|3)*/
/*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|4)*/
void cs_Sample(int3 id: SV_DispatchThreadID) /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|5)*/
{ /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|6)*/
float2 s; /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|7)*/
o2d0.GetDimensions(s.x, s.y); /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|8)*/
float2 uv = (id.xy + 0.5) / s; /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|9)*/
o2d0[id.xy] = float4(uv, 0.5, 1.0); /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|10)*/
} /*(E:\blu-flame.org\8kode\src\intro\shaders\intro.hlsl|11)*/

View File

@@ -0,0 +1,22 @@
#pragma once
#ifdef AUTHORING
struct MutexLock
{
public:
MutexLock(const char* _mutexName)
{
m_MutexHandle = CreateMutex(NULL, FALSE, _mutexName);
while (WaitForSingleObject(m_MutexHandle, 500) != WAIT_OBJECT_0)
::Sleep(1);
}
virtual ~MutexLock()
{
CloseHandle(m_MutexHandle);
}
private:
HANDLE m_MutexHandle;
};
#endif

View File

@@ -0,0 +1,139 @@
#pragma once
#include <d3dcompiler.h>
#pragma bss_seg(".shadersbss")
static ID3DBlob* shaderBlob;
static ID3DBlob* errorBlob;
static pD3DCompile d3dCompile;
#pragma data_seg(".d3dcompiler")
static char d3dcompiler[] = "d3dcompiler_47.dll";
#pragma data_seg(".minifiedShader")
#include "intro_hlsl.h"
#ifdef AUTHORING
#include <process.h>
#include <io.h>
#include <stdio.h>
static char g_sMonitoredShaderPath[MAX_PATH];
static __time64_t shaderChangedDate;
DWORD WINAPI filemon(void* args)
{
while (true)
{
_finddata_t fdata;
long hfile = _findfirst(g_sMonitoredShaderPath, &fdata);
if (hfile != -1)
{
if (fdata.time_write != shaderChangedDate)
{
shaderChangedDate = fdata.time_write;
::SetEvent(shaderCompileEvent);
}
_findclose(hfile);
}
::Sleep(100);
}
return 0;
}
#endif
INLINE void ShadersInit()
{
HINSTANCE hl = LoadLibrary(d3dcompiler);
if (!hl)
{
d3dcompiler[13] = '3';
hl = LoadLibrary(d3dcompiler);
}
d3dCompile = (pD3DCompile)GetProcAddress(hl, "D3DCompile");
#ifdef AUTHORING
static char exePath[MAX_PATH];
GetModuleFileName(NULL, exePath, MAX_PATH);
PathRemoveFileSpec(exePath);
PathCombine(g_sMonitoredShaderPath, exePath, "..\\src\\intro\\framework\\merged.hlsl");
_finddata_t fdata;
long hfile = _findfirst(g_sMonitoredShaderPath, &fdata);
if (hfile != -1)
{
shaderChangedDate = fdata.time_write;
_findclose(hfile);
}
shaderCompileEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("WriteEvent"));
SetThreadPriority((HANDLE)CreateThread(0, 0, &filemon, 0, 0, 0), THREAD_PRIORITY_BELOW_NORMAL);
#endif
}
#ifdef AUTHORING
#pragma code_seg(".CompileShaderA")
bool CompileShader_Authoring(char* entryPoint, char* profile)
{
ReadFile((char*)g_sMonitoredShaderPath, (char**)&shaderCode, &shaderSize);
d3dCompile(shaderCode, shaderSize, g_sMonitoredShaderPath, NULL, NULL, entryPoint, profile, D3DCOMPILE_DEBUG, 0, &shaderBlob, &errorBlob);
if (errorBlob != NULL)
{
auto error = (char*)errorBlob->GetBufferPointer();
if (shaderBlob != NULL)
{
Warn(error);
}
else
{
Error(error);
}
DWORD cbSize = strlen(error);
DWORD cbWritten = 0;
WriteFile(
hShaderErrorPipe, // pipe handle
&cbSize, // message
sizeof(DWORD), // message length
&cbWritten, // bytes written
NULL); // not overlapped
WriteFile(
hShaderErrorPipe, // pipe handle
error, // message
cbSize, // message length
&cbWritten, // bytes written
NULL); // not overlapped
if (shaderBlob == NULL)
{
return false;
}
}
shaderSize = shaderBlob->GetBufferSize();
shaderCode = shaderBlob->GetBufferPointer();
return true;
};
#endif
#pragma code_seg(".CompileShaderR")
void CompileShader_Release(char* entryPoint, char* profile)
{
#ifdef _DEBUG
d3dCompile(merged_hlsl, sizeof(merged_hlsl), NULL, NULL, NULL, entryPoint, profile, 0, 0, &shaderBlob, &errorBlob);
if (errorBlob != NULL)
{
auto error = errorBlob->GetBufferPointer();
Error((char*)error);
}
#else
d3dCompile(merged_hlsl, sizeof(merged_hlsl), NULL, NULL, NULL, entryPoint, profile, 0, 0, &shaderBlob, 0);
#endif
shaderSize = shaderBlob->GetBufferSize();
shaderCode = shaderBlob->GetBufferPointer();
};

View File

@@ -0,0 +1,15 @@
Texture2D<float4> in0 : register(u0);
RWTexture1D<uint> histogramBucketR : register(u1);
RWTexture1D<uint> histogramBucketG : register(u2);
RWTexture1D<uint> histogramBucketB : register(u3);
RWTexture1D<float4> histogramOut : register(u4);
[numthreads(16, 16, 1)]
void main(uint3 id : SV_DispatchThreadID)
{
int3 iPixel = in0[id.xy].rgb * 255.0f;
InterlockedAdd(histogramBucketR[iPixel.r], 1);
InterlockedAdd(histogramBucketG[iPixel.g], 1);
InterlockedAdd(histogramBucketB[iPixel.b], 1);
}

View File

@@ -0,0 +1,13 @@
Texture2D<float4> in0 : register(u0);
RWTexture1D<uint> histogramBucketR : register(u1);
RWTexture1D<uint> histogramBucketG : register(u2);
RWTexture1D<uint> histogramBucketB : register(u3);
RWTexture1D<float4> histogramOut : register(u4);
[numthreads(16, 1, 1)]
void main(uint3 id : SV_DispatchThreadID)
{
InterlockedMax(histogramBucketR[256], histogramBucketR[id.x]);
InterlockedMax(histogramBucketG[256], histogramBucketG[id.x]);
InterlockedMax(histogramBucketB[256], histogramBucketB[id.x]);
}

View File

@@ -0,0 +1,14 @@
Texture2D<float4> in0 : register(u0);
RWTexture1D<uint> histogramBucketR : register(u1);
RWTexture1D<uint> histogramBucketG : register(u2);
RWTexture1D<uint> histogramBucketB : register(u3);
RWTexture1D<float4> histogramOut : register(u4);
[numthreads(16, 1, 1)]
void main(uint3 id : SV_DispatchThreadID)
{
histogramOut[id.x] = float4(
log(1.0 + histogramBucketR[id.x]) / log(1.0 + histogramBucketR[256]),
log(1.0 + histogramBucketG[id.x]) / log(1.0 + histogramBucketG[256]),
log(1.0 + histogramBucketB[id.x]) / log(1.0 + histogramBucketB[256]), 0.0f);
}

View File

@@ -0,0 +1,28 @@
Texture2D<float4> in0 : register(u0);
RWTexture2D<uint> paradeBucketR : register(u1);
RWTexture2D<uint> paradeBucketG : register(u2);
RWTexture2D<uint> paradeBucketB : register(u3);
RWTexture2D<uint> paradeBucketA : register(u4);
RWTexture2D<uint> vectorScopeBucket : register(u5);
RWTexture2D<uint4> paradeOut : register(u6);
RWTexture2D<uint4> vectorScopeOut : register(u7);
[numthreads(16, 16, 1)]
void main(uint3 id : SV_DispatchThreadID)
{
float3 pixel = in0[id.xy].rgb;
int3 iPixel = pixel * 255.0f;
float luminance = dot(pixel, float3(0.2126f, 0.7152f, 0.0722f));
float2 f = float2(0.492f, 0.877f) * (pixel.br - luminance);
int2 uv = min(255, max(0, 128 * (1 + f / float2(0.436f, 0.615f))));
float2 resolution;
in0.GetDimensions(resolution.x, resolution.y);
int paradeCoord = (id.x * 255.0f) / resolution.x;
InterlockedAdd(paradeBucketR[int2(paradeCoord, 255 - iPixel.r)], 1);
InterlockedAdd(paradeBucketG[int2(paradeCoord, 255 - iPixel.g)], 1);
InterlockedAdd(paradeBucketB[int2(paradeCoord, 255 - iPixel.b)], 1);
InterlockedAdd(paradeBucketA[int2(paradeCoord, 255 - (uint)(255.0f * luminance))], 1);
InterlockedAdd(vectorScopeBucket[uv], 1);
}

View File

@@ -0,0 +1,18 @@
Texture2D<float4> in0 : register(u0);
RWTexture2D<uint> paradeBucketR : register(u1);
RWTexture2D<uint> paradeBucketG : register(u2);
RWTexture2D<uint> paradeBucketB : register(u3);
RWTexture2D<uint> paradeBucketA : register(u4);
RWTexture2D<uint> vectorScopeBucket : register(u5);
RWTexture2D<uint4> paradeOut : register(u6);
RWTexture2D<uint4> vectorScopeOut : register(u7);
[numthreads(16, 16, 1)]
void main(uint3 id : SV_DispatchThreadID)
{
InterlockedMax(paradeBucketR[uint2(256, 0)], paradeBucketR[id.xy]);
InterlockedMax(paradeBucketG[uint2(256, 0)], paradeBucketG[id.xy]);
InterlockedMax(paradeBucketB[uint2(256, 0)], paradeBucketB[id.xy]);
InterlockedMax(paradeBucketA[uint2(256, 0)], paradeBucketA[id.xy]);
InterlockedMax(vectorScopeBucket[uint2(256, 0)], vectorScopeBucket[id.xy]);
}

View File

@@ -0,0 +1,31 @@
Texture2D<float4> in0 : register(u0);
RWTexture2D<uint> paradeBucketR : register(u1);
RWTexture2D<uint> paradeBucketG : register(u2);
RWTexture2D<uint> paradeBucketB : register(u3);
RWTexture2D<uint> paradeBucketA : register(u4);
RWTexture2D<uint> vectorScopeBucket : register(u5);
RWTexture2D<uint4> paradeOut : register(u6);
RWTexture2D<uint4> vectorScopeOut : register(u7);
[numthreads(16, 16, 1)]
void main( uint3 id : SV_DispatchThreadID )
{
paradeOut[id.xy] = uint4(
255.0f * log(1.0f + paradeBucketR[id.xy]) / log(1.0f + paradeBucketR[uint2(256, 0)]),
255.0f * log(1.0f + paradeBucketG[id.xy]) / log(1.0f + paradeBucketG[uint2(256, 0)]),
255.0f * log(1.0f + paradeBucketB[id.xy]) / log(1.0f + paradeBucketB[uint2(256, 0)]),
255.0f * log(1.0f + paradeBucketA[id.xy]) / log(1.0f + paradeBucketA[uint2(256, 0)]));
float luminance = 1.0f - max(0.0f, min(1.0f, log(1.0f + vectorScopeBucket[id.xy]) / log(1.0f + vectorScopeBucket[uint2(256, 0)])));
float2 f = (id.xy - 128.0f) / 128.0f;
if (length(f) > 1)
luminance = 0.0f;
float2 uv = ((id.xy / 128.0f) - 1.0f) * float2(0.436f, 0.615f);
float3 _a = float3(0, -0.3950f, 2.03252f);
float3 _b = float3(1.14025f, -0.581f, 0);
uint3 rgb = luminance * 255.0f * min(1, max(0, (0.5f + uv.x * _a + uv.y * _b)));
vectorScopeOut[id.xy] = uint4(rgb, 255);
}

View File

@@ -0,0 +1,34 @@
#pragma once
// WARNING: This file is autogenerated by shc. Do not edit
#pragma data_seg(".cs_5_0")
static char cs_5_0[] = "cs_5_0";
#pragma data_seg(".vs_5_0")
static char vs_5_0[] = "vs_5_0";
#pragma data_seg(".gs_5_0")
static char gs_5_0[] = "gs_5_0";
#pragma data_seg(".ds_5_0")
static char ds_5_0[] = "ds_5_0";
#pragma data_seg(".hs_5_0")
static char hs_5_0[] = "hs_5_0";
#pragma data_seg(".ps_5_0")
static char ps_5_0[] = "ps_5_0";
#pragma bss_seg(".shaderbss")
static ID3D11ComputeShader* cs_Sample;
#pragma code_seg(".FrameworkShadersCompile")
INLINE void FrameworkShadersCompile()
{
CompileShader("cs_Sample", cs_5_0);
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_Sample);
}
#define SyncInit()
#define SyncUpdate(t)

View File

@@ -0,0 +1,76 @@
#pragma once
#define SOUND_TICKS_PER_SCENE 64
#define SYNC_ROWS_PER_SCENE 16
#include <mmsystem.h>
#include <mmreg.h>
#pragma bss_seg(".audio_bss")
#ifdef AUTHORING
static SAMPLE_TYPE* soundBuffer;
#else
static SAMPLE_TYPE soundBuffer[MAX_SAMPLES * 2];
#endif
static HWAVEOUT hWaveOut;
#pragma data_seg(".wavehdr")
#ifndef RELEASE
WAVEHDR WaveHDR =
{
(LPSTR)soundBuffer,
MAX_SAMPLES*sizeof(SAMPLE_TYPE)* 2,
0, 0, 0, 0, 0, 0
};
#else
WAVEHDR WaveHDR =
{
(LPSTR)soundBuffer,
MAX_SAMPLES*sizeof(SAMPLE_TYPE) * 2,
0, 0, WHDR_PREPARED, 0, 0, 0
};
#endif
#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(".mmtime")
static MMTIME mmtime =
{
TIME_SAMPLES
};
INLINE float SoundGetIntroPosition()
{
waveOutGetPosition(hWaveOut, &mmtime, sizeof(MMTIME));
return mmtime.u.sample / (float)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE);
}
#pragma code_seg(".initsnd")
INLINE void SoundInit()
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)_4klang_render, soundBuffer, 0, 0);
#ifndef VIDEO
::Sleep(1024);// give the 4klang render call some time
waveOutOpen(&hWaveOut, -1, &WaveFMT, 0, 0, 0);
#ifndef RELEASE
waveOutPrepareHeader(hWaveOut, &WaveHDR, 0x20);
#endif
waveOutWrite(hWaveOut, &WaveHDR, 0x20);
#endif
}

View File

@@ -0,0 +1,590 @@
#ifndef SYNC_DATA_H
#define SYNC_DATA_H
enum sync_tracks {
SYNC_TRACK_cameraPosition_x = 0,
SYNC_TRACK_cameraPosition_y = 1,
SYNC_TRACK_cameraPosition_z = 2,
SYNC_TRACK_cameraPosition_w = 3,
SYNC_TRACK_cameraCenter_x = 4,
SYNC_TRACK_cameraCenter_y = 5,
SYNC_TRACK_cameraCenter_z = 6,
SYNC_TRACK_cameraCenter_w = 7,
SYNC_TRACK_cameraUp_x = 8,
SYNC_TRACK_cameraUp_y = 9,
SYNC_TRACK_cameraUp_z = 10,
SYNC_TRACK_cameraUp_w = 11,
SYNC_TRACK_fade = 12,
SYNC_TRACK_cubeLifetime = 13,
SYNC_TRACK_transition = 14,
SYNC_TRACK_COUNT = 15
};
static const unsigned short sync_data_offset[SYNC_TRACK_COUNT] = {
0, /* track: cameraPosition_x */
16, /* track: cameraPosition_y */
27, /* track: cameraPosition_z */
47, /* track: cameraPosition_w */
48, /* track: cameraCenter_x */
59, /* track: cameraCenter_y */
75, /* track: cameraCenter_z */
86, /* track: cameraCenter_w */
87, /* track: cameraUp_x */
97, /* track: cameraUp_y */
98, /* track: cameraUp_z */
99, /* track: cameraUp_w */
100, /* track: fade */
128, /* track: cubeLifetime */
140, /* track: transition */
};
static const unsigned char sync_data_count[SYNC_TRACK_COUNT] = {
16, /* track: cameraPosition_x */
11, /* track: cameraPosition_y */
20, /* track: cameraPosition_z */
1, /* track: cameraPosition_w */
11, /* track: cameraCenter_x */
16, /* track: cameraCenter_y */
11, /* track: cameraCenter_z */
1, /* track: cameraCenter_w */
10, /* track: cameraUp_x */
1, /* track: cameraUp_y */
1, /* track: cameraUp_z */
1, /* track: cameraUp_w */
28, /* track: fade */
12, /* track: cubeLifetime */
19, /* track: transition */
};
static const unsigned short sync_data_rows[] = {
/* track: cameraPosition_x */
0,
128,
160,
192,
223,
224,
240,
256,
272,
288,
352,
383,
384,
416,
448,
464,
/* track: cameraPosition_y */
0,
128,
160,
192,
223,
224,
288,
384,
415,
416,
448,
/* track: cameraPosition_z */
0,
95,
96,
128,
160,
192,
223,
224,
248,
287,
288,
352,
368,
383,
384,
416,
447,
448,
456,
480,
/* track: cameraPosition_w */
0,
/* track: cameraCenter_x */
0,
96,
128,
160,
224,
288,
368,
384,
416,
448,
464,
/* track: cameraCenter_y */
0,
96,
128,
160,
192,
224,
287,
288,
352,
360,
384,
416,
447,
448,
464,
512,
/* track: cameraCenter_z */
0,
95,
96,
128,
160,
224,
288,
416,
447,
448,
480,
/* track: cameraCenter_w */
0,
/* track: cameraUp_x */
0,
160,
192,
223,
224,
352,
384,
448,
456,
472,
/* track: cameraUp_y */
0,
/* track: cameraUp_z */
0,
/* track: cameraUp_w */
0,
/* track: fade */
0,
16,
94,
95,
96,
97,
126,
127,
128,
129,
158,
159,
160,
161,
284,
288,
296,
382,
384,
386,
414,
416,
418,
446,
448,
450,
512,
519,
/* track: cubeLifetime */
0,
288,
344,
351,
352,
384,
392,
396,
400,
416,
448,
488,
/* track: transition */
0,
96,
216,
224,
228,
256,
288,
352,
380,
384,
388,
412,
416,
420,
444,
448,
452,
480,
512,
};
static const float sync_data_values[] = {
/* track: cameraPosition_x */
0.000000f,
-40.000000f,
-5.000000f,
0.000000f,
-5.000000f,
-5.500000f,
-3.500000f,
-5.500000f,
-7.500000f,
14.000000f,
14.000000f,
-40.000000f,
-8.000000f,
-5.000000f,
20.000000f,
35.000000f,
/* track: cameraPosition_y */
3.000000f,
4.000000f,
10.000000f,
3.500000f,
5.000000f,
2.500000f,
2.000000f,
15.000000f,
30.000000f,
55.000000f,
5.000000f,
/* track: cameraPosition_z */
0.000000f,
50.000000f,
75.000000f,
100.000000f,
125.000000f,
140.000000f,
175.000000f,
203.000000f,
208.500000f,
225.000000f,
65.000000f,
65.000000f,
40.000000f,
50.000000f,
81.000000f,
135.000000f,
30.000000f,
25.000000f,
25.000000f,
30.000000f,
/* track: cameraPosition_w */
1.000000f,
/* track: cameraCenter_x */
10.000000f,
-20.000000f,
40.000000f,
0.000000f,
-6.000000f,
50.000000f,
50.000000f,
0.000000f,
0.000000f,
15.000000f,
45.000000f,
/* track: cameraCenter_y */
-10.000000f,
-20.000000f,
-40.000000f,
-100.000000f,
-50.000000f,
1.000000f,
-5.000000f,
2.000000f,
2.000000f,
-5.000000f,
20.000000f,
20.000000f,
5.000000f,
10.000000f,
5.000000f,
-5.000000f,
/* track: cameraCenter_z */
25.000000f,
75.000000f,
100.000000f,
125.000000f,
250.000000f,
205.500000f,
100.000000f,
100.000000f,
30.000000f,
25.000000f,
45.000000f,
/* track: cameraCenter_w */
1.000000f,
/* track: cameraUp_x */
0.000000f,
0.050000f,
0.000000f,
-0.100000f,
0.000000f,
0.000000f,
0.100000f,
0.000000f,
-0.200000f,
0.000000f,
/* track: cameraUp_y */
1.000000f,
/* track: cameraUp_z */
0.000000f,
/* track: cameraUp_w */
1.000000f,
/* track: fade */
0.000000f,
0.500000f,
0.500000f,
0.000000f,
0.000000f,
0.500000f,
0.500000f,
0.000000f,
0.000000f,
0.500000f,
0.500000f,
0.000000f,
0.000000f,
0.500000f,
0.500000f,
0.900000f,
0.500000f,
0.500000f,
0.600000f,
0.500000f,
0.500000f,
0.600000f,
0.500000f,
0.500000f,
0.600000f,
0.500000f,
0.500000f,
0.000000f,
/* track: cubeLifetime */
0.000000f,
17.000000f,
17.000000f,
1.000000f,
1.000000f,
17.000000f,
17.000000f,
1.000000f,
1.000000f,
50.000000f,
50.000000f,
4.000000f,
/* track: transition */
1.000000f,
0.000000f,
0.000000f,
1.000000f,
0.000000f,
0.000000f,
1.000000f,
0.000000f,
0.000000f,
1.000000f,
0.000000f,
0.000000f,
1.000000f,
0.000000f,
0.000000f,
1.000000f,
0.000000f,
0.000000f,
1.000000f,
};
static const unsigned char sync_data_type[] = {
/* track: cameraPosition_x */
0,
0,
2,
2,
0,
2,
2,
2,
0,
0,
2,
0,
1,
3,
2,
0,
/* track: cameraPosition_y */
0,
0,
2,
2,
0,
0,
0,
1,
0,
2,
0,
/* track: cameraPosition_z */
1,
0,
1,
1,
3,
1,
0,
2,
3,
0,
0,
2,
3,
0,
1,
1,
0,
0,
2,
0,
/* track: cameraPosition_w */
0,
/* track: cameraCenter_x */
0,
1,
1,
0,
0,
0,
3,
0,
3,
2,
0,
/* track: cameraCenter_y */
0,
0,
1,
2,
0,
3,
0,
0,
2,
2,
1,
2,
0,
3,
2,
0,
/* track: cameraCenter_z */
1,
0,
1,
1,
0,
0,
0,
1,
0,
2,
0,
/* track: cameraCenter_w */
0,
/* track: cameraUp_x */
0,
2,
2,
0,
0,
3,
0,
2,
2,
0,
/* track: cameraUp_y */
0,
/* track: cameraUp_z */
0,
/* track: cameraUp_w */
0,
/* track: fade */
2,
0,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
1,
0,
3,
0,
/* track: cubeLifetime */
0,
0,
3,
0,
1,
0,
1,
0,
1,
0,
1,
0,
/* track: transition */
2,
0,
3,
2,
0,
3,
3,
0,
3,
2,
0,
3,
2,
0,
3,
2,
0,
3,
0,
};
#endif /* !defined(SYNC_DATA_H) */

View File

@@ -0,0 +1,123 @@
/* Copyright (C) 2007-2010 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#ifndef SYNC_BASE_H
#define SYNC_BASE_H
/* configure inline keyword */
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) && !defined(__cplusplus)
#if defined(_MSC_VER) || defined(__GNUC__) || defined(__SASC)
#define inline __inline
#else
/* compiler does not support inline, make function static instead */
#define inline static
#endif
#endif
/* configure lacking CRT features */
#ifdef _MSC_VER
#define strdup _strdup
#define snprintf _snprintf
/* int is 32-bit for both x86 and x64 */
typedef unsigned int uint32_t;
#define UINT32_MAX UINT_MAX
#elif defined(__GNUC__)
#include <stdint.h>
#elif defined(M68000)
typedef unsigned int uint32_t;
#endif
/* configure socket-stack */
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <winsock2.h>
#include <windows.h>
#include <limits.h>
#include <Shlwapi.h>
#elif defined(USE_AMITCP)
#include <sys/socket.h>
#include <proto/exec.h>
#include <proto/socket.h>
#include <netdb.h>
#define SOCKET int
#define INVALID_SOCKET -1
#define select(n,r,w,e,t) WaitSelect(n,r,w,e,t,0)
#define closesocket(x) CloseSocket(x)
#else
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#define SOCKET int
#define INVALID_SOCKET -1
#define closesocket(x) close(x)
#endif
#define CLIENT_GREET "hello, synctracker!"
#define SERVER_GREET "hello, demo!"
enum {
SET_KEY = 0,
DELETE_KEY = 1,
GET_TRACK = 2,
SET_ROW = 3,
PAUSE = 4,
SAVE_TRACKS = 5
};
static inline int socket_poll(SOCKET socket)
{
struct timeval to = { 0, 0 };
fd_set fds;
FD_ZERO(&fds);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127)
#endif
FD_SET(socket, &fds);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
return select((int)socket + 1, &fds, NULL, NULL, &to) > 0;
}
#include <assert.h>
static inline int xsend(SOCKET s, const void *buf, size_t len, int flags)
{
#ifdef WIN32
assert(len <= INT_MAX);
return send(s, (const char *)buf, (int)len, flags) != (int)len;
#else
return send(s, (const char *)buf, len, flags) != len;
#endif
}
static inline int xrecv(SOCKET s, void *buf, size_t len, int flags)
{
#ifdef WIN32
assert(len <= INT_MAX);
return recv(s, (char *)buf, (int)len, flags) != (int)len;
#else
return recv(s, (char *)buf, len, flags) != len;
#endif
}
#ifdef NEED_STRDUP
static inline char *rocket_strdup(const char *str)
{
char *ret = malloc(strlen(str) + 1);
if (ret)
strcpy(ret, str);
return ret;
}
#define strdup rocket_strdup
#endif
#endif /* SYNC_BASE_H */

View File

@@ -0,0 +1,33 @@
/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#include "data.h"
void sync_data_deinit(struct sync_data *d)
{
int i;
for (i = 0; i < (int)d->num_tracks; ++i) {
free(d->tracks[i]->name);
free(d->tracks[i]->keys);
free(d->tracks[i]);
}
free(d->tracks);
}
int sync_create_track(struct sync_data *d, const char *name)
{
struct sync_track *t;
assert(sync_find_track(d, name) < 0);
t = (sync_track*)malloc(sizeof(*t));
t->name = strdup(name);
t->keys = NULL;
t->num_keys = 0;
d->num_tracks++;
d->tracks = (sync_track**)realloc(d->tracks, sizeof(d->tracks[0]) * d->num_tracks);
d->tracks[d->num_tracks - 1] = t;
return (int)d->num_tracks - 1;
}

View File

@@ -0,0 +1,28 @@
/* Copyright (C) 2007-2010 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#ifndef SYNC_DATA_H
#define SYNC_DATA_H
#include "track.h"
struct sync_data {
struct sync_track **tracks;
size_t num_tracks;
};
static inline int sync_find_track(const struct sync_data *data,
const char *name)
{
int i;
for (i = 0; i < (int)data->num_tracks; ++i)
if (!strcmp(name, data->tracks[i]->name))
return i;
return -1; /* not found */
}
void sync_data_deinit(struct sync_data *);
int sync_create_track(struct sync_data *, const char *);
#endif /* SYNC_DATA_H */

View File

@@ -0,0 +1,359 @@
/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#include "device.h"
#include "sync.h"
#include <stdio.h>
#include <math.h>
static const char *sync_track_path(const char *base, const char *name)
{
static char temp[FILENAME_MAX];
strncpy(temp, base, sizeof(temp) - 1);
temp[sizeof(temp) - 1] = '\0';
strncat(temp, "_", sizeof(temp) - 1);
strncat(temp, name, sizeof(temp) - 1);
strncat(temp, ".track", sizeof(temp) - 1);
return temp;
}
#ifndef SYNC_PLAYER
#ifdef USE_AMITCP
static struct Library *socket_base = NULL;
#endif
static SOCKET server_connect(const char *host, unsigned short nport)
{
struct hostent *he;
struct sockaddr_in sa;
char greet[128], **ap;
SOCKET sock = INVALID_SOCKET;
#ifdef WIN32
static int need_init = 1;
if (need_init) {
WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 0), &wsa))
return INVALID_SOCKET;
need_init = 0;
}
#elif defined(USE_AMITCP)
if (!socket_base) {
socket_base = OpenLibrary("bsdsocket.library", 4);
if (!socket_base)
return INVALID_SOCKET;
}
#endif
he = gethostbyname(host);
if (!he)
return INVALID_SOCKET;
for (ap = he->h_addr_list; *ap; ++ap) {
sa.sin_family = he->h_addrtype;
sa.sin_port = htons(nport);
memcpy(&sa.sin_addr, *ap, he->h_length);
sock = socket(he->h_addrtype, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET)
continue;
if (connect(sock, (struct sockaddr *)&sa, sizeof(sa)) >= 0)
break;
closesocket(sock);
sock = INVALID_SOCKET;
}
if (sock == INVALID_SOCKET)
return INVALID_SOCKET;
if (xsend(sock, CLIENT_GREET, strlen(CLIENT_GREET), 0) ||
xrecv(sock, greet, strlen(SERVER_GREET), 0))
return INVALID_SOCKET;
if (!strncmp(SERVER_GREET, greet, strlen(SERVER_GREET)))
return sock;
closesocket(sock);
return INVALID_SOCKET;
}
#else
void sync_set_io_cb(struct sync_device *d, struct sync_io_cb *cb)
{
d->io_cb.open = cb->open;
d->io_cb.read = cb->read;
d->io_cb.close = cb->close;
}
#endif
struct sync_device *sync_create_device(const char *base)
{
struct sync_device *d = (sync_device*)malloc(sizeof(*d));
if (!d)
return NULL;
d->base = strdup(base);
if (!d->base) {
free(d);
return NULL;
}
d->data.tracks = NULL;
d->data.num_tracks = 0;
#ifndef SYNC_PLAYER
d->row = -1;
d->sock = INVALID_SOCKET;
#else
d->io_cb.open = (LPFNCBOPEN)fopen;
d->io_cb.read = (LPFNCBREAD)fread;
d->io_cb.close = (LPFNCBCLOSE)fclose;
#endif
return d;
}
void sync_destroy_device(struct sync_device *d)
{
free(d->base);
sync_data_deinit(&d->data);
free(d);
#if defined(USE_AMITCP) && !defined(SYNC_PLAYER)
if (socket_base) {
CloseLibrary(socket_base);
socket_base = NULL;
}
#endif
}
#ifdef SYNC_PLAYER
static int get_track_data(struct sync_device *d, struct sync_track *t)
{
int i;
void *fp = d->io_cb.open(sync_track_path(d->base, t->name), "rb");
if (!fp)
return -1;
d->io_cb.read(&t->num_keys, sizeof(size_t), 1, fp);
t->keys = (track_key*)malloc(sizeof(struct track_key) * t->num_keys);
if (!t->keys)
return -1;
for (i = 0; i < (int)t->num_keys; ++i) {
struct track_key *key = t->keys + i;
char type;
d->io_cb.read(&key->row, sizeof(int), 1, fp);
d->io_cb.read(&key->value, sizeof(float), 1, fp);
d->io_cb.read(&type, sizeof(char), 1, fp);
key->type = (enum key_type)type;
}
d->io_cb.close(fp);
return 0;
}
#else
static int save_track(const struct sync_track *t, const char *path)
{
int i;
FILE *fp = fopen(path, "wb");
if (!fp)
return -1;
fwrite(&t->num_keys, sizeof(size_t), 1, fp);
for (i = 0; i < (int)t->num_keys; ++i) {
char type = (char)t->keys[i].type;
fwrite(&t->keys[i].row, sizeof(int), 1, fp);
fwrite(&t->keys[i].value, sizeof(float), 1, fp);
fwrite(&type, sizeof(char), 1, fp);
}
fclose(fp);
return 0;
}
void sync_save_tracks(const struct sync_device *d)
{
int i;
for (i = 0; i < (int)d->data.num_tracks; ++i) {
const struct sync_track *t = d->data.tracks[i];
save_track(t, sync_track_path(d->base, t->name));
}
}
static int get_track_data(struct sync_device *d, struct sync_track *t)
{
unsigned char cmd = GET_TRACK;
uint32_t name_len;
assert(strlen(t->name) <= UINT32_MAX);
name_len = htonl((uint32_t)strlen(t->name));
/* send request data */
if (xsend(d->sock, (char *)&cmd, 1, 0) ||
xsend(d->sock, (char *)&name_len, sizeof(name_len), 0) ||
xsend(d->sock, t->name, (int)strlen(t->name), 0))
{
closesocket(d->sock);
d->sock = INVALID_SOCKET;
return -1;
}
return 0;
}
static int handle_set_key_cmd(SOCKET sock, struct sync_data *data)
{
uint32_t track, row;
union {
float f;
uint32_t i;
} v;
struct track_key key;
unsigned char type;
if (xrecv(sock, (char *)&track, sizeof(track), 0) ||
xrecv(sock, (char *)&row, sizeof(row), 0) ||
xrecv(sock, (char *)&v.i, sizeof(v.i), 0) ||
xrecv(sock, (char *)&type, 1, 0))
return -1;
track = ntohl(track);
v.i = ntohl(v.i);
key.row = ntohl(row);
key.value = v.f;
assert(type < KEY_TYPE_COUNT);
assert(track < data->num_tracks);
key.type = (enum key_type)type;
return sync_set_key(data->tracks[track], &key);
}
static int handle_del_key_cmd(SOCKET sock, struct sync_data *data)
{
uint32_t track, row;
if (xrecv(sock, (char *)&track, sizeof(track), 0) ||
xrecv(sock, (char *)&row, sizeof(row), 0))
return -1;
track = ntohl(track);
row = ntohl(row);
assert(track < data->num_tracks);
return sync_del_key(data->tracks[track], row);
}
int sync_connect(struct sync_device *d, const char *host, unsigned short port)
{
int i;
if (d->sock != INVALID_SOCKET)
closesocket(d->sock);
d->sock = server_connect(host, port);
if (d->sock == INVALID_SOCKET)
return -1;
for (i = 0; i < (int)d->data.num_tracks; ++i) {
free(d->data.tracks[i]->keys);
d->data.tracks[i]->keys = NULL;
d->data.tracks[i]->num_keys = 0;
}
for (i = 0; i < (int)d->data.num_tracks; ++i) {
if (get_track_data(d, d->data.tracks[i])) {
closesocket(d->sock);
d->sock = INVALID_SOCKET;
return -1;
}
}
return 0;
}
int sync_update(struct sync_device *d, int row, struct sync_cb *cb,
void *cb_param)
{
if (d->sock == INVALID_SOCKET)
return -1;
/* look for new commands */
while (socket_poll(d->sock)) {
unsigned char cmd = 0, flag;
uint32_t row;
if (xrecv(d->sock, (char *)&cmd, 1, 0))
goto sockerr;
switch (cmd) {
case SET_KEY:
if (handle_set_key_cmd(d->sock, &d->data))
goto sockerr;
break;
case DELETE_KEY:
if (handle_del_key_cmd(d->sock, &d->data))
goto sockerr;
break;
case SET_ROW:
if (xrecv(d->sock, (char *)&row, sizeof(row), 0))
goto sockerr;
if (cb && cb->set_row)
cb->set_row(cb_param, ntohl(row));
break;
case PAUSE:
if (xrecv(d->sock, (char *)&flag, 1, 0))
goto sockerr;
if (cb && cb->pause)
cb->pause(cb_param, flag);
break;
case SAVE_TRACKS:
sync_save_tracks(d);
break;
default:
fprintf(stderr, "unknown cmd: %02x\n", cmd);
goto sockerr;
}
}
if (cb && cb->is_playing && cb->is_playing(cb_param)) {
if (d->row != row && d->sock != INVALID_SOCKET) {
unsigned char cmd = SET_ROW;
uint32_t nrow = htonl(row);
if (xsend(d->sock, (char*)&cmd, 1, 0) ||
xsend(d->sock, (char*)&nrow, sizeof(nrow), 0))
goto sockerr;
d->row = row;
}
}
return 0;
sockerr:
closesocket(d->sock);
d->sock = INVALID_SOCKET;
return -1;
}
#endif
const struct sync_track *sync_get_track(struct sync_device *d,
const char *name)
{
struct sync_track *t;
int idx = sync_find_track(&d->data, name);
if (idx >= 0)
return d->data.tracks[idx];
idx = sync_create_track(&d->data, name);
t = d->data.tracks[idx];
get_track_data(d, t);
return t;
}

View File

@@ -0,0 +1,23 @@
/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#ifndef SYNC_DEVICE_H
#define SYNC_DEVICE_H
#include "data.h"
#include "sync.h"
struct sync_device {
char *base;
struct sync_data data;
#ifndef SYNC_PLAYER
int row;
SOCKET sock;
#else
struct sync_io_cb io_cb;
#endif
};
#endif /* SYNC_DEVICE_H */

View File

@@ -0,0 +1,47 @@
/* Copyright (C) 2010 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#ifndef SYNC_H
#define SYNC_H
#ifdef __cplusplus
extern "C" {
#endif
struct sync_device;
struct sync_track;
struct sync_device *sync_create_device(const char *);
void sync_destroy_device(struct sync_device *);
#ifndef SYNC_PLAYER
struct sync_cb {
void (*pause)(void *, int);
void (*set_row)(void *, int);
int (*is_playing)(void *);
};
#define SYNC_DEFAULT_PORT 1338
int sync_connect(struct sync_device *, const char *, unsigned short);
int sync_update(struct sync_device *, int, struct sync_cb *, void *);
void sync_save_tracks(const struct sync_device *);
#else /* defined(SYNC_PLAYER) */
typedef void *(*LPFNCBOPEN)(const char *filename, const char *mode);
typedef size_t(*LPFNCBREAD)(void *ptr, size_t size, size_t nitems, void *stream);
typedef int(*LPFNCBCLOSE)(void *stream);
struct sync_io_cb {
LPFNCBOPEN open;
LPFNCBREAD read;
LPFNCBCLOSE close;
};
void sync_set_io_cb(struct sync_device *d, struct sync_io_cb *cb);
#endif /* defined(SYNC_PLAYER) */
const struct sync_track *sync_get_track(struct sync_device *, const char *);
double sync_get_val(const struct sync_track *, double);
#ifdef __cplusplus
}
#endif
#endif /* !defined(SYNC_H) */

View File

@@ -0,0 +1,128 @@
/* Copyright (C) 2010 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.141926
#endif
#include "sync.h"
#include "track.h"
#include "base.h"
static double key_linear(const struct track_key k[2], double row)
{
double t = (row - k[0].row) / (k[1].row - k[0].row);
return k[0].value + (k[1].value - k[0].value) * t;
}
static double key_smooth(const struct track_key k[2], double row)
{
double t = (row - k[0].row) / (k[1].row - k[0].row);
t = t * t * (3 - 2 * t);
return k[0].value + (k[1].value - k[0].value) * t;
}
static double key_ramp(const struct track_key k[2], double row)
{
double t = (row - k[0].row) / (k[1].row - k[0].row);
t = pow(t, 2.0);
return k[0].value + (k[1].value - k[0].value) * t;
}
double sync_get_val(const struct sync_track *t, double row)
{
int idx, irow;
/* If we have no keys at all, return a constant 0 */
if (!t->num_keys)
return 0.0f;
irow = (int)floor(row);
idx = key_idx_floor(t, irow);
/* at the edges, return the first/last value */
if (idx < 0)
return t->keys[0].value;
if (idx > (int)t->num_keys - 2)
return t->keys[t->num_keys - 1].value;
/* interpolate according to key-type */
switch (t->keys[idx].type) {
case KEY_STEP:
return t->keys[idx].value;
case KEY_LINEAR:
return key_linear(t->keys + idx, row);
case KEY_SMOOTH:
return key_smooth(t->keys + idx, row);
case KEY_RAMP:
return key_ramp(t->keys + idx, row);
default:
assert(0);
return 0.0f;
}
}
int sync_find_key(const struct sync_track *t, int row)
{
int lo = 0, hi = t->num_keys;
/* binary search, t->keys is sorted by row */
while (lo < hi) {
int mi = (lo + hi) / 2;
assert(mi != hi);
if (t->keys[mi].row < row)
lo = mi + 1;
else if (t->keys[mi].row > row)
hi = mi;
else
return mi; /* exact hit */
}
assert(lo == hi);
/* return first key after row, negated and biased (to allow -0) */
return -lo - 1;
}
#ifndef SYNC_PLAYER
int sync_set_key(struct sync_track *t, const struct track_key *k)
{
int idx = sync_find_key(t, k->row);
if (idx < 0) {
/* no exact hit, we need to allocate a new key */
void *tmp;
idx = -idx - 1;
tmp = realloc(t->keys, sizeof(struct track_key) *
(t->num_keys + 1));
if (!tmp)
return -1;
t->num_keys++;
t->keys = (track_key*)tmp;
memmove(t->keys + idx + 1, t->keys + idx,
sizeof(struct track_key) * (t->num_keys - idx - 1));
}
t->keys[idx] = *k;
return 0;
}
int sync_del_key(struct sync_track *t, int pos)
{
void *tmp;
int idx = sync_find_key(t, pos);
assert(idx >= 0);
memmove(t->keys + idx, t->keys + idx + 1,
sizeof(struct track_key) * (t->num_keys - idx - 1));
assert(t->keys);
tmp = realloc(t->keys, sizeof(struct track_key) *
(t->num_keys - 1));
if (t->num_keys != 1 && !tmp)
return -1;
t->num_keys--;
t->keys = (track_key*)tmp;
return 0;
}
#endif

View File

@@ -0,0 +1,51 @@
/* Copyright (C) 2007-2010 Erik Faye-Lund and Egbert Teeselink
* For conditions of distribution and use, see copyright notice in COPYING
*/
#ifndef SYNC_TRACK_H
#define SYNC_TRACK_H
#include <string.h>
#include <stdlib.h>
#include "base.h"
enum key_type {
KEY_STEP, /* stay constant */
KEY_LINEAR, /* lerp to the next value */
KEY_SMOOTH, /* smooth curve to the next value */
KEY_RAMP,
KEY_TYPE_COUNT
};
struct track_key {
int row;
float value;
enum key_type type;
};
struct sync_track {
char *name;
struct track_key *keys;
int num_keys;
};
int sync_find_key(const struct sync_track *, int);
static inline int key_idx_floor(const struct sync_track *t, int row)
{
int idx = sync_find_key(t, row);
if (idx < 0)
idx = -idx - 2;
return idx;
}
#ifndef SYNC_PLAYER
int sync_set_key(struct sync_track *, const struct track_key *);
int sync_del_key(struct sync_track *, int);
static inline int is_key_frame(const struct sync_track *t, int row)
{
return sync_find_key(t, row) >= 0;
}
#endif /* !defined(SYNC_PLAYER) */
#endif /* SYNC_TRACK_H */

View File

@@ -0,0 +1,171 @@
#include "usync.h"
#include <math.h>
//#include <Shlwapi.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SYNC_PLAYER
static int usync_rows[SYNC_TRACK_COUNT];
float usync_values[SYNC_TRACK_COUNT];
void usync_update(float t, float* targetvalues)
{
int i; float row = t;
for (i = 0; i < SYNC_TRACK_COUNT; ++i) {
int pos;
float mag, x, a, b, c, d;
/* empty tracks should not be neccesary! */
if (!sync_data_count[i]) {
targetvalues[i] = 0.0f;
continue;
}
/* step forward until we're at the right key-frame */
while (usync_rows[i] < (sync_data_count[i] - 1) &&
row >= sync_data_rows[sync_data_offset[i] + usync_rows[i] + 1]) {
usync_rows[i]++;
}
pos = usync_rows[i] + sync_data_offset[i];
/* we need a segment to interpolate over */
if (usync_rows[i] == sync_data_count[i] - 1) {
targetvalues[i] = sync_data_values[pos];
continue;
}
/* prepare coefficients for interpolation */
a = sync_data_values[pos];
mag = sync_data_values[pos + 1] - sync_data_values[pos];
switch (sync_data_type[pos]) {
case 0:
b = c = d = 0.0f;
break;
case 1:
b = mag;
c = d = 0.0f;
break;
case 2:
b = 0.0f;
c = 3 * mag;
d = -2 * mag;
break;
case 3:
b = d = 0.0f;
c = mag;
break;
}
/* evaluate function */
x = (t - sync_data_rows[pos]) / (sync_data_rows[pos + 1] - sync_data_rows[pos]);
targetvalues[i] = a + (b + (c + d * x) * x) * x;
}
}
#else /* !defined(SYNC_PLAYER) */
#include <stdio.h>
#include "sync.h"
#include "device.h"
struct sync_device *usync_dev;
float usync_time = 0;
void usync_update(float t, float* targetValues)
{
usync_time = t;
sync_update(usync_dev, (int)floor(t), &usync_cb, usync_data);
}
int usync_init(void)
{
usync_dev = sync_create_device("sync");
return sync_connect(usync_dev, "localhost", SYNC_DEFAULT_PORT);
}
void usync_export(void)
{
if (usync_dev == 0)
return;
int i, j;
int offset = 0;
static char exePath[MAX_PATH];
static char syncPath[MAX_PATH];
GetModuleFileName(NULL, exePath, MAX_PATH);
PathRemoveFileSpecA(exePath);
PathCombineA(syncPath, exePath, "..\\src\\intro\\framework\\sync-data.h");
FILE *fp = fopen(syncPath, "w");
if (!fp)
return;
/* header-guard */
fputs("#ifndef SYNC_DATA_H\n#define SYNC_DATA_H\n\n", fp);
fputs("enum sync_tracks {\n", fp);
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
struct sync_track *t = usync_dev->data.tracks[i];
fprintf(fp, "\tSYNC_TRACK_%s = %d,\n", t->name, i);
}
fprintf(fp, "\tSYNC_TRACK_COUNT = %d\n", usync_dev->data.num_tracks);
fputs("};\n\n", fp);
fputs("static const unsigned short sync_data_offset[SYNC_TRACK_COUNT] = {\n", fp);
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
struct sync_track *t = usync_dev->data.tracks[i];
fprintf(fp, "\t%d, /* track: %s */\n", offset, t->name);
offset += t->num_keys;
}
fputs("};\n\n", fp);
fputs("static const unsigned char sync_data_count[SYNC_TRACK_COUNT] = {\n", fp);
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
struct sync_track *t = usync_dev->data.tracks[i];
fprintf(fp, "\t%d, /* track: %s */\n", t->num_keys, t->name);
}
fputs("};\n\n", fp);
fputs("static const unsigned short sync_data_rows[] = {\n", fp);
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
struct sync_track *t = usync_dev->data.tracks[i];
fprintf(fp, "\t/* track: %s */\n", t->name);
for (j = 0; j < t->num_keys; ++j)
fprintf(fp, "\t%d,\n", t->keys[j].row);
}
fputs("};\n\n", fp);
fputs("static const float sync_data_values[] = {\n", fp);
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
struct sync_track *t = usync_dev->data.tracks[i];
fprintf(fp, "\t/* track: %s */\n", t->name);
for (j = 0; j < t->num_keys; ++j)
fprintf(fp, "\t%.6ff,\n", t->keys[j].value);
}
fputs("};\n\n", fp);
fputs("static const unsigned char sync_data_type[] = {\n", fp);
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
struct sync_track *t = usync_dev->data.tracks[i];
fprintf(fp, "\t/* track: %s */\n", t->name);
for (j = 0; j < t->num_keys; ++j)
fprintf(fp, "\t%d,\n", t->keys[j].type);
}
fputs("};\n\n", fp);
fputs("#endif /* !defined(SYNC_DATA_H) */\n", fp);
fclose(fp);
}
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,42 @@
#ifndef USYNC_H
#define USYNC_H
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef SYNC_PLAYER
#include "../sync-data.h"
extern float usync_values[SYNC_TRACK_COUNT];
/* tiny api */
#define usync_init() 0
void usync_update(float t, float* targetValues);
#define usync_get_val(x) usync_values[ SYNC_TRACK_##x ]
#define usync_export()
#else /* !defined(SYNC_PLAYER) */
#include "sync.h"
extern struct sync_device *usync_dev;
extern float usync_time;
int usync_init(void);
void usync_update(float t, float* targetValues);
#define usync_get_val(track) sync_get_val(sync_get_track(usync_dev, #track), usync_time)
void usync_export(void);
/* implement these yourself */
extern struct sync_cb usync_cb;
extern void *usync_data;
#endif /* !defined(SYNC_PLAYER) */
#ifdef __cplusplus
}
#endif
#endif /* !defined(USYNC_H) */

View File

@@ -0,0 +1,152 @@
#ifdef VIDEO
#include <vfw.h>
#define FPS 60
#define MOTION_BLUR 8
typedef struct
{
PAVISTREAM m_ps;
PAVISTREAM m_psCompressed;
PAVISTREAM m_psAudio;
AVISTREAMINFO m_strhdr;
AVICOMPRESSOPTIONS m_opts;
PAVIFILE m_pfile;
BITMAPINFOHEADER m_alpbi;
} AVIWRITER;
static D3D11_TEXTURE2D_DESC videoStagingTextureDesc =
{
SCREENWIDTH,
SCREENHEIGHT,
1,
1,
DXGI_FORMAT_R8G8B8A8_UNORM,
{ 1, 0 },
D3D11_USAGE_STAGING,
0,
D3D11_CPU_ACCESS_READ,
0
};
#pragma bss_seg(".videobss")
static AVIWRITER avi;
static int frame = 0;
static ID3D11Texture2D* videoStagingTexture;
static byte buffer[3 * SCREENWIDTH * SCREENHEIGHT];
static int tempBuffer[3 * SCREENWIDTH * SCREENHEIGHT];
#pragma code_seg(".VideoInit")
void VideoInit()
{
AVIFileInit();
CHECK(AVIFileOpen(&avi.m_pfile, "intro.avi", OF_WRITE | OF_CREATE, NULL));
memset(&avi.m_strhdr, 0, sizeof(avi.m_strhdr));
avi.m_strhdr.fccType = streamtypeVIDEO;
avi.m_strhdr.fccHandler = 0;
avi.m_strhdr.dwScale = 1;
avi.m_strhdr.dwRate = FPS;
avi.m_strhdr.dwSuggestedBufferSize = 0;// 3 * SCREENWIDTH * SCREENHEIGHT;
SetRect(&avi.m_strhdr.rcFrame, 0, 0, SCREENWIDTH, SCREENHEIGHT);
CHECK(AVIFileCreateStream(avi.m_pfile, &avi.m_ps, &avi.m_strhdr));
memset(&avi.m_strhdr, 0, sizeof(avi.m_strhdr));
avi.m_strhdr.fccType = streamtypeAUDIO;
avi.m_strhdr.dwScale = WaveFMT.nBlockAlign;
avi.m_strhdr.dwRate = WaveFMT.nSamplesPerSec * WaveFMT.nBlockAlign;
avi.m_strhdr.dwSampleSize = WaveFMT.nBlockAlign;
avi.m_strhdr.dwQuality = (DWORD)-1;
SetRect(&avi.m_strhdr.rcFrame, 0, 0, SCREENWIDTH, SCREENHEIGHT);
CHECK(AVIFileCreateStream(avi.m_pfile, &avi.m_psAudio, &avi.m_strhdr));
CHECK(AVIStreamSetFormat(avi.m_psAudio, 0, &WaveFMT, sizeof(WAVEFORMATEX)));
auto ops = &avi.m_opts;
if (AVISaveOptions(windowHandle, 0, 1, &avi.m_ps, &ops) == FALSE)
{
ExitProcess(0);
}
CHECK(AVIMakeCompressedStream(&avi.m_psCompressed, avi.m_ps, &avi.m_opts, NULL));
memset(&avi.m_alpbi, 0, sizeof(avi.m_alpbi));
avi.m_alpbi.biSize = sizeof(avi.m_alpbi);
avi.m_alpbi.biWidth = SCREENWIDTH;
avi.m_alpbi.biHeight = SCREENHEIGHT;
avi.m_alpbi.biPlanes = 1;
avi.m_alpbi.biBitCount = 24;
avi.m_alpbi.biCompression = BI_RGB;
CHECK(AVIStreamSetFormat(avi.m_psCompressed, 0, &avi.m_alpbi, sizeof(avi.m_alpbi)));
CHECK(device->CreateTexture2D(&videoStagingTextureDesc, NULL, &videoStagingTexture));
}
#pragma code_seg(".VideoGetPosition")
float VideoGetPosition()
{
float seconds = (float)frame / (float)(FPS * MOTION_BLUR);
float samples = seconds * SAMPLE_RATE;
float ticks = samples / (float)SAMPLES_PER_TICK;
return ticks / SOUND_TICKS_PER_SCENE;
}
#pragma code_seg(".VideoUpdate")
void VideoUpdate()
{
static D3D11_MAPPED_SUBRESOURCE videoMappedSubresource;
context->CopyResource(videoStagingTexture, backBufferTexture);
context->Map(videoStagingTexture, 0, D3D11_MAP_READ, 0, &videoMappedSubresource);
auto introPtr = (byte*)videoMappedSubresource.pData;
for (int y = 0; y < SCREENHEIGHT; ++y)
{
auto vy = SCREENHEIGHT - y - 1;
for (int x = 0; x < SCREENWIDTH; ++x)
{
for (int c = 0; c < 4; ++c)
{
byte color = *introPtr++;
if (c < 3)
{
auto vc = 2 - c;
auto vidx = vc + 3 * (x + SCREENWIDTH * vy);
tempBuffer[vidx] += color;
}
}
}
}
context->Unmap(videoStagingTexture, 0);
if ((frame++ % MOTION_BLUR) == 0)
{
auto videoPtr = (byte*)buffer;
auto tempPtr = (int*)tempBuffer;
for (int i = 0; i < SCREENWIDTH * SCREENHEIGHT * 3; ++i)
{
*videoPtr++ = (byte)(*tempPtr / MOTION_BLUR);
*tempPtr++ = 0;
}
CHECK(AVIStreamWrite(avi.m_psCompressed, (frame - 1) / MOTION_BLUR, 1, buffer, 3 * SCREENWIDTH * SCREENHEIGHT, AVIIF_KEYFRAME, NULL, NULL));
}
}
#pragma code_seg(".VideoDispose")
void VideoDispose()
{
auto const extraSamples = 0;// SOUND_TICKS_PER_SCENE * SAMPLES_PER_TICK / 4;
static SAMPLE_TYPE audioBuffer[2 * (MAX_SAMPLES + extraSamples)];
memcpy(audioBuffer + extraSamples * 2, WaveHDR.lpData, WaveHDR.dwBufferLength);
AVIStreamWrite(avi.m_psAudio, 0, MAX_SAMPLES + extraSamples, audioBuffer, WaveHDR.dwBufferLength + extraSamples * sizeof(SAMPLE_TYPE) * 2, 0, NULL, NULL);
AVIStreamClose(avi.m_ps);
AVIStreamClose(avi.m_psCompressed);
AVIStreamClose(avi.m_psAudio);
AVIFileClose(avi.m_pfile);
AVIFileExit();
}
#endif

View File

@@ -0,0 +1,88 @@
#pragma once
#ifndef SCREENWIDTH
#define SCREENWIDTH 1920
#endif
#ifndef SCREENHEIGHT
#define SCREENHEIGHT 1080
#endif
#ifndef WINDOWED
#define WINDOWED FALSE
#endif
#pragma bss_seg(".windowbss")
static float windowWidth = SCREENWIDTH;
static float windowHeight = SCREENHEIGHT;
static HWND windowHandle;
#ifdef VIDEO
#define windowTitle "Intro (rendering to video)"
#endif
#ifdef RELEASE
#define windowTitle "Intro (release)"
#endif
#ifdef SHADERDEBUG
#define windowTitle "Intro (shader debug)"
#endif
#ifdef AUTHORING
#define windowTitle "Intro (authoring)"
#endif
#ifndef windowTitle
#define windowTitle "Intro (unknown configuration)"
#endif
#ifndef COMPRESS
#undef WINDOWED
#define WINDOWED TRUE
#endif
#pragma code_seg(".windowInit")
INLINE void WindowInit()
{
Log("WindowInit");
#ifdef RELEASE
windowHandle = CreateWindowExA(0, (LPCSTR)0x0000C019, 0, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, windowWidth + 16, windowHeight + 39, 0, 0, 0, 0);
ShowCursor(false);
#else
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass.lpfnWndProc = (WNDPROC)DefWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = NULL;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "IntroWindowClass";
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass);
#ifndef AUTHORING
windowHandle = CreateWindowExA(0,
wndclass.lpszClassName,
windowTitle,
WS_EX_APPWINDOW,
GetSystemMetrics(SM_CXSCREEN) - windowWidth - 16,
0,
windowWidth + 16,
windowHeight + 39,
NULL,
NULL,
GetModuleHandle(NULL),
NULL
);
ShowWindow(windowHandle, SW_NORMAL);
SetWindowPos(windowHandle, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
#else
windowHandle = CreateWindowExA(0, wndclass.lpszClassName, windowTitle, 0, 0, 0, SCREENWIDTH + 16, SCREENHEIGHT + 39, 0, 0, GetModuleHandle(NULL), 0);
#endif
#endif
}

BIN
8kode/src/intro/intro.suo Normal file

Binary file not shown.

View File

@@ -0,0 +1,570 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Authoring|Win32">
<Configuration>Authoring</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ShaderDebug|Win32">
<Configuration>ShaderDebug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Compress|Win32">
<Configuration>Compress</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Video|Win32">
<Configuration>Video</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EC001821-5569-4BB5-87B3-20CB8FF9137B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConsoleApplication1</RootNamespace>
<ProjectName>intro</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Video|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)'=='Authoring|Win32'" Label="PropertySheets">
<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)'=='Compress|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</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>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>SHADERDEBUG;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>dxgi.lib;d3d11.lib;D3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>
</Message>
<Outputs>
</Outputs>
<Inputs>
</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>VIDEO;WIN32;SYNC_PLAYER;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>dxgi.lib;d3d11.lib;D3dcompiler.lib;winmm.lib;vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>
</Message>
<Outputs>
</Outputs>
<Inputs>
</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>AUTHORING;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>dxgi.lib;d3d11.lib;dxguid.lib;D3dcompiler.lib;winmm.lib;Shlwapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<Profile>true</Profile>
</Link>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>
</Message>
<Outputs>
</Outputs>
<Inputs>
</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MinSpace</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>COMPRESS;RELEASE;WIN32;NDEBUG;SYNC_PLAYER;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">None</DebugInformationFormat>
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Size</FavorSizeOrSpeed>
<OmitFramePointers Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</OmitFramePointers>
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</WholeProgramOptimization>
<ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExceptionHandling>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</BufferSecurityCheck>
<FloatingPointModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Fast</FloatingPointModel>
<DebugInformationFormat>None</DebugInformationFormat>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<AdditionalOptions>/QIfist %(AdditionalOptions)</AdditionalOptions>
<FloatingPointModel>Fast</FloatingPointModel>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>dxgi.lib;d3d11.lib;D3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/CRINKLER /TRANSFORM:CALLS /COMPMODE:FAST /HASHTRIES:10 /HASHSIZE:256 /ORDERTRIES:200 /UNSAFEIMPORT /REPORT:crinkler.html /PROGRESSGUI %(AdditionalOptions)</AdditionalOptions>
<EntryPointSymbol>main</EntryPointSymbol>
</Link>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>
</Message>
<Outputs>
</Outputs>
<Inputs>
</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>RELEASE;WIN32;SYNC_PLAYER;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerOutput>All</AssemblerOutput>
<CallingConvention>StdCall</CallingConvention>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>dxgi.lib;d3d11.lib;dxguid.lib;D3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/CRINKLER /TRANSFORM:CALLS /COMPMODE:FAST /HASHTRIES:10 /HASHSIZE:256 /ORDERTRIES:200 /UNSAFEIMPORT /REPORT:crinkler.html /PROGRESSGUI %(AdditionalOptions)</AdditionalOptions>
</Link>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>
</Message>
<Outputs>
</Outputs>
<Inputs>
</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="framework\sync\data.cpp" />
<ClCompile Include="framework\sync\device.cpp" />
<ClCompile Include="framework\sync\track.cpp" />
<ClCompile Include="framework\sync\usync.cpp" />
<ClCompile Include="main.cpp">
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">All</AssemblerOutput>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">false</ExcludedFromBuild>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework\4klang.h" />
<ClInclude Include="framework\authoring.h" />
<ClInclude Include="framework\directx.h" />
<ClInclude Include="framework\framework.h" />
<ClInclude Include="framework\intro_hlsl.h" />
<ClInclude Include="framework\log.h" />
<ClInclude Include="framework\mutexlock.h" />
<ClInclude Include="framework\shaders.h" />
<ClInclude Include="framework\shaders_shc.h" />
<ClInclude Include="framework\sync-data.h" />
<ClInclude Include="framework\sync\base.h" />
<ClInclude Include="framework\sync\data.h" />
<ClInclude Include="framework\sync\device.h" />
<ClInclude Include="framework\sync\sync.h" />
<ClInclude Include="framework\sync\track.h" />
<ClInclude Include="framework\sync\usync.h" />
<ClInclude Include="framework\video.h" />
<ClInclude Include="framework\window.h" />
<ClInclude Include="intro\data.h" />
<ClInclude Include="framework\sound.h" />
<ClInclude Include="intro\intro.h" />
<ClInclude Include="intro\update.h" />
<ClInclude Include="intro\functions.h" />
<ClInclude Include="intro\init.h" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="framework\4klang.asm">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compiling 4klang...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compiling 4klang...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling 4klang...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
<Command Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compiling 4klang...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">yasm -D AUTHORING -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compiling 4klang...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<None Include="framework\4klang.inc" />
<None Include="shaders\lib\fxaa311.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\lighting.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\material.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\ogl2dx.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\postprocessing.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\rt.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\sdf.hlsl">
<FileType>Document</FileType>
</None>
<None Include="shaders\lib\utils.hlsl">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="shaders\intro.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compiling intro.hlsl...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling intro.hlsl...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compiling intro.hlsl...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compiling intro.hlsl...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compiling intro.hlsl...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<FxCompile Include="framework\merged.hlsl">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">true</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="framework\shaders\histogramGather.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
</FxCompile>
<FxCompile Include="framework\shaders\histogramSpread.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
</FxCompile>
<FxCompile Include="framework\shaders\histogramMaximum.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
</FxCompile>
<FxCompile Include="framework\shaders\paradeVectorscopeGather.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
</FxCompile>
<FxCompile Include="framework\shaders\paradeVectorscopeMaximum.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
</FxCompile>
<FxCompile Include="framework\shaders\paradeVectorscopeSpread.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
</FxCompile>
<None Include="shaders\parts\shared.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
<FileType>Document</FileType>
</None>
<None Include="shaders\parts\part2.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
<FileType>Document</FileType>
</None>
<None Include="shaders\parts\part1.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
<FileType>Document</FileType>
</None>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,139 @@
<?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;hh;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;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="framework\sync\data.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="framework\sync\device.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="framework\sync\track.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="framework\sync\usync.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework\framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="intro\data.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="intro\init.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="intro\functions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\authoring.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="intro\update.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\directx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\4klang.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\window.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="intro\intro.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\mutexlock.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\shaders.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\intro_hlsl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\shaders_shc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync-data.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync\base.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync\data.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync\device.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync\sync.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync\track.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\sync\usync.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework\video.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="framework\4klang.inc">
<Filter>Header Files</Filter>
</None>
<None Include="shaders\lib\fxaa311.hlsl" />
<None Include="shaders\lib\lighting.hlsl" />
<None Include="shaders\lib\material.hlsl" />
<None Include="shaders\lib\ogl2dx.hlsl" />
<None Include="shaders\lib\postprocessing.hlsl" />
<None Include="shaders\lib\rt.hlsl" />
<None Include="shaders\lib\sdf.hlsl" />
<None Include="shaders\lib\utils.hlsl" />
<None Include="shaders\parts\shared.hlsl" />
<None Include="shaders\parts\part2.hlsl" />
<None Include="shaders\parts\part1.hlsl" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="framework\4klang.asm">
<Filter>Source Files</Filter>
</CustomBuild>
<CustomBuild Include="shaders\intro.hlsl" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="framework\shaders\histogramSpread.hlsl" />
<FxCompile Include="framework\shaders\paradeVectorscopeSpread.hlsl" />
<FxCompile Include="framework\shaders\histogramMaximum.hlsl" />
<FxCompile Include="framework\shaders\paradeVectorscopeMaximum.hlsl" />
<FxCompile Include="framework\shaders\paradeVectorscopeGather.hlsl" />
<FxCompile Include="framework\shaders\histogramGather.hlsl" />
<FxCompile Include="framework\merged.hlsl" />
</ItemGroup>
</Project>

View File

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

View File

@@ -0,0 +1 @@
#pragma once

View File

@@ -0,0 +1,7 @@
#pragma once
#pragma code_seg(".IntroInit")
INLINE void IntroInit()
{
Log("IntroInit");
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include "data.h"
#include "init.h"
#include "update.h"
// EOF

View File

@@ -0,0 +1,11 @@
#pragma once
#pragma code_seg(".IntroUpdate")
INLINE void IntroUpdate(float _introPosition)
{
context->CSSetShader(cs_Sample, NULL, 0);
context->CSSetUnorderedAccessViews(0, 1, &backBufferUAV, NULL);
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
swapChain->Present(0, 0);
}

17
8kode/src/intro/main.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "framework/framework.h"
#include "intro/intro.h"
int _cdecl main(int argc, char* argv[])
{
FrameworkInit();
do
{
FrameworkUpdate();
} while (FrameworkContinueExecuting());
FrameworkDispose();
ExitProcess(0);
return 0;
}

View File

@@ -0,0 +1,11 @@
RWTexture2D<float4> o2d0 : register(u0);
[numthreads(16,16,1)]
[entrypoint(cs)]
void cs_Sample(int3 id: SV_DispatchThreadID)
{
float2 s;
o2d0.GetDimensions(s.x, s.y);
float2 uv = (id.xy + 0.5) / s;
o2d0[id.xy] = float4(uv, 0.5, 1.0);
}

6
8kode/src/shc/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

593
8kode/src/shc/Program.cs Normal file
View File

@@ -0,0 +1,593 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace shc
{
class Program
{
struct EntryPoint
{
public string TypeName { get; set; }
public string Name { get; set; }
public string Prefix { get; set; }
public string[] Parameters { get; set; }
}
struct ShaderInfo
{
public ShaderInfo(string pointerType, string prefix, string createFunction)
: this()
{
PointerType = pointerType;
Prefix = prefix;
CreateFunction = createFunction;
}
public string PointerType { get; set; }
public string Prefix { get; set; }
public string CreateFunction { get; set; }
}
static int Main(string[] args)
{
Console.WriteLine("shc " + string.Join(" ", args.Select(arg => "\"" + arg + "\"")));
if (args.Length != 4)
{
Console.WriteLine("Usage: shc $(HlslInputPath) $(MinifiedHeaderPath) $(ShaderHeaderPath) $(MergedHlslOutputPath) ");
return -1;
}
var path = Path.GetFullPath(args[0]);
if (!File.Exists(args[0]))
{
Console.WriteLine("ERROR: " + args[0] + " does not exist!");
return -2;
}
var resultLines = new List<string>();
var entryPoints = new List<EntryPoint>();
string mergedPath = args[3];
try
{
var lines = GetCombinedLinesFromIncludes(path, resultLines, entryPoints);
lines.Add(string.Empty);
File.WriteAllText(mergedPath, string.Join("\n", lines));
}
catch (Exception e)
{
Console.WriteLine("ERROR: While loading " + path + ": " + e.Message);
return -3;
}
var outputPath = Path.GetFullPath(args[1]);
if (File.Exists(outputPath))
{
File.Delete(outputPath);
}
var toolsLocation = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "..\\tools");
try
{
string arguments = "--hlsl -v -o " + outputPath + " ";
if (entryPoints.Count > 0)
{
arguments += "--no-renaming-list " + string.Join(",", entryPoints.Select(kvp => kvp.Name)) + " ";
}
arguments += mergedPath;
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path.Combine(toolsLocation, "shader_minifier.exe"), arguments);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
var output = myStreamReader.ReadToEnd();
Console.WriteLine(output);
myProcess.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine("ERROR: While running shader minifier: " + e.Message);
return -4;
}
if (!File.Exists(outputPath))
{
return -5;
}
var outputLines = File.ReadAllLines(outputPath).ToArray();
for (int i = 0; i < outputLines.Length; ++i)
{
if (outputLines[i].Trim() == "char merged_hlsl[] =")
{
outputLines[i] = "char merged_hlsl[] = \"#define _ [numthreads(16,16,1)]\\n\"";
}
else if (outputLines[i].Trim() == "\"[numthreads(16,16,1)]\"")
{
outputLines[i] = " \"_ \"";
}
}
File.WriteAllLines(outputPath, outputLines);
try
{
var headerPath = Path.GetFullPath(args[2]);
using (var stream = new FileStream(headerPath, FileMode.Create, FileAccess.Write))
{
using (var writer = new StreamWriter(stream))
{
if (entryPoints.Count > 0)
{
writer.WriteLine("#pragma once");
writer.WriteLine("// WARNING: This file is autogenerated by shc. Do not edit");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\".cs_5_0\")");
writer.WriteLine("static char cs_5_0[] = \"cs_5_0\";");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\".vs_5_0\")");
writer.WriteLine("static char vs_5_0[] = \"vs_5_0\";");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\".gs_5_0\")");
writer.WriteLine("static char gs_5_0[] = \"gs_5_0\";");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\".ds_5_0\")");
writer.WriteLine("static char ds_5_0[] = \"ds_5_0\";");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\".hs_5_0\")");
writer.WriteLine("static char hs_5_0[] = \"hs_5_0\";");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\".ps_5_0\")");
writer.WriteLine("static char ps_5_0[] = \"ps_5_0\";");
writer.WriteLine();
writer.WriteLine("#pragma bss_seg(\".shaderbss\")");
foreach (var entryPoint in entryPoints)
{
if (entryPoint.TypeName == "hc")
continue;
foreach (var shaderInfo in GetShaderInfo(entryPoint.TypeName))
{
writer.WriteLine("static " + shaderInfo.PointerType + "* " + shaderInfo.Prefix + entryPoint.Name + ";");
}
}
foreach (var entryPoint in entryPoints)
{
if (entryPoint.TypeName == "hc")
continue;
if (entryPoint.TypeName == "gs_so" || entryPoint.TypeName == "vs_gs_so")
{
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\"." + entryPoint.Name + "SODeclarations\")");
writer.WriteLine("extern D3D11_SO_DECLARATION_ENTRY " + entryPoint.Name + "SODeclarations[" + entryPoint.Parameters[0] + "];");
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\"." + entryPoint.Name + "Strides\")");
writer.WriteLine("extern UINT " + entryPoint.Name + "Strides[" + entryPoint.Parameters[1] + "];");
}
if (entryPoint.TypeName == "vs_il")
{
writer.WriteLine();
writer.WriteLine("#pragma data_seg(\"." + entryPoint.Name + "InputLayoutDesc\")");
writer.WriteLine("extern D3D11_INPUT_ELEMENT_DESC " + entryPoint.Name + "InputLayoutDesc[" + entryPoint.Parameters[0] + "];");
}
}
writer.WriteLine();
writer.WriteLine("#pragma code_seg(\".FrameworkShadersCompile\")");
writer.WriteLine("INLINE void FrameworkShadersCompile()");
writer.WriteLine("{");
foreach (var entryPoint in entryPoints)
{
if (entryPoint.TypeName == "hc")
continue;
writer.WriteLine("\tCompileShader(\"" + entryPoint.Name + "\", " + entryPoint.Prefix + "_5_0);");
foreach (var shaderInfo in GetShaderInfo(entryPoint.TypeName))
{
if (shaderInfo.CreateFunction == "CreateGeometryShaderWithStreamOutput")
{
var parameters = string.Join(", ", entryPoint.Parameters);
writer.WriteLine("\tdevice->CreateGeometryShaderWithStreamOutput(shaderCode, shaderSize, " + entryPoint.Name + "SODeclarations, " + entryPoint.Parameters[0] + ", " + entryPoint.Name + "Strides, " + entryPoint.Parameters[1] + ", D3D11_SO_NO_RASTERIZED_STREAM, NULL, &" + shaderInfo.Prefix + entryPoint.Name + ");");
}
else if (shaderInfo.CreateFunction == "CreateInputLayout")
{
var parameters = string.Join(", ", entryPoint.Parameters);
writer.WriteLine("\tdevice->CreateInputLayout(" + entryPoint.Name + "InputLayoutDesc, " + entryPoint.Parameters[0] + ", shaderCode, shaderSize, &" + shaderInfo.Prefix + entryPoint.Name + ");");
}
else
{
writer.WriteLine("\tdevice->" + shaderInfo.CreateFunction + "(shaderCode, shaderSize, NULL, &" + shaderInfo.Prefix + entryPoint.Name + ");");
}
}
}
writer.WriteLine("}");
writer.WriteLine();
}
int iSize = 0;
foreach (var line in s_SyncStructLines)
{
var tokens = line.Split(' ', '\t', ';').Select(t => t.Trim()).Where(t => !string.IsNullOrEmpty(t)).ToList();
if (tokens[0] == "struct")
{
s_SyncStructName = tokens[1];
writer.WriteLine(line);
continue;
}
int typeIndex = Math.Max(Math.Max(Math.Max(tokens.IndexOf("float"), tokens.IndexOf("float2")), tokens.IndexOf("float3")), tokens.IndexOf("float4"));
if (typeIndex != -1)
{
switch (tokens[typeIndex])
{
case "float":
{
RecordSyncVariable(1, tokens[typeIndex + 1]);
iSize += 4;
break;
}
case "float2":
{
RecordSyncVariable(2, tokens[typeIndex + 1]);
iSize += 8;
break;
}
case "float3":
{
RecordSyncVariable(3, tokens[typeIndex + 1]);
iSize += 12;
break;
}
case "float4":
{
RecordSyncVariable(4, tokens[typeIndex + 1]);
iSize += 16;
break;
}
}
}
else if (line.Trim()[0] == '}')
{
if (iSize % 16 != 0)
iSize += 16 - (iSize % 16);
foreach (var syncVar in s_SyncVariables)
{
switch (syncVar.Item1)
{
case 1:
writer.WriteLine("\tfloat " + syncVar.Item2 + ";");
iSize -= 4;
break;
case 2:
writer.WriteLine("\tfloat " + syncVar.Item2 + "_x;");
writer.WriteLine("\tfloat " + syncVar.Item2 + "_y;");
iSize -= 8;
break;
case 3:
writer.WriteLine("\tfloat " + syncVar.Item2 + "_x;");
writer.WriteLine("\tfloat " + syncVar.Item2 + "_y;");
writer.WriteLine("\tfloat " + syncVar.Item2 + "_z;");
iSize -= 12;
break;
case 4:
writer.WriteLine("\tfloat " + syncVar.Item2 + "_x;");
writer.WriteLine("\tfloat " + syncVar.Item2 + "_y;");
writer.WriteLine("\tfloat " + syncVar.Item2 + "_z;");
writer.WriteLine("\tfloat " + syncVar.Item2 + "_w;");
iSize -= 16;
break;
}
}
int iDummyIndex = 1;
while (iSize > 0)
{
writer.WriteLine("\tfloat dummy_" + iDummyIndex++ + ";");
iSize -= 4;
}
writer.WriteLine(line);
}
else
{
writer.WriteLine(line);
}
}
if (s_SyncStructLines.Count > 0)
{
writer.WriteLine();
writer.WriteLine("#define SYNC_TYPE_NAME " + s_SyncStructName);
writer.WriteLine("#define SYNC_VAR_NAME s_" + s_SyncStructName);
writer.WriteLine();
writer.WriteLine("#pragma bss_seg(\".syncbss\")");
writer.WriteLine("static SYNC_TYPE_NAME SYNC_VAR_NAME;");
writer.WriteLine();
writer.WriteLine("#pragma code_seg(\".SyncInit\")");
writer.WriteLine("INLINE void SyncInit()");
writer.WriteLine("{");
writer.WriteLine("\tif (usync_init() < 0)");
writer.WriteLine("\t\treturn;");
writer.WriteLine();
writer.WriteLine("#ifndef SYNC_PLAYER");
foreach (var syncVar in s_SyncVariables)
{
if (syncVar.Item2.StartsWith("dummy"))
continue;
switch (syncVar.Item1)
{
case 1:
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + ");");
break;
case 2:
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_x);");
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_y);");
break;
case 3:
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_x);");
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_y);");
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_z);");
break;
case 4:
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_x);");
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_y);");
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_z);");
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_w);");
break;
}
}
writer.WriteLine("\tusync_update(0.0f, NULL);");
writer.WriteLine("#endif");
writer.WriteLine("}");
writer.WriteLine();
writer.WriteLine("INLINE void SyncUpdate(float t)");
writer.WriteLine("{");
writer.WriteLine("#ifndef SYNC_PLAYER");
writer.WriteLine("\tusync_update(t * SYNC_ROWS_PER_SCENE, NULL);");
foreach (var syncVar in s_SyncVariables)
{
if (syncVar.Item2.StartsWith("dummy"))
continue;
switch (syncVar.Item1)
{
case 1:
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + " = usync_get_val(" + syncVar.Item2 + ");");
break;
case 2:
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_x = usync_get_val(" + syncVar.Item2 + "_x);");
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_y = usync_get_val(" + syncVar.Item2 + "_y);");
break;
case 3:
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_x = usync_get_val(" + syncVar.Item2 + "_x);");
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_y = usync_get_val(" + syncVar.Item2 + "_y);");
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_z = usync_get_val(" + syncVar.Item2 + "_z);");
break;
case 4:
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_x = usync_get_val(" + syncVar.Item2 + "_x);");
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_y = usync_get_val(" + syncVar.Item2 + "_y);");
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_z = usync_get_val(" + syncVar.Item2 + "_z);");
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_w = usync_get_val(" + syncVar.Item2 + "_w);");
break;
}
}
writer.WriteLine("#else");
writer.WriteLine("\tusync_update(t * SYNC_ROWS_PER_SCENE, (float*)&SYNC_VAR_NAME);");
writer.WriteLine("#endif");
writer.WriteLine("}");
writer.WriteLine();
}
else
{
writer.WriteLine();
writer.WriteLine("#define SyncInit()");
writer.WriteLine("#define SyncUpdate(t)");
}
writer.Flush();
}
}
}
catch (Exception e)
{
Console.WriteLine("ERROR: While generating shc output: " + e.Message);
return -6;
}
return 0;
}
private static void RecordSyncVariable(int _iSize, string _sSyncVarName)
{
s_SyncVariables.Add(new Tuple<int, string>(_iSize, _sSyncVarName));
}
private static IEnumerable<ShaderInfo> GetShaderInfo(string p)
{
if (p == "cs")
yield return new ShaderInfo("ID3D11ComputeShader", "", "CreateComputeShader");
else if (p == "vs")
yield return new ShaderInfo("ID3D11VertexShader", "", "CreateVertexShader");
else if (p == "vs_il")
{
yield return new ShaderInfo("ID3D11VertexShader", "vs_", "CreateVertexShader");
yield return new ShaderInfo("ID3D11InputLayout", "il_", "CreateInputLayout");
}
else if (p == "ds")
yield return new ShaderInfo("ID3D11DomainShader", "", "CreateDomainShader");
else if (p == "hs")
yield return new ShaderInfo("ID3D11HullShader", "", "CreateHullShader");
else if (p == "gs")
yield return new ShaderInfo("ID3D11GeometryShader", "", "CreateGeometryShader");
else if (p == "ps")
yield return new ShaderInfo("ID3D11PixelShader", "", "CreatePixelShader");
else if (p == "gs_so")
yield return new ShaderInfo("ID3D11GeometryShader", "", "CreateGeometryShaderWithStreamOutput");
else if (p == "vs_gs_so")
{
yield return new ShaderInfo("ID3D11VertexShader", "vs_", "CreateVertexShader");
yield return new ShaderInfo("ID3D11GeometryShader", "gs_", "CreateGeometryShaderWithStreamOutput");
}
}
private static List<string> GetCombinedLinesFromIncludes(string path, List<string> resultLines, List<EntryPoint> entryPoints)
{
var loadedPaths = new List<string>();
AggregateLines(path, resultLines, entryPoints, loadedPaths);
return resultLines;
}
private static void AggregateLines(string path, List<string> resultLines, List<EntryPoint> entryPoints, List<string> loadedPaths)
{
if (loadedPaths.Contains(path))
return;
loadedPaths.Add(path);
var basePath = Path.GetDirectoryName(path);
var lines = File.ReadAllLines(path);
string sEntryPointType = null;
string[] entryPointParameters = null;
int lineNumber = 1;
var enumerator = lines.GetEnumerator();
while (enumerator.MoveNext())
{
var line = (string)enumerator.Current;
if (line.StartsWith("#include"))
{
var includeFile = line.Substring(8).Trim().Split('"')[1];
var includePath = Path.GetFullPath(Path.Combine(basePath, includeFile));
AggregateLines(includePath, resultLines, entryPoints, loadedPaths);
}
else if (line.Trim().StartsWith("[entrypoint"))
{
sEntryPointType = line.Trim().Substring(11).Trim();
if (sEntryPointType.StartsWith("("))
{
entryPointParameters = sEntryPointType.Substring(1, sEntryPointType.Length - 2).Trim().Split(',', ')').Skip(1).ToArray();
entryPointParameters = entryPointParameters.Take(entryPointParameters.Length - 1).Select(p => p.Trim()).ToArray();
sEntryPointType = sEntryPointType.Substring(1).Split(',', ')')[0];
}
else
{
sEntryPointType = "unknown";
}
if (sEntryPointType == "vs_gs_so" || sEntryPointType == "gs_so")
{
if (entryPointParameters.Length != 2)
{
throw new Exception("An entry point of type " + sEntryPointType + " needs 2 parameters: (StreamOutputDeclaration count, Stride count)");
}
}
else if (sEntryPointType == "vs_il")
{
if (entryPointParameters.Length != 1)
{
throw new Exception("An entry point of type " + sEntryPointType + " needs 1 parameter: (InputElementDesc count)");
}
}
else if (entryPointParameters != null && entryPointParameters.Length != 0)
{
throw new Exception("An entry point of type " + sEntryPointType + " needs no parameters");
}
resultLines.Add(GetComment(path, lineNumber));
}
else if (line.Trim().StartsWith("[patchconstantfunc"))
{
var sEntryPointName = line.Trim().Substring(18).Trim();
if (sEntryPointName.StartsWith("("))
{
sEntryPointName = sEntryPointName.Substring(2).Split('\"', ')')[0];
}
entryPoints.Add(new EntryPoint() { TypeName = "hc", Name = sEntryPointName });
resultLines.Add(line + GetComment(path, lineNumber));
}
else if (line.Trim() == "[syncstruct]")
{
int iBracketCount = 0;
bool bStructStarted = false;
bool bStructFound = false;
while (enumerator.MoveNext())
{
line = (string)enumerator.Current;
if (line.Contains('{'))
{
++iBracketCount;
bStructStarted = true;
}
if (line.Contains('}'))
{
--iBracketCount;
}
resultLines.Add(line + GetComment(path, lineNumber));
s_SyncStructLines.Add(line);
++lineNumber;
if (bStructStarted && iBracketCount == 0)
{
bStructFound = true;
break;
}
}
if (!bStructFound)
{
throw new Exception("[syncstruct] may only be used before a struct");
}
}
else
{
if (sEntryPointType != null)
{
var tempLine = line.Trim();
while (tempLine.StartsWith("["))
{
var idx = tempLine.IndexOf("]");
tempLine = tempLine.Substring(idx + 1).Trim();
}
var functionName = tempLine.Split(' ')[1].Split('(')[0];
entryPoints.Add(new EntryPoint() { TypeName = sEntryPointType.ToLower(), Name = functionName, Prefix = sEntryPointType.ToLower().Substring(0, 2), Parameters = entryPointParameters });
sEntryPointType = null;
}
var resultLine = line;
var commentIndex = line.IndexOf("//");
if (commentIndex != -1)
resultLine = resultLine.Substring(0, commentIndex);
if (line.StartsWith("#"))
{
resultLines.Add(resultLine);
}
else
{
resultLines.Add(resultLine + GetComment(path, lineNumber));
}
}
++lineNumber;
}
}
private static string GetComment(string path, int lineNumber)
{
return " /*(" + path + "|" + lineNumber + ")*/";
}
private static List<string> s_SyncStructLines = new List<string>();
private static List<Tuple<int, string>> s_SyncVariables = new List<Tuple<int, string>>();
private static string s_SyncStructName;
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("shc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("shc")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8e619b64-e97a-4b10-8e79-96582ebfe084")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Some files were not shown because too many files have changed in this diff Show More