Initial commit: ROW Client source code

Game client codebase including:
- CharacterActionControl: Character and creature management
- GlobalScript: Network, items, skills, quests, utilities
- RYLClient: Main client application with GUI and event handlers
- Engine: 3D rendering engine (RYLGL)
- MemoryManager: Custom memory allocation
- Library: Third-party dependencies (DirectX, boost, etc.)
- Tools: Development utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 16:24:34 +09:00
commit e067522598
5135 changed files with 1745744 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,161 @@
# Microsoft Developer Studio Project File - Name="MFCPixelShader" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=MFCPixelShader - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "mfcpixelshader.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "mfcpixelshader.mak" CFG="MFCPixelShader - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "MFCPixelShader - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "MFCPixelShader - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "MFCPixelShader - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /YX"stdafx.h" /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 d3dx8.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "MFCPixelShader - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /YX"stdafx.h" /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 d3dx8dt.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "MFCPixelShader - Win32 Release"
# Name "MFCPixelShader - Win32 Debug"
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\pixelshader.rc
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# End Group
# Begin Group "Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\common\src\d3dapp.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\d3dapp.h
# End Source File
# Begin Source File
SOURCE=..\..\common\src\d3dfile.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\d3dfile.h
# End Source File
# Begin Source File
SOURCE=..\..\common\src\d3dfont.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\d3dfont.h
# End Source File
# Begin Source File
SOURCE=..\..\common\src\d3dutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\d3dutil.h
# End Source File
# Begin Source File
SOURCE=..\..\common\src\dxutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dxutil.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\PixelShader.cpp
# End Source File
# Begin Source File
SOURCE=.\pixelshader.h
# End Source File
# Begin Source File
SOURCE=.\stdafx.cpp
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "MFCPixelShader"=.\mfcpixelshader.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,260 @@
# Microsoft Developer Studio Generated NMAKE File, Based on mfcpixelshader.dsp
!IF "$(CFG)" == ""
CFG=MFCPixelShader - Win32 Debug
!MESSAGE No configuration specified. Defaulting to MFCPixelShader - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "MFCPixelShader - Win32 Release" && "$(CFG)" != "MFCPixelShader - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "mfcpixelshader.mak" CFG="MFCPixelShader - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "MFCPixelShader - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "MFCPixelShader - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "MFCPixelShader - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\mfcpixelshader.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\PixelShader.obj"
-@erase "$(INTDIR)\pixelshader.res"
-@erase "$(INTDIR)\stdafx.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\mfcpixelshader.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /Fp"$(INTDIR)\mfcpixelshader.pch" /YX"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\pixelshader.res" /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\mfcpixelshader.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=d3dx8.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\mfcpixelshader.pdb" /machine:I386 /out:"$(OUTDIR)\mfcpixelshader.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\PixelShader.obj" \
"$(INTDIR)\stdafx.obj" \
"$(INTDIR)\pixelshader.res"
"$(OUTDIR)\mfcpixelshader.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "MFCPixelShader - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\mfcpixelshader.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\PixelShader.obj"
-@erase "$(INTDIR)\pixelshader.res"
-@erase "$(INTDIR)\stdafx.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\mfcpixelshader.exe"
-@erase "$(OUTDIR)\mfcpixelshader.ilk"
-@erase "$(OUTDIR)\mfcpixelshader.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /Fp"$(INTDIR)\mfcpixelshader.pch" /YX"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\pixelshader.res" /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\mfcpixelshader.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=d3dx8dt.lib d3dxof.lib d3d8.lib winmm.lib dxguid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\mfcpixelshader.pdb" /debug /machine:I386 /out:"$(OUTDIR)\mfcpixelshader.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\PixelShader.obj" \
"$(INTDIR)\stdafx.obj" \
"$(INTDIR)\pixelshader.res"
"$(OUTDIR)\mfcpixelshader.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("mfcpixelshader.dep")
!INCLUDE "mfcpixelshader.dep"
!ELSE
!MESSAGE Warning: cannot find "mfcpixelshader.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "MFCPixelShader - Win32 Release" || "$(CFG)" == "MFCPixelShader - Win32 Debug"
SOURCE=.\pixelshader.rc
"$(INTDIR)\pixelshader.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\d3dapp.cpp
"$(INTDIR)\d3dapp.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\common\src\d3dfile.cpp
"$(INTDIR)\d3dfile.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\common\src\d3dfont.cpp
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\common\src\d3dutil.cpp
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dxutil.cpp
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.\PixelShader.cpp
"$(INTDIR)\PixelShader.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\stdafx.cpp
"$(INTDIR)\stdafx.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

View File

