Jump to content

  • Log In with Google      Sign In   
  • Create Account


Tispe

Member Since 02 Oct 2010
Offline Last Active Today, 12:41 AM

Topics I've Started

DX12 - Documentation / Tutorials?

03 September 2014 - 04:13 AM

Hi

 

 

I wanted to know if anyone here has had the chance to use/look at the Direct3D 12 API?

 

How different is it from DX9, DX11? Is it a whole paradigm shift?

 

Is it the basics: "create buffer -> copy data to buffer -> Draw from buffer" kind of thing?

 

Im mostly just familiar with DX9 and want to catch up with DX12. Should I learn DX11 while waiting for docs/tutorials?

 

Cheers!

 


Getting perspective Frustum in world coordinates

20 June 2014 - 04:30 AM

Hi

 

I want to implement Shadow Mapping using orthogonal projection for directional lighting. The shadow map orthogonal frustum shall wrap around the Scene perspective frustum.

 

To calculate the projection transfrom for the shadow map I will use the D3DXMatrixOrthoOffCenterLH function. This function takes the vertices from view space (camera pointing in the lights direction) to projection space for the shadow map.

 

But in order to fill out the parameters correctly I need to get the Scene frustum vertices which are in Scene projection space, transform them back to world space, and forward into shadow map view space. Then I will max(), min() the x and y values, maybe I need w-division first?

 

How do I get the scene frustum vertices? Are they the simply the cube corners in clip space (-1, -1, 0) (1, -1, 0) (1,1,0) (-1, 1 ,0), (-1, -1, 1) (1, -1, 1) (1,1,1) (-1, 1 ,1) ? Do I have to perspective (divide)/multiply them with a w-value to get them to projection space from clip space? When I have them in perspective projection space I can use the inverse camera matrix to get them to world coordinates.

 

 

Cheers!


simple win32 hack for user/pass input

08 May 2014 - 05:57 AM

Hi

 

I wanted to know how I can prompt the user for a password at the beginning of the application in the simplest way possible.

LRESULT CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	DialogBox(NULL, (LPCTSTR)IDD_MAIN, 0, (DLGPROC)DlgProc);

	/*
	App code here
	*/
	return 0;
}

The IDD_MAIN needs to be defined in a resource. like so:

IDD_MAIN DIALOG DISCARDABLE  0, 0, 126, 68
STYLE DS_ABSALIGN | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | 
    WS_CAPTION | WS_SYSMENU
CAPTION "Password"
FONT 8, "MS Sans Serif"
BEGIN
    PUSHBUTTON      "&Confirm",IDC_CONFIRM,24,33,68,13
    EDITTEXT        IDC_txtPass,19,14,76,14,ES_AUTOHSCROLL
END

Is there any way to inline this like a lambda, such that I can do this:

LRESULT CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	char data[] = {
		DIALOG DISCARDABLE  0, 0, 126, 68
STYLE DS_ABSALIGN | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | 
    WS_CAPTION | WS_SYSMENU
CAPTION "Password"
FONT 8, "MS Sans Serif"
BEGIN
    PUSHBUTTON      "&Confirm",IDC_CONFIRM,24,33,68,13
    EDITTEXT        IDC_txtPass,19,14,76,14,ES_AUTOHSCROLL
END
	};

	DialogBox(NULL, (LPCTSTR)data, 0, (DLGPROC)DlgProc);

	/*
	App code here
	*/
	return 0;
}

I plan on encapsulating this such that I can pass a string by reference to the construtor of the object and it will write what the user entered. The constructor will block until the user presses "Confirm".

LRESULT CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

	switch (message)
	{
	case WM_COMMAND:
		{
			if (LOWORD(wParam) == IDC_CONFIRM)
			{
				char sPassword[50];
				GetDlgItemText(hWnd,IDC_txtPass,sPassword,50);
			}
			break;
		}

std::async to copy data to resources

25 April 2014 - 02:58 AM

Hi

 

With the c++11 asynch(), I thught it might be useful when doing memcpy to a resource.

 

Something like this:

class VertexBuffer
{
	/*......*/

	void LockAndCopy()
	{
		copying = true;
		v_buffer->Lock(0, 0, (void**)&pVoid, 0);
		done = std::async([&]{std::memcpy(pVoid, vertices.data(), vertices.size()*sizeof(vertex));});

	}

	void Unlock()
	{
		if(copying){
			done.get();
			v_buffer->Unlock();
			copying = false;
		}
	}

	LPDIRECT3DVERTEXBUFFER9 v_buffer;
	std::vector<vertex> vertices;
	std::future<void> done;
	bool copying;
	VOID* pVoid;

	/*......*/
};

Is this something worth considering? Any ideas on how I can make VertexBuffer::Unlock() not block and just check if it is finished?


copy/assignment/move constructors and private data

24 April 2014 - 01:27 AM

Hi

 

Let's say we have class A and class B that both have private data and are very different from each other.

 

We want to implement copy/assignment/move constructors for both classes such that A can be constructed with private data from B and vice versa.

 

Do we have to invoke the friend keyword in order for these constructors to get access to the private data?


PARTNERS