-
Dec 27th, 2011, 05:56 PM
#41
Re: DirectX 2D Tutorials For VB5/VB6/VB.NET
Also coming soon, I'm writing C# DirectX9 tutorials as well.
-
Jan 2nd, 2012, 11:08 AM
#42
Re: DirectX 2D Tutorials For VB5/VB6/VB.NET
I've decided to go truely Massive and plan to dedicate my tutorials to a website with my own domain name which I haven't created yet. The following languages will be covered (and I'm not kidding):
- Visual C++ 6.0 - DirectX7 / DirectX8 / DirectX9
- Visual C++ 2008 - DirectX9
- Visual C++ 2010 - DirectX9
- Visual C# 2008 - DirectX9
- Visual C# 2010 - DirectX9
- Visual Basic 6.0 - DirectX7 / DirectX8
- Visual Basic.Net 2008 - DirectX9
- Visual Basic.Net 2010 - DirectX9
I have tons of tutorials made already in all these languages, with all of em being consistant in structure, variable names, functions, etc. I will also have a Word document explaining step by step on how to initialize DirectX to your IDE in all these languages. It's been a lot of hard work and there are no plans yet to include DirectX10 and DirectX11 or XNA but if I decide to, I'll include it. Also there are no plans whether I should include Visual Studio.Net 2003 / 2005, because the damn links have been removed by MS. So your wisest choice is to upgrade to VS 2008 or VS 2010. Each of these tutorials will be simplified and only have one file to work with. So there won't be no header files or anything in C++. Just one Main.cpp. C# will only have one Main.cs. VB6 only one Main.frm, etc. And each language will consist of a ton of tutorials to cover, but no idea on how many for each just yet, in both 2D and 3D, but not limited to just DirectDraw 2D, it'll have Direct3D 2D as well.
When I said consistantcy, I meant it. Compare these 2 languages for example:
c++ Code:
#include <windows.h> #include <d3d8.h> struct CUSTOM_VERTEX { float X, Y, Z, RHW; DWORD Color; }; #define CUSTOM_VERTEX_FORMAT (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) const D3DFORMAT COLOR_DEPTH_16_BIT = D3DFMT_R5G6B5; const D3DFORMAT COLOR_DEPTH_24_BIT = D3DFMT_A8R8G8B8; const D3DFORMAT COLOR_DEPTH_32_BIT = D3DFMT_X8R8G8B8; LPDIRECT3D8 Direct3D = NULL; LPDIRECT3DDEVICE8 Direct3D_Device = NULL; D3DDISPLAYMODE Display_Mode; D3DPRESENT_PARAMETERS Direct3D_Window; HWND hWnd; MSG msg; bool Fullscreen_Enabled; bool Running; CUSTOM_VERTEX Vertex_List[3]; CUSTOM_VERTEX Create_Custom_Vertex(); void Create_Polygon(); void Draw_Polygon(); void Render(); void Game_Loop(); void Main(); void Shutdown(); void DirectX8_Initialize(); LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); CUSTOM_VERTEX Create_Custom_Vertex(float X, float Y, float Z, float RHW, DWORD Color) { CUSTOM_VERTEX Vertex; Vertex.X = X; Vertex.Y = Y; Vertex.Z = Z; Vertex.RHW = RHW; Vertex.Color = Color; return Vertex; } void DirectX8_Initialize() { Direct3D = Direct3DCreate8(D3D_SDK_VERSION); memset(&Direct3D_Window, 0, sizeof(D3DPRESENT_PARAMETERS)); if (Fullscreen_Enabled == true) { Display_Mode.Width = 800; Display_Mode.Height = 600; Display_Mode.Format = COLOR_DEPTH_16_BIT; Direct3D_Window.Windowed = FALSE; Direct3D_Window.BackBufferCount = 1; Direct3D_Window.BackBufferWidth = Display_Mode.Width; Direct3D_Window.BackBufferHeight = Display_Mode.Height; Direct3D_Window.hDeviceWindow = hWnd; } else { Direct3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &Display_Mode); Direct3D_Window.Windowed = TRUE; } Direct3D_Window.SwapEffect = D3DSWAPEFFECT_COPY; Direct3D_Window.BackBufferFormat = Display_Mode.Format; Direct3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &Direct3D_Window, &Direct3D_Device); } void Create_Polygon() { Vertex_List[0] = Create_Custom_Vertex(0, 0, 0, 1, D3DCOLOR_RGBA(255, 255, 255, 255)); Vertex_List[1] = Create_Custom_Vertex(100, 0, 0, 1, D3DCOLOR_RGBA(255, 255, 255, 255)); Vertex_List[2] = Create_Custom_Vertex(0, 100, 0, 1, D3DCOLOR_RGBA(255, 255, 255, 255)); Vertex_List[3] = Create_Custom_Vertex(100, 100, 0, 1, D3DCOLOR_RGBA(255, 255, 255, 255)); } void Draw_Polygon() { Direct3D_Device->SetVertexShader(CUSTOM_VERTEX_FORMAT); Direct3D_Device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertex_List, sizeof(CUSTOM_VERTEX)); } void Render() { Direct3D_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 1.0f, 0); // clear frame Direct3D_Device->BeginScene(); Create_Polygon(); Draw_Polygon(); Direct3D_Device->EndScene(); Direct3D_Device->Present(NULL, NULL, NULL, NULL); } void Game_Loop() { while (Running == true) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE) > 0) { if (WM_QUIT == msg.message) break; TranslateMessage (&msg); DispatchMessage (&msg); } else Render(); } } void Main() { DirectX8_Initialize(); Running = true; } void Shutdown() { Running = false; Direct3D_Device->Release(); Direct3D->Release(); PostQuitMessage (0); HANDLE Process; Process = OpenProcess(PROCESS_ALL_ACCESS , true , GetCurrentProcessId()); TerminateProcess(Process , 0); } int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow) { WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC, WindowProcedure, 0, 0, hInstance, NULL, LoadCursor(NULL, IDC_ARROW), NULL, NULL, "DX_TUT", NULL}; RegisterClassEx(&wc); if (MessageBox(hWnd, "Click Yes to go to fullscreen (Recommended)", "", MB_ICONQUESTION | MB_YESNO) == IDYES) Fullscreen_Enabled = true; if (Fullscreen_Enabled == true) hWnd = CreateWindowEx (0, "DX_TUT", "DirectX Tutorial", WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 330, 250, HWND_DESKTOP, NULL, hInstance, NULL); else hWnd = CreateWindowEx (0, "DX_TUT", "DirectX Tutorial", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 330, 250, HWND_DESKTOP, NULL, hInstance, NULL); ShowWindow (hWnd, nCmdShow); Main(); Game_Loop(); return msg.wParam; } LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DESTROY: Shutdown(); break; case WM_KEYDOWN: if(wParam == VK_ESCAPE) { DestroyWindow(hWnd); return(0); } default: return DefWindowProc (hWnd, msg, wParam, lParam); } return 0; }
vb Code:
Option Explicit Private Type CUSTOM_VERTEX X As Single Y As Single Z As Single RHW As Single Color As Long End Type Private Const COLOR_DEPTH_16_BIT As Long = D3DFMT_R5G6B5 Private Const COLOR_DEPTH_24_BIT As Long = D3DFMT_A8R8G8B8 Private Const COLOR_DEPTH_32_BIT As Long = D3DFMT_X8R8G8B8 Private Const CUSTOM_VERTEX_FORMAT As Long = D3DFVF_XYZRHW Or D3DFVF_DIFFUSE Private DX As DirectX8 Private Direct3D As Direct3D8 Private Direct3D_Device As Direct3DDevice8 Private Display_Mode As D3DDISPLAYMODE Private Direct3D_Window As D3DPRESENT_PARAMETERS Private Fullscreen_Enabled As Boolean Private Running As Boolean Private Vertex_List(3) As CUSTOM_VERTEX Private Function Create_Custom_Vertex(X As Single, Y As Single, Z As Single, RHW As Single, Color As Long) As CUSTOM_VERTEX Create_Custom_Vertex.X = X Create_Custom_Vertex.Y = Y Create_Custom_Vertex.Z = Z Create_Custom_Vertex.RHW = RHW Create_Custom_Vertex.Color = Color End Function Private Sub DirectX_Initialize() Set DX = New DirectX8 Set Direct3D = DX.Direct3DCreate() If Fullscreen_Enabled = True Then Display_Mode.Width = 800 Display_Mode.Height = 600 Display_Mode.Format = COLOR_DEPTH_16_BIT Direct3D_Window.Windowed = False Direct3D_Window.BackBufferCount = 1 Direct3D_Window.BackBufferWidth = Display_Mode.Width Direct3D_Window.BackBufferHeight = Display_Mode.Height Direct3D_Window.hDeviceWindow = frmMain.hWnd Else Direct3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, Display_Mode Direct3D_Window.Windowed = True End If Direct3D_Window.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC Direct3D_Window.BackBufferFormat = Display_Mode.Format Set Direct3D_Device = Direct3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, Direct3D_Window) End Sub Private Sub Create_Polygon() Vertex_List(0) = Create_Custom_Vertex(0, 0, 0, 1, D3DColorRGBA(255, 255, 255, 255)) Vertex_List(1) = Create_Custom_Vertex(100, 0, 0, 1, D3DColorRGBA(255, 255, 255, 255)) Vertex_List(2) = Create_Custom_Vertex(0, 100, 0, 1, D3DColorRGBA(255, 255, 255, 255)) Vertex_List(3) = Create_Custom_Vertex(100, 100, 0, 1, D3DColorRGBA(255, 255, 255, 255)) End Sub Private Sub Draw_Polygon() Direct3D_Device.SetVertexShader CUSTOM_VERTEX_FORMAT Direct3D_Device.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, Vertex_List(0), Len(Vertex_List(0)) End Sub Private Sub Render() Direct3D_Device.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorRGBA(0, 0, 0, 255), 1#, 0 Direct3D_Device.BeginScene Create_Polygon Draw_Polygon Direct3D_Device.EndScene Direct3D_Device.Present ByVal 0, ByVal 0, 0, ByVal 0 End Sub Private Sub Game_Loop() Do While Running = True Render DoEvents Loop End Sub Private Sub Main() If MsgBox("Click Yes to go to fullscreen (Recommended)", vbQuestion Or vbYesNo, "Options") = vbYes Then Fullscreen_Enabled = True With Me .Show .Caption = "DirectX Tutorial" If Fullscreen_Enabled = True Then .BorderStyle = vbBSNone End With DirectX_Initialize Running = True Game_Loop End Sub Private Sub Shut_Down() Running = False Set Direct3D_Device = Nothing Set Direct3D = Nothing Set DX = Nothing Unload Me End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyEscape Then Shut_Down End Sub Private Sub Form_Load() Main End Sub Private Sub Form_Unload(Cancel As Integer) Shut_Down End Sub
Last edited by Jacob Roman; Jan 2nd, 2012 at 11:49 AM.
-
Jan 11th, 2012, 12:48 AM
#43
Re: DirectX 2D Tutorials For VB5/VB6/VB.NET
Its official. DirectX7 - DirectX11 will be covered with whatever languages support them, along with XNA. I will be covering 2D, 3D, and DirectDraw. The websites up www.massivedirectxtutorial.com but is still undergoing construction since the sites relatively new. I will be covering every aspect of directX possible that no other tutorial has dared to cover, including handling the dreaded Alt Tab issue, which I have completed in C++, C#, VB6, and VB.Net. I hope for this to be the greatest DirectX tutorial online. Its been a hell of a learning process for me and I want to share it with the world.
-
Dec 11th, 2020, 01:52 AM
#44
Banned
Re: DirectX 2D Tutorials For VB5/VB6/VB.NET
Please allow me to translate your tutorial and publish it. Your name will be signed, but there is no money for you. Whether you agree or not, I will translate. This is your pleasure, you must accept it! (PS: I am a campus security from Greater China)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|