C++ 未定义Directx错误y

C++ 未定义Directx错误y,c++,directx,undefined,directx-9,C++,Directx,Undefined,Directx 9,因此,我试图从Chillitomatos教程中获得一个简单的程序来工作,但我遇到了一个我不理解的错误 #include "D3DGraphics.h" D3DGraphics::D3DGraphics( HWND hWnd ) { pDirect3D = Direct3DCreate9( D3D_SDK_VERSION ); D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp,sizeof( d3dpp ) );

因此,我试图从Chillitomatos教程中获得一个简单的程序来工作,但我遇到了一个我不理解的错误

#include "D3DGraphics.h"

D3DGraphics::D3DGraphics( HWND hWnd )
{
    pDirect3D = Direct3DCreate9( D3D_SDK_VERSION );

    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp,sizeof( d3dpp ) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
    d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

    pDirect3D->CreateDevice( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,
        D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,&d3dpp,&pDevice );
}

D3DGraphics::~D3DGraphics()
{
    if( pDevice )
    {
        pDevice->Release();
        pDevice = NULL;
    }
    if( pDirect3D )
    {
        pDirect3D->Release();
        pDirect3D = NULL;
    }
}

void D3DGraphics::PutPixel( int x,int y,int r,int g,int b )
{
    IDirect3DSurface9* pBackBuffer = NULL;
    D3DLOCKED_RECT rect;

    pDevice->GetBackBuffer( 0,0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer );
    pBackBuffer->LockRect( &rect,NULL,NULL );
    ((D3DCOLOR*)rect.pBits)[ x + (rect.Pitch >> 2) * y ] = D3DCOLOR_XRGB( r,g,b );
    pBackBuffer->UnlockRect();
    pBackBuffer->Release();
}


void D3DGraphics::BeginFrame()
{
    pDevice->Clear( 0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),0.0f,0 );
}

void D3DGraphics::EndFrame()
{
    pDevice->Present( NULL,NULL,NULL,NULL );
}

void D3DGraphics::DrawLine(int x1, int y1, int x2, int y2,int r, int g, int b)
{
    for (int x = x1; x <= x2; x++)
    {
        PutPixel( x, y, r, g, b);
    }
}


//Here I have PutPixel(x,y,r,g,b); and It tells me y is undefined. but in the header file:

    class D3DGraphics
    {
    public:
        D3DGraphics( HWND hWnd );
        ~D3DGraphics();
        void PutPixel( int x,int y,int r,int g,int b );
        void DrawLine(int x1, int y1, int x2, int y2);
        void BeginFrame();
        void EndFrame();
    private:
    IDirect3D9*         pDirect3D;
    IDirect3DDevice9*   pDevice;
};
#包括“D3DGraphics.h”
D3DGraphics::D3DGraphics(HWND HWND)
{
pDirect3D=Direct3DCreate9(D3D_SDK_版本);
D3D当前参数d3dpp;
零内存(&d3dpp,sizeof(d3dpp));
d3dpp.Windowed=TRUE;
d3dpp.SwapEffect=d3dswapeeffect_DISCARD;
d3dpp.BackBufferFormat=D3DFMT_未知;
d3dpp.PresentationInterval=D3DPRESENT\u INTERVAL\u ONE;
d3dpp.Flags=D3DPRESENTFLAG\u LOCKABLE\u BACKBUFFER;
pDirect3D->CreateDevice(D3DADAPTER_默认值,D3DDEVTYPE_HAL,hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE和d3dpp及pDevice);
}
D3DGraphics::~D3DGraphics()
{
如果(pDevice)
{
pDevice->Release();
pDevice=NULL;
}
如果(pDirect3D)
{
pDirect3D->Release();
pDirect3D=NULL;
}
}
void D3DGraphics::PutPixel(整数x,整数y,整数r,整数g,整数b)
{
IDirect3DSurface9*pBackBuffer=NULL;
D3DLOCKED_RECT;
pDevice->GetBackBuffer(0,0,D3DBACKBUFFER\u TYPE\u MONO和pBackBuffer);
pBackBuffer->LockRect(&rect,NULL,NULL);
((D3DCOLOR*)rect.pBits)[x+(rect.Pitch>>2)*y]=D3DCOLOR_XRGB(r,g,b);
pBackBuffer->UnlockRect();
pBackBuffer->Release();
}
void D3DGraphics::BeginFrame()
{
p设备->清除(0,空,D3DCLEAR\u目标,D3DCOLOR\u XRGB(0,0,0),0.0f,0);
}
void D3DGraphics::EndFrame()
{
pDevice->Present(空,空,空,空);
}
虚空D3DGraphics::绘图线(整数x1、整数y1、整数x2、整数y2、整数r、整数g、整数b)
{

对于(int x=x1;x),声明也与定义不匹配。无论如何,这看起来更像是您应该询问作者的问题。显示错误代码而不是mate,这根本没有帮助。严重性代码描述项目文件行错误智能感知:标识符“y”是未定义的Chili DirectX Framework e:\Chili DirectX Framework\Assets\D3DGraphics。cpp 87显示类声明。需要知道类中是否声明了
y
。需要从某处定义
DrawLine
中的
y
变量。请参阅对
PutPixel
的调用。声明也与定义不匹配ition。无论如何,这看起来更像是你应该问作者的问题。显示错误代码,而不是mate,这根本没有帮助。严重性代码描述项目文件行错误智能感知:标识符“y”是未定义的Chili DirectX Framework e:\Chili DirectX Framework\Assets\D3DGraphics。cpp 87显示类声明。需要知道类中是否声明了
y
。需要从某处定义
DrawLine
中的
y
变量。请参阅对
PutPixel
的调用。