Try to render a cube and add a Win32 version
This commit is contained in:
parent
3f434f8592
commit
eb59407ba2
4 changed files with 540 additions and 22 deletions
|
@ -6,6 +6,7 @@ EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
|
Debug Win32 = Debug Win32
|
||||||
Profile = Profile
|
Profile = Profile
|
||||||
Profile_FastCap = Profile_FastCap
|
Profile_FastCap = Profile_FastCap
|
||||||
Release = Release
|
Release = Release
|
||||||
|
@ -14,6 +15,8 @@ Global
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Debug.ActiveCfg = Debug|Xbox
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Debug.ActiveCfg = Debug|Xbox
|
||||||
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Debug.Build.0 = Debug|Xbox
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Debug.Build.0 = Debug|Xbox
|
||||||
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Debug Win32.ActiveCfg = Debug|Win32
|
||||||
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Debug Win32.Build.0 = Debug|Win32
|
||||||
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Profile.ActiveCfg = Profile|Xbox
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Profile.ActiveCfg = Profile|Xbox
|
||||||
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Profile.Build.0 = Profile|Xbox
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Profile.Build.0 = Profile|Xbox
|
||||||
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox
|
{65C32018-7565-47A4-BE2A-8217AC6C15CD}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox
|
||||||
|
|
|
@ -4,10 +4,13 @@
|
||||||
Version="7.10"
|
Version="7.10"
|
||||||
Name="XboxProject2"
|
Name="XboxProject2"
|
||||||
ProjectGUID="{65C32018-7565-47A4-BE2A-8217AC6C15CD}"
|
ProjectGUID="{65C32018-7565-47A4-BE2A-8217AC6C15CD}"
|
||||||
|
RootNamespace="XboxProject2"
|
||||||
Keyword="XboxProj">
|
Keyword="XboxProj">
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Xbox"/>
|
Name="Xbox"/>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
|
@ -253,6 +256,343 @@
|
||||||
Name="XboxImageTool"
|
Name="XboxImageTool"
|
||||||
StackSize="65536"/>
|
StackSize="65536"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="_DEBUG"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
EnableEnhancedInstructionSet="1"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="d3d8.lib d3dx8.lib"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
GenerateMapFile="TRUE"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Profile|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Profile_FastCap|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release_LTCG|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Profile|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Profile_FastCap|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug_Win32|Xbox"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="XboxDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="XboxImageTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug_Win32|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
|
|
212
main.cpp
212
main.cpp
|
@ -15,17 +15,82 @@ struct Vertex
|
||||||
|
|
||||||
#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
|
#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
|
||||||
|
|
||||||
|
#ifndef _XBOX
|
||||||
|
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
HWND CreateGameWindow() {
|
||||||
|
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL),
|
||||||
|
NULL, NULL, NULL, NULL, "Cube", NULL};
|
||||||
|
RegisterClassEx(&wc);
|
||||||
|
return CreateWindow("Cube", "Cube", WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
HRESULT InitVertexBuffer()
|
HRESULT InitVertexBuffer()
|
||||||
{
|
{
|
||||||
|
// Vertex g_Vertices[] =
|
||||||
|
// {
|
||||||
|
// {-1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0)},
|
||||||
|
// {0.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0)},
|
||||||
|
// {1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255)}
|
||||||
|
// };
|
||||||
|
|
||||||
Vertex g_Vertices[] =
|
Vertex g_Vertices[] =
|
||||||
{
|
{
|
||||||
{-1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0)},
|
{-1.0f,-1.0f,-1.0f},
|
||||||
{0.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0)},
|
{-1.0f,-1.0f, 1.0f},
|
||||||
{1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255)}
|
{-1.0f, 1.0f, 1.0f},
|
||||||
|
{1.0f, 1.0f,-1.0f},
|
||||||
|
{-1.0f,-1.0f,-1.0f},
|
||||||
|
{-1.0f, 1.0f,-1.0f},
|
||||||
|
{1.0f,-1.0f, 1.0f},
|
||||||
|
{-1.0f,-1.0f,-1.0f},
|
||||||
|
{1.0f,-1.0f,-1.0f},
|
||||||
|
{1.0f, 1.0f,-1.0f},
|
||||||
|
{1.0f,-1.0f,-1.0f},
|
||||||
|
{-1.0f,-1.0f,-1.0f},
|
||||||
|
{-1.0f,-1.0f,-1.0f},
|
||||||
|
{-1.0f, 1.0f, 1.0f},
|
||||||
|
{-1.0f, 1.0f,-1.0f},
|
||||||
|
{1.0f,-1.0f, 1.0f},
|
||||||
|
{-1.0f,-1.0f, 1.0f},
|
||||||
|
{-1.0f,-1.0f,-1.0f},
|
||||||
|
{-1.0f, 1.0f, 1.0f},
|
||||||
|
{-1.0f,-1.0f, 1.0f},
|
||||||
|
{1.0f,-1.0f, 1.0f},
|
||||||
|
{1.0f, 1.0f, 1.0f},
|
||||||
|
{1.0f,-1.0f,-1.0f},
|
||||||
|
{1.0f, 1.0f,-1.0f},
|
||||||
|
{1.0f,-1.0f,-1.0f},
|
||||||
|
{1.0f, 1.0f, 1.0f},
|
||||||
|
{1.0f,-1.0f, 1.0f},
|
||||||
|
{1.0f, 1.0f, 1.0f},
|
||||||
|
{1.0f, 1.0f,-1.0f},
|
||||||
|
{-1.0f, 1.0f,-1.0f},
|
||||||
|
{1.0f, 1.0f, 1.0f},
|
||||||
|
{-1.0f, 1.0f,-1.0f},
|
||||||
|
{-1.0f, 1.0f, 1.0f},
|
||||||
|
{1.0f, 1.0f, 1.0f},
|
||||||
|
{-1.0f, 1.0f, 1.0f},
|
||||||
|
{1.0f,-1.0f, 1.0f}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < (sizeof(g_Vertices) / sizeof(*g_Vertices)); i++) {
|
||||||
|
g_Vertices[i].color = D3DCOLOR_XRGB(255,255,0);
|
||||||
|
}
|
||||||
|
|
||||||
// Create a Vertex Buffer
|
// Create a Vertex Buffer
|
||||||
HRESULT vertexBufferCreation = g_pd3dDevice->CreateVertexBuffer(3 * sizeof(Vertex),
|
HRESULT vertexBufferCreation = g_pd3dDevice->CreateVertexBuffer(36 * sizeof(Vertex),
|
||||||
D3DUSAGE_WRITEONLY, D3DFVF_VERTEX, D3DPOOL_MANAGED, &g_pVB);
|
D3DUSAGE_WRITEONLY, D3DFVF_VERTEX, D3DPOOL_MANAGED, &g_pVB);
|
||||||
if (FAILED(vertexBufferCreation))
|
if (FAILED(vertexBufferCreation))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
@ -36,14 +101,35 @@ HRESULT InitVertexBuffer()
|
||||||
if (FAILED(g_pVB->Lock(0, 0, (BYTE**)&pVertices, 0)))
|
if (FAILED(g_pVB->Lock(0, 0, (BYTE**)&pVertices, 0)))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
// Copy vertices to the GPU
|
// Copy vertices to the GPU
|
||||||
memcpy(pVertices, g_Vertices, 3 * sizeof(Vertex));
|
memcpy(pVertices, g_Vertices, 36 * sizeof(Vertex));
|
||||||
// Unlock the Vertex Buffer
|
// Unlock the Vertex Buffer
|
||||||
g_pVB->Unlock();
|
g_pVB->Unlock();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT InitD3D8()
|
void SetupMatrices()
|
||||||
|
{
|
||||||
|
D3DXMATRIX matWorld;
|
||||||
|
D3DXMatrixTranslation(&matWorld, 0.0f, 0.0f, 10.0f);
|
||||||
|
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
|
||||||
|
|
||||||
|
// Set the projection matrix
|
||||||
|
D3DXMATRIX matProj;
|
||||||
|
D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f);
|
||||||
|
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);
|
||||||
|
|
||||||
|
// Set the view matrix
|
||||||
|
D3DXVECTOR3 vEyePt = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
|
||||||
|
D3DXVECTOR3 vLookatPt = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||||
|
D3DXVECTOR3 vUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
|
||||||
|
D3DXMATRIX matView;
|
||||||
|
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUp);
|
||||||
|
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _XBOX
|
||||||
|
HRESULT InitD3D8(void* hWnd)
|
||||||
{
|
{
|
||||||
// Create D3D8 object
|
// Create D3D8 object
|
||||||
g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
|
g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
|
||||||
|
@ -64,26 +150,56 @@ HRESULT InitD3D8()
|
||||||
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE_OR_IMMEDIATE;
|
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE_OR_IMMEDIATE;
|
||||||
|
|
||||||
// Create the D3D8 device with the device settings (present parameters).
|
// Create the D3D8 device with the device settings (present parameters).
|
||||||
HRESULT deviceCreation = g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
|
HRESULT deviceCreation;
|
||||||
|
deviceCreation = g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
|
||||||
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
|
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
|
||||||
if (FAILED(deviceCreation))
|
if (FAILED(deviceCreation))
|
||||||
|
{
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the projection matrix
|
SetupMatrices();
|
||||||
D3DXMATRIX matProj;
|
|
||||||
D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 4.0f/3.0f, 1.0f, 200.0f);
|
|
||||||
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);
|
|
||||||
|
|
||||||
// Set the view matrix
|
|
||||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3(0.0f, 0.0f, -7.0f);
|
|
||||||
D3DXVECTOR3 vLookatPt = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
|
||||||
D3DXVECTOR3 vUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
|
|
||||||
D3DXMATRIX matView;
|
|
||||||
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUp);
|
|
||||||
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
HRESULT InitD3D8(HWND hWnd)
|
||||||
|
{
|
||||||
|
// Create D3D8 object
|
||||||
|
g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
|
||||||
|
if (g_pD3D == (NULL))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
D3DDISPLAYMODE d3ddm;
|
||||||
|
if (FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Error getting adapter display mode", "", 0);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create D3D device settings
|
||||||
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
|
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
||||||
|
d3dpp.Windowed = TRUE;
|
||||||
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
||||||
|
|
||||||
|
// Create the D3D8 device with the device settings (present parameters).
|
||||||
|
HRESULT deviceCreation;
|
||||||
|
deviceCreation = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hWnd,
|
||||||
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
|
||||||
|
|
||||||
|
if (FAILED(deviceCreation))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Error creating device", "", 0);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupMatrices();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VOID Render()
|
VOID Render()
|
||||||
{
|
{
|
||||||
|
@ -96,15 +212,17 @@ VOID Render()
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||||
g_pd3dDevice->SetStreamSource(0, g_pVB, sizeof(Vertex));
|
g_pd3dDevice->SetStreamSource(0, g_pVB, sizeof(Vertex));
|
||||||
g_pd3dDevice->SetVertexShader(D3DFVF_VERTEX);
|
g_pd3dDevice->SetVertexShader(D3DFVF_VERTEX);
|
||||||
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
|
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 12);
|
||||||
|
|
||||||
g_pd3dDevice->EndScene();
|
g_pd3dDevice->EndScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cdecl main()
|
|
||||||
|
#ifdef _XBOX
|
||||||
|
void XboxMain()
|
||||||
{
|
{
|
||||||
// Initialize Direct3D 8.1
|
// Initialize Direct3D 8.1
|
||||||
if (FAILED(InitD3D8()))
|
if (FAILED(InitD3D8(NULL)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Initialize the Vertex Buffer
|
// Initialize the Vertex Buffer
|
||||||
|
@ -117,4 +235,54 @@ void __cdecl main()
|
||||||
|
|
||||||
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void WindowsMain()
|
||||||
|
{
|
||||||
|
HWND window = CreateGameWindow();
|
||||||
|
|
||||||
|
// Initialize Direct3D 8.1
|
||||||
|
if (FAILED(InitD3D8(window)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Initialize the Vertex Buffer
|
||||||
|
InitVertexBuffer();
|
||||||
|
|
||||||
|
ShowWindow(window, SW_SHOWDEFAULT);
|
||||||
|
UpdateWindow(window);
|
||||||
|
|
||||||
|
MSG msg;
|
||||||
|
ZeroMemory(&msg, sizeof(msg));
|
||||||
|
while (msg.message != WM_QUIT)
|
||||||
|
{
|
||||||
|
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Render the current scene
|
||||||
|
Render();
|
||||||
|
|
||||||
|
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _XBOX
|
||||||
|
void __cdecl main()
|
||||||
|
#else
|
||||||
|
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef _XBOX
|
||||||
|
XboxMain();
|
||||||
|
#else
|
||||||
|
WindowsMain();
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
7
stdafx.h
7
stdafx.h
|
@ -1,4 +1,11 @@
|
||||||
#ifndef STDAFX_H
|
#ifndef STDAFX_H
|
||||||
#define STDAFX_H
|
#define STDAFX_H
|
||||||
|
#ifdef _XBOX
|
||||||
#include <xtl.h>
|
#include <xtl.h>
|
||||||
|
#else
|
||||||
|
#include <windows.h>
|
||||||
|
#include <d3d8.h>
|
||||||
|
#include <d3dx8.h>
|
||||||
|
#include <d3d8types.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue