Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

106 Neutral

About PavelB

  • Rank
  1. I would like to revive DirectX application that originally used DirectDraw7 and transfer it to DirectX 11. I have never worked before with DirectDraw.   Does anyone know any resources that would allow me to convert it as close as possible to DirectDraw, still using full power of DirectX 11?
  2. I have created the application that shows on the screen flat simple terrain 100 * 100. It works and camera flies around on the laptop. However, when I connect my laptop to the external monitor, it doesn't show anything. Does anyone experianced this kind of strange behaviour?
  3. I don't know. Something wrong with my understanding of what you are saying. Below I show the logic I am using and it works for the triangle, but it doesn't work for square. As you see below I commented a lot of code and it still consistant. It works, but show only one of the triangles of the square. depends on which one of them are 0,1,2. When I replace the order it shows one triangle or another. ID3DBlob* pVSBlob = NULL; hr = CompileShaderFromFile( L"Tutorial02.fx", "vshader", "vs_4_0", &pVSBlob ); if( FAILED( hr ) ) { MessageBox( NULL, L"The FX file cannot be compiled. Please run this executable from the directory that contains the FX file.", L"Error", MB_OK ); return hr; } // Create the vertex shader hr = g_pd3dDevice->CreateVertexShader( pVSBlob->GetBufferPointer(), pVSBlob->GetBufferSize(), NULL, &g_pVertexShader ); if( FAILED( hr ) ) { pVSBlob->Release(); return hr; } //// Define the input layout //D3D11_INPUT_ELEMENT_DESC layout[] = //{ // { "SV_VertexId", 0, DXGI_FORMAT_R32G32B32_UINT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, //}; //UINT numElements = ARRAYSIZE( layout ); //// Create the input layout //hr = g_pd3dDevice->CreateInputLayout( layout, numElements, pVSBlob->GetBufferPointer(), // pVSBlob->GetBufferSize(), &g_pVertexLayout ); //pVSBlob->Release(); //if( FAILED( hr ) ) // return hr; // Set the input layout //g_pImmediateContext->IASetInputLayout( NULL ); // Compile the pixel shader ID3DBlob* pPSBlob = NULL; hr = CompileShaderFromFile( L"Tutorial02.fx", "PS", "ps_4_0", &pPSBlob ); if( FAILED( hr ) ) { MessageBox( NULL, L"The FX file cannot be compiled. Please run this executable from the directory that contains the FX file.", L"Error", MB_OK ); return hr; } // Create the pixel shader hr = g_pd3dDevice->CreatePixelShader( pPSBlob->GetBufferPointer(), pPSBlob->GetBufferSize(), NULL, &g_pPixelShader ); pPSBlob->Release(); if( FAILED( hr ) ) return hr; //// Create vertex buffer //SimpleVertex vertices[] = //{ // XMFLOAT3( 0.0f, 0.5f, 0.5f ), // XMFLOAT3( 0.5f, -0.5f, 0.5f ), // XMFLOAT3( -0.5f, -0.5f, 0.5f ), //}; //D3D11_BUFFER_DESC bd; //ZeroMemory( &bd, sizeof(bd) ); //bd.Usage = D3D11_USAGE_DEFAULT; //bd.ByteWidth = sizeof( SimpleVertex ) * 3; //bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; //bd.CPUAccessFlags = 0; //D3D11_SUBRESOURCE_DATA InitData; //ZeroMemory( &InitData, sizeof(InitData) ); //InitData.pSysMem = vertices; //hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &g_pVertexBuffer ); //if( FAILED( hr ) ) // return hr; //// Set vertex buffer //UINT stride = sizeof( SimpleVertex ); //UINT offset = 0; //g_pImmediateContext->IASetVertexBuffers( 0, 1, &g_pVertexBuffer, &stride, &offset ); // Set primitive topology g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); //-------------------------------------------------------------------------------------- // File: Tutorial02.fx // // Copyright (c) Microsoft Corporation. All rights reserved. //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- // Vertex Shader //-------------------------------------------------------------------------------------- float4 VS( float4 Pos : POSITION ) : SV_POSITION { return Pos; } //-------------------------------------------------------------------------------------- // Pixel Shader //-------------------------------------------------------------------------------------- float4 PS( float4 Pos : SV_POSITION ) : SV_Target { return float4( 1.0f, 1.0f, 0.0f, 1.0f ); // Yellow, with Alpha = 1 } struct VS_OUT { float4 pos : SV_Position; // insert other vs output fields here as needed }; // vertex shader that draws a triangle without vbuffers VS_OUT vshader(uint idx : SV_VertexId) { VS_OUT ret = (VS_OUT)0; switch (idx) { case 3: ret.pos = float4(-0.1,-0.1,1,1); break; case 4: ret.pos = float4(0.1,0.1,1,1); break; case 5: ret.pos = float4(0.1,-0.1,1,1); break; case 0: ret.pos = float4(-0.1,-0.1,1,1); break; case 1: ret.pos = float4(-0.1,0.1,1,1); break; case 2: ret.pos = float4(0.1,0.1,1,1); break; } return ret; }
  4. But how does it know how many vertices in model - 3 or 300000. is it Draw(300000, 0) tell about it?
  5. This is what I try to understand, how do I give the indices to the shader. In regulat way it works this way: Initialize Buffer: ......................... Code // Load the vertex array with data. vertices[0].position = ... // Bottom left. vertices[1].position = ... // Bottom Right vertices[2].position = ... // Top Right vertices[3].position = ... // Top Left // Load the index array with data. indices[0] = 0; // Bottom left. indices[1] = 1; // Bottom Right. indices[2] = 2; // Top right. indices[3] = 0; // Bottom left. indices[4] = 2; // Top Right. indices[5] = 3; // Top Left. ......... Code Render Buffer: [size="2"]deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset); [size="2"]deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0); [size="2"]deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); Now, what am I doing? From the samples that I found, at least the simpliest one I should do something like this: m_pD3D11Device->IASetInputLayout( NULL ); m_pD3D11Device->IASetPrimitiveTopology( D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); ID3DX11EffectTechnique * pTech = NULL; pTech = m_pEffect->GetTechniqueByIndex(0); pTech->GetPassByIndex(iPass)->Apply(0); m_pD3D11Device->Draw( 3, 0 ); Where do I set the order of the indices for the triangles? How do I know in shader about it?
  6. Thanks. It is what I found on SDK, too. Again It has permanent coordinates. However, I cannot figure out, how I can do complex shader, which includes 2 triangles, as in Square or 400 triangles as for Circle, by sending in only center of those shapes. For instant, here is what I hope to achieve. struct VS_OUT { float4 pos: SV_Position; }; struct VS_IN { float4 origin; float4 radius; uint idx : SV_VertexId; }; VS_OUT vsshader(VS_IN in) { VS_OUT ret = (VS_OUT)0; float4 inRightTop; ... // Calculation of the Right Top corner float4 inLeftTop; .... float4 inRightBottom; .... float4 inLeftBottom; switch (idx) { case 0: ret.pos = inLeftBottom; break; case 1: ret.pos = inRightBottom; break; case 2: ret.pos = inRightTop; break; case 3: ret.pos = inLeftBottom; break; case 4: ret.pos = inRightTop; break; case 5: ret.pos = inLeftTop; break; } }
  7. I am new at shaders. I can find a lot of examples that would help me with the traditional ways of computing and very little with what I describe above. Could you give me some tutorials to read about this technique or even small working small sample of the example above and I will try using that for what I really want to try (see below) In ideal variant for the square I'd like to do something like this: I will send 3 parameters: - Polar System Coordinate vector from "World Space" origin to the origin of the square's Object Polar Coordinate System; - Quadrion of the orientation for the origin "unit" vector of the square's Object Polar Coordinate System; - Polar System Coordinate vector to the point of one of the corners of the square within Object Polar Coordinate System. It is it and then shader create the vertice buffer by itself. P.S. As bonus, I'd like to keep the third vector in GPU as long as possible during the time my application is running. Only 2 first parameters will be changed between frames to do some animation.
  8. Hi, I have the question regarding HLSL. When I create new model I have to give all vertices to the HLSL. The question is if it is possible to create all vertices within the shader itself. Here small example of what I am asking about. I'd like to send for instant the coordinates of the centre of the square and half diagonal length. And program I will create in shader will calculate all 6 coordinate by itself and "in the loop somehow" will execute it. In this case, my CPU won't work on this, but GPU itself. Is it possible to do something like this?
  9. I have created small egine that put the results of the RawInput on the screen. I am using my own font texture. While I am not moving the mouse it is OK, the text moves and screen is cleaned. When I am starting to move it, see the attached video files from here http://sharpdx.googl...Y:1335867800863 http://sharpdx.googl...M:1335867800863
  10. I am learning DirectX from this site http://www.rastertek.com/ and also SharpDX. I decided to do is simulteneously. It means, every tutorial I develop using SharpDX. Until tutorial 13 I have succeded to implement the code similatr to the original. However, I am stuck with DirectInput, related to the mouse. Below I attached the original tutorial written in C++ and my implementation of it. In original when I move the mouse it shows me right coordinates of the window. In mine only relative or absolute. The issue is I don't understand why it works there and in mine.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!