• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
falcon93

Draw a Textured Quad

10 posts in this topic

Hello everyone!

I'm trying to draw a textured quad made from 4 vertices using DirectX9. I've followed some tutorials but it simply wont work. I've pasted the code below and I would appreciate it very much if someone could look through it and help me.

I know that the code should be splitted up into methods and classes, but before i do that I want to keep it as simple as possible and be able to see and learn the entire process.

What i want this code to do is to simply draw my quad with a texture on it. Could anyone please help me?

My current code (I've also attached the project):

[CODE]
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>

#define FULLSCREEN FALSE
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 800

#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

const DWORD D3DFVF_TLVERTEX = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;

struct TLVERTEX { float x, y, z; float rhw; D3DCOLOR color; float u, v; };

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 vertexBuffer;
D3DPRESENT_PARAMETERS d3dpp;
LPDIRECT3DTEXTURE9 d3dTexture;
TLVERTEX* vertices;

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
HRESULT WINAPI D3DXCreateTextureFromFile(LPDIRECT3DDEVICE9 pDevice, LPCTSTR pSrcFile, LPDIRECT3DTEXTURE9 *ppTexture);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;
MSG msg;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = L"WindowClass";
RegisterClassEx(&wc);
if (FULLSCREEN)
{
hWnd = CreateWindowEx(NULL, L"WindowClass", L"Window 1", WS_EX_TOPMOST | WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL);
}
else
{
hWnd = CreateWindowEx(NULL, L"WindowClass", L"Window 1", WS_OVERLAPPEDWINDOW, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL);
}
ShowWindow(hWnd, nCmdShow);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = !FULLSCREEN;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3d -> CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
d3ddev -> CreateVertexBuffer(sizeof(TLVERTEX) * 4, NULL, D3DFVF_TLVERTEX, D3DPOOL_MANAGED, &vertexBuffer, NULL);
vertexBuffer->Lock(0, 0, (void**)&vertices, NULL);
vertices[0].x = 0.0F;
vertices[0].y = 0.0F;
vertices[0].z = 0.0F;
vertices[0].u = 0.0F;
vertices[0].v = 0.0F;
vertices[0].rhw = 1.0F;
vertices[0].color = D3DCOLOR_ARGB(255, 255, 255, 255);
vertices[0].x = 64.0F;
vertices[0].y = 0.0F;
vertices[0].z = 0.0F;
vertices[0].u = 1.0F;
vertices[0].v = 0.0F;
vertices[0].rhw = 1.0F;
vertices[0].color = D3DCOLOR_ARGB(255, 255, 255, 255);
vertices[0].x = 0.0F;
vertices[0].y = 64.0F;
vertices[0].z = 0.0F;
vertices[0].u = 0.0F;
vertices[0].v = 1.0F;
vertices[0].rhw = 1.0F;
vertices[0].color = D3DCOLOR_ARGB(255, 255, 255, 255);
vertices[0].x = 64.0F;
vertices[0].y = 64.0F;
vertices[0].z = 0.0F;
vertices[0].u = 1.0F;
vertices[0].v = 1.0F;
vertices[0].rhw = 1.0F;
vertices[0].color = D3DCOLOR_ARGB(255, 255, 255, 255);
vertexBuffer->Unlock();
VOID* pVoid;

vertexBuffer -> Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertices, sizeof(vertices));
vertexBuffer -> Unlock();
D3DXCreateTextureFromFile(d3ddev, L"ParticleSmokeCloud64x64.png", &d3dTexture);
while (TRUE)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage (&msg);
}
if (msg.message == WM_QUIT) break;
d3ddev -> Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);
d3ddev -> BeginScene();
d3ddev -> SetRenderState(D3DRS_LIGHTING, FALSE);
d3ddev -> SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
d3ddev -> SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d3ddev -> SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
d3ddev -> SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
d3ddev -> SetTexture (0, d3dTexture);
d3ddev -> SetVertexShader(NULL);
d3ddev -> SetFVF(D3DFVF_TLVERTEX);
d3ddev -> SetStreamSource(0, vertexBuffer, 0, sizeof(TLVERTEX));
d3ddev -> DrawPrimitive (D3DPT_TRIANGLEFAN, 0, 2);
d3ddev -> EndScene();
d3ddev -> Present(NULL, NULL, NULL, NULL);
}
d3ddev -> Release();
d3d -> Release();
return msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY: PostQuitMessage(0); return 0; break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
[/CODE] Edited by falcon93
0

