Original Post
Hello! This is my first sprite program using dx9 and c++. I have this errors that I can't seem to figure out! A little help will mean so much to me. I hope you dx gurus out there can help me on this. thanks in advance :) --------------------Configuration: sprite - Win32 Debug-------------------- Compiling... main.cpp C:\projects\sprite\main.cpp(39) : error C2143: syntax error : missing ';' before '}' C:\projects\sprite\main.cpp(110) : error C2065: 'DXUTGetBackBufferSurfaceDesc' : undeclared identifier C:\projects\sprite\main.cpp(110) : error C2100: illegal indirection C:\projects\sprite\main.cpp(113) : error C2664: 'D3DXCreateTextureFromFileA' : cannot convert parameter 2 from 'unsigned short [10]' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast C:\projects\sprite\main.cpp(121) : error C2065: 'D3DXSPRITE_ALPHABLEND' : undeclared identifier C:\projects\sprite\main.cpp(122) : error C2660: 'Draw' : function does not take 5 parameters C:\projects\sprite\main.cpp(143) : error C2065: 'SAFE_RELEASE' : undeclared identifier Error executing cl.exe. main.obj - 7 error(s), 0 warning(s)
[sourcecode]
#include <windows.h>
#include <stdio.h>
#include <d3dx9core.h>
#include <d3d9.h>
#include <d3dx9.h>
const char g_szClassName[] = "myWindowClass";
class CMainFrame
{
protected:
IDirect3DTexture9* m_pTitleTexture;
ID3DXSprite* m_pTitleSprite;
IDirect3DDevice9* m_pd3dDevice;
public:
CMainFrame(IDirect3DDevice9*);
~CMainFrame() {}
void Render( void );
HRESULT RestoreDeviceObjects( void );
HRESULT InvalidateDeviceObjects(void);
HRESULT Release(void);
};
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
{
void CMainFrame::Render( void )
}
return 0;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
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 = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Makoy's window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
CMainFrame::CMainFrame(IDirect3DDevice9* pDevice)
{
m_pd3dDevice = pDevice;
m_pTitleSprite = NULL;
D3DSURFACE_DESC desc;
desc = *DXUTGetBackBufferSurfaceDesc();
D3DXCreateSprite( m_pd3dDevice, &m_pTitleSprite );
D3DXCreateTextureFromFile(m_pd3dDevice, L"sball.png", &m_pTitleTexture);
}
void CMainFrame::Render( void )
{
const RECT r1 = {0,0,500,200};
m_pTitleSprite->Begin(D3DXSPRITE_ALPHABLEND);
m_pTitleSprite->Draw(m_pTitleTexture, &r1, NULL, NULL, 0xFFFFFFFF);
m_pTitleSprite->End();
}
HRESULT CMainFrame::RestoreDeviceObjects( void )
{
if(m_pTitleSprite)
m_pTitleSprite->OnResetDevice();
return TRUE;
}
HRESULT CMainFrame::InvalidateDeviceObjects(void)
{
if( m_pTitleSprite )
m_pTitleSprite->OnLostDevice();
return TRUE;
}
HRESULT CMainFrame::Release(void)
{
SAFE_RELEASE( m_pTitleSprite);
SAFE_RELEASE( m_pTitleTexture );
return TRUE;
}
[/sourcecode]