• 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

110 Neutral

About jozsef.horvath

  • Rank
  1. Greetings, I'm trying to derive the matrix form of Rodrigues rotation formula but I do something really bad. R{N}(V) = cos(a)*V+(1-cos(a))*(N*V)*N+sin(a)*(NxV) Where, N: Unit vector of the rotation angle.V: The vector to be rotated around Na: The angle of rotation (deg).(N*V): The dot product of N and V vectors.(NxV): The cross product of N and V vectors. What I have found is that I have to apply the i(1,0,0) j(0,1,0) and k(0,0,1) to this formula to get the desired form. So I did chose to express the first row vector of the matrix form which should be: R{1,*} = (cos(a)+(1-cos(a))*x2 , (1-cos(a))*x*y-sin(a)*z , (1-cos(a))*x*z-sin(a)*y) Here's my best try so far: Let: n = i => n(1,0,0) v(x,y,z) N*V = 1*x+0*y+0*z = x NxV = (0,-z,y) |cos(a)*x+(1-cos(a))*x+0 | => cos(a)*x + (1-cos(a))*x ?= cos(a)+(1-cos(a))*x2 |cos(a)*y+(1-cos(a))*x-sin(a)*z | => how will cos(a) disappear? | cos(a)*z+(1-cos(a))*x+sin(a)*y | => again no cos(a) in the final matrix :-/ I can't really understand the concept of the first element of this vector. How can I actually calculate cos(a)+(1-cos(a))*x2 from the actual cos(a)*x+(1-cos(a))*x? Everytime I stuck at: cos(a)*x+(1-cos(a))*x+0 = cos(a)*x+(1-cos(a))*x = (cos(a) + (1 - cos(a)) * x which does not look equals to me.
  2. Greetings, I know there has been qute a few topics like this but none of them turned out to be useful for my case. I'm in the middle of the development of my simple engine but I'm struggling with creating a fast reliable input manager. To illustrate my case let me show you my choose of design. Main Entry -> Instantiates a SystemClass that encapsulates the following factories:[list] [*]InputManager [*]GraphicsManager - Handles Direct3D related code. [list] [*]CameraManager [*]TextureManager [*]EffectManader [*]LightManager [*]MeshManager [/list][*]TimerManager [*]Demo Projects - Derives from DirectXManager [/list] To handle user input I'm using the WINAPI Message handler like: [source lang="cpp"]LRESULT CALLBACK SystemClass::MsgHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_KEYDOWN: case WM_KEYUP: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_MOUSEMOVE: m_GraphicsHandler->OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; }[/source] You can see the basic idea. The GraphicsHandler has the necessary functions which handles the user Events. My last attempt was something like this: [source lang="cpp"]class InputFactory { static InputFactory* Instance; InputFactory(void); public: static InputFactory* GetInstance(void); IHandler* CreateHandler(HandlerType hType = HandlerType::MouseHandler); ~InputFactory(void) }; class IHandler { friend class InputFactory; protected: struct Event { private: EventType eType; void (*Handler)(MappedKey mKey, State* hState); }; private: std::queue<Event> Interactions; public: void RegisterEvent(EventType eType = EventType::MouseEvent, ...); void ProcessEvent(void); };[/source] I think you get the main idea. My problem with this approach is that it's way too complex and hard to add new features. Not to mention that to modify the keybindings it's a nightmare. I found an article about inputmanager here on gamedev.net but I can't apply it to my case.
  3. Actually you helped me quite a lot. Now the only one question that remains and that none of the sites I've read explains is the Orientation of the Camera. What exactly is the camera orientation? O.o
  4. Okay, so I've cleared everything and a fresh start. So the main idea if I get right would be this: (In a very simple case) We have a position for the camera (Eye) We have a focus point where the camera looks (LookAt) And finally we have the World's Up vector (Up XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f)) From this we create the View Matrix which is a 4x4 matrix: XMStoreFloat4x4(&m_ViewMatrix, XMMatrixLookAtLH(m_Position, m_Target, XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f)); Now to have a quaternion based camera we need the actual direction (orientation) of the camera. m_Direction = XMQuaternionNormalize(XMQuaternionRotationMatrix(XMLoadFloat4x4(&m_ViewMatrix))); Aaand here I get lost. As I've watched over tutorials I found that to rebuild the viewMatrix they to a MatrixRotationQuaternion like: XMStoreFloat4x4(&m_ViewMatrix, XMMatrixRotationQuaternion(m_Direction)); Zero movement or rotation for the camera yet, but if I do this nothing is drawn on my screen. On a second note to actually move or rotate the camera I thought something like this: void UpdatePosition(const XMVECTOR Direction, float dt = 1.0f); -> Update the position (Eye) of the camera based on deltaTime. void Move(float dx, float dy, float dz); Calculate the direction XMVectorSet(dx, dy, dz, 0.0f) - m_Position. Call UpdatePosition. (I may be wrong tho) void Rotate(float Pitch, float Yaw, float Roll); -y No idea yet but I'll eventually find the answer
  5. Greetings, My whole day ran off while I tried to implement a quaternion based camera system with the following requirements: With LeftmouseDown allow the camera to rotate around it's focus on a sphere trackball. I'm okay with the mathematics part, I have problems with the implementation. Currently I've achieved the following: I have the necessary handling functions: [source lang="cpp"]XMFLOAT2 Previous_MousePosition; void OnMouseDown(WPARAM KeyState, int x, int y) { if (KeyState & VM_LBUTTON) Previous_MousePosition = XMFLOAT2(x, y); } void OnMouseMove(WPARAM KeyState, int x, int y) { if(KeyState & VM_LBUTTON) { XMFLOAT2 NewPosition(x, y); XMFLOAT2 SphereLocation2D(x / (m_Width >> 1), y / (m_Height >> 1)); SphereLocation2D.x -= 1; SphereLocation2D.y = 1 - SphereLocation2D.y; double z = 1 - x * x - y * y; XMFLOAT3 SphereLocation3D(SphereLocation2D.x, SphereLocation2D.y, z > 0 ? z : 0); // no idea where to go from here... } }[/source] And I have my camera currently defined like: [source lang="java"]class Camera { XMFLOAT3 m_Position; // If I'm not mistaken no need for rotation since my camera will always look at the same point. XMFLOAT4X4 m_ViewMatrix; XMFLOAT4X4 m_ProjectionMatrix; public: Camera(void) : m_Position(XMVectorZero()) { m_ViewMatrix = XMMatrixIdentity(); m_ProjectionMatrix = XMMatrixIdentity(); } ~Camera(void) { } void Update(XMFLOAT3 NewPosition, float Dt = 1.0f) { // Calc Axis between m_Position & NewPosition // FLOAT Angle(m_Position, NewPosition); // No idea how to continue from here // m_Position = NewPosition; } void BuildViewMatrix(void) { XMVECTOR Eye = XMVectorSet(m_Position.x, m_Position.y, m_Position.z, 0.0f); XMVECTOR At = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f); XMVECTOR Up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMMATRIX ViewMatrix = XMMatrixLookAtLH(Eye, At, Up); XMStoreFloat4x4(&m_ViewMatrix, ViewMatrix); } } [/source] So I really think I already messed up everything in here.
  6. thanks a lot. you helped me implement my view matrix creation a lot more efficient. My problem however was the missing of projection matrix. So the Correct Projection matrix would be: [source lang="cpp"]XMStoreFloat4x4(&m_ProjectionMatrix, XMMatrixTranspose(XMMatrixPerspectiveFovLH(XM_PIDIV2, static_cast<float>(ClientWidth) / static_cast<float>(ClientHeight), 0.01f, 100.0f))); //instead of: XMStoreFloat4x4(&m_ProjectionMatrix, XMMatrixIdentity());[/source] I should just get some sleep maybe because I'm going nuts of silly things that I don't notice... @[url="http://www.gamedev.net/user/196305-hornsj3/"][color="#284b72"]Hornsj3[/color][/url]: Thanks for your recommendation. I'm aware of these, and actually CameraClass will serve as an abstract Camera for the other specific cameras I'm going to implement in the near future. Actually the next would be the Quaternion based camera for a free-look system controlled with mouse from the inherited: [source lang="cpp"]void MouseDown(WPARAM, int, int) = 0; void MouseUp(WPARAM, int. int) = 0; void MouseMove(WPARAM, int, int) = 0;[/source] functions. I'm not sure if this is the best way to go but for the first look it seems promising.
  7. Greetings, So right one problem after another. After successfully been able to update the contents of the cBuffer, I found that my simple Camera does not work correctly. [source lang="cpp"]#pragma once #include <Windows.h> #include <xnamath.h> class CameraManager { XMFLOAT3 m_Position; XMFLOAT3 m_Rotation; XMFLOAT4X4 m_ViewMatrix; public: CameraManager(void); virtual ~CameraManager(void); void SetPosition(float, float, float); void SetRotation(float, float, float); XMVECTOR GetPosition(void) const; XMVECTOR GetRotation(void) const; XMMATRIX GetViewMatrix(void) const; void BuildViewMatrix(void); };[/source] I'm using this simple class to render the scene from camera perspective but well this isn't going well... The BuildViewMatrix function looks like this: [source lang="cpp"]void CameraManager::BuildViewMatrix(void) { // ******************* // World Up Direction. // ******************* XMFLOAT3 Up(0.0f, 1.0f, 0.0f); // ************************ // The Observer's position. // ************************ XMFLOAT3 Eye(m_Position); // ************************* // The LookAt (Focus) point. // ************************* XMFLOAT3 LookAt(0.0f, 0.0f, 1.0f); // ************************ // Set the Camera Rotation. // ************************ XMFLOAT3 Rotation_VEC(m_Rotation); float Pitch = Rotation_VEC.x * 0.0174532925f; float Yaw = Rotation_VEC.y * 0.0174532925f; float Roll = Rotation_VEC.z * 0.0174532925f; // **************************************** // Build Rotation matrix upon the rotation. // **************************************** XMMATRIX Rotation = XMMatrixIdentity(); Rotation = XMMatrixRotationRollPitchYaw(Pitch, Yaw, Roll); XMVECTOR Look = XMVector3TransformCoord(XMLoadFloat3(&LookAt), Rotation); XMVECTOR Up_D = XMVector3TransformCoord(XMLoadFloat3(&Up), Rotation); Look = XMLoadFloat3(&Eye) + Look; XMStoreFloat4x4(&m_ViewMatrix, XMMatrixLookAtLH(XMLoadFloat3(&Eye), Look, Up_D)); }[/source] And well my problem is simple. Whenever I set the CameraPosition on other than the Depth(Z) axis, the scene gets demorfed. Like basically: m_Camera->SetPosition(3.0f, 2.0f, -5.0f); m_Camera->BuildViewMatrix(); m_ViewMatrix = m_Camera->GetViewMatrix(); // Update the cb. ... // HLSL: output.Position = mul(mul(mul(float4(input.Position, 1.0f), WorldMatrix),ViewMatrix), ProjectionMatrix); The camera seems like is nowhere near the -15.0f coordinate. The Triangle goes out of the screen like -I'm close to it. The screen talks for screenshot talks for itself. Honestly I think I've done everything correctly when building the camera's ViewMatrix but I may be nissing something.
  8. Awesome! I knew it'll be something like this... Thanks a lot mate, you saved my day! ;)
  9. Greetings, I've some problems updating my constant buffers. If I don't use cb in my Vertex Shader, then my Triangle is drawn else nothing is drawn on the screen. No errors but blank d3d window. HLSL: [source lang="cpp"]cbuffer PerFrame { float4x4 WorldMatrix; float4x4 ViewMatrix; float4x4 ProjectionMatrix; }; struct VS_OUT { float4 Position : SV_POSITION; float4 Color : COLOR; }; VS_OUT MainVS(float3 Position : POSITION, float4 Color : COLOR) { VS_OUT output = (VS_OUT)0; output.Position = mul(mul(mul(float4(Position, 1.0f), WorldMatrix), ViewMatrix), ProjectionMatrix); output.Color = Color; return output; }[/source] As you can see its as simple as it can be in this case. Cpp side cBuffer struct: [source lang="cpp"] struct VS_CONSTANTS { private: XMFLOAT4X4 World; XMFLOAT4X4 View; XMFLOAT4X4 Projection; public: VS_CONSTANTS(void) { } VS_CONSTANTS(XMFLOAT4X4 _World, XMFLOAT4X4 _View, XMFLOAT4X4 _Projection) { World = _World; View = _View; Projection = _Projection; } }; VS_CONSTANTS m_cPerObject;[/source] CONSTANT Buffer Creation: [source lang="cpp"]D3D11_BUFFER_DESC Cb_DESCRIPTOR; ZeroMemory(&Cb_DESCRIPTOR, sizeof(D3D11_BUFFER_DESC)); Cb_DESCRIPTOR.ByteWidth = sizeof(VS_CONSTANTS); Cb_DESCRIPTOR.BindFlags = D3D11_BIND_CONSTANT_BUFFER; Cb_DESCRIPTOR.Usage = D3D11_USAGE_DYNAMIC; Cb_DESCRIPTOR.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; HRESULT Result(E_FAIL); Result = m_Device->CreateBuffer(Buffer_DESCRIPTOR, InitialData, m_ConstantBuffer)); if (FAILED(Result)) return Result;[/source] And finally here's how I try to update the contents of the buffer: [source lang="cpp"]template <class Type> HRESULT Demo::SetShaderResource(ID3D11Buffer** Buffer, const Type* Data) { D3D11_MAPPED_SUBRESOURCE BufferContents; assert(m_Context); HRESULT Result(E_FAIL); m_Context->Map(*Buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &BufferContents); if (FAILED(Result)) return Result; BufferContents.pData = &m_cPerObject; m_Context->Unmap(*Buffer, 0); return S_OK; }[/source] Data contains the following values: [source lang="cpp"] m_SimpleCamera = new CameraManager; XMStoreFloat4x4(&m_WorldMatrix, XMMatrixIdentity()); XMStoreFloat4x4(&m_ViewMatrix, m_SimpleCamera->GetViewMatrix()); XMStoreFloat4x4(&m_ProjectionMatrix, XMMatrixIdentity()); m_cPerObject = VS_CONSTANTS(m_WorldMatrix, m_ViewMatrix, m_ProjectionMatrix);[/source] Phew, that's quite a lot of code right here. I hope I gave every information needed. The method that should be used it this but I can't seem to find the answer what I did wrong, but I searched for nearly 3 hours now... Any help would be appreciated!
  10. Greetings, Actually I have a double problem with the DepthStencilView creation. On one side when I try to create the depth stencil view with a given D3D11_DEPTH_STENCIL_VIEW_DESC structure I get an "An invalid argument was passed to the returning function." error mesage; and on the other side if I set this parameter to 0, nothing is drawn onto my screen. Here's the correspoding code snipet: [source lang="cpp"]D3D11_TEXTURE2D_DESC depthStencil_DESCRIPTOR; ZeroMemory(&depthStencil_DESCRIPTOR, sizeof(D3D11_TEXTURE2D_DESC)); depthStencil_DESCRIPTOR.Width = ClientWidth; depthStencil_DESCRIPTOR.Height = ClientHeight; depthStencil_DESCRIPTOR.MipLevels = 1; depthStencil_DESCRIPTOR.ArraySize = 1; depthStencil_DESCRIPTOR.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthStencil_DESCRIPTOR.SampleDesc.Count = 4; depthStencil_DESCRIPTOR.SampleDesc.Quality = m4xMsaaQuality - 1; depthStencil_DESCRIPTOR.Usage = D3D11_USAGE_DEFAULT; depthStencil_DESCRIPTOR.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthStencil_DESCRIPTOR.CPUAccessFlags = 0; depthStencil_DESCRIPTOR.MiscFlags = 0; ID3D11Texture2D* depthStencilBuffer; result = m_Device->CreateTexture2D(&depthStencil_DESCRIPTOR, 0, &depthStencilBuffer); if (FAILED(result)) return false; D3D11_DEPTH_STENCIL_DESC DepthStencilState_DESCRIPTOR; ZeroMemory(&DepthStencilState_DESCRIPTOR, sizeof(D3D11_DEPTH_STENCIL_DESC)); DepthStencilState_DESCRIPTOR.DepthEnable = true; DepthStencilState_DESCRIPTOR.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; DepthStencilState_DESCRIPTOR.DepthFunc = D3D11_COMPARISON_LESS; DepthStencilState_DESCRIPTOR.StencilEnable = true; DepthStencilState_DESCRIPTOR.StencilReadMask = 0xFF; DepthStencilState_DESCRIPTOR.StencilWriteMask = 0xFF; // Stencil Operations on Front facing pixels DepthStencilState_DESCRIPTOR.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; DepthStencilState_DESCRIPTOR.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Stencil operations on Back facint pixels DepthStencilState_DESCRIPTOR.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; DepthStencilState_DESCRIPTOR.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; result = m_Device->CreateDepthStencilState(&DepthStencilState_DESCRIPTOR, &m_DepthStencilState); if (FAILED(result)) return false; m_Context->OMSetDepthStencilState(m_DepthStencilState, 1); D3D11_DEPTH_STENCIL_VIEW_DESC DepthStencilView_DESCRIPTOR; ZeroMemory(&DepthStencilView_DESCRIPTOR, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC)); DepthStencilView_DESCRIPTOR.Format = depthStencil_DESCRIPTOR.Format; DepthStencilView_DESCRIPTOR.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; DepthStencilView_DESCRIPTOR.Texture2D.MipSlice = 0; result = m_Device->CreateDepthStencilView(depthStencilBuffer, &DepthStencilView_DESCRIPTOR, &m_DepthStencilView); if (FAILED(result)) return false;[/source]
  11. Ah thanks, but changing those to positive 0.25 doesn't change anything. Only the blue d3d client area is visible but the triangle is nowhere.
  12. Hey everyone. I've been stuck at this nonsense error for a week now and I can't seem to find the problem. Okay I simplyfied it, because I can't draw even a triangle. Must be some initialization problem but I can't find it even with compare tools. In my other project I could succesfully render my scenes. Here're the correspoding code snipets: [CODE] bool DXManager::Initialize(const HINSTANCE hInstance, const HWND hWnd) { m_hInstance = hInstance; m_hWnd = hWnd; assert(DriverTypes); assert(DriverTypes_COUNT); assert(FeatureLevels); assert(FeatureLevels_COUNT); RECT ClientRect; ZeroMemory(&ClientRect, sizeof(RECT)); GetClientRect(m_hWnd, &ClientRect); UINT ClientWidth = ClientRect.right - ClientRect.left; UINT ClientHeight = ClientRect.bottom - ClientRect.top; DXGI_SWAP_CHAIN_DESC SwapChain_DESCRIPTOR; ZeroMemory(&SwapChain_DESCRIPTOR, sizeof(DXGI_SWAP_CHAIN_DESC)); SwapChain_DESCRIPTOR.BufferCount = 1; SwapChain_DESCRIPTOR.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; SwapChain_DESCRIPTOR.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; SwapChain_DESCRIPTOR.BufferDesc.Width = ClientWidth; SwapChain_DESCRIPTOR.BufferDesc.Height = ClientHeight; SwapChain_DESCRIPTOR.BufferDesc.RefreshRate.Numerator = 60; SwapChain_DESCRIPTOR.BufferDesc.RefreshRate.Denominator = 1; SwapChain_DESCRIPTOR.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; SwapChain_DESCRIPTOR.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; SwapChain_DESCRIPTOR.Flags = 0; SwapChain_DESCRIPTOR.OutputWindow = m_hWnd; SwapChain_DESCRIPTOR.SampleDesc.Count = 1; SwapChain_DESCRIPTOR.SampleDesc.Quality = 0; SwapChain_DESCRIPTOR.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; SwapChain_DESCRIPTOR.Windowed = true; HRESULT result = E_FAIL; for (UINT Driver_INDEX = 0; Driver_INDEX < DriverTypes_COUNT; ++Driver_INDEX) { result = D3D11CreateDeviceAndSwapChain( 0, DriverTypes[Driver_INDEX], 0, D3D11_CREATE_DEVICE_DEBUG, FeatureLevels, FeatureLevels_COUNT, D3D11_SDK_VERSION, &SwapChain_DESCRIPTOR, &m_SwapChain, &m_Device, &m_FeatureLevel, &m_Context); if (SUCCEEDED(result)) { m_DriverType = DriverTypes[Driver_INDEX]; break; } } if (FAILED(result)) { const WCHAR* ErrorString = DXGetErrorStringW(result); const WCHAR* ErrorDescription = DXGetErrorDescriptionW(result); MessageBox(m_hWnd, ErrorDescription, ErrorString, MB_ICONERROR | MB_OK); return false; } result = E_FAIL; ID3D11Texture2D* BackBufferPTR; result = m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(&BackBufferPTR)); if (FAILED(result)) { if (BackBufferPTR != 0) BackBufferPTR->Release(); DXTRACE_MSG(L"Failed to retrieve backbuffer!"); return false; } result = E_FAIL; result = m_Device->CreateRenderTargetView(BackBufferPTR, 0, &m_RenderTargetView); if (BackBufferPTR) BackBufferPTR->Release(); if (FAILED(result)) { DXTRACE_MSG(L"Failed to create RenderTargetView!"); return false; } D3D11_VIEWPORT Viewport; ZeroMemory(&Viewport, sizeof(D3D11_VIEWPORT)); Viewport.Width = static_cast<float>(ClientWidth); Viewport.Height = static_cast<float>(ClientHeight); Viewport.TopLeftX = 0.0f; Viewport.TopLeftY = 0.0f; Viewport.MinDepth = 0.0f; Viewport.MaxDepth = 1.0f; m_Context->RSSetViewports(1, &Viewport); return true; } [/CODE] And the triangle file: [CODE] bool Triangle::LoadContent(void) { bool CompilationResult = false; HRESULT Result = E_FAIL; // Vertex Shader ID3DBlob* vsBuffer = 0; CompilationResult = CompileShaderFromFile(L"./Shaders/BasicHLSL.fx", "VS_Main", "vs_4_0", &vsBuffer); if (!CompilationResult) return false; Result = m_Device->CreateVertexShader( vsBuffer->GetBufferPointer(), vsBuffer->GetBufferSize(), 0, &m_VertexShader); if (FAILED(Result)) { DXTRACE_ERR_MSGBOX(L"Error loading vertex shader", Result); if (vsBuffer != 0) vsBuffer->Release(); return false; } // Vertex Shader END Result = m_Device->CreateInputLayout( SimpleVertex_InputLayout, 1, vsBuffer->GetBufferPointer(), vsBuffer->GetBufferSize(), &m_InputLayout); if (FAILED(Result)) { DXTRACE_ERR_MSGBOX(L"Error while creating input layout", Result); vsBuffer->Release(); return false; } if (vsBuffer != 0) vsBuffer->Release(); vsBuffer = 0; // PIXEL SHADER ID3DBlob* psBuffer = 0; CompilationResult = CompileShaderFromFile(L"./Shaders/BasicHLSL.fx", "PS_Main", "ps_4_0", &psBuffer); if (!CompilationResult) return false; Result = E_FAIL; Result = m_Device->CreatePixelShader( psBuffer->GetBufferPointer(), psBuffer->GetBufferSize(), 0, &m_PixelShader); if (FAILED(Result)) { DXTRACE_ERR_MSGBOX(L"Error loading pixel shader", Result); psBuffer->Release(); return false; } if (psBuffer != 0) psBuffer->Release(); psBuffer = 0; // PIXEL SHADER END // Load Vertices to array SimpleVertex Vertices[] = { XMFLOAT3( 0.0f, 0.5f, -0.25f), XMFLOAT3( 0.5f,-0.5f, -0.25f), XMFLOAT3(-0.5f,-0.5f, -0.25f) }; D3D11_BUFFER_DESC VertexBuffer_DESCRIPTOR; ZeroMemory(&VertexBuffer_DESCRIPTOR, sizeof(D3D11_BUFFER_DESC)); VertexBuffer_DESCRIPTOR.Usage = D3D11_USAGE_DEFAULT; VertexBuffer_DESCRIPTOR.BindFlags = D3D11_BIND_VERTEX_BUFFER; VertexBuffer_DESCRIPTOR.ByteWidth = sizeof(SimpleVertex) * 3; // setup vertex data D3D11_SUBRESOURCE_DATA InitialData; ZeroMemory(&InitialData, sizeof(D3D11_SUBRESOURCE_DATA)); InitialData.pSysMem = Vertices; Result = m_Device->CreateBuffer(&VertexBuffer_DESCRIPTOR, &InitialData, &m_VertexBuffer); if (FAILED(Result)) return false; // TODO // FIX: - causes assertion! // delete/[]/ Vertices; return true; } void Triangle::Render(void) { assert(m_Context); float BgColor[4] = { 0.0f, 0.0f, 0.15f, 1.0f }; m_Context->ClearRenderTargetView(m_RenderTargetView, BgColor); UINT Stride = sizeof(SimpleVertex); UINT Offset = 0; assert(m_InputLayout); assert(m_VertexBuffer); m_Context->IASetInputLayout(m_InputLayout); m_Context->IASetVertexBuffers(0, 1, &m_VertexBuffer, &Stride, &Offset); m_Context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); assert(m_VertexShader); assert(m_PixelShader); m_Context->VSSetShader(m_VertexShader, 0, 0); m_Context->PSSetShader(m_PixelShader, 0, 0); m_Context->Draw(3, 0); assert(m_SwapChain); m_SwapChain->Present(0, 0); } [/CODE] Could someone tell me what am I missing? HLSL in this simple case: [CODE] float4 VS_Main(float4 Position : POSITION) : SV_POSITION { return Position; } float4 PS_Main(float4 Position : SV_POSITION) : SV_TARGET { return float4( 1.0f, 1.0f, 1.0f, 1.0f); } [/CODE] Only the blank d3d client area is visible but no triangle. Vertex buffers are loaded and the fx file is compiled so I have no idea where is that error.
  13. Hi! I'm struggling to understand to goal of the mentioned matrices. I only know the meaning behind the World matrix. If I get that right that looks something like this: Every model has it's own coordinate system wich occasionally may differ from the one we use on our programs. With the WorldMatrix we can convert the model's vertices to our world position with a simple multiplication: mul(vertex.position, worldMatrix); Now with the other two I have no idea what to do. Could someone give me a slight explanation what are they good for and why? Thanks, Joe
  14. Thank you very much I really appreciate it. I'll go through the tutorials provided on the website and see if I can understand it all. Thanks again. Regards, - Joe
  15. Greetings, I've been entrusted with a development of a simple teaching software in different kind of curves & surfaces. The API which I should be using is DirectX 10. I started to read several tutorials available on the internet along with the following books: [indent=1][url="http://www.amazon.com/Beginning-DirectX-10-Game-Programming/dp/1598633619"]http://www.amazon.com/Beginning-DirectX-10-Game-Programming/dp/1598633619[/url][/indent] [indent=1][url="http://www.amazon.com/Introduction-3D-Game-Programming-DirectX/dp/1598220535/ref=pd_sim_b_1"]http://www.amazon.com/Introduction-3D-Game-Programming-DirectX/dp/1598220535/ref=pd_sim_b_1[/url][/indent] [indent=1][url="http://www.amazon.com/Advanced-Programming-DirectX-Wordware-Graphics/dp/1598220543/ref=sr_1_1?s=books&ie=UTF8&qid=1333990946&sr=1-1"]http://www.amazon.com/Advanced-Programming-DirectX-Wordware-Graphics/dp/1598220543/ref=sr_1_1?s=books&ie=UTF8&qid=1333990946&sr=1-1[/url][/indent] Now these books are trully great for starting, does not answer my questions. The same problem goes for the online tutorials, and don't take it personally but I find them like: "Here's the nothing bite it". I barely could understand the process of initializing in depth from these books and tutorials. Currently I can easily initialize a simple Direct3D interface. Now to go on I don't know what to read. It is trully a great idea to draw a triangle which vertices are statically given but what if I want to use dynamic data? Till now I just have a slight guess of what it's all about. So correct me if I get this wrong please: [i] So if I get this right with the init process (Create SwapChain, Device, RenderTargetView and Viewport) we define the graphical pipeline.[/i] [i] With the different kinds of HLSL shaders we define how a particular part of the pipeline is working.[/i] Now what I couldn't figure out: [indent=1]How does this rendering thing works in particular in D3D? - [i]Given an empty initialized D3D interface, how can I draw different kind of objects on specific user interactions? Like a mouseclick is done on the screen, and the program should create a a vertex on that particular point with (x,y,1,1) homogenious coordinates. So it's great to actually draw anything with statically given vertices but what if I have dynamic resource?[/i][/indent] [indent=1]Also what's the prurpose of Vertex Buffers? - [i]I don't think what are they used for. I know about that, but how to manage them? Should I have a simple vertex buffer for all the objects that are to be drawn onto the screen or one vertex buffer for each element? Same goes for shaders.[/i][/indent] You see I'm missing the in depth information. I want to understand the concepts and not to drag some basic example and learn nothing from it. It can helpfor other people of course just not for me. I want to get the answer for the mythical "[i]WHY?[/i]" questions. And obviously from the mentioned sources I didn't got any. So if any of you could give me any link to a decent well written tutorial (Can be zero code also, I can write that by myself just give me that [sub]d4mm3d [/sub]in depth information that the DX works like THIS because of THAT particular reason. We use THIS tool to manage THAT goal. Writting down some code which can be managed to put together using MSDN won't help a bit. Thanks for every response - recommendation. Cheers, Joe