Share this post


Link to post
Share on other sites
i don't know directx, but i dont see any viewport setting, so z = 0.0 might be invalid
have you checked for errors? in opengl you have a command called glGetError() which you can use to check the validity of your calls

second, do you even have a valid directx context opened? i see you opening the window in software mode
then you start making a vertex buffer, the texture and finally you render it all

i think i would guess that you don't have a valid viewport
a viewport is defined as a region of your window that you draw on

second, you'll need to initialize how you wish to render 3D (it's defined as a 4x4 matrix)
the typical frustums are ortographic (2D-ish), and perspective frustum (3D-ish) [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
so, maybe you'll need to check out a tutorial on the various ways you can represent 3d!

if, however directx has a default viewport and frustum, perhaps z = 0.0 is the problem Edited by Kaptein
0

Share this post


Link to post
Share on other sites
I've tried to rewrite everything, so now it atleast appears a quad. However, the quad isn't textured but instead some sort of a gradient with black and red.

I guess that I don't have to set up any veiwport, otherways the quad itself wouldn't appear, right? Any other ideas? I've pasted the new code below

[CODE]
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>

#define FULLSCREEN FALSE
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 800

#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

#define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 v_buffer;
LPDIRECT3DTEXTURE9 d3dtex;
D3DPRESENT_PARAMETERS d3dpp;

struct CUSTOMVERTEX { float X, Y, Z, RHW, U, V; DWORD COLOR; };

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;
MSG msg;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = L"WindowClass";
RegisterClassEx(&wc);
if (FULLSCREEN)
{
hWnd = CreateWindowEx(NULL, L"WindowClass", L"Window 1", WS_EX_TOPMOST | WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL);
}
else
{
hWnd = CreateWindowEx(NULL, L"WindowClass", L"Window 1", WS_OVERLAPPEDWINDOW, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL);
}
ShowWindow(hWnd, nCmdShow);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = !FULLSCREEN;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3d -> CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
D3DXCreateTextureFromFile(d3ddev, L"ParticleSmokeCloud64x64", &d3dtex);
struct CUSTOMVERTEX vertices[] =
{
{ 10.0f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
{ 110.0f, 10.0f, 0.0f, 1.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), },
{ 10.0f, 110.0f, 0.0f, 1.0f, 0.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },
{ 110.0f, 110.0f, 0.0f, 1.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 255), },
};
d3ddev -> CreateVertexBuffer(4 * sizeof(CUSTOMVERTEX), NULL, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL);
VOID* pVoid;
v_buffer -> Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertices, sizeof(vertices));
v_buffer -> Unlock();
while (TRUE)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage (&msg);
}
if (msg.message == WM_QUIT) break;
d3ddev -> Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);

d3ddev -> BeginScene();
d3ddev -> SetFVF(CUSTOMFVF);

d3ddev -> SetTexture(0, d3dtex);
d3ddev -> SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
d3ddev -> DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
d3ddev -> EndScene();
d3ddev -> Present(NULL, NULL, NULL, NULL);
}
v_buffer -> Release();
d3ddev -> Release();
d3d -> Release();
return msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY: PostQuitMessage(0); return 0; break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
[/CODE]
0

Share this post


Link to post
Share on other sites
I see that you are not doing any error checking. I realize you're a beginner but it can help a lot. Most DirectX functions return an error value if they fail. You should check for that :)

I believe you forgot the texture file extension in this line:
D3DXCreateTextureFromFile(d3ddev, L"ParticleSmokeCloud64x64", &d3dtex);
1

Share this post


Link to post
Share on other sites
Thanks for your reply Waaayoff. I've added the file extension, ".png". I'll look deeper into error checking, while I do that; I've done some minor chages to the code again, and there's actually something appearing on the screen now, however, the texture just looks strange.

