VertexShader with directX in pb

Advanced game related topics
Megaborsti
User
User
Posts: 35
Joined: Sat Aug 16, 2003 4:52 pm
Location: Germany

VertexShader with directX in pb

Post by Megaborsti »

Hi,
it is now possible to use DirectX directly in PureBasic (you can download the needed include-files and read some examples in codemonger´s forum: http://www.codemonger.com/Forum/default.asp (thanks, codemonger)).

I already have some experience in Direct3D and tried the last week to translate some c++-examples (from a book I bought 2 years ago) to pb.

Everything worked fine (I had to use the header-converter to translate some header-files from the dx8-SDK), but now I tried to use a vertex-shader.

That is the c++-file:

Code: Select all

/*
#############################################################################

  Ch10p1_SimpleVertexShader.cpp: a program that demonstrates how to create
  and use vertex shaders.

#############################################################################
*/

// include files ////////////////////////////////////////////////////////////

#include <d3dx8.h>
#include <mmsystem.h>

//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D8             g_pD3D       = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE8       g_pd3dDevice = NULL; // Our rendering device
LPDIRECT3DVERTEXBUFFER8 g_pVB        = NULL; // Buffer to hold vertices
DWORD                   g_dwShader   = 0;    // Handle to shader

D3DXMATRIX g_matProj;
D3DXMATRIX g_matView;
D3DXMATRIX g_matWorld;

// A structure for our custom vertex type.
struct CUSTOMVERTEX
{
  D3DXVECTOR3 position; // The position
  D3DCOLOR    color;    // The color
};

// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
  // Create the D3D object.
  if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
    return E_FAIL;

  // Get the current desktop display mode, so we can set up a back
  // buffer of the same format
  D3DDISPLAYMODE d3ddm;
  if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
    return E_FAIL;

  // Set up the structure used to create the D3DDevice. Since we are now
  // using more complex geometry, we will create a device with a zbuffer.
  D3DPRESENT_PARAMETERS d3dpp;
  ZeroMemory( &d3dpp, sizeof(d3dpp) );
  d3dpp.Windowed = TRUE;
  d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  d3dpp.BackBufferFormat = d3ddm.Format;
  d3dpp.EnableAutoDepthStencil = TRUE;
  d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

  // Create the D3DDevice
  if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                    D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                    &d3dpp, &g_pd3dDevice ) ) )
  {
    return E_FAIL;
  }

  // Turn off culling
  g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

  // Turn off D3D lighting
  g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

  // Turn on the zbuffer
  g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

  return S_OK;
}

//-----------------------------------------------------------------------------
// Name: InitGeometry()
// Desc: Create the vertex buffer
//-----------------------------------------------------------------------------
HRESULT InitGeometry()
{
  HRESULT hr;
  
  // Create the vertex buffer.
  if( FAILED( g_pd3dDevice->CreateVertexBuffer( 6*2*sizeof(CUSTOMVERTEX),
                                                0, D3DFVF_CUSTOMVERTEX,
                                                D3DPOOL_DEFAULT, &g_pVB ) ) )
  {
    return E_FAIL;
  }

  // Fill the vertex buffer. We are setting the tu and tv texture
  // coordinates, which range from 0.0 to 1.0
  CUSTOMVERTEX* pVertices;
  if( FAILED( g_pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 ) ) )
    return E_FAIL;
  
  // first triangle
  pVertices[0].position = D3DXVECTOR3(-2.0f, -2.0f, 0.0f);
  pVertices[0].color    = D3DCOLOR_ARGB(255, 255, 0, 0);
  
  pVertices[1].position = D3DXVECTOR3(2.0f, -2.0f, 0.0f);
  pVertices[1].color    = D3DCOLOR_ARGB(255, 0, 255, 0);
  
  pVertices[2].position = D3DXVECTOR3(2.0f, 2.0f, 0.0f);
  pVertices[2].color    = D3DCOLOR_ARGB(255, 0, 0, 255);
  
  // second triangle
  pVertices[3].position = D3DXVECTOR3(2.0f, 2.0f, 0.0f);
  pVertices[3].color    = D3DCOLOR_ARGB(255, 0, 255, 255);
  
  pVertices[4].position = D3DXVECTOR3(-2.0f, 2.0f, 0.0f);
  pVertices[4].color    = D3DCOLOR_ARGB(255, 255, 255, 0);
  
  pVertices[5].position = D3DXVECTOR3(-2.0f, -2.0f, 0.0f);
  pVertices[5].color    = D3DCOLOR_ARGB(255, 255, 0, 255);
  
  g_pVB->Unlock();

// Create vertex shader
  {
    LPD3DXBUFFER pCode;

    DWORD dwDecl[] =
    {
      D3DVSD_STREAM(0),
      D3DVSD_REG(D3DVSDE_POSITION,  D3DVSDT_FLOAT3),
			D3DVSD_REG(D3DVSDE_DIFFUSE, 	D3DVSDT_D3DCOLOR),
      D3DVSD_END()
    };

    // Assemble the vertex shader from the file
    // change this to Ch10p1_SimpleShader2.vsh to see vertex diffuse colors
    if( FAILED( hr = D3DXAssembleShaderFromFile( "Ch10p1_SimpleShader1.vsh", 
                                                 0, NULL, &pCode, NULL ) ) )
      return hr;

    // Create the vertex shader
    hr = g_pd3dDevice->CreateVertexShader( dwDecl, 
      (DWORD*)pCode->GetBufferPointer(), &g_dwShader, 0 );
    pCode->Release();
    if( FAILED(hr) ) return hr;
  }

  return S_OK;
}

//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
  if (g_dwShader != 0)       g_pd3dDevice->DeleteVertexShader(g_dwShader);
  if( g_pVB != NULL )        g_pVB->Release();
  if( g_pd3dDevice != NULL ) g_pd3dDevice->Release();
  if( g_pD3D != NULL )       g_pD3D->Release();
}

//-----------------------------------------------------------------------------
// Name: SetupMatrices()
// Desc: Sets up the world, view, and projection transform matrices.
//-----------------------------------------------------------------------------
VOID SetupMatrices()
{
  // For our world matrix, we will just leave it as the identity
  D3DXMatrixIdentity( &g_matWorld );
  D3DXMatrixRotationYawPitchRoll( &g_matWorld, timeGetTime()/1000.0f, 
    timeGetTime()/700.0f, timeGetTime()/850.0f );
  
  // Set up our view matrix. A view matrix can be defined given an eye point,
  // a point to lookat, and a direction for which way is up. Here, we set the
  // eye five units back along the z-axis and up three units, look at the
  // origin, and define "up" to be in the y-direction.
  D3DXMatrixLookAtLH( &g_matView, &D3DXVECTOR3( 0.0f, 3.0f,-5.0f ),
                                &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
                                &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
  
  // For the projection matrix, we set up a perspective transform (which
  // transforms geometry from 3D view space to 2D viewport space, with
  // a perspective divide making objects smaller in the distance). To build
  // a perpsective transform, we need the field of view (1/4 pi is common),
  // the aspect ratio, and the near and far clipping planes (which define at
  // what distances geometry should be no longer be rendered).
  D3DXMatrixPerspectiveFovLH( &g_matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
  
}

//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
   // Setup the world, view, and projection matrices
  SetupMatrices();

  // Clear the backbuffer and the zbuffer
  g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
                       D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

  // Begin the scene
  g_pd3dDevice->BeginScene();

  g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
  g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );
  g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

  // Render the vertex buffer contents
  g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) );
  g_pd3dDevice->SetVertexShader( g_dwShader ); // set our vertex shader active
  
  // Set up the vertex shader constants
  {
    D3DXMATRIX mat;
    D3DXMatrixMultiply( &mat, &g_matWorld, &g_matView );
    D3DXMatrixMultiply( &mat, &mat, &g_matProj );
    D3DXMatrixTranspose( &mat, &mat );

    g_pd3dDevice->SetVertexShaderConstant(0, &mat,  4);

    // plug the diffuse color into constant register 4
    float color[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
    g_pd3dDevice->SetVertexShaderConstant(4, color, 1);
  }
 

  g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2 );

  // End the scene
  g_pd3dDevice->EndScene();

  // Present the backbuffer contents to the display
  g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}

