Plein ecran + affichage de texte

Description

Necessite les librairies de Direct3D de DirectX8.
telechargables gratuitement sur le site de microsoft avec la SDK DirectX8.

Source / Exemple :


/*** Lightness1024! ProgrammatO 01/02/2001 17:38:31 ***

      • Base de programme Directx8 plein ecran ***/
#include <d3d8.h> #include <D3dx8core.h> #ifdef UNICODE #define _tWinMain wWinMain #else #define _tWinMain WinMain #endif // Variables globales: LPDIRECT3D8 g_pD3D = NULL; // pour faire l'objet d3d8 LPDIRECT3DDEVICE8 g_pd3dDevice = NULL; // le materiel de rendu LPDIRECT3DVERTEXBUFFER8 g_pVB = NULL; // la zone des vertices (non utilisé encore) // Initialisation de Direct3D HRESULT InitD3D( HWND hWnd ) { // Create the D3D object, which is needed to create the D3DDevice. if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) ) return E_FAIL; // Get the current desktop display mode D3DDISPLAYMODE d3ddm; d3ddm.Width = 1024; d3ddm.Height = 768; d3ddm.Format = D3DFMT_R5G6B5; d3ddm.RefreshRate = 0; // Au cas où on veut détecter les paramètres courants: /*if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) return E_FAIL;*/ D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = FALSE; d3dpp.BackBufferWidth = 1024; d3dpp.BackBufferHeight = 768; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.hDeviceWindow = hWnd; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; d3dpp.BackBufferCount = 1; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp.EnableAutoDepthStencil = FALSE; //d3dpp.AutoDepthStencilFormat = D3DFMT_D16; // software : D3DDEVTYPE_REF if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) { return E_FAIL; } // c bon // le debut de l'initialisation du vertex buffer //if (FAILED (g_pd3dDevice->CreateVertexBuffer (3, return S_OK; } // Nettoie tout le bordel VOID Cleanup() { if( g_pd3dDevice != NULL) g_pd3dDevice->Release(); if( g_pD3D != NULL) g_pD3D->Release(); } // Calcul du rendu VOID Render() { if( NULL == g_pd3dDevice ) return; LPD3DXFONT pD3DXFont; LOGFONT lf; ZeroMemory (&lf, sizeof(LOGFONT)); lf.lfHeight = 200; lf.lfWeight = 45; if (FAILED (D3DXCreateFontIndirect(g_pd3dDevice, &lf, &pD3DXFont))) return; RECT rct; rct.left = 0; rct.top = 0; rct.bottom = 768; rct.right = 1024; // Clear the backbuffer g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(128,128,128), 1.0f, 0 ); // Begin the scene g_pd3dDevice->BeginScene(); // Trucs a tracer: pD3DXFont->DrawText (TEXT("hello world"), -1, &rct, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(255, 255, 255)); // 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; case WM_PAINT: Render(); ValidateRect( hWnd, NULL ); return 0; } return DefWindowProc( hWnd, msg, wParam, lParam ); } //----------------------------------------------------------------------------- // Name: WinMain() // Desc: The application's entry point //----------------------------------------------------------------------------- INT WINAPI _tWinMain( HINSTANCE /*hInst*/, HINSTANCE, LPTSTR, INT ) { // Register the window class WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, TEXT("D3D Tutorial"), NULL }; RegisterClassEx( &wc ); // Create the application's window HWND hWnd = CreateWindow( TEXT("D3D Tutorial"), TEXT("Essai"), WS_OVERLAPPEDWINDOW, 0, 0, 1024, 768, GetDesktopWindow(), NULL, wc.hInstance, NULL ); // Initialize Direct3D if( SUCCEEDED( InitD3D( hWnd ) ) ) { // Show the window ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); // Enter the message loop MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } // Clean up everything and exit the app Cleanup(); UnregisterClass( TEXT("D3D Tutorial"), wc.hInstance ); return 0; }

Conclusion :


langage C++
le projet pour MS VC++ 6.0 est dans le ZIP (workspace) avec executable compilé en Release pour Win32.
le script de compilation est inscrit dans le log (.plg)

pour infos: lightness1024@aol.com

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.