DirectX未解决的外部错误 [英] DirectX unresolved external error

查看:163
本文介绍了DirectX未解决的外部错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图进入一些directX编程,所以我下面这本书叫开始Dir​​ectX 11游戏编程,但我已经在第二个例子。



我花了大约一个小时来寻找解决这个问题的方法,但没有找到任何可以帮助我的东西。



所以我得到的错误代码是这样的:

  Main.obj:error LNK2019:unresolved external symbollong __stdcall WndProc在函数_wWinMain @ 16中引用的(struct HWND__ *,unsigned int,unsigned int,long)(?WndProc @@ YGJPAUHWND __ @@ IIJ @ Z) 

除了LRESULT CALLBACK WndProc

  #include< Windows.h> 

LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);

int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE prevInstance,LPWSTR cmdLine,int cmdShow)
{
UNREFERENCED_PARAMETER(prevInstance);
UNREFERENCED_PARAMETER(cmdLine);

WNDCLASSEX wndClass = {0};
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.hInstance = hInstance;
wndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndClass.hbrBackground =(HBRUSH)(COLOR_WINDOW + 1);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName =DX11BookWindowClass;

if(!RegisterClassEx(& wndClass))
return -1;

RECT rc = {0,0,640,480};
AdjustWindowRect(& rc,WS_OVERLAPPEDWINDOW; FALSE);

HWND hwnd = CreateWindowA(DX11BookWindowClass,Blank Win32 Window,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,rc.right - rc.left,
rc.bottom - rc.top,NULL ,NULL,hInstance,NULL);

if(!hwnd)
return -1;

ShowWindow(hwnd,cmdShow);

return 0;
}


解决方案

返回 一个可怕的想法> c> c> em>。所以你可以自己定义它来处理消息,或者只是使用默认的过程:

  wndClass.lpfnWndProc = DefWindowProc; 

或者:

 code> LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam){return DefWindowProc(hWnd,msg,wParam,lParam); } 

每当您不处理邮件时,应该这样做。


So I'm trying to get into some directX programming so I'm following this book called "Beginning DirectX 11 Game Programming", but I'm stuck already at the second example.

I've spend roughly an hour searching for a solution to this problem, but havn't been able to find anything that could help me.

So the error code I'm getting is this.:

Main.obj : error LNK2019: unresolved external symbol "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z) referenced in function _wWinMain@16

And here's the code - written exactly as in the book, except for LRESULT CALLBACK WndProc

#include <Windows.h>

LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );

int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow )
{
    UNREFERENCED_PARAMETER( prevInstance );
    UNREFERENCED_PARAMETER( cmdLine );

    WNDCLASSEX wndClass = { 0 };
    wndClass.cbSize = sizeof( WNDCLASSEX );
    wndClass.style = CS_HREDRAW | CS_VREDRAW;
    wndClass.lpfnWndProc = WndProc;
    wndClass.hInstance = hInstance;
    wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
    wndClass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
    wndClass.lpszMenuName = NULL;
    wndClass.lpszClassName = "DX11BookWindowClass";

    if( !RegisterClassEx( &wndClass ) )
        return -1;

    RECT rc = { 0,0,640,480 };
    AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );

    HWND hwnd = CreateWindowA( "DX11BookWindowClass", "Blank Win32 Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left,
                                rc.bottom - rc.top, NULL, NULL, hInstance, NULL );

    if( !hwnd )
        return -1;

    ShowWindow( hwnd, cmdShow );

    return 0;
}

解决方案

Returning 0 from your WndProc callback IS a terrible idea if you're not handling any messages. So you can either define it to handle messages yourself, or simply use the default procedure:

wndClass.lpfnWndProc = DefWindowProc;

Alternatively:

LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc(hWnd, msg, wParam, lParam); }

Which you should do whenever you don't handle your messages.

这篇关于DirectX未解决的外部错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