Ok so i got that working so now i went back to fix the original programme and its not working abain and its giving the same error
framework.h
#ifndef _FRAMEWORK_ #define _FRAMEWORK_#include <d3d8.h>#include <d3dx8.h>#include <mmsystem.h>#include <stdio.h>#include <tchar.h>#include <D3DUtil.h>#include <DXUtil.h>#include <dinput.h>#define DIRECTINPUT_VERSION 0x0800#define VEC D3DXVECTOR3#define WINDOWED 1#define FULLSCREEN 0INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT );LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );class CFrameWorkApplication{protected: int iAppWidth; int iAppHeight; int iAppBpp; bool bWindowed; int bActive; int bReady; int bHasFocus; HWND Apphwnd; char *ApplicationName; LPDIRECT3D8 d3d; LPDIRECT3DDEVICE8 d3ddevice; LPDIRECT3DSURFACE8 backbuffer; LPDIRECT3DSURFACE8 zbuffer; HRESULT SetDisplayMode(); //Setup up direct 3D HRESULT ReleaseDisplay(); HRESULT ResetDisplay(); HRESULT ToggleFullScreen();public: ~CFrameWorkApplication(); //Desturctor CFrameWorkApplication(); //Consturctor RunApplication(); ShutDownApplication(); SetUpApplication(int width,int height,int bpp,bool screenmode,char *name); LRESULT FrameWorkMsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM lParam );};#endif
framework.cpp
#include "framework.h"static CFrameWorkApplication* pThisApp = NULL;/////////////////////Message handler/////////////////////LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){ return pThisApp->FrameWorkMsgProc(hWnd,msg,wParam,lParam);}////////////////////////Class Constructor ////////////////////////CFrameWorkApplication::CFrameWorkApplication(){ pThisApp = this; /////////////////// //Setup the class// /////////////////// //Spec App bWindowed=false; bActive=false; bReady=false; bHasFocus=false; iAppWidth=NULL; iAppHeight=NULL; iAppBpp=NULL; Apphwnd=NULL; ApplicationName=NULL; d3d=NULL; d3ddevice=NULL; backbuffer=NULL; zbuffer=NULL;}//////////////////////Class Destructor//////////////////////CFrameWorkApplication::~CFrameWorkApplication(){}/////////////////////////////////////////////////This function Creates the Direct 3d Objects/////////////////////////////////////////////////HRESULT CFrameWorkApplication::SetDisplayMode(){ // Create the D3D object. d3d=Direct3DCreate8(D3D_SDK_VERSION); if(d3d==NULL) { MessageBox(Apphwnd,"Can not creat Direct 3D interface","ERROR",MB_OK); return E_FAIL; } D3DDISPLAYMODE d3ddm; if(FAILED(d3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) { MessageBox(Apphwnd,"Can not get display mode","ERROR",MB_OK); return E_FAIL; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) );// if(!bWindowed)// { d3dpp.Windowed = false; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.FullScreen_PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.BackBufferWidth=800;//iAppWidth; d3dpp.BackBufferHeight=600;//iAppHeight;/* } else { d3dpp.Windowed = true; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = TRUE; //if(iAppBpp==16) //{ d3dpp.AutoDepthStencilFormat = D3DFMT_D16; //} d3dpp.BackBufferWidth=iAppWidth; d3dpp.BackBufferHeight=iAppHeight; }*/ HRESULT hr = d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Apphwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddevice ); if(FAILED(hr)) { MessageBox(Apphwnd,"Failed to Create a Direct 3D Device","ERROR",MB_OK); return E_FAIL; } d3ddevice->GetRenderTarget(&backbuffer); d3ddevice->GetDepthStencilSurface(&zbuffer); return S_OK;}//////////////////////////////////////////////////This function Releases the direct 3d Objects//////////////////////////////////////////////////HRESULT CFrameWorkApplication::ReleaseDisplay(){ return S_OK;}////////////////////////////////////////////////This function Resets the direct 3d object ////when the windows has regained focus of ////switched mode ////////////////////////////////////////////////HRESULT CFrameWorkApplication::ResetDisplay(){ return S_OK;}////////////////////////////////////////////////This function switches between full screen////and windowed mode ////////////////////////////////////////////////HRESULT CFrameWorkApplication::ToggleFullScreen(){ return S_OK;}////////////////////////////////////////////////////This function starts the framework application////////////////////////////////////////////////////CFrameWorkApplication::RunApplication(){ //First we must call the init function// if(FAILED(InitApp())) goto ShutDown; //Set the application to active bActive=true; WNDCLASSEX wc={sizeof(WNDCLASSEX), CS_CLASSDC,MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, (HBRUSH)GetStockObject(BLACK_BRUSH), NULL,ApplicationName, NULL }; RegisterClassEx( &wc ); // Create the application's window Apphwnd = CreateWindow( ApplicationName,ApplicationName, WS_EX_TOPMOST, 50, 50, iAppWidth+8, iAppHeight+34, GetDesktopWindow(), NULL, wc.hInstance, NULL); if(!Apphwnd) { // MessageBox(Apphwnd,"Failed to create the Window","ERROR",MB_OK); // goto ShutDown; } // Show the window ShowWindow( Apphwnd, SW_SHOWDEFAULT ); UpdateWindow( Apphwnd ); if(FAILED(SetDisplayMode())) goto ShutDown; bReady=true; //Now lets get the Application loop running MSG msg; ZeroMemory( &msg, sizeof(msg) ); while(msg.message!=WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else if(bHasFocus && bActive) { } }ShutDown: //If we get here then the app is closing ShutDownApplication(); UnregisterClass("ApplicationName", wc.hInstance );}///////////////////////////////////////////////////////This function shutsdown the framework application///////////////////////////////////////////////////////CFrameWorkApplication::ShutDownApplication(){}//////////////////////////////////////////////////////This function is call directly after you declair////the framework because is sets the display params//////////////////////////////////////////////////////CFrameWorkApplication::SetUpApplication(int width,int height,int bpp,bool screenmode,char *name){ iAppWidth=width; iAppHeight=height; iAppBpp=bpp; bWindowed=screenmode; ApplicationName = name;}/////////////////////////////////////////////The message handler for the application/////////////////////////////////////////////LRESULT CFrameWorkApplication::FrameWorkMsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM lParam ){ switch( uMsg ) { case WM_DESTROY: PostQuitMessage( 0 ); return 0; break; } return DefWindowProc( Apphwnd, uMsg, wParam, lParam );}
main.cpp
#include "framework.h"INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ){ CFrameWorkApplication App; App.SetUpApplication(800,600,16,FULLSCREEN,"TestApp"); App.RunApplication(); //The app has closed so good buy return 0;}
[edited by - kapru on December 16, 2003 8:19:29 PM]