It's supposed to be a small cloud:
[url=http://postimage.org/][img]http://s16.postimage.org/lalw86mfl/Image.png[/img][/url]

But instead this is showing up:
[url=http://postimage.org/image/xqim1xfrl/][img]http://s16.postimage.org/xqim1xfrl/Window.jpg[/img][/url]


Current code below (error checking coming soon):

[CODE]
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>

#define FULLSCREEN FALSE
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 800

#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

#define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_TEX1)

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 v_buffer;
LPDIRECT3DTEXTURE9 d3dtex;
D3DPRESENT_PARAMETERS d3dpp;

struct CUSTOMVERTEX { float X, Y, Z, RHW, U, V; };

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;
MSG msg;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = L"WindowClass";
RegisterClassEx(&wc);
if (FULLSCREEN)
{
hWnd = CreateWindowEx(NULL, L"WindowClass", L"Window 1", WS_EX_TOPMOST | WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL);
}
else
{
hWnd = CreateWindowEx(NULL, L"WindowClass", L"Window 1", WS_OVERLAPPEDWINDOW, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL);
}
ShowWindow(hWnd, nCmdShow);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = !FULLSCREEN;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3d -> CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
D3DXCreateTextureFromFile(d3ddev, L"ParticleSmokeCloud64x64.png", &d3dtex);
struct CUSTOMVERTEX vertices[] =
{
{ 10.0f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, },
{ 110.0f, 10.0f, 0.0f, 1.0f, 1.0f, 0.0f, },
{ 10.0f, 110.0f, 0.0f, 1.0f, 0.0f, 1.0f, },
{ 110.0f, 110.0f, 0.0f, 1.0f, 1.0f, 1.0f, },
};
d3ddev -> CreateVertexBuffer(4 * sizeof(CUSTOMVERTEX), NULL, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL);
VOID* pVoid;
v_buffer -> Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertices, sizeof(vertices));
v_buffer -> Unlock();
while (TRUE)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage (&msg);
}
if (msg.message == WM_QUIT) break;
d3ddev -> Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);

d3ddev -> BeginScene();
d3ddev -> SetRenderState( D3DRS_LIGHTING, TRUE);
d3ddev -> SetTexture(0, d3dtex);
d3ddev -> SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
d3ddev -> SetFVF(CUSTOMFVF);

d3ddev -> DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
d3ddev -> EndScene();
d3ddev -> Present(NULL, NULL, NULL, NULL);
}
v_buffer -> Release();
d3ddev -> Release();
d3d -> Release();
return msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY: PostQuitMessage(0); return 0; break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
[/CODE]
0

Share this post


Link to post
Share on other sites
If you don't mind me asking, why are you learning DirectX9...an "ancient" DirectX API from circa 2002? Why not start learning DirectX10 and/or 11? I actually think 10 and 11 are a lot easier to work with as they don't suffer from 9's technical flaws and bugs. They also share the common DXGI layer which encapsulates and simplifies dealing with graphics hardware.

It would also help you a LOT if you separated your game/scene code from the Windows app code. In other words, write a new class called "Game" or "Scene" and let it handle the initialization of DirectX and the drawing of your 3D scene. It will make editing and debugging your code 10,000% easier because things will be logically separated and much neater. Besides, you need to learn good software engineering practices such as encapsulization and decoupling.
0

Share this post


Link to post
Share on other sites
Thanks for your reply ATC.

I actually wanted to learn DirectX11, but I havn't managed to find any good tutorials about textured quads. The only tutorial I found was really overkill, using shaders etc. I would really like to learn DirectX11, but could you help me to find any totorial that just picks the absolutely neccessary to draw a textured quad?

I'm already familiar with encapsulization and separating into classes as I have 5 years experience of C# and XNA. I just felt that I wanted to move on with something more advanced than XNA, and therefore decided to learn C++ and DirectX. I know that the code should be splitted into classes, but before I do that, I just want everything in one place so I can overveiw it easy. The only purpose of the current project is so I learn the simpliest basics. When I've learn these, I'll move along with a new project where I'll split the code into classes and learn more complicated things.

Could you please help me find a good tutorial with [i]only the absolutely neccessary steps[/i] to render a textured quad in DirectX11?
Or, if you want to be very kind, would you like to spend like 10-15 minutes and write a short tutorial with the absolutely neccessary steps?
0

