• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

109 Neutral

About col_anderson

  • Rank

Personal Information

  • Location
  1. Hi AlzPatz. I received your code, however I currently have no win8 dev environment therefore no chance to compile your code. The code and the shaders seem fine, but the devil is in the details as usual. To diagnose my problem I switched the cull mode to D3D11_CULL_NONE so the rasterizer would render everything that should be on screen. in native c++ it would look somethin like this: [source] D3D11_RASTERIZER_DESC rd; ZeroMemory(&rd, sizeof(rd)); rd.CullMode = D3D11_CULL_NONE; rd.FrontCounterClockwise = false; rd.FillMode = D3D11_FILL_SOLID; device->CreateRasterizerState(&rd, &rasterizerState); immediateContext->RSSetState(rasterizerState); [/source] Also try to disable the depthstencilbuffer as you don't need it anyway when you draw screen coordinates directly, by not setting in the OMSetRenderTargets call: [source] //Set the Render Context d3dContext->OMSetRenderTargets(1, renderTargetView.GetAddressOf(), nullptr) [/source] You should also have a look at the DX11 MSDN tutorial (especially No 2), if you have not already. [url="http://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef?SRC=VSIDE"]http://code.msdn.mic...979ef?SRC=VSIDE[/url] I hoped I could be more helpful. Let me know if that brought you forward. C.
  2. I solved the issue for me, but you seem to use untransformed screen coordinates. The root cause with my code were the Projection and View matrices. While I stored the world matrix correctly: [Code]sChangesEveryFrame.mWorld = XMMatrixTranspose(XMLoadFloat4x4(&worldMatrix));[/Code] I did not do it with the other two: [CODE]sNeverChanges.mView = XMLoadFloat4x4(&ViewMatrix);[/CODE] and [CODE]sChangesOnResize.mProjection = XMLoadFloat4x4(&ProjectionMatrix);[/CODE] The shader has to use a transposed version of the matrices. AlzPatz - I will get in touch with you via PM.
  3. The problem you are describing sound like the exact same problem when I try to render a cube. Inspecting the problem with the Graphics Diagnosis Tool tells me that the Pixel Shader has not participate in the graphics pipeline process, in my case, without any obvious reason. I have double checked it, but it was loaded properly and set correctly in the device context. This leaves me clueless. Perhaps the additional diag info helps in your case as well, AlzPatz. (see attachment) And this is the corresponding source code Cube.cpp: [Code] #include "Cube.h" #include "GlobalDefines.h" #include "Direct3dUtils.h" struct SChangesEveryFrame{ XMMATRIX mWorld; }; Cube::Cube(void) :isInitialized(false), vertexBuffer(NULL), indexBuffer(NULL), cbChangesEveryFrame(NULL), vertexShaderFile(L"SimpleVertexShader"), pixelShaderFile(L"SimplePixelShader"), vertexShader(NULL), pixelShader(NULL), inputLayout(NULL) { } Cube::~Cube(void) { SAFE_RELEASE(inputLayout); SAFE_RELEASE(pixelShader); SAFE_RELEASE(vertexShader); SAFE_RELEASE(cbChangesEveryFrame); SAFE_RELEASE(vertexBuffer); SAFE_RELEASE(indexBuffer); } void Cube::Render() { if(isInitialized){ SChangesEveryFrame sChangesEveryFrame; //using XMMATRIX causes runtime error - better use XMFloat4x4 //http://www.gamedev.net/topic/627033-xmmatrixtranspose-crashes/ //http://xboxforums.create.msdn.com/forums/t/84299.aspx sChangesEveryFrame.mWorld = XMMatrixTranspose(XMLoadFloat4x4(&worldMatrix)); UINT stride =sizeof(SimpleColorVertex) ; UINT offset = 0; immediateContext->IASetInputLayout(inputLayout); immediateContext->IASetVertexBuffers(0,1,&vertexBuffer,&stride,&offset); immediateContext->IASetIndexBuffer(indexBuffer,DXGI_FORMAT_R16_UINT,0); immediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); immediateContext->UpdateSubresource(cbChangesEveryFrame,0,NULL,&sChangesEveryFrame,0,0); immediateContext->VSSetConstantBuffers(2,1,&cbChangesEveryFrame); //immediateContext->PSSetConstantBuffers(2,1,&cbChangesEveryFrame); immediateContext->VSSetShader(vertexShader, NULL,0); immediateContext->PSSetShader(pixelShader, NULL,0); immediateContext->DrawIndexed( 36, 0, 0 ); } } void Cube::Initialize(ID3D11Device* device, ID3D11DeviceContext* immediateContext) { this->device = device; this->immediateContext = immediateContext; SimpleColorVertex vertices[] = { { XMFLOAT3( -1.0f, 1.0f, -1.0f ), XMFLOAT4( 0.0f, 0.0f, 1.0f, 1.0f ) }, { XMFLOAT3( 1.0f, 1.0f, -1.0f ), XMFLOAT4( 0.0f, 1.0f, 0.0f, 1.0f ) }, { XMFLOAT3( 1.0f, 1.0f, 1.0f ), XMFLOAT4( 0.0f, 1.0f, 1.0f, 1.0f ) }, { XMFLOAT3( -1.0f, 1.0f, 1.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) }, { XMFLOAT3( -1.0f, -1.0f, -1.0f ), XMFLOAT4( 1.0f, 0.0f, 1.0f, 1.0f ) }, { XMFLOAT3( 1.0f, -1.0f, -1.0f ), XMFLOAT4( 1.0f, 1.0f, 0.0f, 1.0f ) }, { XMFLOAT3( 1.0f, -1.0f, 1.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) }, { XMFLOAT3( -1.0f, -1.0f, 1.0f ), XMFLOAT4( 0.0f, 0.0f, 0.0f, 1.0f ) } }; WORD indices[] = { 3,1,0, 2,1,3, 0,5,4, 1,5,0, 3,4,7, 0,4,3, 1,6,5, 2,6,1, 2,7,6, 3,7,2, 6,4,5, 7,4,6, }; HRESULT hr; vertexBuffer = Direct3dUtils::CreateBuffer(device,D3D11_BIND_VERTEX_BUFFER,sizeof(SimpleColorVertex) * ARRAYSIZE(vertices),vertices,hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create vertexbuffer"); return; } indexBuffer = Direct3dUtils::CreateBuffer(device,D3D11_BIND_INDEX_BUFFER,sizeof(WORD) * ARRAYSIZE(indices),indices,hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create indexbuffer"); return; } cbChangesEveryFrame = Direct3dUtils::CreateBuffer(device,D3D11_BIND_CONSTANT_BUFFER,sizeof(SChangesEveryFrame),NULL,hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create cbChangesEveryFrame"); return; } D3D11_INPUT_ELEMENT_DESC layoutDesciption[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT,0 ,0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR" , 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; Direct3dUtils::LoadVertexShader(device, vertexShaderFile, layoutDesciption,ARRAYSIZE(layoutDesciption), &vertexShader, &inputLayout, hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"LoadVertexShader"); return; } Direct3dUtils::LoadPixelShader(device, pixelShaderFile,&pixelShader, hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"LoadPixelShader"); return; } XMStoreFloat4x4(&worldMatrix,XMMatrixIdentity()); isInitialized = true; } [/code] Direct3d.cpp [code] #include "Direct3d.h" struct SNeverChanges{ XMMATRIX mView; }; struct SChangesOnResize{ XMMATRIX mProjection; }; Direct3d::Direct3d(HWND hwnd) { // TODO set up configuration class to determine proper system configuration, for now we go with the dev system requirments IDXGIAdapter* adapter = NULL; D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_HARDWARE; // TODO allow multiple display modes, including full-screen resolutions - for now we go with windowed 1024x768x60hz int resolutionWidth = WINDOWWITDH; int resolutionHeight = WINDOWHEIGHT; int refreshrate = 60; bool windowed = true; int multisamplingCount = 1; int mulitsamplingQuality = 0; UINT createDeviceFlags = 0; #ifdef _DEBUG createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif DXGI_SWAP_CHAIN_DESC sd; ZeroMemory( &sd, sizeof(sd) ); sd.BufferCount = 1; sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; sd.BufferDesc.RefreshRate.Numerator = refreshrate; sd.BufferDesc.RefreshRate.Denominator = 1; sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; sd.BufferDesc.Width = resolutionWidth; sd.BufferDesc.Height = resolutionHeight; sd.Windowed = windowed; sd.SampleDesc.Count = multisamplingCount; sd.SampleDesc.Quality = mulitsamplingQuality; sd.OutputWindow = hwnd; D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0 }; int numberOfFeatureLevels = ARRAYSIZE(featureLevels); HRESULT hr; hr = D3D11CreateDeviceAndSwapChain(adapter, driverType, NULL, createDeviceFlags, featureLevels, numberOfFeatureLevels, D3D11_SDK_VERSION, &sd, &swapChain, &device, NULL, &immediateContext ); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateDevice&SwapChain" ); return; } hr = swapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (void**) &backBuffer ); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"SwapChain-GetBuffer" ); return; } hr = device->CreateRenderTargetView(backBuffer, NULL, &renderTargetView); backBuffer->Release(); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateRenderTargetView" ); return; } D3D11_TEXTURE2D_DESC stencilDescription; ZeroMemory(&stencilDescription,sizeof(stencilDescription)); stencilDescription.Usage = D3D11_USAGE_DEFAULT; stencilDescription.Width = resolutionWidth; stencilDescription.Height = resolutionHeight; stencilDescription.MipLevels = 1; stencilDescription.ArraySize = 1; stencilDescription.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; stencilDescription.SampleDesc.Count = 1; stencilDescription.SampleDesc.Quality = 0; stencilDescription.BindFlags = D3D11_BIND_DEPTH_STENCIL; stencilDescription.CPUAccessFlags = 0; stencilDescription.MiscFlags = 0; hr = device->CreateTexture2D(&stencilDescription,NULL, &depthStencilBuffer); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateDepthStencilBuffer" ); return; } D3D11_DEPTH_STENCIL_VIEW_DESC viewDescription; ZeroMemory(&viewDescription,sizeof(viewDescription)); viewDescription.Format = stencilDescription.Format; viewDescription.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; hr = device->CreateDepthStencilView(depthStencilBuffer,&viewDescription,&depthStencilView); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateDepthStencilView" ); return; } immediateContext->OMSetRenderTargets( 1, &renderTargetView, depthStencilView); D3D11_VIEWPORT vp; vp.Width = float(resolutionWidth); vp.Height = float(resolutionHeight); vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; vp.TopLeftX = 0; vp.TopLeftY = 0; immediateContext->RSSetViewports( 1, &vp ); XMVECTOR eye = XMVectorSet(0.0f, 3.0f, -2.0f, 0.0f); XMVECTOR at = XMVectorSet(0.0f,1.0f,1.0f,0.0f); XMVECTOR up = XMVectorSet(0.0f,1.0f,1.0f,0.0f); XMStoreFloat4x4(&ViewMatrix,XMMatrixLookAtLH(eye,at,up)); SNeverChanges sNeverChanges; sNeverChanges.mView = XMLoadFloat4x4(&ViewMatrix); cbNeverChanges = Direct3dUtils::CreateBuffer(device,D3D11_BIND_CONSTANT_BUFFER,sizeof(SNeverChanges),NULL,hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create cbNeverChanges"); return; } immediateContext->UpdateSubresource( cbNeverChanges, 0, NULL, &sNeverChanges, 0, 0 ); XMStoreFloat4x4(&ProjectionMatrix,XMMatrixPerspectiveFovLH(XM_PIDIV2,resolutionWidth/(float)resolutionHeight,0.01f,1.0f)); SChangesOnResize sChangesOnResize; sChangesOnResize.mProjection = XMLoadFloat4x4(&ProjectionMatrix); cbChangesOnResize = Direct3dUtils::CreateBuffer(device,D3D11_BIND_CONSTANT_BUFFER,sizeof(SChangesOnResize),NULL,hr); if (FAILED(hr)){ Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create cbNeverChanges"); return; } immediateContext->UpdateSubresource( cbChangesOnResize, 0, NULL, &sChangesOnResize, 0, 0 ); } Direct3d::~Direct3d(void) { if (immediateContext) immediateContext->ClearState(); SAFE_RELEASE(cbNeverChanges); SAFE_RELEASE(cbChangesOnResize); SAFE_RELEASE(depthStencilView); SAFE_RELEASE(renderTargetView); SAFE_RELEASE(backBuffer); SAFE_RELEASE(immediateContext); SAFE_RELEASE(swapChain); SAFE_RELEASE(device); } void Direct3d::Render() { float color[] = { 0.0f, 0.2f, 0.0f, 1.0f }; immediateContext->ClearRenderTargetView(renderTargetView, color); immediateContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); immediateContext->VSSetConstantBuffers(1,1,&cbChangesOnResize); immediateContext->VSSetConstantBuffers(0,1,&cbNeverChanges); renderObjects(); swapChain->Present( 0, 0 ); } void Direct3d::Add(Renderable* object) { object->Initialize(device,immediateContext); objects.insert(objects.end(),object); } void Direct3d::renderObjects() { for (std::vector<Renderable*>::iterator iter = objects.begin(); iter != objects.end(); iter++) (*iter)->Render(); } [/code] My shaders are pretty basic as well: definitions.fx: [code] cbuffer cbNeverChanges : register(b0) { matrix View; }; cbuffer cbChangesOnResize: register(b1) { matrix Projection; }; cbuffer cbChangesEveryFrame : register (b2) { matrix World; }; struct VS_INPUT{ float4 Pos : POSITION; float4 Color : COLOR0; }; struct PS_INPUT{ float4 Pos : SV_POSITION; float4 Color : COLOR0; }; [/code] SimplePixelShader.hlsl: [code] #include "definitions.fx" float4 main(PS_INPUT input) : SV_Target { return input.Color; } [/code] SimpleVertexShader.hlsl: [code] #include "definitions.fx" PS_INPUT main( VS_INPUT input ) { PS_INPUT output = (PS_INPUT)0; output.Pos = mul(input.Pos,World); output.Pos = mul(output.Pos, View); output.Pos = mul(output.Pos, Projection); output.Color = input.Color; return output; } [/code]