@@ -0,0 +1,806 @@
//-----------------------------------------------------------------------------
// File: PixelShader.cpp
//
// Desc: Example code showing how to use pixel shaders in D3D
//
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include "stdafx.h"
#include <tchar.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <D3DX8.h>
#include "resource.h"
#include "D3DApp.h"
#include "D3DUtil.h"
#include "DXUtil.h"
#include "PixelShader.h"
//-----------------------------------------------------------------------------
// Global data and objects
//-----------------------------------------------------------------------------
CApp g_App;
CAppForm* g_AppFormView = NULL;
TCHAR* g_strAppTitle = _T("MFCPixelShader");
//-----------------------------------------------------------------------------
// The MFC macros are all listed here
//-----------------------------------------------------------------------------
IMPLEMENT_DYNCREATE( CAppDoc, CDocument )
IMPLEMENT_DYNCREATE( CAppFrameWnd, CFrameWnd )
IMPLEMENT_DYNCREATE( CAppForm, CFormView )
BEGIN_MESSAGE_MAP( CApp, CWinApp )
//{{AFX_MSG_MAP(CD3DApp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP( CAppForm, CFormView )
//{{AFX_MSG_MAP(CAppForm)
ON_WM_HSCROLL()
ON_COMMAND( IDC_VIEWFULLSCREEN, OnToggleFullScreen )
ON_COMMAND( IDM_CHANGEDEVICE, OnChangeDevice )
ON_BN_CLICKED( IDC_OPEN, OnOpenPixelShaderFile )
ON_BN_CLICKED( IDC_PRESET_0, OnPresets )
ON_BN_CLICKED( IDC_PRESET_1, OnPresets )
ON_BN_CLICKED( IDC_PRESET_2, OnPresets )
ON_BN_CLICKED( IDC_PRESET_3, OnPresets )
ON_BN_CLICKED( IDC_PRESET_4, OnPresets )
ON_BN_CLICKED( IDC_PRESET_5, OnPresets )
ON_EN_CHANGE( IDC_INSTRUCTIONS, OnChangeInstructions )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CAppDoc, CDocument)
//{{AFX_MSG_MAP(CAppDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CAppFrameWnd, CFrameWnd)
//{{AFX_MSG_MAP(CAppFrameWnd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//-----------------------------------------------------------------------------
// Function prototypes and global (or static) variables
//-----------------------------------------------------------------------------
struct CUSTOMVERTEX
{
FLOAT x, y, z;
DWORD color1, color2;
FLOAT tu1, tv1;
FLOAT tu2, tv2;
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|D3DFVF_TEX2)
static CUSTOMVERTEX g_Vertices[]=
{
// Color 0 (diffuse) is a color gradient
// Color 1 (specular) is a greyscale ramp
// x y z diffuse specular u1 v1 u2 v2
{ -1.0f, -1.0f, 0.0f, 0xff00ffff, 0xffffffff, 1.0f, 1.0f, 1.0f, 1.0f },
{ +1.0f, -1.0f, 0.0f, 0xffffff00, 0xffffffff, 0.0f, 1.0f, 0.0f, 1.0f },
{ +1.0f, +1.0f, 0.0f, 0xffff0000, 0xff000000, 0.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, +1.0f, 0.0f, 0xff0000ff, 0xff000000, 1.0f, 0.0f, 1.0f, 0.0f },
};
inline DWORD FtoDW( FLOAT f ) { return *((DWORD*)&f); }
//-----------------------------------------------------------------------------
// Name: AdjustWindowForChange()
// Desc: Adjusts the window properties for windowed or fullscreen mode
//-----------------------------------------------------------------------------
HRESULT CAppForm::AdjustWindowForChange()
{
if( m_bWindowed )
{
::ShowWindow( m_hwndRenderFullScreen, SW_HIDE );
CD3DApplication::m_hWnd = m_hwndRenderWindow;
}
else
{
if( ::IsIconic( m_hwndRenderFullScreen ) )
::ShowWindow( m_hwndRenderFullScreen, SW_RESTORE );
::ShowWindow( m_hwndRenderFullScreen, SW_SHOW );
CD3DApplication::m_hWnd = m_hwndRenderFullScreen;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FullScreenWndProc()
// Desc: The WndProc funtion used when the app is in fullscreen mode. This is
// needed simply to trap the ESC key.
//-----------------------------------------------------------------------------
LRESULT CALLBACK FullScreenWndProc( HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam )
{
if( msg == WM_CLOSE )
{
// User wants to exit, so go back to windowed mode and exit for real
g_AppFormView->OnToggleFullScreen();
g_App.GetMainWnd()->PostMessage( WM_CLOSE, 0, 0 );
}
if( msg == WM_SETCURSOR )
{
SetCursor( NULL );
}
if( msg == WM_KEYUP && wParam == VK_ESCAPE )
{
// User wants to leave fullscreen mode
g_AppFormView->OnToggleFullScreen();
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//-----------------------------------------------------------------------------
// Name: CheckForLostFullscreen()
// Desc: If fullscreen and device was lost (probably due to alt-tab),
// automatically switch to windowed mode
//-----------------------------------------------------------------------------
HRESULT CAppForm::CheckForLostFullscreen()
{
HRESULT hr;
if( m_bWindowed )
return S_OK;
if( FAILED( hr = m_pd3dDevice->TestCooperativeLevel() ) )
ForceWindowed();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: PreCreateWindow()
// Desc: Change the window style (so it cannot maximize or be sized) before
// the main frame window is created.
//-----------------------------------------------------------------------------
BOOL CAppFrameWnd::PreCreateWindow( CREATESTRUCT& cs )
{
cs.style = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX;
return CFrameWnd::PreCreateWindow( cs );
}
//-----------------------------------------------------------------------------
// Name: InitInstance()
// Desc: This is the main entry point for the application. The MFC window stuff
// is initialized here. See also the main initialization routine for the
// CAppForm class, which is called indirectly from here.
//-----------------------------------------------------------------------------
BOOL CApp::InitInstance()
{
// Asscociate the MFC app with the frame window and doc/view classes
AddDocTemplate( new CSingleDocTemplate( IDR_MAINFRAME,
RUNTIME_CLASS(CAppDoc),
RUNTIME_CLASS(CAppFrameWnd),
RUNTIME_CLASS(CAppForm) ) );
// Dispatch commands specified on the command line (req'd by MFC). This
// also initializes the the CAppDoc, CAppFrameWnd, and CAppForm classes.
CCommandLineInfo cmdInfo;
ParseCommandLine( cmdInfo );
if( !ProcessShellCommand( cmdInfo ) )
return FALSE;
if( !g_AppFormView->IsReady() )
return FALSE;
g_AppFormView->GetParentFrame()->RecalcLayout();
g_AppFormView->ResizeParentToFit( FALSE );
m_pMainWnd->SetWindowText( g_strAppTitle );
m_pMainWnd->UpdateWindow();
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: OnIdle()
// Desc: Uses idle time to render the 3D scene.
//-----------------------------------------------------------------------------
BOOL CApp::OnIdle( LONG )
{
// Do not render if the app is minimized
if( m_pMainWnd->IsIconic() )
return FALSE;
// Update and render a frame
if( g_AppFormView->IsReady() )
{
g_AppFormView->CheckForLostFullscreen();
g_AppFormView->RenderScene();
}
// Keep requesting more idle time
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: CAppForm()
// Desc: Constructor for the dialog resource form
//-----------------------------------------------------------------------------
CAppForm::CAppForm()
:CFormView( IDD_FORMVIEW )
{
g_AppFormView = this;
m_pTexture0 = NULL;
m_pTexture1 = NULL;
m_pQuadVB = NULL;
m_hPixelShader = NULL;
m_pD3DXBufShader = NULL;
}
//-----------------------------------------------------------------------------
// Name: ~CAppForm()
// Desc: Destructor for the dialog resource form. Shuts down the app
//-----------------------------------------------------------------------------
CAppForm::~CAppForm()
{
Cleanup3DEnvironment();
}
//-----------------------------------------------------------------------------
// Name: OnInitialUpdate()
// Desc: When the AppForm object is created, this function is called to
// initialize it. Here we getting access ptrs to some of the controls,
// and setting the initial state of some of them as well.
//-----------------------------------------------------------------------------
VOID CAppForm::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// Save static reference to the render window
m_hwndRenderWindow = GetDlgItem(IDC_RENDERVIEW)->GetSafeHwnd();
// Register a class for a fullscreen window
WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW, FullScreenWndProc, 0, 0, NULL,
NULL, NULL, (HBRUSH)GetStockObject(WHITE_BRUSH), NULL,
_T("Fullscreen Window") };
RegisterClass( &wndClass );
// We create the fullscreen window (not visible) at startup, so it can
// be the focus window. The focus window can only be set at CreateDevice
// time, not in a Reset, so ToggleFullscreen wouldn't work unless we have
// already set up the fullscreen focus window.
m_hwndRenderFullScreen = CreateWindow( _T("Fullscreen Window"), NULL,
WS_POPUP, CW_USEDEFAULT,
CW_USEDEFAULT, 100, 100,
GetTopLevelParent()->GetSafeHwnd(), 0L, NULL, 0L );
// Note that for the MFC samples, the device window and focus window
// are not the same.
CD3DApplication::m_hWnd = m_hwndRenderWindow;
CD3DApplication::m_hWndFocus = m_hwndRenderFullScreen;
CD3DApplication::Create( AfxGetInstanceHandle() );
// Set up the form's UI
((CButton*)GetDlgItem(IDC_PRESET_0))->SetCheck(TRUE);
OnPresets();
}
//-----------------------------------------------------------------------------
// Name: SetPixelShader()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CAppForm::SetPixelShader( TCHAR* strOpcodes )
{
HRESULT hr;
LPD3DXBUFFER pBuffer = NULL;
SAFE_RELEASE( m_pD3DXBufShader );
// Build a DWORD array of opcodes from the text string
hr = D3DXAssembleShader( strOpcodes, lstrlen(strOpcodes), 0, NULL,
&m_pD3DXBufShader, &pBuffer );
if( FAILED(hr) )
{
if( pBuffer != NULL)
{
TCHAR* pstr;
TCHAR strOut[4096];
TCHAR* pstrOut;
// Need to replace \n with \r\n so edit box shows newlines properly
pstr = (TCHAR*)pBuffer->GetBufferPointer();
strOut[0] = _T('\0');
pstrOut = strOut;
for( int i = 0; i < 4096; i++ )
{
if( *pstr == _T('\n') )
*pstrOut++ = _T('\r');
*pstrOut = *pstr;
if( *pstr == _T('\0') )
break;
if( i == 4095 )
*pstrOut = _T('\0');
pstrOut++;
pstr++;
}
// remove any blank lines at the end
while( strOut[lstrlen(strOut) - 1] == _T('\n') ||
strOut[lstrlen(strOut) - 1] == _T('\r') )
{
strOut[lstrlen(strOut) - 1] = _T('\0');
}
SetDlgItemText( IDC_COMPRESULT, strOut );
SAFE_RELEASE( pBuffer );
}
return hr;
}
else
{
SAFE_RELEASE( pBuffer );
// Delete old pixel shader
if( m_hPixelShader )
m_pd3dDevice->DeletePixelShader( m_hPixelShader );
m_hPixelShader = NULL;
// Create new pixel shader
hr = m_pd3dDevice->CreatePixelShader( (DWORD*)m_pD3DXBufShader->GetBufferPointer(),
&m_hPixelShader );
if( FAILED(hr) )
{
((CStatic*)GetDlgItem(IDC_COMPRESULT))->SetWindowText( _T("Failure (D3D)"));
return hr;
}
else
{
((CStatic*)GetDlgItem(IDC_COMPRESULT))->SetWindowText( _T("Success"));
}
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
// permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CAppForm::OneTimeSceneInit()
{
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FrameMove()
// Desc: Called once per frame, the call is the entry point for animating
// the scene.
//-----------------------------------------------------------------------------
HRESULT CAppForm::FrameMove()
{
// Move the camera along an ellipse
D3DXVECTOR3 from( 3*sinf(m_fTime/3), 3*cosf(m_fTime/3), 5.0f );
D3DXVECTOR3 at( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 up( 0.0f, 1.0f, 0.0f );
D3DXMATRIX matWorld;
D3DXMatrixIdentity( &matWorld );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView, &from, &at, &up );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 0.5f, 1000.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Called once per frame, the call is the entry point for 3d
// rendering. This function sets up render states, clears the
// viewport, and renders the scene.
//-----------------------------------------------------------------------------
HRESULT CAppForm::Render()
{
// Clear the viewport
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0L );
// Begin the scene
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
{
// Set device state
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
m_pd3dDevice->SetRenderState( D3DRS_CLIPPING, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
// Set the textures
m_pd3dDevice->SetTexture( 0, m_pTexture0 );
m_pd3dDevice->SetTexture( 1, m_pTexture1 );
// Set the pixel shader constants
FLOAT fPixelShaderConstants[8][4] =
{ // Red Green Blue Alpha
{ 1.0f, 0.0f, 0.0f, 1.0f, }, // red
{ 0.0f, 1.0f, 0.0f, 1.0f, }, // green
{ 0.0f, 0.0f, 1.0f, 1.0f, }, // blue
{ 1.0f, 1.0f, 0.0f, 1.0f, }, // yellow
{ 0.0f, 1.0f, 1.0f, 1.0f, }, // cyan
{ 1.0f, 0.0f, 1.0f, 1.0f, }, // purple
{ 1.0f, 1.0f, 1.0f, 1.0f, }, // white
{ 0.0f, 0.0f, 0.0f, 1.0f, }, // black
};
m_pd3dDevice->SetPixelShaderConstant( 0, (VOID*)fPixelShaderConstants, 8 );
// Render the quad with the pixel shader
m_pd3dDevice->SetStreamSource( 0, m_pQuadVB, sizeof(CUSTOMVERTEX) );
m_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
m_pd3dDevice->SetPixelShader( m_hPixelShader );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0, 2 );
// End the scene.
m_pd3dDevice->EndScene();
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CAppForm::InitDeviceObjects()
{
HRESULT hr;
// Create some textures
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("DX5_Logo.bmp"),
&m_pTexture0, D3DFMT_R5G6B5 ) ) )
{
return E_FAIL;
}
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Tree01S.tga"),
&m_pTexture1, D3DFMT_R5G6B5 ) ) )
{
return E_FAIL;
}
// Create quad VB
hr = m_pd3dDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED, &m_pQuadVB );
if( FAILED(hr) )
return hr;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CAppForm::RestoreDeviceObjects()
{
HRESULT hr;
// Fill the quad VB
CUSTOMVERTEX* pVertices = NULL;
hr = m_pQuadVB->Lock( 0, 4*sizeof(CUSTOMVERTEX), (BYTE**)&pVertices, 0 );
if( FAILED(hr) )
return hr;
for( DWORD i=0; i<4; i++ )
pVertices[i] = g_Vertices[i];
m_pQuadVB->Unlock();
// Delete old pixel shader (redundant if InvalidateDeviceObjects is called first)
if( m_hPixelShader )
m_pd3dDevice->DeletePixelShader( m_hPixelShader );
m_hPixelShader = NULL;
// Create new pixel shader
if( m_pD3DXBufShader )
hr = m_pd3dDevice->CreatePixelShader(
(DWORD*)m_pD3DXBufShader->GetBufferPointer(),
&m_hPixelShader );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc: Called when the device-dependent objects are about to be lost.
//-----------------------------------------------------------------------------
HRESULT CAppForm::InvalidateDeviceObjects()
{
if( m_hPixelShader )
m_pd3dDevice->DeletePixelShader( m_hPixelShader );
m_hPixelShader = NULL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Called when the app is exiting, or the device is being changed,
// this function deletes any device dependent objects.
//-----------------------------------------------------------------------------
HRESULT CAppForm::DeleteDeviceObjects()
{
SAFE_RELEASE( m_pTexture0 );
SAFE_RELEASE( m_pTexture1 );
SAFE_RELEASE( m_pQuadVB );
SAFE_RELEASE( m_pD3DXBufShader );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FinalCleanup()
// Desc: Called before the app exits, this function gives the app the chance
// to cleanup after itself.
//-----------------------------------------------------------------------------
HRESULT CAppForm::FinalCleanup()
{
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ConfirmDevice()
// Desc: Called during device intialization, this code checks the device
// for some minimum set of capabilities
//-----------------------------------------------------------------------------
HRESULT CAppForm::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior, D3DFORMAT Format )
{
if( D3DSHADER_VERSION_MAJOR( pCaps->PixelShaderVersion ) < 1 )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// The remaining code handles the UI for the MFC-based app.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Name: OnChangeDevice()
// Desc: Use hit the "Change Device.." button. Display the dialog for the user
// to select a new device/mode, and call Change3DEnvironment to
// use the new device/mode.
//-----------------------------------------------------------------------------
VOID CAppForm::OnChangeDevice()
{
UserSelectNewDevice();
GeneratePixelShaderOpcodes();
}
//-----------------------------------------------------------------------------
// Name: OnToggleFullScreen()
// Desc: Called when user toggles the fullscreen mode
//-----------------------------------------------------------------------------
void CAppForm::OnToggleFullScreen()
{
ToggleFullscreen();
GeneratePixelShaderOpcodes();
}
//-----------------------------------------------------------------------------
// Name: OnHScroll()
// Desc: Called when the user moves any scroll bar. Check which scrollbar was
// moved, and extract the appropiate value to a global variable.
//-----------------------------------------------------------------------------
void CAppForm::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}
//-----------------------------------------------------------------------------
// Name: UpdateUIForDeviceCapabilites()
// Desc: Whenever we get a new device, call this function to enable/disable the
// appropiate UI controls to match the device's capabilities.
//-----------------------------------------------------------------------------
VOID CAppForm::UpdateUIForDeviceCapabilites()
{
// Check the capabilities of the device
// Update the UI checkbox states
}
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
void CAppForm::OnPresets()
{
DWORD dwPreset = 0L;
dwPreset = ((CButton*)GetDlgItem(IDC_PRESET_0))->GetCheck() ? 0 : dwPreset;
dwPreset = ((CButton*)GetDlgItem(IDC_PRESET_1))->GetCheck() ? 1 : dwPreset;
dwPreset = ((CButton*)GetDlgItem(IDC_PRESET_2))->GetCheck() ? 2 : dwPreset;
dwPreset = ((CButton*)GetDlgItem(IDC_PRESET_3))->GetCheck() ? 3 : dwPreset;
dwPreset = ((CButton*)GetDlgItem(IDC_PRESET_4))->GetCheck() ? 4 : dwPreset;
dwPreset = ((CButton*)GetDlgItem(IDC_PRESET_5))->GetCheck() ? 5 : dwPreset;
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_INSTRUCTIONS);
pEdit->SetWindowText( g_strPixelShaderPresets[dwPreset] );
// Generate the opcodes and pass them to the app
if( m_pd3dDevice != NULL )
GeneratePixelShaderOpcodes();
}
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
void CAppForm::GeneratePixelShaderOpcodes()
{
TCHAR strOpcodes[2048] = _T("");
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_INSTRUCTIONS);
pEdit->GetWindowText(strOpcodes, 2048);
SetPixelShader( strOpcodes );
}
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
void CAppForm::OnOpenPixelShaderFile()
{
((CButton*)GetDlgItem(IDC_PRESET_0))->SetCheck( FALSE );
((CButton*)GetDlgItem(IDC_PRESET_1))->SetCheck( FALSE );
((CButton*)GetDlgItem(IDC_PRESET_2))->SetCheck( FALSE );
((CButton*)GetDlgItem(IDC_PRESET_3))->SetCheck( FALSE );
((CButton*)GetDlgItem(IDC_PRESET_4))->SetCheck( FALSE );
((CButton*)GetDlgItem(IDC_PRESET_5))->SetCheck( FALSE );
static TCHAR g_strFileName[MAX_PATH] = _T("");
static TCHAR g_strInitialDir[MAX_PATH] = _T("");
TCHAR strFileName[MAX_PATH] = _T("");
TCHAR strBuffer[81];
// Display the OpenFileName dialog. Then, try to load the specified file
OPENFILENAME ofn = { sizeof(OPENFILENAME), NULL, NULL,
_T("Pixel Shader Text Files (.txt)\0*.txt\0\0"),
NULL, 0, 1, strFileName, MAX_PATH, g_strFileName, MAX_PATH,
g_strInitialDir, _T("Open Pixel Shader File"),
OFN_FILEMUSTEXIST, 0, 1, NULL, 0, NULL, NULL };
if( FALSE == GetOpenFileName( &ofn ) )
return;
FILE* file = fopen( strFileName, _T("r") );
if( file == NULL )
return;
// Fill the list box with the preset's pixel shader instructions
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_INSTRUCTIONS);
pEdit->SetSel(0, -1);
while( fgets( strBuffer, 80, file ) )
{
// Remove trailing newline char
if( strBuffer[max(1,strlen(strBuffer))-1] == '\n' )
strBuffer[max(1,strlen(strBuffer))-1] = '\0';
pEdit->ReplaceSel(strBuffer);
pEdit->ReplaceSel("\r\n");
}
fclose(file);
// Generater the opcodes and pass them to the app
GeneratePixelShaderOpcodes();
}
void CAppForm::OnChangeInstructions()
{
GeneratePixelShaderOpcodes();
}

View File

@@ -0,0 +1,311 @@
//-----------------------------------------------------------------------------
// File: D3DApp.h
//
// Desc: Header file for a D3DIM app that uses MFC
//
//
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef D3D_MFC_APP_H
#define D3D_MFC_APP_H
#if _MSC_VER >= 1000
#pragma once
#endif
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file
#endif
//-----------------------------------------------------------------------------
// Name: class CAppDoc
// Desc: Overridden CDocument class needed for the CFormView
//-----------------------------------------------------------------------------
class CAppDoc : public CDocument
{
protected:
DECLARE_DYNCREATE(CAppDoc)
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAppDoc)
public:
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CAppDoc)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//-----------------------------------------------------------------------------
// Name: class CAppFrameWnd
// Desc: CFrameWnd-based class needed to override the CFormView's window style
//-----------------------------------------------------------------------------
class CAppFrameWnd : public CFrameWnd
{
protected:
DECLARE_DYNCREATE(CAppFrameWnd)
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAppFrameWnd)
public:
virtual BOOL PreCreateWindow( CREATESTRUCT& cs );
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG(CAppFrameWnd)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//-----------------------------------------------------------------------------
// Name: class CApp
// Desc: Main MFCapplication class derived from CWinApp.
//-----------------------------------------------------------------------------
class CApp : public CWinApp
{
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CApp)
public:
virtual BOOL InitInstance();
virtual BOOL OnIdle( LONG );
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CApp)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//-----------------------------------------------------------------------------
// Name: class CAppForm
// Desc: CFormView-based class which allows the UI to be created with a form
// (dialog) resource. This class manages all the controls on the form.
//-----------------------------------------------------------------------------
class CAppForm : public CFormView, public CD3DApplication
{
HWND m_hwndRenderWindow;
HWND m_hwndRenderFullScreen;
LPDIRECT3DTEXTURE8 m_pTexture0;
LPDIRECT3DTEXTURE8 m_pTexture1;
LPDIRECT3DVERTEXBUFFER8 m_pQuadVB;
DWORD m_hPixelShader;
LPD3DXBUFFER m_pD3DXBufShader;
VOID UpdateUIForInstruction( INT iInstruction );
VOID UpdateUIForDeviceCapabilites();
VOID DisablePixelShaderEditingControls();
VOID GeneratePixelShaderOpcodes();
HRESULT SetPixelShader( TCHAR* strOpcodes );
HRESULT ConfirmDevice( D3DCAPS8*,DWORD,D3DFORMAT );
HRESULT OneTimeSceneInit();
HRESULT InitDeviceObjects();
HRESULT RestoreDeviceObjects();
HRESULT FrameMove();
HRESULT Render();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT FinalCleanup();
virtual HRESULT AdjustWindowForChange();
protected:
DECLARE_DYNCREATE(CAppForm)
CAppForm();
virtual ~CAppForm();
public:
BOOL IsReady() { return m_bReady; }
TCHAR* PstrFrameStats() { return m_strFrameStats; }
VOID RenderScene() { Render3DEnvironment(); }
HRESULT CheckForLostFullscreen();
//{{AFX_DATA(CAppForm)
enum { IDD = IDD_FORMVIEW };
//}}AFX_DATA
//{{AFX_VIRTUAL(CAppForm)
virtual void OnInitialUpdate();
//}}AFX_VIRTUAL
//{{AFX_MSG(CAppForm)
afx_msg void OnToggleFullScreen();
afx_msg void OnChangeDevice();
afx_msg void OnHScroll( UINT, UINT, CScrollBar* );
afx_msg void OnPresets();
afx_msg void OnOpenPixelShaderFile();
afx_msg void OnPixelShaderEdit();
afx_msg void OnChangeInstructions();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//-----------------------------------------------------------------------------
// Pixel shader instructions
//-----------------------------------------------------------------------------
struct PIXELSHADER_OPCODE
{
DWORD opcode;
DWORD dwNumArgs;
BOOL bInstructionSupportsScaling;
BOOL bInstructionSupportsBias;
BOOL bInputsSupportModifiers;
BOOL bUsesTextureRegisters;
TCHAR* optext;
TCHAR* description;
};
struct PIXELSHADER_PARAMETER
{
DWORD opcode;
TCHAR* optext;
TCHAR* description;
};
#define D3DSIO_PS 0x00010000 // for specifying PixelShader version
// The pixel shader instructions
PIXELSHADER_OPCODE g_PixelShaderInstructions[] =
{ // opcode numArgs Scaling Bias InputMods Tex opText Description
{ D3DSIO_NOP, 0, FALSE, FALSE, FALSE, FALSE, "nop", "No operation" },
{ D3DSIO_PS, 2, FALSE, FALSE, FALSE, FALSE, "ps", "Pixel Shader Version" },
{ D3DSIO_DEF, 5, FALSE, FALSE, FALSE, FALSE, "def", "Define Constant" },
{ D3DSIO_MOV, 2, TRUE, TRUE, TRUE, FALSE, "mov", "Move" },
{ D3DSIO_ADD, 3, TRUE, TRUE, TRUE, FALSE, "add", "Add" },
{ D3DSIO_SUB, 3, TRUE, TRUE, TRUE, FALSE, "sub", "Subtract" },
{ D3DSIO_MAD, 4, TRUE, TRUE, TRUE, FALSE, "mad", "Multiply and add" },
{ D3DSIO_MUL, 3, TRUE, TRUE, TRUE, FALSE, "mul", "Multiply" },
{ D3DSIO_DP3, 3, TRUE, TRUE, TRUE, FALSE, "dp3", "DotProduct3" },
{ D3DSIO_LRP, 4, TRUE, TRUE, TRUE, FALSE, "lrp", "Interpolate (blend)" },
{ D3DSIO_CND, 4, TRUE, TRUE, TRUE, FALSE, "cnd", "Conditional" },
{ D3DSIO_TEXCOORD, 1, FALSE, FALSE, FALSE, TRUE, "texcoord", "Texture coord ???" },
{ D3DSIO_TEXKILL, 1, FALSE, FALSE, FALSE, TRUE, "texkill", "Texture kill ???" },
{ D3DSIO_TEX, 1, FALSE, FALSE, FALSE, TRUE, "tex", "Texture" },
{ D3DSIO_TEXBEM, 2, FALSE, FALSE, FALSE, TRUE, "texbem", "Bump env map" },
{ D3DSIO_TEXBEML, 2, FALSE, FALSE, FALSE, TRUE, "texbeml", "Bump env map w/luminance" },
{ D3DSIO_TEXREG2AR, 2, FALSE, FALSE, FALSE, TRUE, "texreg2ar", "???" },
{ D3DSIO_TEXREG2GB, 2, FALSE, FALSE, FALSE, TRUE, "texreg2gb", "???" },
{ D3DSIO_TEXM3x2PAD, 2, FALSE, FALSE, FALSE, TRUE, "texm3x2pad", "3x2 ???" },
{ D3DSIO_TEXM3x2TEX, 2, FALSE, FALSE, FALSE, TRUE, "texm3x2tex", "3x2 ???" },
{ D3DSIO_TEXM3x3PAD, 2, FALSE, FALSE, FALSE, TRUE, "texm3x3pad", "3x3 ???" },
{ D3DSIO_TEXM3x3TEX, 2, FALSE, FALSE, FALSE, TRUE, "texm3x3tex", "3x3 ???" },
{ D3DSIO_TEXM3x3DIFF, 2, FALSE, FALSE, FALSE, TRUE, "texm3x3diff", "3x3 ???" },
{ D3DSIO_TEXM3x3SPEC, 3, FALSE, FALSE, FALSE, TRUE, "texm3x3spec", "3x3 ???" },
{ D3DSIO_TEXM3x3VSPEC, 2, FALSE, FALSE, FALSE, TRUE, "texm3x3vspec","3x3 ???" },
{ D3DSIO_END, 0, FALSE, FALSE, FALSE, FALSE, NULL, NULL },
};
// The source parameters for the pixel shader instructions
PIXELSHADER_PARAMETER g_PixelShaderParameters[] =
{
{ D3DS_SR0, "r0", "Register 0" },
{ D3DS_SR1, "r1", "Register 1" },
{ D3DS_SR2, "r2", "Register 2" },
{ D3DS_SR3, "r3", "Register 3" },
{ D3DS_SR4, "r4", "Register 4" },
{ D3DS_SR5, "r5", "Register 5" },
{ D3DS_SR6, "r6", "Register 6" },
{ D3DS_SR7, "r7", "Register 7" },
{ D3DS_T0, "t0", "Texture 0" },
{ D3DS_T1, "t1", "Texture 1" },
{ D3DS_T2, "t2", "Texture 2" },
{ D3DS_T3, "t3", "Texture 3" },
{ D3DS_T4, "t4", "Texture 4" },
{ D3DS_T5, "t5", "Texture 5" },
{ D3DS_T6, "t6", "Texture 6" },
{ D3DS_T7, "t7", "Texture 7" },
{ D3DS_C0, "c0", "Constant 0" },
{ D3DS_C1, "c1", "Constant 1" },
{ D3DS_C2, "c2", "Constant 2" },
{ D3DS_C3, "c3", "Constant 3" },
{ D3DS_C4, "c4", "Constant 4" },
{ D3DS_C5, "c5", "Constant 5" },
{ D3DS_C6, "c6", "Constant 6" },
{ D3DS_C7, "c7", "Constant 7" },
{ D3DS_V0, "v0", "Vertex color 0" },
{ D3DS_V1, "v1", "Vertex color 1" },
{ D3DS_V1, NULL, NULL },
};
// Define some preset pixel shaders
TCHAR* g_strPixelShaderPresets[10] =
{
{
"// Diffuse only\r\n"
"ps.1.0\r\n"
"mov r0, v0"
},
{
"// Decal\r\n"
"ps.1.0\r\n"
"tex t0\r\n"
"mov r0, t0"
},
{
"// Modulate texture with diffuse (color0)\r\n"
"ps.1.0\r\n"
"tex t0\r\n"
"mul r0, v0, t0"
},
{
"// Blend between tex0 and tex1\r\n"
"ps.1.0\r\n"
"tex t0\r\n"
"tex t1\r\n"
"mov r1, t1\r\n"
"lrp r0, v0, t0, r1"
},
{
"// Scale tex0 by color0 and add to tex1\r\n"
"ps.1.0\r\n"
"tex t0\r\n"
"tex t1\r\n"
"mov r1, t1\r\n"
"mad r0, v0, t0, r1"
},
{
"// Add tex0, tex1, color0, and color1\r\n"
"ps.1.0\r\n"
"tex t0\r\n"
"tex t1\r\n"
"add r0, t0, v1\r\n"
"add r0, r0, t1\r\n"
"add r0, r0, v0"
},
};
#endif

View File

@@ -0,0 +1,193 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "DirectX.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
BEGIN
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
VK_RETURN, IDM_PAUSE, VIRTKEY, NOINVERT
VK_RETURN, IDM_ALTENTER, VIRTKEY, ALT, NOINVERT
VK_SPACE, IDM_SINGLESTEP, VIRTKEY, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_FORMVIEW DIALOGEX 0, 0, 416, 242
STYLE WS_CHILD
FONT 8, "MS Shell Dlg"
BEGIN
PUSHBUTTON "Change &Device...",IDM_CHANGEDEVICE,6,175,76,15
PUSHBUTTON "View Full&screen",IDC_VIEWFULLSCREEN,94,175,76,15
CONTROL "",IDC_RENDERVIEW,"Static",SS_BLACKFRAME,5,30,165,140,
WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE
GROUPBOX "Shade&rs",IDC_STATIC,6,1,402,25
CONTROL "Shader 0",IDC_PRESET_0,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,15,11,45,10
CONTROL "Shader 1",IDC_PRESET_1,"Button",BS_AUTORADIOBUTTON,65,
11,45,10
CONTROL "Shader 2",IDC_PRESET_2,"Button",BS_AUTORADIOBUTTON,115,
11,45,10
CONTROL "Shader 3",IDC_PRESET_3,"Button",BS_AUTORADIOBUTTON,165,
11,45,10
CONTROL "Shader 4",IDC_PRESET_4,"Button",BS_AUTORADIOBUTTON,215,
11,45,10
CONTROL "Shader 5",IDC_PRESET_5,"Button",BS_AUTORADIOBUTTON,265,
11,45,10
PUSHBUTTON "&Open...",IDC_OPEN,321,8,76,15
GROUPBOX "&Pixel Shader Instructions",IDC_STATIC,175,28,233,162
EDITTEXT IDC_INSTRUCTIONS,179,39,224,145,ES_MULTILINE |
ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
GROUPBOX "Compilation Result",IDC_STATIC,6,192,402,47
EDITTEXT IDC_COMPRESULT,12,202,391,32,ES_MULTILINE |
ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN |
WS_VSCROLL
END
IDD_SELECTDEVICE DIALOG DISCARDABLE 0, 0, 267, 138
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Device"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Rendering device",IDC_STATIC,5,5,200,45
LTEXT "&Adapter:",IDC_STATIC,22,17,65,10,SS_CENTERIMAGE
COMBOBOX IDC_ADAPTER_COMBO,90,15,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "&Device:",IDC_STATIC,22,32,65,10,SS_CENTERIMAGE
COMBOBOX IDC_DEVICE_COMBO,90,30,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
GROUPBOX "Rendering mode",IDC_STATIC,5,52,200,45
CONTROL "Use desktop &window",IDC_WINDOW,"Button",
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,62,85,15
CONTROL "&Fullscreen mode:",IDC_FULLSCREEN,"Button",
BS_AUTORADIOBUTTON,10,77,75,15
COMBOBOX IDC_FULLSCREENMODES_COMBO,90,77,105,204,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_GROUP | WS_TABSTOP
GROUPBOX "Multisample",IDC_STATIC,5,101,200,28
LTEXT "&Multisample Type:",IDC_STATIC,22,113,62,10,
SS_CENTERIMAGE
COMBOBOX IDC_MULTISAMPLE_COMBO,90,111,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,210,10,50,14
PUSHBUTTON "Cancel",IDCANCEL,210,30,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_FORMVIEW, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 408
TOPMARGIN, 7
BOTTOMMARGIN, 237
END
IDD_SELECTDEVICE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 259
TOPMARGIN, 7
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Change &device...", IDM_CHANGEDEVICE
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,50 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by pixelshader.rc
//
#define IDI_MAIN_ICON 101
#define IDR_MAINFRAME 101
#define IDD_FORMVIEW 102
#define IDR_MAIN_ACCEL 113
#define IDD_SELECTDEVICE 144
#define IDC_DEVICE_COMBO 1000
#define IDC_MODE_COMBO 1001
#define IDC_ADAPTER_COMBO 1002
#define IDC_FULLSCREENMODES_COMBO 1003
#define IDC_MULTISAMPLE_COMBO 1005
#define IDC_WINDOWED_CHECKBOX 1012
#define IDC_FULLSCREEN_TEXT 1014
#define IDC_WINDOW 1016
#define IDC_FULLSCREEN 1018
#define IDC_RENDERVIEW 1050
#define IDC_VIEWFULLSCREEN 1059
#define IDC_OPEN 1111
#define IDC_PRESET_0 1114
#define IDC_PRESET_1 1115
#define IDC_PRESET_2 1116
#define IDC_PRESET_3 1117
#define IDC_PRESET_4 1118
#define IDC_PRESET_5 1119
#define IDC_PRESET_6 1120
#define IDC_ADDAFTER_BUTTON 1121
#define IDC_PIXELSHADER_EDIT 1125
#define IDC_COMPRESULT 1133
#define IDC_INSTRUCTIONS 1138
#define IDM_EXIT 40001
#define IDM_CHANGEDEVICE 40010
#define IDM_ALTENTER 40010
#define IDM_TOGGLEFULLSCREEN 40011
#define IDM_PAUSE 40018
#define IDM_SINGLESTEP 40019
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 153
#define _APS_NEXT_COMMAND_VALUE 40020
#define _APS_NEXT_CONTROL_VALUE 1139
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// Gear.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,25 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__F8D95047_DC20_11D0_9A2C_00C04FD7D17B__INCLUDED_)
#define AFX_STDAFX_H__F8D95047_DC20_11D0_9A2C_00C04FD7D17B__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__F8D95047_DC20_11D0_9A2C_00C04FD7D17B__INCLUDED_)