Accueil > > > PLEIN ECRAN + AFFICHAGE DE TEXTE
PLEIN ECRAN + AFFICHAGE DE TEXTE
Information sur la source
Description
Necessite les librairies de Direct3D de DirectX8. telechargables gratuitement sur le site de microsoft avec la SDK DirectX8.
Source
- /*** 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;
- }
-
-
/*** 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
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYSTECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYS par ROMELARD Fabrice
Speakers : Lionel Limozin et Alain Marty La session commence par une découverte de SharePoint à travers la mise en place d'un environnement SharePoint pour la gestion des Sessions animées par BeWise. Le besoin est très ba...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice PERSPECTIVE 3.0 POUR SILVERLIGHT 5.0PERSPECTIVE 3.0 POUR SILVERLIGHT 5.0 par odewit
Je viens de publier la version 3.0 de Perspective pour Silverlight, qui regroupe un portage sous Silverlight 5.0 des fonctionnalités de Perspective 2.0, le framework 3D de haut-niveau introduit récemment et de nouveaux exemples de code. En voici la li...
Cliquez pour lire la suite de l'article par odewit TECHDAYS PARIS 2012 : TOP 10 DES BEST PRACTICES POUR SQL SERVERTECHDAYS PARIS 2012 : TOP 10 DES BEST PRACTICES POUR SQL SERVER par ROMELARD Fabrice
Speaker : Nadia Ben El Kadi Configuration machine La session commence par la toute première question à se poser lors de la mise en place d'environnement SQL Server, la configuration des machines : Type de mac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : KINECT + OFFICE 365 UN BON GESTE POUR VOTRE SITECHDAYS PARIS 2012 : KINECT + OFFICE 365 UN BON GESTE POUR VOTRE SI par ROMELARD Fabrice
Speakers : Fabrice Barbin, Samuel Blanchard, Julien Lo Presti Titre Prometteur et attractif invitant à voir comment lier le composant ludique Kinect dans le cadre d'une structure IT classique, notamment au travers de la plat...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE DU PREMIER JOURTECHDAYS PARIS 2012 : PLEINIèRE DU PREMIER JOUR par ROMELARD Fabrice
KeyNotes du premier jour pour les développeurs. La session est principalement axée sur une des principales directions prise par Microsoft à travers tous ses nouveaux produits : Cloud privé ou public (Solution Azure) ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : C++ RE : C++ par louis14
Cliquez pour lire la suite par louis14 C++ C++ par yesoun1
Cliquez pour lire la suite par yesoun1 OPNETOPNET par hth21
Cliquez pour lire la suite par hth21
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|