| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 523 人关注过本帖
标题:VS中既不说出错又不给生成.exe 的问题
只看楼主 加入收藏
Nitpicker
Rank: 1
等 级:新手上路
帖 子:26
专家分:8
注 册:2012-3-28
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:5 
VS中既不说出错又不给生成.exe 的问题
代码写好后在VS2005中点生成  
输出这样的结果:==== 生成: 0 已成功, 0 已失败, 1 最新, 0 已跳过 ==========
以前也遇到过,又没说哪里有错,又不能运行  ,莫名其妙啊
另外里面的最新指的是什么?
那位大哥知道原因 ?

[ 本帖最后由 Nitpicker 于 2012-12-2 12:18 编辑 ]
搜索更多相关主题的帖子: 大哥 
2012-12-02 12:04
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:14 
贴个错误信息出来看看?、
用vs建立一个空的工程
没有增加任何文件也没有main函数,也有这个问题的
不确定你的是怎么样

或者把你的工程发出来大家瞧瞧

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-02 13:05
Nitpicker
Rank: 1
等 级:新手上路
帖 子:26
专家分:8
注 册:2012-3-28
收藏
得分:0 
回复 2楼 yuccn
//这是用来做DirectX 练习的
#include<d3d9.h>
#include<d3dx9.h>

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

#define WINDOW_CLASS    L"UGPDX"
#define WINDOW_NAME     L"Template"
#define WINDOW_WIDTH    640
#define WINDOW_HEIGHT   480

//定义全局网面对象
LPD3DXMESH g_teapot=NULL;
LPD3DXMESH g_cube=NULL;
LPD3DXMESH g_sphere=NULL;
LPD3DXMESH g_torus=NULL;


// Function Prototypes...
bool InitializeD3D(HWND hWnd, bool fullscreen);
bool InitializeObjects();
void RenderScene();
void Shutdown();


// Direct3D object and device.
LPDIRECT3D9 g_D3D = NULL;
LPDIRECT3DDEVICE9 g_D3DDevice = NULL;

// Matrices.
D3DXMATRIX g_projection;
D3DXMATRIX g_ViewMatrix;
D3DXMATRIX g_WorldMatrix;


LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
   switch(msg)
      {
         case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
            break;

         case WM_KEYUP:
            if(wp == VK_ESCAPE) PostQuitMessage(0);
            break;
      }

   return DefWindowProc(hWnd, msg, wp, lp);
}


int WINAPI WinMain(HINSTANCE hInst, HINSTANCE ph, LPSTR cmd, int s)
{
   // Register the window class
   WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
                     GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                     WINDOW_CLASS, NULL };

   RegisterClassEx(&wc);

   // Create the application's window
   HWND hWnd = CreateWindow(WINDOW_CLASS, WINDOW_NAME,
      WS_OVERLAPPEDWINDOW, 100, 100, WINDOW_WIDTH, WINDOW_HEIGHT,
      GetDesktopWindow(), NULL, wc.hInstance, NULL);

   // Initialize Direct3D
   if(InitializeD3D(hWnd, false))
      {
         // Show the window
         ShowWindow(hWnd, SW_SHOWDEFAULT);
         UpdateWindow(hWnd);

         // Enter the message loop
         MSG msg;
         ZeroMemory(&msg, sizeof(msg));

         while(msg.message != WM_QUIT)
            {
               if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
                  {
                     TranslateMessage(&msg);
                     DispatchMessage(&msg);
                  }
               else
                  RenderScene();
            }
      }

   // Release any and all resources.
   Shutdown();

   // Unregister our window.
   UnregisterClass(WINDOW_CLASS, wc.hInstance);
   return 0;
}


bool InitializeD3D(HWND hWnd, bool fullscreen)
{
   D3DDISPLAYMODE displayMode;

   // Create the D3D object.
   g_D3D = Direct3DCreate9(D3D_SDK_VERSION);
   if(g_D3D == NULL) return false;

   // Get the desktop display mode.
   if(FAILED(g_D3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,
      &displayMode))) return false;

   // Set up the structure used to create the D3DDevice
   D3DPRESENT_PARAMETERS d3dpp;
   ZeroMemory(&d3dpp, sizeof(d3dpp));

   if(fullscreen)
      {
         d3dpp.Windowed = FALSE;
         d3dpp.BackBufferWidth = WINDOW_WIDTH;
         d3dpp.BackBufferHeight = WINDOW_HEIGHT;
      }
   else
      d3dpp.Windowed = TRUE;
   d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
   d3dpp.BackBufferFormat = displayMode.Format;

   // Create the D3DDevice
   if(FAILED(g_D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
      hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,
      &d3dpp, &g_D3DDevice))) return false;


   // Initialize any objects we will be displaying.
   if(!InitializeObjects()) return false;

   return true;
}