//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
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 );
}

//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
  // Register the window class
  WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
                    GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                    "Ch10p1_SimpleVertexShader", NULL };
  RegisterClassEx( &wc );

  // Create the application's window
  HWND hWnd = CreateWindow( "Ch10p1_SimpleVertexShader", "Ch10p1_SimpleVertexShader",
                            WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
                            GetDesktopWindow(), NULL, wc.hInstance, NULL );

  // Initialize Direct3D
  if( SUCCEEDED( InitD3D( hWnd ) ) )
  {
    // Create the scene geometry
    if( SUCCEEDED( InitGeometry() ) )
    {
      // Show the window
      ShowWindow( hWnd, SW_SHOWDEFAULT );
      UpdateWindow( hWnd );

      // Enter the 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 Render();
      }
    }
  }

  // Clean up everything and exit the app
  Cleanup();
  UnregisterClass("Ch10p1_SimpleVertexShader", wc.hInstance );
  return 0;
}



That code isn´t much difficult and i could translate nearly everything, but i have no idea how to translate especially these few lines:

Code: Select all

{
    LPD3DXBUFFER pCode;

    DWORD dwDecl[] =
    {
      D3DVSD_STREAM(0),
      D3DVSD_REG(D3DVSDE_POSITION,  D3DVSDT_FLOAT3),
			D3DVSD_REG(D3DVSDE_DIFFUSE, 	D3DVSDT_D3DCOLOR),
      D3DVSD_END()
    };

    // Assemble the vertex shader from the file
    // change this to Ch10p1_SimpleShader2.vsh to see vertex diffuse colors
    if( FAILED( hr = D3DXAssembleShaderFromFile( "Ch10p1_SimpleShader1.vsh", 
                                                 0, NULL, &pCode, NULL ) ) )
      return hr;

    // Create the vertex shader
    hr = g_pd3dDevice->CreateVertexShader( dwDecl, 
      (DWORD*)pCode->GetBufferPointer(), &g_dwShader, 0 );
    pCode->Release();
    if( FAILED(hr) ) return hr;
  }
I have absolutely no idea how these lines should look like in pb.
Could someone (with some experience with directx) help me?

(If you need something like the translated c-headerfiles, please tell me, I will post them)
I become better!!! :)
Megaborsti
User
User
Posts: 35
Joined: Sat Aug 16, 2003 4:52 pm
Location: Germany

Post by Megaborsti »

58 Views, but nobody anwered, thats not good :?

After all, I searched the last two days to find a way to use the vertexshader and there is only 1 problem left.

The following line of code does not work:

Code: Select all

D3DDevice\Createvertexshader(dwDecl(0), dwVertexShader(0), ?, 0) ; 
That is written in the directx8.chm:

Code: Select all

HRESULT CreateVertexShader(
  CONST DWORD* pDeclaration,
  CONST DWORD* pFunction,
  DWORD* pHandle,
  DWORD Usage
);

The first two parametres are pointer. I found out that I have to create Arrays and have to put in the first element. That worked

Usage can be set to 0 or to a (unimportant) flag.

My last problem is pHandle. I do not know what to put in there.
In the c++-example it looks like that:

Code: Select all

DWORD g_dwShader   = 0;    // Handle to shader, that is made at the top of the code

// That is the function
hr = g_pd3dDevice->CreateVertexShader( dwDecl, 
      (DWORD*)pCode->GetBufferPointer(), &g_dwShader, 0 );

They wrote: &g_dwShader

I thought that & means "pointer" and that I have to use * in purebasic.
But if I call the function like that:

Code: Select all

Global g_dwShader.l  // at the top of the code

// the function
D3DDevice\Createvertexshader(dwDecl(0), dwVertexShader(0), *g_dwShader, 0)

The debugger says "Syntax error!".

If I write "g_dwShader", he says "g_dwShader is not a valid operator".
If I write "@g_dwShader", he says "Garbage to the end of line".


PLEASE ANSWER THIS TIME!!!
WHAT DO I HAVE TO WRITE AS THIRD PARAMETER ???

Thanks in advance.
I become better!!! :)
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

No dx experience but re third parameter try @ instead of *

Edit: oops, I see you already have. Wait a mo...

Edit: Oh, I see your main problem now: post pb code if you want help. Most people are using PB because either they don't know C/C++ or, like myself, find life is just too short to bother with it (or more specifically the compilers).

With the limited info you have provided I still say use @ and check your syntax carefully. I assume the "//" comment were only in the posting not your code? Either way, without full listing it's difficult to suggest anything else. Good luck.
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

Hi Guys & Merry Christmas :D

@Megaborsti

If you are using DX9 do not use DX8 as they are not compatible code except DXINput uses DX8 even in DX9.

Anyway here is the code you are trying to use with DX9:

Code: Select all

D3DDevice\Createvertexshader(dwDecl(0), dwVertexShader(0), ?, 0) 
THe DX8 code has changed in DX9 to simplify things:

Code: Select all

CreateVertexShader(const DWORD *pFunction, IDirect3DVertexShader9** ppShader
);

VertexShaders are actually much easier in DX9. Also be carefull using pointers in PB and simply substituting what C++ code has. As they have double pointers and such.

The '&' symbol in C is equivilent to '@' in PB. Remeber to get a return value on your functions so you can tell if your function was successful. A return value of '0' is equivelent to D3D_OK.

Also do not get frustrated using DX. Micsroft bloated their code with so many pointers and macros etc ... this makes it very difficult to convert without stumbling into a bug. If you really want to find where an error is occuring check out the post on my site that can help you with using D3DSpy, heres the link:

http://www.codemonger.com/Forum/forum_p ... TID=8&PN=1


That is very cool, that some of my code has helped you. Thanks for taking the time to check it out. If you change the above code, let us know what else you stumble on, I'll sure help out.
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
Megaborsti
User
User
Posts: 35
Joined: Sat Aug 16, 2003 4:52 pm
Location: Germany

Post by Megaborsti »

Ok, the dx8-function was the problem, thanks codemonger.
I finally downloaded the dx9sdk and translated the example.

If I try to run it, it crashes at the LOCK-function.
I hope someone (codemonger) can find the bug.

I have not commented much, post if you need help.

Code: Select all

; Codemonger-files
IncludeFile "D3D9.pbi"
IncludeFile "D3D9Interface.pbi"

; directx-libraries
OpenLibrary(0,"D3D9.DLL") 
OpenLibrary(1,"D3DX9.dll")

; a compiled vertexshader
Dim dwVertexShader.l(38)
  dwVertexShader(0) = $fffe0100
  dwVertexShader(1) = $0009fffe
  dwVertexShader(2) = $58443344
  dwVertexShader(3) = $68532038
  dwVertexShader(4) = $72656461
  dwVertexShader(5) = $73734120
  dwVertexShader(6) = $6c626d65
  dwVertexShader(7) = $56207265
  dwVertexShader(8) = $69737265
  dwVertexShader(9) = $30206e6f
  dwVertexShader(10) = $0031392e
  dwVertexShader(11) = $000dfffe
  dwVertexShader(12) = $454c4946
  dwVertexShader(13) = $705c3a63
  dwVertexShader(14) = $72676f72
  dwVertexShader(15) = $656d6d61
  dwVertexShader(16) = $7269645c
  dwVertexShader(17) = $78746365
  dwVertexShader(18) = $6b647320
  dwVertexShader(19) = $6e69625c
  dwVertexShader(20) = $7578645c
  dwVertexShader(21) = $5c6c6974
  dwVertexShader(22) = $706d6973
  dwVertexShader(23) = $762e656c
  dwVertexShader(24) = $00006873
  dwVertexShader(25) = $0002fffe
  dwVertexShader(26) = $454e494c
  dwVertexShader(27) = $00000005
  dwVertexShader(28) = $00000014
  dwVertexShader(29) = $c00f0000
  dwVertexShader(30) = $90e40000
  dwVertexShader(31) = $a0e40000
  dwVertexShader(32) = $0002fffe
  dwVertexShader(33) = $454e494c
  dwVertexShader(34) = $0000000b
  dwVertexShader(35) = $00000001
  dwVertexShader(36) = $d00f0000
  dwVertexShader(37) = $a0e40000
  dwVertexShader(38) = $0000ffff
  
; a structure that is not included in codemongers pbis
Structure D3DVERTEXELEMENT9 
  Stream.b
  Offset.b
  Type.b
  Method.b
  Usage.b
  UsageIndex.b
EndStructure

; the vertex-structure
Structure CUSTOMVERTEX  
  x.f                      
  y.f                      
  z.f                        
  color.l        
EndStructure

; a position-structure (the float3-structure from c++)
Structure Simplevertex
  x.f
  y.f
  z.f
EndStructure

; the globals
Global D3D.IDirect3D9
Global D3DDevice.IDirect3DDevice9
Global D3DVertexBuffer.IDirect3DVertexBuffer9
Global D3DVertexDeclaration.IDirect3DVertexDeclaration9
Global D3DVertexShader.IDirect3DVertexShader9
Global pVertices.l

; three matrices
g_matProj.d3dxmatrix    
g_matView.d3dxmatrix    
g_matWorld.d3dxmatrix   

; FVF
D3DFVF_CUSTOMVERTEX = (#d3dfvf_xyz|#d3dfvf_diffuse)

; the vertices and the size of CUSTOMVERTEX
Dim Vertices.CUSTOMVERTEX(5) 
CustomSize = SizeOf(CUSTOMVERTEX) 

; the first procedure: initd3d
Procedure Initd3d()

; a window
window = OpenWindow(0,0,0,800,600,#ws_overlappedwindow|#pb_window_screencentered,"Test")  

; the first interface
D3D = CallFunction(0,"Direct3DCreate9",#D3D_SDK_VERSION)

; the d3ddevice (second interface)
D3DPP.D3DPRESENT_PARAMETERS              
D3DPP\Windowed = #TRUE                   
D3DPP\SwapEffect = #D3DSWAPEFFECT_DISCARD
D3DPP\BackBufferFormat = #D3DFMT_UNKNOWN 
D3D\CreateDevice(#D3DADAPTER_DEFAULT,#D3DDEVTYPE_HAL,window,#D3DCREATE_SOFTWARE_VERTEXPROCESSING,@D3DPP,@D3DDevice)

; setting renderstates
D3DDevice\Setrenderstate(#d3drs_cullmode, #d3dcull_none)
D3DDevice\Setrenderstate(#D3DRS_LIGHTING, #FALSE ) ;    
D3DDevice\Setrenderstate(#D3DRS_ZENABLE, #TRUE ) ;      

; end of the first procedure
  ProcedureReturn 1 
EndProcedure        

; the second procedure: initgeometry
Procedure Initgeometry()

; the vertexbuffer (the third interface)
D3DDevice\CreateVertexBuffer(CustomSize*6,0, D3DFVF_CUSTOMVERTEX, #D3DPOOL_DEFAULT, @D3DVertexBuffer, #NULL)

; the six vertices
Vertices(0)\x = -2 : Vertices(0)\y = -2 : Vertices(0)\z = 0
Vertices(0)\color = $ffff0000                                                                 
Vertices(1)\x = 2 : Vertices(1)\y = -2 : Vertices(1)\z = 0 
Vertices(1)\color = $ff00ff00                                  
Vertices(2)\x = 2 : Vertices(2)\y = 2 : Vertices(2)\z = 0 
Vertices(2)\color = $ff0000ff    
                          
Vertices(3)\x = 2 : Vertices(3)\y = 2 : Vertices(3)\z = 0 
Vertices(3)\color = $ff00ffff                              
Vertices(4)\x = -2 : Vertices(4)\y = 2 : Vertices(4)\z = 0 
Vertices(4)\color = $ffffff00                                
Vertices(5)\x = -2 : Vertices(5)\y = -2 : Vertices(5)\z = 0
Vertices(5)\color = $ffff00ff  

; that part does not work
D3DVertexBuffer\Lock(0, 0, @pVertices, 0)
  CopyMemory(@Vertices(0), pVertices, CustomSize*3) 
D3DVertexBuffer\Unlock()                             

; vertexdeclaration
Dim dwDecl.D3DVERTEXELEMENT9(2)
dwDecl(0)\Stream=0 : dwDecl(0)\Offset=0 : dwDecl(0)\Type=2 : dwDecl(0)\Method=0 : dwDecl(0)\Usage=0 : dwDecl(0)\UsageIndex=0  
dwDecl(1)\Stream=0 : dwDecl(1)\Offset=0 : dwDecl(1)\Type=4 : dwDecl(1)\Method=0 : dwDecl(1)\Usage=10 : dwDecl(1)\UsageIndex=0 
dwDecl(2)\Stream=$FF : dwDecl(2)\Offset=0 : dwDecl(2)\Type=17 : dwDecl(2)\Method=0 : dwDecl(2)\Usage=0 : dwDecl(2)\UsageIndex=0 
D3DDevice\Createvertexdeclaration(dwDecl(0),*D3DVertexDeclaration)

; vertexshader
D3DDevice\Createvertexshader(dwVertexShader(0),*D3DVertexShader)

; end of the second procedure
  ProcedureReturn 1 
EndProcedure        

; the cleanup-procedure
Procedure Cleanup()           
D3DVertexShader\Release()     
D3DVertexBuffer\Release()     
D3DVertexDeclaration\Release()
D3DDevice\Release()           
D3D\Release()     
CloseLibrary(0)
CloseLibrary(1)               
EndProcedure                  


; setup the matrices
Procedure SetupMatrices() 
vec1.Simplevertex : vec1\x = 0 : vec1\y = 3 : vec1\z = -5
vec2.Simplevertex : vec2\x = 0 : vec2\y = 0 : vec2\z = 0
vec3.Simplevertex : vec3\x = 0 : vec3\y = 1 : vec3\z = 0

CallFunction(1,"D3dxmatrixidentity",@g_matWorld)
CallFunction(1,"D3DXMatrixRotationYawPitchRoll",@g_matWorld,gettickcount_()/1000,gettickcount_()/700,gettickcount_()/850)
CallFunction(1,"D3dxmatrixlookatlh",@g_matView,@vec1,@vec2,@vec3)
CallFunction(1,"D3dxMatrixperspectiveFovLH",@g_matProj,#d3dx_pi/4,1,1,100)
EndProcedure  

; render
Procedure Render()

; setup the matrices each frame
SetupMatrices() 

; clear
D3DDevice\Clear(0,#NULL,#d3dClear_target|#d3dclear_zbuffer,RGB(0,0,255),1,0)

; begin
D3DDevice\Beginscene()

; setting texturestagestates
D3DDevice\SettextureStageState(0,1,2)       
D3DDevice\SettextureStageState(0,2,$00000000)
D3DDevice\SettextureStageState(0,4,1)     

; necessary for vertexshader
D3DDevice\Setstreamsource(0,D3DVertexBuffer,0,CustomSize)
D3DDevice\setvertexdeclaration(D3DVertexDeclaration)    
D3DDevice\setvertexshader(D3DVertexShader)             

; making the worldviewprojectionmatrix
mat.d3dxmatrix          
CallFunction(1,"D3dxmatrixmultiply",@mat,@g_matWorld,@g_matView)
CallFunction(1,"d3dxmatrixmultiply",@mat,@mat,@g_matProj)       
CallFunction(1,"d3dxmatrixtranspose",@mat,@mat)                 

; vertexshaderconstants
D3DDevice\setvertexshaderconstantf(0,@mat,4)

Dim color.f(3) : color(0)=1 : color(1)=1 : color(2)=0 : color(3)=1
D3DDevice\setvertexshaderconstantf(4,color(0),1)

; drawing and end
D3DDevice\Drawprimitive(#d3dpt_trianglelist,0,2)
D3DDevice\Endscene()
D3DDevice\Present(0,0,0,0)
EndProcedure

; the mainpart

Initd3d()
Initgeometry() 

Repeat 
  Render()

  EventID.l = WindowEvent()
  If EventID = #PB_EventCloseWindow 
    Quit = 1
  EndIf 
  
Until Quit = 1 

Cleanup()

That was three days work. Hope it will work.
I become better!!! :)
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

I just got back from work and had a quick glance at your post, anyway here are a couple of things that i spotted off the top of my head ...

CopyMemory(@Vertices(0), pVertices, CustomSize*3)

should be:

CopyMemory(@Vertices(0), pVertices, CustomSize*6)

and CustomSize should be Global if it used in a Procedure, otherwise it may seem that your code is working until it crashed unexplainably, because variable CustomSize is always passing a '0' value no matter what.

Hope this helps a bit ... tell me how you make out :wink:

[EDIT]
oh ya, if you are ever wandering what the g_ in front of a lot of variables are it's just the hungarian notation indicating a global variable. Just thought I would point this out as DX code always looks crappy and confusing.

ie:

g_matProj.d3dxmatrix

g_ - indicates a global variable

also any p used in front of a readable variable indicates it is a pointer -
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
Megaborsti
User
User
Posts: 35
Joined: Sat Aug 16, 2003 4:52 pm
Location: Germany

Post by Megaborsti »

Ok, I updated my code a bit, it now crashes much later :?
This time without comments (not much changed):

Code: Select all


IncludeFile "D3D9.pbi" 
IncludeFile "D3D9Interface.pbi" 

OpenLibrary(0,"D3D9.DLL") 
OpenLibrary(1,"D3DX9.dll") 

Dim dwVertexShader.l(11) 
  dwVertexShader(0) = $fffe0101 
  dwVertexShader(1) = $0000001f 
  dwVertexShader(2) = $80000000 
  dwVertexShader(3) = $900f0000 
  dwVertexShader(4) = $00000014 
  dwVertexShader(5) = $c00f0000 
  dwVertexShader(6) = $90e40000 
  dwVertexShader(7) = $a0e40000 
  dwVertexShader(8) = $00000001 
  dwVertexShader(9) = $d00f0000 
  dwVertexShader(10) = $a0e40004 
  dwVertexShader(11) = $0000ffff 
  
; vs.1.1
; dcl_position v0
; m4x4 oPos , v0 , c0
; mov oDo , c4
  
Structure D3DVERTEXELEMENT9 
  Stream.b 
  Offset.b 
  Type.b 
  Method.b 
  Usage.b 
  UsageIndex.b 
EndStructure 

Structure SIMPLEVERTEX 
  x.f 
  y.f 
  z.f 
EndStructure

Structure CUSTOMVERTEX  
  position.SIMPLEVERTEX
  color.l        
EndStructure 

Global D3D.IDirect3D9 
Global D3DDevice.IDirect3DDevice9 
Global D3DVertexBuffer.IDirect3DVertexBuffer9 
Global D3DVertexDeclaration.IDirect3DVertexDeclaration9 
Global D3DVertexShader.IDirect3DVertexShader9 
Global pVertices.l 
Global Customsize.l

Global g_matProj.d3dxmatrix    
Global g_matView.d3dxmatrix    
Global g_matWorld.d3dxmatrix    

Global vec1.Simplevertex : vec1\x = 0 : vec1\y = 3 : vec1\z = -5 
Global vec2.Simplevertex : vec2\x = 0 : vec2\y = 0 : vec2\z = 0 
Global vec3.Simplevertex : vec3\x = 0 : vec3\y = 1 : vec3\z = 0 

D3DFVF_CUSTOMVERTEX = (#d3dfvf_xyz|#d3dfvf_diffuse) 

Dim Vertices.CUSTOMVERTEX(5) 
CustomSize = SizeOf(CUSTOMVERTEX) 


Procedure Initd3d() 
  window = OpenWindow(0,0,0,800,600, #ws_overlappedwindow|#pb_window_screencentered,"Test")  

  D3D = CallFunction(0,"Direct3DCreate9",#D3D_SDK_VERSION) 

  D3DPP.D3DPRESENT_PARAMETERS              
  D3DPP\Windowed = #TRUE                    
  D3DPP\SwapEffect = #D3DSWAPEFFECT_DISCARD 
  D3DPP\BackBufferFormat = #D3DFMT_UNKNOWN 
  D3D\CreateDevice(#D3DADAPTER_DEFAULT,#D3DDEVTYPE_HAL,window, #D3DCREATE_SOFTWARE_VERTEXPROCESSING,@D3DPP,@D3DDevice) 

  D3DDevice\Setrenderstate(#d3drs_cullmode, #d3dcull_none) 
  D3DDevice\Setrenderstate(#D3DRS_LIGHTING, #FALSE ) ;    
  D3DDevice\Setrenderstate(#D3DRS_ZENABLE, #TRUE ) ;      

  ProcedureReturn 1 
EndProcedure        


Procedure Initgeometry() 

  D3DDevice\CreateVertexBuffer(CustomSize*6,0,D3DFVF_CUSTOMVERTEX, #D3DPOOL_DEFAULT,@D3DVertexBuffer, #NULL) 

  Vertices(0)\position\x = -2 : Vertices(0)\position\y = -2 : Vertices(0)\position\z = 0 
  Vertices(0)\color = ffff0000                                                                  
  Vertices(1)\position\x = 2 : Vertices(1)\position\y = -2 : Vertices(1)\position\z = 0 
  Vertices(1)\color = $ff00ff00                                  
  Vertices(2)\position\x = 2 : Vertices(2)\position\y = 2 : Vertices(2)\position\z = 0 
  Vertices(2)\color = $ff0000ff    
                          
  Vertices(3)\position\x = 2 : Vertices(3)\position\y = 2 : Vertices(3)\position\z = 0 
  Vertices(3)\color = $ff00ffff                              
  Vertices(4)\position\x = -2 : Vertices(4)\position\y = 2 : Vertices(4)\position\z = 0 
  Vertices(4)\color = $ffffff00                                
  Vertices(5)\position\x = -2 : Vertices(5)\position\y = -2 : Vertices(5)\position\z = 0 
  Vertices(5)\color = $ffff00ff  

  D3DVertexBuffer\Lock(0, 0, @pVertices, 0) 
    CopyMemory(@Vertices(0), pVertices, CustomSize*6) 
  D3DVertexBuffer\Unlock()                              

  Dim dwDecl.D3DVERTEXELEMENT9(2) 
  dwDecl(0)\Stream=0 : dwDecl(0)\Offset=0 : dwDecl(0)\Type=2
  dwDecl(0)\Method=0 : dwDecl(0)\Usage=0 : dwDecl(0)\UsageIndex=0  
  dwDecl(1)\Stream=0 : dwDecl(1)\Offset=0 : dwDecl(1)\Type=4
  dwDecl(1)\Method=0 : dwDecl(1)\Usage=10 : dwDecl(1)\UsageIndex=0 
  dwDecl(2)\Stream=$FF : dwDecl(2)\Offset=0 : dwDecl(2)\Type=17 
  dwDecl(2)\Method=0 : dwDecl(2)\Usage=0 : dwDecl(2)\UsageIndex=0 

  D3DDevice\Createvertexdeclaration(dwDecl(0),*D3DVertexDeclaration) 
  D3DDevice\Createvertexshader(dwVertexShader(0), *D3DVertexShader) 

  ProcedureReturn 1 
EndProcedure        


Procedure Cleanup()            
  D3DVertexShader\Release()      
  D3DVertexBuffer\Release()      
  D3DVertexDeclaration\Release() 
  D3DDevice\Release()            
  D3D\Release()      
  CloseLibrary(0) 
  CloseLibrary(1)                
EndProcedure                  

; the code chrashes in this procedure
Procedure SetupMatrices() 
  CallFunction(1,"D3dxmatrixidentity",@g_matWorld) 
  CallFunction(1,"D3DXMatrixRotationYawPitchRoll",@g_matWorld, gettickcount_()/1000,gettickcount_()/700,gettickcount_()/850) 
  CallFunction(1,"D3dxmatrixlookatlh",@g_matView,@vec1,@vec2,@vec3) 
  CallFunction(1,"D3dxMatrixperspectiveFovLH",@g_matProj, #d3dx_pi/4,1,1,100) 
EndProcedure  


Dim color.f(3)
color(0)=1 : color(1)=1 : color(2)=0 : color(3)=1

Procedure Render() 
  SetupMatrices() 

  D3DDevice\Clear(0,#NULL,#d3dClear_target|#d3dclear_zbuffer, RGB(0,0,255),1,0) 

  D3DDevice\Beginscene() 

  D3DDevice\SettextureStageState(0,1,2)        
  D3DDevice\SettextureStageState(0,2,$00000000) 
  D3DDevice\SettextureStageState(0,4,1)      

  D3DDevice\Setstreamsource(0,D3DVertexBuffer,0,CustomSize) 
  D3DDevice\setvertexdeclaration(D3DVertexDeclaration)    
  D3DDevice\setvertexshader(D3DVertexShader)              

  mat.d3dxmatrix          
  CallFunction(1,"D3dxmatrixmultiply",@mat,@g_matWorld,@g_matView) 
  CallFunction(1,"d3dxmatrixmultiply",@mat,@mat,@g_matProj)        
  CallFunction(1,"d3dxmatrixtranspose",@mat,@mat)                  

  D3DDevice\setvertexshaderconstantf(0,@mat,4) 
  D3DDevice\setvertexshaderconstantf(4,@color(0),1) 

  D3DDevice\Drawprimitive(#d3dpt_trianglelist,0,2) 
  D3DDevice\Endscene() 
  D3DDevice\Present(0,0,0,0) 
EndProcedure 
; If I ";" out the setupmatrices-procedure, the code crashes at "present"


Initd3d() 
Initgeometry() 

Repeat 
  Render() 

  EventID.l = WindowEvent() 
  If EventID = #PB_EventCloseWindow 
    Quit = 1 
  EndIf 
  
Until Quit = 1 

Cleanup() 

You need >=DirectX9.0 and a "new" graphicscard to test that code.
Hope you can find the error if you have time again, codemonger. :wink:

Happy new year :P
I become better!!! :)
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

I have the same problem when I try to create a vertex buffer with directx 9 on pb.
CreateVertexBuffer/SetStreamSource/drawprimitive crash the program.

Have you found the solution, Megaborsti ? (or Codemonger :D )
Megaborsti
User
User
Posts: 35
Joined: Sat Aug 16, 2003 4:52 pm
Location: Germany

Post by Megaborsti »

Here is my solution (it isn´t really difficult if you think about it a bit):

Code: Select all


; The Codemonger Include Files
IncludeFile "D3D9.pbi"
IncludeFile "D3D9Interface.pbi"

; Setting Global variables
Global *D3D.IDirect3D9 
Global *D3DDevice.IDirect3DDevice9
Global *D3DVS.IDirect3DVertexShader9
Global *D3DVB.IDirect3DVertexBuffer9
Global matProj.D3DXMatrix, matView.D3DXMatrix, matWorld.D3DXMatrix, netmat.D3DXMatrix
Global VertexSize

; Declare my procedures
Declare InitD3D()
Declare InitScene()
Declare DoFrame()
Declare Cleanup()

; Needed structure (see DirectX9 Doc)
Structure D3DVERTEXELEMENT9
  _1.b
  _2.b
  _3.b
  _4.b
  _5.b
  _6.b
EndStructure

; Vertex Structure
Structure Vertex
  x.f : y.f : z.f
EndStructure
VertexSize = SizeOf(Vertex)

; That is the Vertex FVF, it is needed if you want to use Shaders
#VertexFVF = (#D3DFVF_XYZ)


; That is the mainloop, read more to find the procedures
InitD3D()
InitScene()

Repeat 
  DoFrame()
Until WindowEvent() = #PB_EventCloseWindow

Cleanup()
; End of mainloop




Procedure InitD3D()

  ; The window
  hWnd = OpenWindow(1, 100, 100, 400, 400, #WS_OVERLAPPEDWINDOW | #PB_Window_ScreenCentered , "DirectX Demo")

  ; Create the D3D-Interface
  *D3D = Direct3DCreate9_(#D3D_SDK_VERSION) 

  ; Fill the present parameters to create a device
  D3DPP.D3DPRESENT_PARAMETERS
  D3DPP\Windowed = #TRUE
  D3DPP\SwapEffect = #D3DSWAPEFFECT_DISCARD
  D3DPP\BackBufferFormat = #D3DFMT_UNKNOWN 
  D3DPP\EnableAutoDepthStencil = #TRUE;
  D3DPP\AutoDepthStencilFormat = #D3DFMT_D16;
  
  ; Create the D3DDevice-Interface
  If *D3D\CreateDevice(#D3DADAPTER_DEFAULT,#D3DDEVTYPE_HAL,hWnd,#D3DCREATE_SOFTWARE_VERTEXPROCESSING,@D3DPP,@*D3DDevice) <> 0
    MessageRequester("Error","Create Device")
  EndIf
  
EndProcedure


Procedure InitScene()
  
  ; The Vertices I use in this example
  ; They build a square

  Dim Vertices.Vertex(3)
  Vertices(0)\x = -100
  Vertices(0)\y = 100
  Vertices(0)\z = 0
  Vertices(1)\x = 100
  Vertices(1)\y = 100
  Vertices(1)\z = 0
  Vertices(2)\x = -100
  Vertices(2)\y = -100
  Vertices(2)\z = 0
  Vertices(3)\x = 100
  Vertices(3)\y = -100
  Vertices(3)\z = 0
  
  ; This is difficult to explain. First you should look in the DirectX9 Doc
  ; for ways how to fill the Structure, then you will see lots of constants.
  ; I looked up these constants in the c++ header files of the DirectXSdk
  ; an used them here als numbers or hex values. You could also create
  ; all these constants in purebasic, but I did not want to ^^.
  Dim decl.D3DVERTEXELEMENT9(1)
  decl(0)\_1 = 0
  decl(0)\_2 = 0
  decl(0)\_3 = 2
  decl(0)\_4 = 0
  decl(0)\_5 = 0
  decl(0)\_6 = 0
  decl(1)\_1 = $FF
  decl(1)\_2 = 0
  decl(1)\_3 = 17
  decl(1)\_4 = 0
  decl(1)\_5 = 0
  decl(1)\_6 = 0
  
  ; I build the following vertex shader (*.vsh) with an editor:
  ;
  ; vs_1_1
  ; dcl_position v0 
  ; m4x4 oPos , v0, c0    
  ; mov  oD0, c4        
  ;
  ; I hope you already know something about shaders. This shader
  ; simply uses a matrix(c0-3) and a vertex(v0) to determine 
  ; where to draw it and a color value(c4) to color it.
  ;
  ; I compiled the shader and now it looks like that:
  Dim shader.l(11)
  shader(0)=$FFFE0101
  shader(1)=$0000001F
  shader(2)=$80000000
  shader(3)=$900F0000
  shader(4)=$00000014
  shader(5)=$C00F0000
  shader(6)=$90E40000
  shader(7)=$A0E40000
  shader(8)=$00000001
  shader(9)=$D00F0000
  shader(10)=$A0E40004
  shader(11)=$0000FFFF
  
  ; I create the shader (^^ doublepointer)
  Str(*D3DDevice\CreateVertexShader( @shader(0), @*D3DVS))

  ; Create the projection matrix (see DirectX9 Doc)
  D3DXMatrixPerspectiveFovLH_(@matProj, #D3DX_PI/4.0, 1.3333, 1.0, 1000.0)
  
  ; Set the MY projection matrix as THE projection matrix 
  *D3DDevice\SetTransform(#D3DTS_PROJECTION, @matProj)
  
  ; Building and setting the viewing matrix
  vec1.D3DXVECTOR3 : vec2.D3DXVECTOR3 : vec3.D3DXVECTOR3
  vec1\x=0.0 : vec1\y=0.0 : vec1\z=-500.0
  vec2\x=0.0 : vec2\y=0.0 : vec2\z=0.0
  vec3\x=0.0 : vec3\y=1.0 : vec3\z=0.0
  D3DXMatrixLookAtLH_(@matView, @vec1, @vec2, @vec3)
  *D3DDevice\SetTransform(#D3DTS_VIEW, @matView)
  
  ; Here I create the Vertex Buffer (^^doublepointer again)
  Str(*D3DDevice\CreateVertexBuffer(4*SizeOf(Vertex), 0, #VertexFVF, #D3DPOOL_DEFAULT, @*D3DVB, 0))
  
  ; I lock the vertexbuffer and copy the vertex information to it
  ; ^^ doublepointer
  *Ptr = 0
  *D3DVB\Lock(0,0, @*Ptr, 0)
  CopyMemory(@Vertices(0), *Ptr, 4*SizeOf(Vertex))
  *D3DVB\Unlock();
 
EndProcedure


Procedure DoFrame()
  
  ; Here I clear the device to blue (the hex value is "alpha red green blue")
  *D3DDevice\Clear(0, 0, #D3DCLEAR_TARGET | #D3DCLEAR_ZBUFFER, $FF0000FF, 1, 0)

  ; Begin the scene
  *D3DDevice\BeginScene()
  
  ; Creating an setting the Worldmatrix. I do this each frame because i
  ; want the square to rotate (timegettime_()/1000.0).
  D3DXMatrixRotationZ_(@matWorld, timegettime_()/1000.0)
  *D3DDevice\SetTransform(#D3DTS_WORLD, @matWorld)
  
  ; This is an identity matrix. You can multiplicate it with any other matrix
  ; without altering it (the other matrix). You have to use such a matrix 
  ; to build up a new matrix by multiplicating others.
  ; Excuse me for the shit name, I had not much time that time.
  matmat.D3DXMatrix
  matmat\_11=1 : matmat\_12=0 : matmat\_13=0 : matmat\_14=0
  matmat\_21=0 : matmat\_22=1 : matmat\_23=0 : matmat\_24=0
  matmat\_31=0 : matmat\_32=0 : matmat\_33=1 : matmat\_34=0
  matmat\_41=0 : matmat\_42=0 : matmat\_43=0 : matmat\_44=1
  
  ; Here now, I create the WorldViewProjection Matrix.
  ; I will give this one matrix to the vertexshader.
  d3dxMatrixmultiply_(@matmat,@matWorld ,@matView)
  d3dxMatrixmultiply_(@matmat,@matmat,@matProj)
  
  ; In the following lines, I will fill the vertexbuffer:
  
  ; I give the matrix to the registers c0-3
  *D3DDevice\SetVertexShaderConstantF( 0, @matmat, 4 );
  
  ; This is the color you want to give to the vertex shader.
  Dim color.f(3)
  color(0) = 0.0
  color(1) = 1.0
  color(2) = 0.0
  color(3) = 0.0
  
  ; Here I give the color value to the shader.
  ; I found out (by an error I made^^) that you can create very cool
  ; effects by giving the shader unexpected colorinformation. That meens:
  ; You have to pass a LONG-value, no matter what, so try a pointer to
  ; your WorldViewProjectionmatrix or something different that alters each
  ; frame... Your square will look very nice, try it out.
  *D3DDevice\SetVertexShaderConstantF( 4, color(), 1 );
  
  ; You link the vertexbuffer to the vertexshader
  Str(*D3DDevice\SetStreamSource(0, *D3DVB, 0, SizeOf(Vertex)))

  ; Setting vertexshader and vertex FVF.
  ; Do not think to much why I used the Str() here. I found out, that
  ; the program crashed without it, so I tried to save the returnvalue in
  ; a variable and messagebox it ^^, but the compiler said the 
  ; returnvalue was from type string, I tried to messagebox it and it said
  ; it was not from type string. I thought "what a strange bug, ^^microsoft"
  ; and tried the str(), ^^and it worked.
  Str(*D3DDevice\setvertexshader(*D3DVS))
  *D3DDevice\Setfvf(#VertexFVF)
  
  ; Finally draw the primitives (see DirectX9 Doc)
  *D3DDevice\DrawPrimitive(#D3DPT_TRIANGLESTRIP, 0, 2)
  
  ; ... and end the scene and present it.
  *D3DDevice\Endscene()
  *D3DDevice\Present(0,0,0,0)
  
EndProcedure


Procedure Cleanup()
  
  ; You have to release alle the Interfaces
  *D3DVB\Release()
  *D3DVS\Release()
  *D3DDevice\Release()
  *D3D\Release()
  
EndProcedure

If you want to test this example, you have to use the LibrarySDK from Purebasic to build a userlib from the d3d9.dll and the d3dx9d.dll. I expect that everyone can do this alone (^^ I have no webspace to load it up). If you haven´t understood something, simply ask, I will explain it, I know how really bad it is to use directX and have an error somewhere, finding is the hell. However, if you cannot create the userlibs yourself, you can use the dll-commands from purebasic to open both dlls manually. If this also does not work, I will see where to get some webspace.

Please post if I could help you. Don´t give up.
I become better!!! :)
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Megaborsti wrote: [...]
to build a userlib from the d3d9.dll and the d3dx9d.dll.
[...]
Alternatively, you can use the d3dx -replacement-functions which you'll find here:
viewtopic.php?t=9457

That saves you the need for d3dx9.dll
Good programmers don't comment their code. It was hard to write, should be hard to read.
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

thanks for the replies.
I try to convert a c++ example in purebasic.

There's the original code :

Code: Select all

//-----------------------------------------------------------------------------
//           Name: cube.cpp
//         Author: Kevin Harris
//  Last Modified: 04/30/03
//    Description: This sample demonstrates how to create 3D geometry with 
//                 Direct3D by loading the vertex data representing a cube into 
//                 a Vertex Buffer.
//-----------------------------------------------------------------------------

#define STRICT
#define WIN32_LEAN_AND_MEAN

#include <d3dx9.h>
#include <mmsystem.h>
#include "resource.h"

//-----------------------------------------------------------------------------
// GLOBALS
//-----------------------------------------------------------------------------
HWND                    g_hWnd          = NULL;
LPDIRECT3D9             g_pD3D          = NULL;
LPDIRECT3DDEVICE9       g_pd3dDevice    = NULL;
LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer = NULL;

float  g_fElpasedTime;
double g_dCurrentTime;
double g_dLastTime;

//
// Create a simple, six-sided cube which uses a different color for each side 
// or face. Note how each face is created as a small tri-strip which contains  
// only two triangles. Probably not the most efficient way to create a cube, 
// but it's just a demonstration.
//

#define D3DFVF_CUBE_VERTEX ( D3DFVF_XYZ | D3DFVF_DIFFUSE )

struct CubeVertex
{
    float x, y, z; // Position of vertex in 3D space
    DWORD color;   // Color of vertex
};

CubeVertex g_cubeVertices[] =
{
    // Side #1 - red
    {-1.0f, 1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) },
    { 1.0f, 1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) },
    {-1.0f,-1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) },
    { 1.0f,-1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) },

    // Side #2 - green
    {-1.0f, 1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },
    {-1.0f,-1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },
    { 1.0f, 1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },
    { 1.0f,-1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },

    // Side #3 - blue
    {-1.0f, 1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },
    { 1.0f, 1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },
    {-1.0f, 1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },
    { 1.0f, 1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },

    // Side #4 - yellow (red + green)
    {-1.0f,-1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 1.0, 1.0, 0.0, 1.0 ) },
    {-1.0f,-1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 1.0, 0.0, 1.0 ) },
    { 1.0f,-1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 1.0, 1.0, 0.0, 1.0 ) },
    { 1.0f,-1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 1.0, 0.0, 1.0 ) },

    // Side #5 - magenta (red + blue)
    { 1.0f, 1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 1.0, 1.0 ) },
    { 1.0f, 1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 1.0, 1.0 ) },
    { 1.0f,-1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 1.0, 1.0 ) },
    { 1.0f,-1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 1.0, 0.0, 1.0, 1.0 ) },

    // Side #6 - cyan (blue + green)
    {-1.0f, 1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 1.0, 1.0 ) },
    {-1.0f,-1.0f,-1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 1.0, 1.0 ) },
    {-1.0f, 1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 1.0, 1.0 ) },
    {-1.0f,-1.0f, 1.0f,  D3DCOLOR_COLORVALUE( 0.0, 1.0, 1.0, 1.0 ) }
};

//-----------------------------------------------------------------------------
// PROTOTYPES
//-----------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                   LPSTR lpCmdLine, int nCmdShow);
LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void init(void);
void shutDown(void);
void render(void);

//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
int WINAPI WinMain( HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     lpCmdLine,
                    int       nCmdShow )
{
    WNDCLASSEX winClass;
    MSG        uMsg;

    memset(&uMsg,0,sizeof(uMsg));
    
    winClass.lpszClassName = "MY_WINDOWS_CLASS";
    winClass.cbSize        = sizeof(WNDCLASSEX);
    winClass.style         = CS_HREDRAW | CS_VREDRAW;
    winClass.lpfnWndProc   = WindowProc;
    winClass.hInstance     = hInstance;
    winClass.hIcon         = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON);
    winClass.hIconSm       = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON);
    winClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
    winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    winClass.lpszMenuName  = NULL;
    winClass.cbClsExtra    = 0;
    winClass.cbWndExtra    = 0;

    if(!RegisterClassEx( &winClass) )
        return E_FAIL;

    g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", "Direct3D (DX9) - Cube",
                             WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                             0, 0, 640, 480, NULL, NULL, hInstance, NULL );

    if( g_hWnd == NULL )
        return E_FAIL;

    ShowWindow( g_hWnd, nCmdShow );
    UpdateWindow( g_hWnd );

    init();

    while( uMsg.message != WM_QUIT )
    {
        if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
        { 
            TranslateMessage( &uMsg );
            DispatchMessage( &uMsg );
        }
        else
        {
            // Calculate the elapsed time...
            g_dCurrentTime = timeGetTime();
            g_fElpasedTime = (float)((g_dCurrentTime - g_dLastTime) * 0.001);
            g_dLastTime    = g_dCurrentTime;

            render();
        }
    }

    shutDown();

    UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance );

    return uMsg.wParam;
}

//-----------------------------------------------------------------------------
// Name: WindowProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT CALLBACK WindowProc( HWND   hWnd, 
                             UINT   msg, 
                             WPARAM wParam, 
                             LPARAM lParam )
{
    switch( msg )
    {   
        case WM_KEYDOWN:
        {
            switch( wParam )
            {
                case VK_ESCAPE:
                    PostQuitMessage(0);
                    break;
            }
        }
        break;

        case WM_CLOSE:
        {
            PostQuitMessage(0); 
        }
        
        case WM_DESTROY:
        {
            PostQuitMessage(0);
        }
        break;

        default:
        {
            return DefWindowProc( hWnd, msg, wParam, lParam );
        }
        break;
    }

    return 0;
}

//-----------------------------------------------------------------------------
// Name: init()
// Desc: 
//-----------------------------------------------------------------------------
void init( void )
{
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

    D3DDISPLAYMODE d3ddm;

    g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );

    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );

    d3dpp.Windowed               = TRUE;
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat       = d3ddm.Format;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
                          D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                          &d3dpp, &g_pd3dDevice );

    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
    g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

    D3DXMATRIX mProjection;
    D3DXMatrixPerspectiveFovLH( &mProjection, 45.0f, 640.0f / 480.0f, 0.1f, 100.0f );
    g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &mProjection );

    //
    // Create a Vertex Buffer and copy our cube data into it...
    //

    g_pd3dDevice->CreateVertexBuffer( 24*sizeof(CubeVertex),0, D3DFVF_CUBE_VERTEX,
                                      D3DPOOL_DEFAULT, &g_pVertexBuffer, NULL );
    void *pVertices = NULL;

    g_pVertexBuffer->Lock( 0, sizeof(g_cubeVertices), (void**)&pVertices, 0 );
    {
        memcpy( pVertices, g_cubeVertices, sizeof(g_cubeVertices) );
    }
    g_pVertexBuffer->Unlock();
}

//-----------------------------------------------------------------------------
// Name: shutDown()
// Desc: 
//-----------------------------------------------------------------------------
void shutDown( void )
{
    if( g_pVertexBuffer != NULL )
        g_pVertexBuffer->Release(); 

    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}

//-----------------------------------------------------------------------------
// Name: render()
// Desc: 
//-----------------------------------------------------------------------------
void render( void )
{
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
                         D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 );

    g_pd3dDevice->BeginScene();

    //
    // To see our cube better, lets translate it out some and spin it about  
    // each of the three axis of the coordinate system.
    //

    static float fXrot = 0.0f;
    static float fYrot = 0.0f;
    static float fZrot = 0.0f;

    fXrot += (g_fElpasedTime * 10.0f);
    fYrot += (g_fElpasedTime * 25.0f);
    fZrot += (g_fElpasedTime * 50.0f);

    D3DXMATRIX matWorld;
    D3DXMATRIX matTranslation;
    D3DXMATRIX matRotation;

    D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 4.0f );

    D3DXMatrixRotationYawPitchRoll( &matRotation,
                                    D3DXToRadian(fXrot), 
                                    D3DXToRadian(fYrot), 
                                    D3DXToRadian(fZrot) );

    matWorld = matRotation * matTranslation;
    
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    //
    // Now, lets render our cube...
    //

    g_pd3dDevice->SetStreamSource( 0, g_pVertexBuffer, 0, sizeof(CubeVertex) );
    g_pd3dDevice->SetFVF( D3DFVF_CUBE_VERTEX );

    //
    // Note, because each face of the cube is a separate tri-strip, we'll 
    // need to call DrawPrimitive six times to render the whole cube. 
    // Of course, we stored all of the face vertices in the same Vertex 
    // Buffer so we'll need to move the start vertex up with each call.
    //

    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP,  0, 2 ); // Side #1 starts at vertex 0 and has two triangles.
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP,  4, 2 ); // Side #2 starts at vertex 4 and has two triangles.
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP,  8, 2 ); // Side #3 starts at vertex 8 and has two triangles.
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 12, 2 ); // Side #4 starts at vertex 12 and has two triangles.
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 16, 2 ); // Side #5 starts at vertex 16 and has two triangles.
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 20, 2 ); // Side #6 starts at vertex 20 and has two triangles.

    g_pd3dDevice->EndScene();
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
and there's my (attempt of) pb conversion :

