<legend id='z9qvl'><style id='z9qvl'><dir id='z9qvl'><q id='z9qvl'></q></dir></style></legend>
  • <i id='z9qvl'><tr id='z9qvl'><dt id='z9qvl'><q id='z9qvl'><span id='z9qvl'><b id='z9qvl'><form id='z9qvl'><ins id='z9qvl'></ins><ul id='z9qvl'></ul><sub id='z9qvl'></sub></form><legend id='z9qvl'></legend><bdo id='z9qvl'><pre id='z9qvl'><center id='z9qvl'></center></pre></bdo></b><th id='z9qvl'></th></span></q></dt></tr></i><div id='z9qvl'><tfoot id='z9qvl'></tfoot><dl id='z9qvl'><fieldset id='z9qvl'></fieldset></dl></div>

    <small id='z9qvl'></small><noframes id='z9qvl'>

  • <tfoot id='z9qvl'></tfoot>

          <bdo id='z9qvl'></bdo><ul id='z9qvl'></ul>

        FXC:错误 X3501:'main':未找到入口点

        FXC : error X3501: #39;main#39;: entrypoint not found(FXC:错误 X3501:main:未找到入口点)

        <small id='J2dTB'></small><noframes id='J2dTB'>

                <tfoot id='J2dTB'></tfoot>
              1. <legend id='J2dTB'><style id='J2dTB'><dir id='J2dTB'><q id='J2dTB'></q></dir></style></legend>
                • <bdo id='J2dTB'></bdo><ul id='J2dTB'></ul>

                • <i id='J2dTB'><tr id='J2dTB'><dt id='J2dTB'><q id='J2dTB'><span id='J2dTB'><b id='J2dTB'><form id='J2dTB'><ins id='J2dTB'></ins><ul id='J2dTB'></ul><sub id='J2dTB'></sub></form><legend id='J2dTB'></legend><bdo id='J2dTB'><pre id='J2dTB'><center id='J2dTB'></center></pre></bdo></b><th id='J2dTB'></th></span></q></dt></tr></i><div id='J2dTB'><tfoot id='J2dTB'></tfoot><dl id='J2dTB'><fieldset id='J2dTB'></fieldset></dl></div>
                    <tbody id='J2dTB'></tbody>
                  本文介绍了FXC:错误 X3501:'main':未找到入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在学习一本名为:DirectX 11 的 3D 游戏编程简介

                  I am following an example book called: Introduction to 3D Game Programming with DirectX 11

                  都是用VS2010写的.我想尝试使用VS2013...它是Windows桌面程序的示例项目

                  It is all written in VS2010. I would like to try using VS2013... It is an example project for Windows Desktop Program

                  我有一个包含以下内容的程序(包括一些其他常用文件):

                  I have a program with the following in it (including some other files as part of common use):

                  color.fx

                  //***************************************************************************************
                  // color.fx by Frank Luna (C) 2011 All Rights Reserved.
                  //
                  // Transforms and colors geometry.
                  //***************************************************************************************
                  
                  cbuffer cbPerObject
                  {
                      float4x4 gWorldViewProj; 
                  };
                  
                  struct VertexIn
                  {
                      float3 PosL  : POSITION;
                      float4 Color : COLOR;
                  };
                  
                  struct VertexOut
                  {
                      float4 PosH  : SV_POSITION;
                      float4 Color : COLOR;
                  };
                  
                  VertexOut VS(VertexIn vin)
                  {
                      VertexOut vout;
                  
                      // Transform to homogeneous clip space.
                      vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj);
                  
                      // Just pass vertex color into the pixel shader.
                      vout.Color = vin.Color;
                  
                      return vout;
                  }
                  
                  float4 PS(VertexOut pin) : SV_Target
                  {
                      return pin.Color;
                  }
                  
                  technique11 ColorTech
                  {
                      pass P0
                      {
                          SetVertexShader( CompileShader( vs_5_0, VS() ) );
                          SetGeometryShader( NULL );
                          SetPixelShader( CompileShader( ps_5_0, PS() ) );
                      }
                  }
                  

                  BoxDemo.cpp

                  //***************************************************************************************
                  // BoxDemo.cpp by Frank Luna (C) 2011 All Rights Reserved.
                  //
                  // Demonstrates rendering a colored box.
                  //
                  // Controls:
                  //      Hold the left mouse button down and move the mouse to rotate.
                  //      Hold the right mouse button down to zoom in and out.
                  //
                  //***************************************************************************************
                  
                  #include "d3dApp.h"
                  #include "d3dx11Effect.h"
                  #include "MathHelper.h"
                  
                  struct Vertex
                  {
                      XMFLOAT3 Pos;
                      XMFLOAT4 Color;
                  };
                  
                  class BoxApp : public D3DApp
                  {
                  public:
                      BoxApp(HINSTANCE hInstance);
                      ~BoxApp();
                  
                      bool Init();
                      void OnResize();
                      void UpdateScene(float dt);
                      void DrawScene(); 
                  
                      void OnMouseDown(WPARAM btnState, int x, int y);
                      void OnMouseUp(WPARAM btnState, int x, int y);
                      void OnMouseMove(WPARAM btnState, int x, int y);
                  
                  private:
                      void BuildGeometryBuffers();
                      void BuildFX();
                      void BuildVertexLayout();
                  
                  private:
                      ID3D11Buffer* mBoxVB;
                      ID3D11Buffer* mBoxIB;
                  
                      ID3DX11Effect* mFX;
                      ID3DX11EffectTechnique* mTech;
                      ID3DX11EffectMatrixVariable* mfxWorldViewProj;
                  
                      ID3D11InputLayout* mInputLayout;
                  
                      XMFLOAT4X4 mWorld;
                      XMFLOAT4X4 mView;
                      XMFLOAT4X4 mProj;
                  
                      float mTheta;
                      float mPhi;
                      float mRadius;
                  
                      POINT mLastMousePos;
                  };
                  
                  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance,
                                     PSTR cmdLine, int showCmd)
                  {
                      // Enable run-time memory check for debug builds.
                  #if defined(DEBUG) | defined(_DEBUG)
                      _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
                  #endif
                  
                      BoxApp theApp(hInstance);
                  
                      if( !theApp.Init() )
                          return 0;
                  
                      return theApp.Run();
                  }
                  
                  
                  BoxApp::BoxApp(HINSTANCE hInstance)
                  : D3DApp(hInstance), mBoxVB(0), mBoxIB(0), mFX(0), mTech(0),
                    mfxWorldViewProj(0), mInputLayout(0), 
                    mTheta(1.5f*MathHelper::Pi), mPhi(0.25f*MathHelper::Pi), mRadius(5.0f)
                  {
                      mMainWndCaption = L"Box Demo";
                  
                      mLastMousePos.x = 0;
                      mLastMousePos.y = 0;
                  
                      XMMATRIX I = XMMatrixIdentity();
                      XMStoreFloat4x4(&mWorld, I);
                      XMStoreFloat4x4(&mView, I);
                      XMStoreFloat4x4(&mProj, I);
                  }
                  
                  BoxApp::~BoxApp()
                  {
                      ReleaseCOM(mBoxVB);
                      ReleaseCOM(mBoxIB);
                      ReleaseCOM(mFX);
                      ReleaseCOM(mInputLayout);
                  }
                  
                  bool BoxApp::Init()
                  {
                      if(!D3DApp::Init())
                          return false;
                  
                      BuildGeometryBuffers();
                      BuildFX();
                      BuildVertexLayout();
                  
                      return true;
                  }
                  
                  void BoxApp::OnResize()
                  {
                      D3DApp::OnResize();
                  
                      // The window resized, so update the aspect ratio and recompute the projection matrix.
                      XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f);
                      XMStoreFloat4x4(&mProj, P);
                  }
                  
                  void BoxApp::UpdateScene(float dt)
                  {
                      // Convert Spherical to Cartesian coordinates.
                      float x = mRadius*sinf(mPhi)*cosf(mTheta);
                      float z = mRadius*sinf(mPhi)*sinf(mTheta);
                      float y = mRadius*cosf(mPhi);
                  
                      // Build the view matrix.
                      XMVECTOR pos    = XMVectorSet(x, y, z, 1.0f);
                      XMVECTOR target = XMVectorZero();
                      XMVECTOR up     = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
                  
                      XMMATRIX V = XMMatrixLookAtLH(pos, target, up);
                      XMStoreFloat4x4(&mView, V);
                  }
                  
                  void BoxApp::DrawScene()
                  {
                      md3dImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&Colors::LightSteelBlue));
                      md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);
                  
                      md3dImmediateContext->IASetInputLayout(mInputLayout);
                      md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
                  
                      UINT stride = sizeof(Vertex);
                      UINT offset = 0;
                      md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB, &stride, &offset);
                      md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);
                  
                      // Set constants
                      XMMATRIX world = XMLoadFloat4x4(&mWorld);
                      XMMATRIX view  = XMLoadFloat4x4(&mView);
                      XMMATRIX proj  = XMLoadFloat4x4(&mProj);
                      XMMATRIX worldViewProj = world*view*proj;
                  
                      mfxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj));
                  
                      D3DX11_TECHNIQUE_DESC techDesc;
                      mTech->GetDesc( &techDesc );
                      for(UINT p = 0; p < techDesc.Passes; ++p)
                      {
                          mTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
                  
                          // 36 indices for the box.
                          md3dImmediateContext->DrawIndexed(36, 0, 0);
                      }
                  
                      HR(mSwapChain->Present(0, 0));
                  }
                  
                  void BoxApp::OnMouseDown(WPARAM btnState, int x, int y)
                  {
                      mLastMousePos.x = x;
                      mLastMousePos.y = y;
                  
                      SetCapture(mhMainWnd);
                  }
                  
                  void BoxApp::OnMouseUp(WPARAM btnState, int x, int y)
                  {
                      ReleaseCapture();
                  }
                  
                  void BoxApp::OnMouseMove(WPARAM btnState, int x, int y)
                  {
                      if( (btnState & MK_LBUTTON) != 0 )
                      {
                          // Make each pixel correspond to a quarter of a degree.
                          float dx = XMConvertToRadians(0.25f*static_cast<float>(x - mLastMousePos.x));
                          float dy = XMConvertToRadians(0.25f*static_cast<float>(y - mLastMousePos.y));
                  
                          // Update angles based on input to orbit camera around box.
                          mTheta += dx;
                          mPhi   += dy;
                  
                          // Restrict the angle mPhi.
                          mPhi = MathHelper::Clamp(mPhi, 0.1f, MathHelper::Pi-0.1f);
                      }
                      else if( (btnState & MK_RBUTTON) != 0 )
                      {
                          // Make each pixel correspond to 0.005 unit in the scene.
                          float dx = 0.005f*static_cast<float>(x - mLastMousePos.x);
                          float dy = 0.005f*static_cast<float>(y - mLastMousePos.y);
                  
                          // Update the camera radius based on input.
                          mRadius += dx - dy;
                  
                          // Restrict the radius.
                          mRadius = MathHelper::Clamp(mRadius, 3.0f, 15.0f);
                      }
                  
                      mLastMousePos.x = x;
                      mLastMousePos.y = y;
                  }
                  
                  void BoxApp::BuildGeometryBuffers()
                  {
                      // Create vertex buffer
                      Vertex vertices[] =
                      {
                          { XMFLOAT3(-1.0f, -1.0f, -1.0f), (const float*)&Colors::White   },
                          { XMFLOAT3(-1.0f, +1.0f, -1.0f), (const float*)&Colors::Black   },
                          { XMFLOAT3(+1.0f, +1.0f, -1.0f), (const float*)&Colors::Red     },
                          { XMFLOAT3(+1.0f, -1.0f, -1.0f), (const float*)&Colors::Green   },
                          { XMFLOAT3(-1.0f, -1.0f, +1.0f), (const float*)&Colors::Blue    },
                          { XMFLOAT3(-1.0f, +1.0f, +1.0f), (const float*)&Colors::Yellow  },
                          { XMFLOAT3(+1.0f, +1.0f, +1.0f), (const float*)&Colors::Cyan    },
                          { XMFLOAT3(+1.0f, -1.0f, +1.0f), (const float*)&Colors::Magenta }
                      };
                  
                      D3D11_BUFFER_DESC vbd;
                      vbd.Usage = D3D11_USAGE_IMMUTABLE;
                      vbd.ByteWidth = sizeof(Vertex) * 8;
                      vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
                      vbd.CPUAccessFlags = 0;
                      vbd.MiscFlags = 0;
                      vbd.StructureByteStride = 0;
                      D3D11_SUBRESOURCE_DATA vinitData;
                      vinitData.pSysMem = vertices;
                      HR(md3dDevice->CreateBuffer(&vbd, &vinitData, &mBoxVB));
                  
                  
                      // Create the index buffer
                  
                      UINT indices[] = {
                          // front face
                          0, 1, 2,
                          0, 2, 3,
                  
                          // back face
                          4, 6, 5,
                          4, 7, 6,
                  
                          // left face
                          4, 5, 1,
                          4, 1, 0,
                  
                          // right face
                          3, 2, 6,
                          3, 6, 7,
                  
                          // top face
                          1, 5, 6,
                          1, 6, 2,
                  
                          // bottom face
                          4, 0, 3, 
                          4, 3, 7
                      };
                  
                      D3D11_BUFFER_DESC ibd;
                      ibd.Usage = D3D11_USAGE_IMMUTABLE;
                      ibd.ByteWidth = sizeof(UINT) * 36;
                      ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
                      ibd.CPUAccessFlags = 0;
                      ibd.MiscFlags = 0;
                      ibd.StructureByteStride = 0;
                      D3D11_SUBRESOURCE_DATA iinitData;
                      iinitData.pSysMem = indices;
                      HR(md3dDevice->CreateBuffer(&ibd, &iinitData, &mBoxIB));
                  }
                  
                  void BoxApp::BuildFX()
                  {
                      DWORD shaderFlags = 0;
                  #if defined( DEBUG ) || defined( _DEBUG )
                      shaderFlags |= D3D10_SHADER_DEBUG;
                      shaderFlags |= D3D10_SHADER_SKIP_OPTIMIZATION;
                  #endif
                  
                      ID3D10Blob* compiledShader = 0;
                      ID3D10Blob* compilationMsgs = 0;
                      HRESULT hr = D3DX11CompileFromFile(L"FX/color.fx", 0, 0, 0, "fx_5_0", shaderFlags, 
                          0, 0, &compiledShader, &compilationMsgs, 0);
                  
                      // compilationMsgs can store errors or warnings.
                      if( compilationMsgs != 0 )
                      {
                          MessageBoxA(0, (char*)compilationMsgs->GetBufferPointer(), 0, 0);
                          ReleaseCOM(compilationMsgs);
                      }
                  
                      // Even if there are no compilationMsgs, check to make sure there were no other errors.
                      if(FAILED(hr))
                      {
                          DXTrace(__FILE__, (DWORD)__LINE__, hr, L"D3DX11CompileFromFile", true);
                      }
                  
                      HR(D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 
                          0, md3dDevice, &mFX));
                  
                      // Done with compiled shader.
                      ReleaseCOM(compiledShader);
                  
                      mTech    = mFX->GetTechniqueByName("ColorTech");
                      mfxWorldViewProj = mFX->GetVariableByName("gWorldViewProj")->AsMatrix();
                  }
                  
                  void BoxApp::BuildVertexLayout()
                  {
                      // Create the vertex input layout.
                      D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
                      {
                          {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
                          {"COLOR",    0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}
                      };
                  
                      // Create the input layout
                      D3DX11_PASS_DESC passDesc;
                      mTech->GetPassByIndex(0)->GetDesc(&passDesc);
                      HR(md3dDevice->CreateInputLayout(vertexDesc, 2, passDesc.pIAInputSignature, 
                          passDesc.IAInputSignatureSize, &mInputLayout));
                  }
                  

                  当我去编译它时,它抛出错误:

                  When I goto compile it it throws the error:

                  FXC : error X3501: 'main': entrypoint not found
                  

                  示例中我的着色器文件的入口点是什么?以及如何在着色器编译器属性中设置它?考虑到它在着色器文件中提到 vs_5_0,我是否还必须将其设置为着色器 5?

                  What is the entry point of my shader file from the examples? and how do I set that in the shader compiler properties? do I also have to set it to shader 5 considering it is mentioning vs_5_0 in the shader file?

                  我尝试了以下文章的变体:http://social.msdn.microsoft.com/Forums/windowsapps/en-US/51859322-fc36-4946-b4cb-b5971fcaa9e5/fxc-error-x3501-main-entrypoint-not-found?forum=wingameswithdirectx 但就是无法运行.

                  I have tried a variation of the following article: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/51859322-fc36-4946-b4cb-b5971fcaa9e5/fxc-error-x3501-main-entrypoint-not-found?forum=wingameswithdirectx but just can't get it to run.

                  推荐答案

                  以下选项仅适用于 Visual Studio 2012 或更高版本.

                  如果你编译一个.fx文件,你可以将着色器类型设置为fx",如下所示:

                  If you compile a .fx file, you can set the shader type to "fx" as below:

                  1. 在 VS 中右键单击您的项目并选择属性

                  1. Right click your project in VS and select properties

                  展开HLSL编译器选项,Shader Type选择Effect(/fx)",即可还为入口点名称指定入口点函数.

                  Expand the HLSL compiler option, select "Effect(/fx)" for Shader Type, you can also specify a entry point function for Entrypoint Name.

                  这篇关于FXC:错误 X3501:'main':未找到入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                  Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                  Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                  Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                  How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                  Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                  <small id='B5ct0'></small><noframes id='B5ct0'>

                  <i id='B5ct0'><tr id='B5ct0'><dt id='B5ct0'><q id='B5ct0'><span id='B5ct0'><b id='B5ct0'><form id='B5ct0'><ins id='B5ct0'></ins><ul id='B5ct0'></ul><sub id='B5ct0'></sub></form><legend id='B5ct0'></legend><bdo id='B5ct0'><pre id='B5ct0'><center id='B5ct0'></center></pre></bdo></b><th id='B5ct0'></th></span></q></dt></tr></i><div id='B5ct0'><tfoot id='B5ct0'></tfoot><dl id='B5ct0'><fieldset id='B5ct0'></fieldset></dl></div>
                    <tfoot id='B5ct0'></tfoot>
                      <bdo id='B5ct0'></bdo><ul id='B5ct0'></ul>
                        <legend id='B5ct0'><style id='B5ct0'><dir id='B5ct0'><q id='B5ct0'></q></dir></style></legend>
                              <tbody id='B5ct0'></tbody>