bool InitializeObjects()
{
   // Set the projection matrix.
   D3DXMatrixPerspectiveFovLH(&g_projection, 45.0f,
      WINDOW_WIDTH/WINDOW_HEIGHT, 0.1f, 1000.0f);

   g_D3DDevice->SetTransform(D3DTS_PROJECTION, &g_projection);

   // Set default rendering states.
   g_D3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

   //****************在这里创建网面对象
   if(FAILED(D3DXCreateTeapot(g_D3DDevice,&g_teapot,NULL)))  //Create a teapot
       return false;

   if(FAILED(D3DXCreateBox(g_D3DDevice,2,2,2,&g_cube,NULL))) //Create a box
       return false;

   if(FAILED(D3DXCreateSphere(g_D3DDevice,1.5,25,25,&g_sphere,NULL))) //Create a sphere
       return false;

   if(FAILED(D3DXCreateTorus(g_D3DDevice,0.5f,1.2f,25,25,&g_torus,NULL))) //Create a torus(圆环)
       return false;
 //////*************************

   // Define camera information.//要是看不到,或看不全物体可以改改下面的参数
   D3DXVECTOR3 cameraPos(0.0f, 0.0f, 9.0f);
   D3DXVECTOR3 lookAtPos(0.0f, 0.0f, 0.0f);
   D3DXVECTOR3 upDir(0.0f, 1.0f, 0.0f);

   // Build view matrix.
   D3DXMatrixLookAtLH(&g_ViewMatrix, &cameraPos,
                      &lookAtPos, &upDir);

   return true;
}


void RenderScene()
{
   // Clear the backbuffer.
   g_D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET,
                      D3DCOLOR_XRGB(0,0,0), 1.0f, 0);

   // Begin the scene.  Start rendering.
   g_D3DDevice->BeginScene();

      // Apply the view (camera).
      g_D3DDevice->SetTransform(D3DTS_VIEW, &g_ViewMatrix);

      ////*************************开始画对象
      //teapot
      D3DXMatrixTranslation(&g_WorldMatrix,2.0f,-2.0,0.0f);
      g_D3DDevice->SetTransform(D3DTS_WORLD,&g_WorldMatrix);
      g_teapot->DrawSubset(0);   //唯一的参数指的是要绘制的索引,应该是网面索引吧

      //Cube
      D3DXMatrixTranslation(&g_WorldMatrix,-2.0f,-2.0,0.0f);  //每次创建物体时都要应用一次矩阵变换吗?为什么?
      g_D3DDevice->SetTransform(D3DTS_WORLD,&g_WorldMatrix);  //注意到后面的三个参数是xyz,不同的数值用来定义位置
      g_cube->DrawSubset(0);

      //Sphere.
      D3DXMatrixTranslation(&g_WorldMatrix,2.0f,2.0,0.0f);  
      g_D3DDevice->SetTransform(D3DTS_WORLD,&g_WorldMatrix);
      g_sphere->DrawSubset(0);

      //Torus.
      D3DXMatrixTranslation(&g_WorldMatrix,-2.0f,2.0,0.0f);
      g_D3DDevice->SetTransform(D3DTS_WORLD,&g_WorldMatrix);
      g_torus->DrawSubset(0);
      //************************************
      
   // End the scene.  Stop rendering.
   g_D3DDevice->EndScene();

   // Display the scene.
   g_D3DDevice->Present(NULL, NULL, NULL, NULL);
}


void Shutdown()
{
   // Release all resources.
   if(g_D3DDevice != NULL) g_D3DDevice->Release();
   if(g_D3D != NULL) g_D3D->Release();
   
   //释放网面对象
   if(g_teapot !=NULL){g_teapot->Release();  g_teapot=NULL;}
   if(g_cube !=NULL)  {g_cube->Release();    g_teapot=NULL;}
   if(g_sphere !=NULL){g_sphere->Release();  g_sphere=NULL;}
   if(g_torus !=NULL) {g_torus->Release();   g_torus=NULL;}


   g_D3DDevice = NULL;
   g_D3D = NULL;
}
2012-12-02 17:01
Nitpicker
Rank: 1
等 级:新手上路
帖 子:26
专家分:8
注 册:2012-3-28
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

没编译成功,同时又说“失败0” 什么意思?

[ 本帖最后由 Nitpicker 于 2012-12-2 17:03 编辑 ]
2012-12-02 17:02
Nitpicker
Rank: 1
等 级:新手上路
帖 子:26
专家分:8
注 册:2012-3-28
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

没人解答,自己解决了问题  原来我在工程属性里把上面的两个依赖库添加就运行成功了,
上个图供后人借鉴
不过VS没有依赖库都不报错,应该算一个Bug吧

[ 本帖最后由 Nitpicker 于 2012-12-3 11:28 编辑 ]
2012-12-03 11:27
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
回复 5楼 Nitpicker
有依赖项时候,要自己增加进去的,默认不会帮你加进去的。

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-03 23:41
快速回复:VS中既不说出错又不给生成.exe 的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020476 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved