orache
چهارشنبه 22 خرداد 1392, 21:17 عصر
سلام من خیلی گیج شدم دقیقا نمیدونم windows.h چیه برای کد نویسی صفحه ی انجین از این استفاده میکنن حتی تو دایرکت ایکس از کد های هدر windows.h استفاده میکنن متاسفانه نمیدونم از کجا کد ها و تابع هاشو یاد بگیرم اصلا اموزشی براش هست؟؟ من متاسفانه نمیتونم از این جلوتر برم باید این windows.h رو یاد بگیرم تا بتونم یک صفحه برای دایرکت ایکس یا انجین درست کنم
لطفا یک اموزش معرفی کنین ممنون
مثلا این کد همش از توابع ویندوز دات اچ هست نگاه کنین
#include "d3d9.h"
#include "d3dx9.h"
class Engine
{
public:
void Init(HWND hwnd);
void BeginRender();
void EndRender();
private:
LPDIRECT3D9 d3d9;
LPDIRECT3DDEVICE9 device;
int w ;
int h ;
};#include "Engine.h"
void Engine::Init(HWND hwnd)
{
w = 640; h = 480;
d3d9 = Direct3DCreate9( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS pp;
ZeroMemory( &pp, sizeof(pp) );
pp.BackBufferWidth = w;
pp.BackBufferHeight = h;
pp.Windowed = TRUE;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pp.BackBufferFormat = D3DFMT_UNKNOWN;
d3d9->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hw nd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&device );
}
void Engine::BeginRender()
{
device->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
}
void Engine::EndRender()
{
device->Present(NULL,NULL,NULL,NULL);
}#include <windows.h>
#include "resource.h"
#include "Engine.h"
//--------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
Engine *e = new Engine();
//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
return 0;
// Main message loop
MSG msg = {0};
while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return (int) msg.wParam;
}
//--------------------------------------------------------------------------------------
// Register class and create window
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
{
// Register class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"TutorialWindowClass";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_TUTORIAL1);
if( !RegisterClassEx(&wcex) )
return E_FAIL;
// Create window
g_hInst = hInstance;
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
g_hWnd = CreateWindow( L"TutorialWindowClass", L"Create A Simple Engine With DirectX 9.0c", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
if( !g_hWnd )
return E_FAIL;
ShowWindow( g_hWnd, nCmdShow );
e->Init(g_hWnd);
return S_OK;
}
//--------------------------------------------------------------------------------------
// Called every time the application receives a message
//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
e->BeginRender();
e->EndRender();
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
لطفا یک اموزش معرفی کنین ممنون
مثلا این کد همش از توابع ویندوز دات اچ هست نگاه کنین
#include "d3d9.h"
#include "d3dx9.h"
class Engine
{
public:
void Init(HWND hwnd);
void BeginRender();
void EndRender();
private:
LPDIRECT3D9 d3d9;
LPDIRECT3DDEVICE9 device;
int w ;
int h ;
};#include "Engine.h"
void Engine::Init(HWND hwnd)
{
w = 640; h = 480;
d3d9 = Direct3DCreate9( D3D_SDK_VERSION );
D3DPRESENT_PARAMETERS pp;
ZeroMemory( &pp, sizeof(pp) );
pp.BackBufferWidth = w;
pp.BackBufferHeight = h;
pp.Windowed = TRUE;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pp.BackBufferFormat = D3DFMT_UNKNOWN;
d3d9->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hw nd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&device );
}
void Engine::BeginRender()
{
device->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
}
void Engine::EndRender()
{
device->Present(NULL,NULL,NULL,NULL);
}#include <windows.h>
#include "resource.h"
#include "Engine.h"
//--------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
Engine *e = new Engine();
//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
return 0;
// Main message loop
MSG msg = {0};
while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return (int) msg.wParam;
}
//--------------------------------------------------------------------------------------
// Register class and create window
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
{
// Register class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"TutorialWindowClass";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_TUTORIAL1);
if( !RegisterClassEx(&wcex) )
return E_FAIL;
// Create window
g_hInst = hInstance;
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
g_hWnd = CreateWindow( L"TutorialWindowClass", L"Create A Simple Engine With DirectX 9.0c", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
if( !g_hWnd )
return E_FAIL;
ShowWindow( g_hWnd, nCmdShow );
e->Init(g_hWnd);
return S_OK;
}
//--------------------------------------------------------------------------------------
// Called every time the application receives a message
//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
e->BeginRender();
e->EndRender();
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}