Share this post


Link to post
Share on other sites
[quote name='falcon93' timestamp='1348576263' post='4983544']
Thanks for your reply ATC.

I actually wanted to learn DirectX11, but I havn't managed to find any good tutorials about textured quads. The only tutorial I found was really overkill, using shaders etc. I would really like to learn DirectX11, but could you help me to find any totorial that just picks the absolutely neccessary to draw a textured quad?
[/QUOTE]

Shaders [i]are[/i] absolutely necessary to getting anything on the screen nowadays. The days of the FFP (fixed-function pipeline) are dead. This is even true in XNA, though they provide the BasicEffect class which may have hidden that fact from you. There's certainly nothing overkill about using shaders. Shaders are simple, easy to use and very powerful. I will certainly be happy to help you write a very basic shader and understand how it works.

[quote name='falcon93' timestamp='1348576263' post='4983544']
I'm already familiar with encapsulization and separating into classes as I have 5 years experience of C# and XNA. I just felt that I wanted to move on with something more advanced than XNA, and therefore decided to learn C++ and DirectX. I know that the code should be splitted into classes, but before I do that, I just want everything in one place so I can overveiw it easy. The only purpose of the current project is so I learn the simpliest basics. When I've learn these, I'll move along with a new project where I'll split the code into classes and learn more complicated things.
[/QUOTE]

I think it's [i]more[/i] complicated to mix a bunch of DirectX code in with Win32 code. That's a LOT of code lol. It's just a pain to read, imo. It's so easy to split it into two files/classes that I just think you're doing yourself a disservice to keep it all jumbled up. We could create you a C++ template you can use anytime you start a new project that will automatically set your code up properly if you like.

Also, if you're good with C# and have XNA experience perhaps you jumped to the wrong platform. Were you aware of SlimDX (and even SharpDX)? These are both very good C# wrappers for DirectX, and SlimDX (not sure about SharpDX) covers the entirety of DirectX 9, 10 and 11 (even 10.1 and 11.1). Basically, SlimDX is just DirectX for C#. It's almost a 1:1 wrapper, so there's really nothing you can do with native DirectX that can't be done with SlimDX. It's more than powerful enough for professional software development. I'm using it for the DirectX back-end of my engine. And if I was going to write a DirectX-based PC game I would definitely choose SlimDX.

That being said there's nothing wrong with learning native DirectX and C++. It will actually be a valuable learning experience, and there's no reason you can't learn both at the same time. Also, since they're almost exactly the same, language differences aside, knowledge from one translates to the other. So if you were to learn either one the other would make perfect sense.

[quote name='falcon93' timestamp='1348576263' post='4983544']
Could you please help me find a good tutorial with only the absolutely neccessary steps to render a textured quad in DirectX11?
Or, if you want to be very kind, would you like to spend like 10-15 minutes and write a short tutorial with the absolutely neccessary steps?
[/quote]

Yes. [url="http://rastertek.com/tutdx11.html"]Here[/url] is a great place to start.

But I will help you too if you need me. If you like, we can start a new C++ project and I'll show you how to draw a textured quad and explain the shader part of things so you'll see how easy and powerful it is. Hit me up with a pm. We could also do the same thing with C# and SlimDX.
1

Share this post


Link to post
Share on other sites
Thanks very much for your help ATC [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I've heard of different wrappers of DirectX for C#. The reason that I chose C++ and DirectX anyway, is becouse many companies in the game industry uses it. As I'm a student, having knowledge in these areas can be a very good qualification when it's time to search for a job.

I'll take a look at the link and try a little bit by my own again. However I recently tried to get it work with DirectX11, but problems accured and I guess that they will this time too. If so, I'll send you a pm so you can help me.

Thanks again so much for your help [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
I tested your code and it works correctly. Are you sure it's not working for you?

I second learning DX11 by the way. Shaders can be daunting at first but you will have to learn them eventually :)
0

Share this post


Link to post
Share on other sites
Yes, I've compiled it a couple of times and it builds successfully, the window appears and there's something drawn, but it draws realy strange (see image in previous post).

I'll move on to DirectX11 instead. Exciting [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0