After contacting Lee Bamber, to make sure it was ok to post about C17 static libraries. He gave me the following guidelines -- "Just stay clear of subjects like price, promises and licensing and focus on features, what works right now and what the current issues are."
EDIT: C17 is a Wrapper for any API, but is focused on game making. Currently it Wraps Direct X 9.0, Nvidia PhysX, basic windows, and XAudio2.
What I am trying to accomplish with this post is to see what other indie game makers think, and if there is interest for something like this.
What exactly are C17 Static Libraries? For those of you who may not know, a static library is simply a collection of "commands" contained in a .lib file. This is very similar to a .dll.
What C17 is attempting to do is create a different approach to game making. This is done by using a modular design. Each library can be used seperatly or together as a unit. No one library relies on another. The Object Oriented design also makes it very flexable. (I'm sure many of you will appreciate this.)
Which brings me to another key design feature of C17. We all know how technology changes, take for example, Direct X 9,10,11, OpenGL..ect. The basic idea is to develop the libraries to be easily interchanged between technologies. For example the command set from the Direct X 9 and 10 libraries will be very similar to ensure that compiling against either one will require minimal code changes. Functions that the user has created will be easily transferable between either(if they used functions included with C17). The basic idea is that there is a clear path to upgrade as technology changes. Users wont have to wait years to use a new api after it has been released. Once a library has been decided to be built, users can take advantage. I think what librarys to build should be based on what the actual end-users want.
So what exactly is done, and what technologies are already present?
1. Windows lib
2. Direct X 9 lib
3. Nvidia PhysX lib
4. XAudio2 lib
The Librarys are mostly done, but I haven't finished every aspect. I don't even know if I'm going to release them because I don't know if there is anyone who wants them.
I chose to start with Direct X 9 because its the most popular at the moment an probably will be for quite some time. I went with a heavily shader based approach and left out alot of FFP stuff that could be added in if thats what is wanted. I think the shader based approach is the best since, thats pretty much the wave of the future.
Current C17 command set.
Direct X 9
//setup D3D
bool InitializeDirect3D( ); //returns true if success
bool InitializeDirect3D( UINT Width, UINT Height, UINT Refresh, D3DFORMAT Format, bool Windowed ); //returns true if success
void ReleaseResources( );
void ChangeDirectory( char* Directory );
//D3D settings functions
void ColorBackDrop( int Red, int Green, int Blue );
void SetCullMode( int Mode );
void SetWindowMode(bool Mode );
void EnableAlphaBlend( );
void DisableAlphaBlend( );
//buffer commands
void ClearALLBuffers( int Red, int Green, int Blue );
void ClearBackBuffer( int Red, int Green, int Blue );
void ClearZBuffer( );
void ClearStencil( );
//camera commands
D3DXMATRIX SetCameraProjection( float FOV, float NearClip, float FarClip );
void UpdateCamera( D3DXMATRIX &ProjectionMatrix );
D3DXMATRIX BuildProjectionMatrix( float FOV,float Aspect, float NearClip, float FarClip );
//render target commands
IDirect3DTexture9* CreateRenderTarget( D3DFORMAT Format, int SizeX, int SizeY, IDirect3DTexture9* Texture );
IDirect3DCubeTexture9* CreateCubicTarget( D3DFORMAT Format, int CubeSize, IDirect3DCubeTexture9* Texture );
void ClearTexture( IDirect3DTexture9* Texture, int red, int green, int blue );
void ClearTexture( IDirect3DTexture9* Texture, int red, int green, int blue, int alpha );
void SetRenderTarget( int RenderTarget, IDirect3DTexture9* RenderTargetTexture);
D3DXMATRIX RenderToCubicTexture( IDirect3DCubeTexture9* Texture, UINT Face, float PosX, float PosY, float PosZ );
void DisableRenderTargets( );
//effect functions
ID3DXEffect* LoadEffect( char* EffectFilename, bool Legacy );
ID3DXMesh* SetMeshDec( ID3DXMesh* Mesh );
void CreateVertexDeclaration( int offset1, int method1, int type1,
int offset2, int method2, int type2,
int offset3, int method3, int type3,
int offset4, int method4, int type4,
int offset5, int method5, int type5 );
void ComputeNormals( ID3DXMesh* Mesh );
IDirect3DVertexDeclaration9* GetVertexDeclaration( );
//image commands
IDirect3DTexture9* CreateHeightMap( IDirect3DTexture9* texture );
IDirect3DTexture9* CreateNormalMap( IDirect3DTexture9* texture );
IDirect3DTexture9* LoadTexture( char* TextureFileName );
void SaveImage( char* ImageName, D3DXIMAGE_FILEFORMAT Format, IDirect3DTexture9* Texture );
//D3D Main functions
void RenderBegin( ); //start scene
void RenderEnd( ); //end scene
//D3D Common Matrix Functions
D3DXMATRIX MatrixMultiply( D3DXMATRIX &Matrix1, D3DXMATRIX &Matrix2 ); //multiplies 2 matrix
D3DXMATRIX SetWorldViewProjecton( D3DXMATRIX &Matrix1, D3DXMATRIX &Matrix2, D3DXMATRIX &Matrix3 ); //sets wvp commonly used in shaders
D3DXMATRIX MatrixInverse( D3DXMATRIX &Matrix );
D3DXMATRIX MartixTranspose( D3DXMATRIX &Matrix );
void SetViewMatrix( D3DXMATRIX View );
//return functions
UINT GetScreenWidth( );
UINT GetScreenHeight( );
UINT GetScreenFormat( );
UINT GetScreenRefresh( );
IDirect3DDevice9* GetD3DDevice( );
D3DXMATRIX GetWorldMatrix( );
D3DXMATRIX GetViewMatrix( );
D3DXMATRIX GetProjectionMatrix( );
void InitializeDirectInput(HINSTANCE appInstance, HWND hwnd,
DWORD keyboardCoopFlags, DWORD mouseCoopFlags);
void Poll();
int KeyDown(char key);
bool MouseButtonDown(int button);
void PositionCamera( float PosX, float PosY, float PosZ );
void PositionCameraX( float PosX );
void PositionCameraY( float PosY );
void PositionCameraZ( float PosZ );
void SetPitch( float NewPitch );
void SetYaw(float NewYaw );
void UpdateCamera( float ForwardUnits, float SidewardUnits );
void MoveCamera( float Units );
void StrafeCamera( float Units );
void SetTarget( float TargetX, float TargetY, float TargetZ );
void SetTargetVector( D3DXVECTOR3 NewTarget );
//return functions
float GetCameraPositionX( );
float GetCameraPositionY( );
float GetCameraPositionZ( );
D3DXVECTOR3 GetCameraPositionXYZ( );
float GetCameraPitch( );
float GetCameraYaw( );
D3DXMATRIX GetCameraViewMatrix( );
D3DXVECTOR3 GetViewVector( );
D3DXVECTOR3 GetTargetVector( );
//physx specific returns
float GetVelocityX( );
float GetVelocityY( );
float GetVelocityZ( );
void SetFontSize( int SetPointSize );
void PrintText( int x, int y, char* TexString, int iVar );
void PrintText( int x, int y, char* TexString, float fVar );
void PrintText( int x, int y, char* TexString );
void SetFontColor(int red, int green, int blue, int alpha );
void SetBold( bool SetBold );
void SetItalic( bool SetItalic );
void SetFontType( char* SetFontName );
//object functions
void LoadXObject( char* MeshFileName );
void LoadXObjectTextured( char* MeshFileName );
void LoadXObjectTextured( char* MeshFileName, bool MakeNormalMaps );
void LoadXObjectAnimated( char* MeshFileName );
//void LoadXObjectAnimated( char* MeshFileName );
//animation functions
int animations_count;
void Render(Bone *bone);
void RenderSkeleton(Bone* bone, Bone *parent, D3DXMATRIX world);
void PlayAnimation( float time);
void SetAnimationNumber(int AnimNumber);
void GetAnimations( );
char* GetAnimationName( int AnimNumber );
void SetMesh( ID3DXMesh* NewMesh ); //change pointer of mesh to point to new mesh
//image helper functions
IDirect3DTexture9* CreateHeightMap( IDirect3DTexture9* texture );
IDirect3DTexture9* CreateNormalMap( IDirect3DTexture9* texture );
void PositionObject( float x, float y, float z );
void ScaleObject( float x, float y, float z );
void RotateObject( float x, float y, float z );
//texture functions
void BindTextureToStage( IDirect3DTexture9* Texture, int Stage ); //associate a stage With a texture -- both FFP and Shader
void TextureLimb( IDirect3DTexture9* Texture, int Limb ); //apply custom texture to limb/subset
void TextureLimbStage( IDirect3DTexture9* Texture, int Limb, int Stage ); //apply custom texture to limb/subset on specified stage (0-7 valid)
void SetTextureStageName( char* StageName, int Stage ); //shader specific
void SetEffectVector( char* Handle, float x);
void SetEffectVector( char* Handle, float x, float y);
void SetEffectVector( char* Handle, float x, float y, float z);
void SetEffectVector( char* Handle, float x, float y, float z, float w);
void SetEffectVector( char* Handle, D3DXVECTOR3 &Vec );
void SetEffectVector( char* Handle, D3DXVECTOR4 &Vec );
void SetEffectFloat( char* Handle, float &Val );
void SetVertexDeclaration( IDirect3DVertexDeclaration9* VertexDec );
void SetEffectMatrix( char* Handle, D3DXMATRIX &matrix );
void SetEffectTechnique( char* Handle );
void SetEffectCubicTexture( char* Handle, IDirect3DCubeTexture9* CubeMapTexture );
void SetEffectTexture( char* Handle, IDirect3DTexture9* Texture );
//set shading to specified effect
void SetShaderOn( ID3DXEffect* Effect ); //enable shading to specified effect
void SetShaderOff( ); //disable object shading
//object rendering comands
void ComputeWorldMatrix( bool physx );
void Render( );
//return value functions
ID3DXMesh* GetMesh( ); //return pointer to mesh
int GetLimbCount( ); //get total number of limbs/subsets
D3DXMATRIX GetWorldMatrix( );
float GetPositionX( ); //Object X Position
float GetPositionY( ); //Object Y Position
float GetPositionZ( ); //Object Z Position
char* GetTextureName( int limb ); //get name of texture for limb
//float GetAngleX( );
//float GetAngleY( );
//float GetAngleZ( );
void MakeSprite( float TopX, float TopY, float BottomX, float BottomY );
void DrawSprite( IDirect3DTexture9* Texture, float TopX, float TopY, float BottomX, float BottomY );
void DrawScreenQuad( float SCREENWIDTH, float SCREENHEIGHT );
C17 windows lib
HWND InitWindow(HINSTANCE hInstance, int nCmdShow);
HWND InitWindow(HINSTANCE hInstance, int nCmdShow, char* Title,int sizeX, int sizeY, int PosX, int PosY);
static LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
void SetWindowSize( int X, int Y );
void SetWindowTitle( char* Title );
void SetWindowPosition( int PosX, int PosY );
void MaximizeWindow( );
void MinimizeWindow( );
void HideWindow( );
void UnHideWindow( );
void RestoreWindow( );
void WindowDefaults( );
HWND GetWindowHandle( );
C17 PhysX library
//start the physx system
void InitPhysx( );
void UpdatePhysX( bool Pause, double DeltaTime );
//object creation functions
NxActor* CreateGroundPlane( DWORD Material );
NxActor* CreateBox( const NxVec3& pos, const NxVec3& boxDim, const NxReal density, DWORD Material);
NxActor* CreateSphere( const NxVec3& pos, const NxReal radius, const NxReal density, DWORD Material );
NxActor* CreateCapsule( const NxVec3& pos, const NxReal height, const NxReal radius, const NxReal density, DWORD Material);
NxActor* GenerateTriangleMeshFromDXMesh( ID3DXMesh* Mesh, NxVec3 &pos, float ScaleX,float ScaleY, float ScaleZ, DWORD Material);
NxActor* GenerateConvexFromDXMesh( ID3DXMesh* Mesh, NxVec3 &pos, float ScaleX,float ScaleY, float ScaleZ, DWORD Material);
//collision functions
void CreateGroup( int GroupNumber );
void SetActorCollisionGroup(NxActor *actor, int GroupNumber ) ;
NxRaycastHit RayCastClosestObject( NxVec3 &Origin, NxVec3 &Direction );
NxRaycastHit RayCastClosestObject( NxVec3 &Origin, NxVec3 &Direction, int GroupNumber );
//material functions
DWORD CreateMaterial(float restitution, float staticFriction, float dynamicFriction);
//actor manipulaton functions
void FreezeRotationXYZ( NxActor *Actor );
void FreezeRotationX( NxActor *Actor );
void FreezeRotationY( NxActor *Actor );
void FreezeRotationZ( NxActor *Actor );
void ApplyLinearForceToActorXYZ( NxActor *Actor, float ForceX, float ForceY, float ForceZ );
void ApplyLinearForceToActorX( NxActor *Actor, float Force );
void ApplyLinearForceToActorY( NxActor *Actor, float Force );
void ApplyLinearForceToActorZ( NxActor *Actor, float Force );
void ApplyForceXYZ( NxActor *Actor, float ForceX, float ForceY, float ForceZ );
void SetGravity(float PullX, float PullY, float PullZ);
//making a object static is the same as making it kinematic
void MakeStatic( NxActor *Actor );
void MakeDynamic( NxActor *Actor );
//get world matrix
void GetWorldMatrix( NxActor *Actor, D3DXMATRIX &World );
//character controller
NxActor* CreateCharacterController( float posX, float posY, float posZ,const NxReal height, const NxReal radius, const NxReal density, DWORD Material);
void UpdateCharacterController( NxActor *Actor );
//delete actor from scene
void DeleteActor( NxActor *Actor );
void ReleasePhysx( );
C17 Sound library
//sound commands
HRESULT PlayWav( ); //plays wave file
bool IsPlaying( ); //returns true if sound is currently playing
void PauseSound( ); //pause sound if playing
void ResumeSound( ); //resume sound if playing
void ChangeVolume( float Volume );
float GetVolume( );
//only call if you are going to use sound as a 3d sound
void SetSoundPosition( float X, float Y, float Z );
void SetListenerPosition( );
void SetSoundRange( float Range );
void Update3dSound( float ListenerX, float ListenerY, float ListenerZ ); //only call for 3d sounds 2d sounds need not apply
HRESULT LoadSound( char* SoundFileName ); //load a sound file
HRESULT FindChunk(HANDLE hFile, DWORD fourcc, DWORD & dwChunkSize, DWORD & dwChunkDataPosition);
HRESULT ReadChunkData(HANDLE hFile, void * buffer, DWORD buffersize, DWORD bufferoffset);
Simple Sample project -- so you can get an idea how it works
//Include Directives
#include "C17_Win.h"
#include "C17_DX9.h"
#include <vector>
//include all the C17_Win lib file
#pragma comment(lib, "C17_Win.lib")
#pragma comment(lib, "C17_DX9.lib")
//use namespace to make coding easier
using namespace C17_Win;
using namespace C17_DX9;
//create a new instance of Win
Win wn;
CGraphics *dx;
//pointer to texture
IDirect3DTexture9* Texture0;
/****************************************************************************
WinMain: program execution starts here.
****************************************************************************/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
//create a window
HWND hwnd = wn.InitWindow(hInstance, nCmdShow);
//Create a new instance of CGraphics with the windows handle
dx = new CGraphics(hwnd);
//start direct x
dx->SetWindowMode( true ); //set windows mode on -- default is fullscreen
if (dx->InitializeDirect3D( ) == false){MessageBox(0, "D3D ERROR", 0, 0);} //init directx and throw error if failed
//set all static settings here
//backdrop color //load objects //load textures //load shaders
dx->ColorBackDrop( 100,100,25); //set backdrop color
dx->UpdateCamera( dx->SetCameraProjection( 35, 0.1, 1000 ) ); //Call this function anytime you change camera setting to actually apply those settings
Texture0 = dx->LoadTexture( "brick1_T.bmp" );
//make array for object data
//make vector array object handler
std::vector< CObjects > ModelData;
// load 100 objects
for(DWORD i = 0; i < 100; i++) // loop through each world object
{
//create a new instance of modeldata
ModelData.push_back(CObjects( dx->GetD3DDevice() ));
//load a texture for the object
ModelData[i].BindTextureToStage( Texture0 , 0 );
//load a mesh
ModelData[i].LoadXObject( "cube.x" );
//position the mesh
ModelData[i].PositionObject( (rand() % 1000)-500 ,0,rand() % 1000 );
//finally set the world matrix for each object
ModelData[i].ComputeWorldMatrix( false );
}
// Main message loop:
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
//do all the work in this area
//this is where you would control all game logic
//start a scene
dx->RenderBegin( );
//finally call UpdateObject when you have done all the work on your objects
for(DWORD i = 0; i < 100; i++) // loop through each world object
{
ModelData[i].Render( );
}
//end a scene
dx->RenderEnd( );
}
}
//clean up here -- release all resources you have made
Texture0->Release();
//release direct X
dx->ReleaseResources( );
return (int) msg.wParam;
}
In closing if you have anything constructive to say, please do so. Again I would like to state that I'm posting this to see if there is actually any community interest.
Thank you.
EDIT: I attached a sample Cubic Shadow Mapping program. (also the shadow shader is an edited shader I downloaded as an example.)