Jump to content
  • Advertisement

null434

Member
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

133 Neutral

About null434

  • Rank
    Member
  1. Do the books that are sold on the market provide knowledge sufficient to become a 3d game developer and  join a game company? Or do I have to learn from other source, like regular courses?  How does a 3d game programmer learn what it needs to be program a 3d game before entering a game company?
  2. Is a game engine usually made from Directx or OpenGl with a programming language(s)? I'm completely new to game design.
  3. null434

    Cubemap issue

    Hi, I encountered some issues as I attempted to render the scene with cube map. Currently there are  3 issues I think have to be solved. The scene is comprised of a grid with a grass texture rendered from vertex and index buffers,a sphere with texture loaded from a .dat file, and a cube map as sky made from Direct tool.    The first issue is in the scene, the sphere doesn't look right. Some of its faces disappears and I can look the inside of it. The second is the cube map(used as sky) is also doesn't look right as it looks too much like a cube that wraps the scene. The final is only when I put the render loop of the cube map ahead of the render loop for grid and sphere, can it be displayed correctly, otherwise the sphere and grid disappear.   The Shader code is in effect.txt, and the source code is in sourcecode.txt.   I think the cause of problems is likely in the source code. If you can have a look, thanks for any help.
  4. I'm using visual studio c++ 2012 on windows 7 and directx 10. I copied the code from the tutorial in the directx sdk documention which produces a flat triangle on screen. I can successfully compile the code and see the result but when I sent the .exe and necessary .fx file to other computer, the user on the other side encountered a problem that the window appears and disappeared quickly after clicking the .exe. I've installed c++ redistributed 2012 x86 update 3 on that computer but it seems that's not where problem is.    Here's the shader code:       struct vin                          // The input to vertex shader { float4 pos : POSITION; float4 col : COLOR; };   struct vout                      // The output of vertex shader and input of pixel shader { float4 pos : SV_POSITION; float4 col : COLOR; };   // // Vertex Shader // vout VS( vin Vin )  { vout Vout;     Vout.pos = Vin.pos; Vout.col = Vin.col; return Vout; }     // // Pixel Shader // float4 PS( vout Vout) : SV_Target {     return Vout.col;    }     technique10 Render {     pass P0     {         SetVertexShader( CompileShader( vs_4_0, VS() ) );         SetPixelShader( CompileShader( ps_4_0, PS() ) );     } }   And since the source code is too long, I added it as an attach file.  
  5. null434

    Transformation

    Thanks. Another question: I read from a tutorial  from Directx SDK that explains how render a flat triangle on screen and it said the vertices of the flat triangle are already defined in screen space. My question is how to let Direct3D know I define vertices in object space? It looks like Direct3D automatically sees the vertices put into vertex buffer as untransformed?
  6. I'd like to know which transformation matrix put the 3d objects into viewing frustum? Is that view matrix? And is that projection matrix is just to create the viewing frustum, if not, then what does?  And also what is projection space?
  7. I want to render 3 vertices in the vertex buffer to the screen to form a triangle. But instead a black window appeared and there was no vertices. the code is the following..       #include <windows.h> #include <d3d10.h> #include<D3DX10.h>   #pragma comment( lib, "D3DX10.lib" ) #pragma comment( lib, "D3D10.lib" ) const int width = 640; const int height = 640;    const char ClassName[] = "myWindowClass";   // D3D() bool D3D();   ID3D10Device* mDevice=0; IDXGISwapChain* mSwapChain=NULL; ID3D10Effect* effect=0; ID3D10EffectTechnique *technique=NULL; ID3D10InputLayout* input=0; ID3D10Buffer* vbd=0;   HWND hwnd; // The HWND to the window   // Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {     switch(msg)     {         case WM_CLOSE:             DestroyWindow(hwnd);         break;         case WM_DESTROY:             PostQuitMessage(0);         break;         default:             return DefWindowProc(hwnd, msg, wParam, lParam);     }     return 0; }   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,     LPSTR lpCmdLine, int nCmdShow) {     WNDCLASSEX wc;     MSG Msg;       //Step 1: Registering the Window Class     wc.cbSize        = sizeof(WNDCLASSEX);     wc.style         = 0;     wc.lpfnWndProc   = WndProc;     wc.cbClsExtra    = 0;     wc.cbWndExtra    = 0;     wc.hInstance     = hInstance;     wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);     wc.lpszMenuName  = NULL;     wc.lpszClassName = L"ClassName";     wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);       if(!RegisterClassEx(&wc))     {         MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"),             MB_ICONEXCLAMATION | MB_OK);         return 0;     }       // Step 2: Creating the Window     hwnd = CreateWindowEx(         WS_EX_CLIENTEDGE,         L"ClassName",         TEXT("The title of my window"),         WS_OVERLAPPEDWINDOW,         CW_USEDEFAULT, CW_USEDEFAULT, width, height,         NULL, NULL, hInstance, NULL);       if(hwnd == NULL)     {         MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"),             MB_ICONEXCLAMATION | MB_OK);         return 0;     }       ShowWindow(hwnd, nCmdShow);     UpdateWindow(hwnd); D3D();     // Step 3: The Message Loop     while(GetMessage(&Msg, NULL, 0, 0) > 0)     { if (Msg.message == WM_QUIT) { break; }         TranslateMessage(&Msg);         DispatchMessage(&Msg);     }     return Msg.wParam; }     bool D3D()     { DXGI_SWAP_CHAIN_DESC SwapchainDESC; SwapchainDESC.BufferDesc.Width = width ; // SwapchainDESC.BufferDesc.Height = height ; // SwapchainDESC.BufferDesc.RefreshRate.Numerator = 60; SwapchainDESC.BufferDesc.RefreshRate.Denominator = 1 ; SwapchainDESC.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM ; SwapchainDESC.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED ; SwapchainDESC.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED ;   //no Multisampling SwapchainDESC.SampleDesc.Count = 1; SwapchainDESC.SampleDesc.Quality = 0;   SwapchainDESC.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT ; SwapchainDESC.BufferCount = 1 ; SwapchainDESC.OutputWindow =  hwnd; // SwapchainDESC.Windowed = true ; // SwapchainDESC.SwapEffect = DXGI_SWAP_EFFECT_DISCARD ; SwapchainDESC.Flags =  0 ;   // Create D3D10Device and SwapChain     if(FAILED(D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &SwapchainDESC, &mSwapChain, &mDevice))) {MessageBox(hwnd, L"DEVE",L"error",MB_OK); return FALSE; }           D3D10_VIEWPORT vp;     vp.Width = 1024;     vp.Height = 1024;     vp.MinDepth = 0.0f;     vp.MaxDepth = 1.0f;     vp.TopLeftX = 0;     vp.TopLeftY = 0;     mDevice->RSSetViewports( 1, &vp ); // Create Render Target View and set back buffer as Render Target     ID3D10RenderTargetView* mRenderTargetView=0; ID3D10Texture2D* backBuffer=0; if(FAILED(mSwapChain -> GetBuffer(0,__uuidof(ID3D10Texture2D), reinterpret_cast<void**>(&backBuffer)))) {MessageBox(hwnd, L"swap",L"error",MB_OK); return FALSE; } mDevice -> CreateRenderTargetView ( backBuffer, 0, &mRenderTargetView ); backBuffer->Release();   D3D10_TEXTURE2D_DESC depthDESC; depthDESC.Width = width; //The width of the client area of the window depthDESC.Height = height; depthDESC.MipLevels = 1; depthDESC.ArraySize = 1; depthDESC.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthDESC.SampleDesc.Count = 1; //multisampling must match depthDESC.SampleDesc.Quality = 0; depthDESC.Usage = D3D10_USAGE_DEFAULT; depthDESC.BindFlags = D3D10_BIND_DEPTH_STENCIL; depthDESC.CPUAccessFlags = 0; depthDESC.MiscFlags = 0;   // Create the Depth/Stencil Buffer and View   ID3D10Texture2D* mDepthStencilBuffer; ID3D10DepthStencilView* mDepthStencilView;   mDevice -> CreateTexture2D( &depthDESC,  0, &mDepthStencilBuffer); mDevice -> CreateDepthStencilView( mDepthStencilBuffer, 0 , &mDepthStencilView );   // Bind the Views to the Outout Merger Stage   mDevice -> OMSetRenderTargets(1, &mRenderTargetView, mDepthStencilView );       if(FAILED(D3DX10CreateEffectFromFile(L"Empty.fx", NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,    mDevice, NULL, NULL, &effect, NULL, NULL))) {   MessageBox(hwnd, L"effect,", L"error", MB_OK); return FALSE; }       // Obtain technique   if(FAILED(technique = effect->GetTechniqueByName("Render"))) { MessageBox(hwnd, L"technique",L"error",MB_OK); return FALSE; }     // Define layout   D3D10_INPUT_ELEMENT_DESC layout[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}   };     UINT num = sizeof(layout)/sizeof(layout[0]);   // Create layout   D3D10_PASS_DESC PassDesc; technique->GetPassByIndex(0)->GetDesc(&PassDesc); mDevice->CreateInputLayout(layout, 1, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &input);   mDevice->IASetInputLayout(input);     // Vertex Struct   struct Vertex { D3DXVECTOR3 pos; };   // Initialization Vertices   Vertex vertices[]= { {D3DXVECTOR3 ( 0.0f, 0.5f, 0.5f )}, {D3DXVECTOR3 ( 1.0f, -0.5f, 0.5f)}, {D3DXVECTOR3 ( -1.0f, -0.5f, 0.5f)} }; // Create Vertex Desc   D3D10_BUFFER_DESC bd; bd.Usage = D3D10_USAGE_DEFAULT; bd.ByteWidth = sizeof(Vertex)*3; bd.BindFlags = D3D10_BIND_VERTEX_BUFFER; bd.CPUAccessFlags = 0; bd.MiscFlags = 0; D3D10_SUBRESOURCE_DATA Initdata; Initdata.pSysMem = vertices; mDevice->CreateBuffer( &bd, &Initdata, &vbd);     // Set vertex buffer   UINT stride = sizeof(Vertex); UINT offset = 0; mDevice->IASetVertexBuffers( 0, 1, &vbd, &stride, &offset);   // Set Topology mDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);   // Render       D3D10_TECHNIQUE_DESC techDesc;     technique->GetDesc( &techDesc );     for( UINT p = 0; p < techDesc.Passes; ++p )     {   float col[4]={0.0f, 0.0f, 0.0f, 1.0f}; mDevice->ClearRenderTargetView(mRenderTargetView, col); mDevice->Draw(3,0); mSwapChain->Present(0,0); } return true; }     And the shader code is   //-------------------------------------------------------------------------------------- // 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 }     //-------------------------------------------------------------------------------------- technique10 Render {     pass P0     {         SetVertexShader( CompileShader( vs_4_0, VS() ) );         SetGeometryShader( NULL );         SetPixelShader( CompileShader( ps_4_0, PS() ) );     } }     [attachment=17900:pic.jpg]     And when I executed the exe. file that is inside the Debug folder in the project folder, the window appeared but message box also appeared showing something is wrong with the D3DX10CreateEffectFromFile() in the code. I set up that message box to show when there is error with the function.   [attachment=17901:pic2.jpg]    
  8. null434

    Directx10

    Thanks for the replies. There's another quesiton.. I used FX Composer 2.5 to create a fx.file in which the shader code is following: cbuffer cbObject { float4x4 gWVP; };   void VS(float3 iPosL : POSITION,              out float4 oPosH : SV_POSITION) { oPosH = mul(float4(iPosL, 1.0f), gWVP); }   float4 PS(float4 oPosH : SV_POSITION) :SV_TARGET  {  return oPosH;  }   technique10 ColorTech { pass PO { SetVertexShader( CompileShader( vs_4_0, VS() ); SetGeometryShader(NULL); SetPixelShader(CompileShader( ps_4_0, PS() ); } }   And I added the fx file in the Resource files. When I launched debugger, a series of errors appeared as following:   1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(2): error C2146: syntax error : missing ';' before identifier 'cbObject' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(2): error C2470: 'cbObject' : looks like a function definition, but there is no parameter list; skipping apparent body 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(6): error C2065: 'float3' : undeclared identifier 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(6): error C2146: syntax error : missing ')' before identifier 'iPosL' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(6): error C2182: 'VS' : illegal use of type 'void' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(6): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7): error C2146: syntax error : missing ';' before identifier 'float4' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7): error C2146: syntax error : missing ';' before identifier 'oPosH' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7): error C2470: 'oPosH' : looks like a function definition, but there is no parameter list; skipping apparent body 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7): error C2059: syntax error : ')' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(8): error C2059: syntax error : '{' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C2146: syntax error : missing ';' before identifier 'PS' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C2086: 'int float4' : redefinition 1>          c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(7) : see declaration of 'float4' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C2146: syntax error : missing ')' before identifier 'oPosH' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C2059: syntax error : ')' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(11): error C2470: 'SV_POSITION' : looks like a function definition, but there is no parameter list; skipping apparent body 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(12): error C2059: syntax error : '{' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(17): error C2146: syntax error : missing ';' before identifier 'ColorTech' 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\peter\documents\visual studio 2010\projects\newpp\newpp\ew.fx(17): error C2470: 'ColorTech' : looks like a function definition, but there is no parameter list; skipping apparent body   Is it the problem that I integrated the fx file in the wrong way?
  9. null434

    Directx10

    I have set up one input layout and one vertex buffer that contains only three vertices. I wonder if i can only use that to draw the three vertices on the screen without using shader. I didn't declare ID3D10Effect or ID3D10EffectTechnique..
  10. null434

    Directx10

    Can I make points displayed on screen without technique and effect like directx 9? If so, what is the way to do that?
  • 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!