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
L'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIESL'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIES par odewit
La tendance est aux interfaces naturelles (NUI), et le keynote de Bill Buxton au MIX l'a bien souligné.
La charte graphique et ergonomique de Windows Phone 7 a donc été entièrement repensée en vue d'obtenir un maximum d'efficacité sur ce point. En re...
Cliquez pour lire la suite de l'article par odewit COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|