Code: Select all

IncludeFile "D3D9.pbi"
;IncludeFile "D3D9Interface.pbi"
OpenLibrary(0,"d3d9.dll")
OpenLibrary(1,"d3dx9d.dll")

Global D3D.IDirect3D9 
Global D3DDevice.IDirect3DDevice9
Global pVertexBuffer.IDirect3DVertexBuffer9 
Global hWnd.l 

D3D = #NULL
D3DDevice = #NULL
pVertexBuffer = #NULL

D3DFVF_CUBE_VERTEX = #D3DFVF_XYZ | #D3DFVF_DIFFUSE
Structure CubeVertex
    x.f
    y.f
    z.f
    color.l  
EndStructure
Dim cubeVertices.CubeVertex(23)

cubeVertices(0)\x=-1 : cubeVertices(0)\y= 1 : cubeVertices(0)\z=-1 : cubeVertices(0)\color=RGB(0,0,255) 
cubeVertices(1)\x= 1 : cubeVertices(1)\y= 1 : cubeVertices(1)\z=-1 : cubeVertices(1)\color=RGB(0,0,255)
cubeVertices(2)\x=-1 : cubeVertices(2)\y=-1 : cubeVertices(2)\z=-1 : cubeVertices(2)\color=RGB(0,0,255)
cubeVertices(3)\x= 1 : cubeVertices(3)\y=-1 : cubeVertices(3)\z=-1 : cubeVertices(3)\color=RGB(0,0,255)
cubeVertices(4)\x=-1 : cubeVertices(4)\y= 1 : cubeVertices(4)\z=-1 : cubeVertices(4)\color=RGB(0,255,0) 
cubeVertices(5)\x=-1 : cubeVertices(5)\y=-1 : cubeVertices(5)\z=-1 : cubeVertices(5)\color=RGB(0,255,0)
cubeVertices(6)\x= 1 : cubeVertices(6)\y= 1 : cubeVertices(6)\z=-1 : cubeVertices(6)\color=RGB(0,255,0)
cubeVertices(7)\x= 1 : cubeVertices(7)\y=-1 : cubeVertices(7)\z=-1 : cubeVertices(7)\color=RGB(0,255,0)
cubeVertices(8)\x=-1 : cubeVertices(8)\y= 1 : cubeVertices(8)\z= 1 : cubeVertices(8)\color=RGB(255,0,0) 
cubeVertices(9)\x= 1 : cubeVertices(9)\y= 1 : cubeVertices(9)\z= 1 : cubeVertices(9)\color=RGB(255,0,0)
cubeVertices(10)\x=-1 : cubeVertices(10)\y= 1 : cubeVertices(10)\z=-1 : cubeVertices(10)\color=RGB(255,0,0)
cubeVertices(11)\x= 1 : cubeVertices(11)\y= 1 : cubeVertices(11)\z=-1 : cubeVertices(11)\color=RGB(255,0,0)
cubeVertices(12)\x=-1 : cubeVertices(12)\y=-1 : cubeVertices(12)\z= 1 : cubeVertices(12)\color=RGB(255,0,255) 
cubeVertices(13)\x=-1 : cubeVertices(13)\y=-1 : cubeVertices(13)\z=-1 : cubeVertices(13)\color=RGB(255,0,255)
cubeVertices(14)\x= 1 : cubeVertices(14)\y=-1 : cubeVertices(14)\z= 1 : cubeVertices(14)\color=RGB(255,0,255)
cubeVertices(15)\x= 1 : cubeVertices(15)\y=-1 : cubeVertices(15)\z=-1 : cubeVertices(15)\color=RGB(255,0,255)
cubeVertices(16)\x= 1 : cubeVertices(16)\y= 1 : cubeVertices(16)\z=-1 : cubeVertices(16)\color=RGB(255,255,0) 
cubeVertices(17)\x= 1 : cubeVertices(17)\y= 1 : cubeVertices(17)\z= 1 : cubeVertices(17)\color=RGB(255,255,0)
cubeVertices(18)\x= 1 : cubeVertices(18)\y=-1 : cubeVertices(18)\z=-1 : cubeVertices(18)\color=RGB(255,255,0)
cubeVertices(19)\x= 1 : cubeVertices(19)\y=-1 : cubeVertices(19)\z= 1 : cubeVertices(19)\color=RGB(255,255,0)
cubeVertices(20)\x=-1 : cubeVertices(20)\y= 1 : cubeVertices(20)\z=-1 : cubeVertices(20)\color=RGB(0,255,255) 
cubeVertices(21)\x=-1 : cubeVertices(21)\y=-1 : cubeVertices(21)\z=-1 : cubeVertices(21)\color=RGB(0,255,255)
cubeVertices(22)\x=-1 : cubeVertices(22)\y= 1 : cubeVertices(22)\z= 1 : cubeVertices(22)\color=RGB(0,255,255)
cubeVertices(23)\x=-1 : cubeVertices(23)\y=-1 : cubeVertices(23)\z= 1 : cubeVertices(23)\color=RGB(0,255,255)


    hWnd = OpenWindow(1, 0, 0, 640, 480, #WS_OVERLAPPEDWINDOW|#PB_Window_ScreenCentered , "DirectX 9 test")
    D3D = CallFunction(0,"Direct3DCreate9",#D3D_SDK_VERSION) 
    D3D = Direct3DCreate9_(#D3D_SDK_VERSION) 
    D3DPP.D3DPRESENT_PARAMETERS
    D3DPP\Windowed = #TRUE
    D3DPP\SwapEffect = #D3DSWAPEFFECT_DISCARD
    D3DPP\BackBufferFormat = #D3DFMT_UNKNOWN 
    D3DPP\EnableAutoDepthStencil = #TRUE
    D3DPP\AutoDepthStencilFormat = #D3DFMT_D16      
    If D3D\CreateDevice(#D3DADAPTER_DEFAULT,#D3DDEVTYPE_HAL,hWnd,#D3DCREATE_SOFTWARE_VERTEXPROCESSING,@D3DPP,@D3DDevice) <> 0 : MessageRequester("Error","Create Device") : EndIf

    D3DDevice\SetRenderState( #D3DRS_LIGHTING, #FALSE )
    D3DDevice\SetRenderState( #D3DRS_ZENABLE, #TRUE )

    mProjection.D3DXMATRIX
    CallFunction(1,"D3DXMatrixPerspectiveFovLH",@mProjection, 45.0, 640/480, 0.1, 100.0 )
    D3DDevice\SetTransform( #D3DTS_PROJECTION, @mProjection )

    Str(D3DDevice\CreateVertexBuffer (24*SizeOf(CubeVertex), 0, D3DFVF_CUBE_VERTEX, #D3DPOOL_DEFAULT, @pVertexBuffer, #NULL))

    *Ptr = 0 
    pVertexBuffer\Lock(0,0, @*Ptr, 0) 
        CopyMemory(@cubeVertices(0), *Ptr, 24*SizeOf(CubeVertex)) 
    pVertexBuffer\Unlock() 
Repeat 
    matWorld.D3DXMATRIX 
    matTranslation.D3DXMATRIX 
    matRotation.D3DXMATRIX 

    D3DDevice\Clear( 0, #NULL, #D3DCLEAR_TARGET | #D3DCLEAR_ZBUFFER,  RGB(150,0,0), 1.0, 0 )
    D3DDevice\BeginScene()  
    CallFunction(1,"D3DXMatrixTranslation",@matTranslation, 0.0, 0.0, 4.0 )
    CallFunction(1,"D3DXMatrixRotationYawPitchRoll", @matRotation, 0.0, 0.0, 0.0 )
    CallFunction(1,"D3DXMatrixMultiply",@matWorld ,@matRotation ,@matTranslation)  ;matWorld = matRotation * matTranslation
    D3DDevice\SetTransform( #D3DTS_WORLD, @matWorld )
    D3DDevice\SetFVF(D3DFVF_CUBE_VERTEX)   
    D3DDevice\SetStreamSource( 0, pVertexBuffer, 0, 16 )

    D3DDevice\DrawPrimitive( #D3DPT_TRIANGLESTRIP,  0, 2 ); // Side #1 starts at vertex 0 and has two triangles.
    D3DDevice\DrawPrimitive( #D3DPT_TRIANGLESTRIP,  4, 2 ); // Side #2 starts at vertex 4 and has two triangles.
    D3DDevice\DrawPrimitive( #D3DPT_TRIANGLESTRIP,  8, 2 ); // Side #3 starts at vertex 8 and has two triangles.
    D3DDevice\DrawPrimitive( #D3DPT_TRIANGLESTRIP, 12, 2 ); // Side #4 starts at vertex 12 and has two triangles.
    D3DDevice\DrawPrimitive( #D3DPT_TRIANGLESTRIP, 16, 2 ); // Side #5 starts at vertex 16 and has two triangles.
    D3DDevice\DrawPrimitive( #D3DPT_TRIANGLESTRIP, 20, 2 ); // Side #6 starts at vertex 20 and has two triangles.
    
    D3DDevice\EndScene()
    D3DDevice\Present( #NULL, #NULL, #NULL, #NULL )   

Until WindowEvent()=#PB_EventCloseWindow Or GetAsyncKeyState_(#VK_ESCAPE)

D3DDevice\Release()
D3D\Release()
CloseLibrary(0)
CloseLibrary(1)
I can't find where's the problem (certainly a stupid thing :))

I have tested the dll importer, and it works fine. It's easy with d3d9.dll, but more complicated with d3dx9d.dll, because there's a lot of functions. Have you made a complete d3dx9d.pbl ?

(traumatic : thank you for your replacement functions, it can be useful.)
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

hi. where can i find and download following needed files?

IncludeFile "D3D9.pbi"
IncludeFile "D3D9Interface.pbi"
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

on codemonger's page : http://www.codemonger.com/Forum/forum_topics.asp?FID=1

Does anyone have the same include files for dx8 ? (I don't know if there's a lot of differences)
Megaborsti
User
User
Posts: 35
Joined: Sat Aug 16, 2003 4:52 pm
Location: Germany

Post by Megaborsti »

I have finally created a DirectX-zip-file, containing the header-files from codemonger, my PB-Libraries and the matching DLLs, and four examples in different difficulties for beginners (one of these examples is my working translation of coma´s c++ example).
Because I have no webspace myself, I mailed this package to darklordz (I do not know who he is, he wrote me a mail that he could upload this DXstuff for me) and I hope he will make it public available very soon. Maybe you should look in the tips´n´tricks section the next days.

Hope this helps you.
Bye, Megaborsti.
I become better!!! :)
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

Megaborsti wrote:Because I have no webspace myself....
already looked at the http://pureproject.reelmedia.org/ site ?
you already get 2 mb as a registered pure-user :)
SPAMINATOR NR.1
Post Reply