Ok, i've tried passing pointers and declaring functions as static, but theres always some kind of error, so i'm going to post all the relevant code and error and hopefully someone will tell me where to go from there
error C3867: 'DXGraphics::bDisplay': function call missing argument list; use '&DXGraphics::bDisplay' to create a pointer to member
DXEngine.h
Code:
#include "DXGraphics"
class DXEngine: public DXGraphics
{
public:
....
int iRunMessageLoop(bool(*)(float)); /*Function pointer to wrap the message loop*/
....
}
DXGraphics.h
Code:
#include "D3D.h"
class DXGraphics
{
public:
....
bool bDisplay(float); /*Function to display graphics in the client window*/
....
}
DXEngine.cpp
Code:
int DXEngine::iRunMessageLoop(bool (*p_bPointerToDisplayFunction)(float))
{
m_fLastTime = (float)timeGetTime(); /*Record the time when the application entered the message queue
and store it in m_fLastTime*/
ZeroMemory(&m_msg, /*The starting address of the block of memory to fill with zero's*/
sizeof(MSG)); /*The size of the block of memory to fill with zero's(bytes)*/
while(m_msg.message != WM_QUIT) /*While the message identifier doesn't equal WM_QUIT*/
{
if(PeekMessage(&m_msg, /*Address of MSG instance passed into the function for info on the members of MSG*/
0, /*Handle to the associating window, if NULL, the function retrieves all messages for the thread*/
0, /*First input type filter, e.g. Keyboard or mouse. If NULL, the function retreives all messages, no filtering is carried out*/
0, /*Last input type filter, e.g. Keyboard or mouse. If NULL, the function retrieces all messahes, no filtering is carries out*/
PM_REMOVE)) /*Flag for removing the messages after the function has processed them*/
{
TranslateMessage(&m_msg); /*Function for translating virtual key messages into character messages,
takes an instance of a MSG struct that contains info processed by PeekMessage()*/
DispatchMessage(&m_msg); /*Function for dispatching messages to the windows procedure, takes an instance
of a MSG struct that contains the message info*/
}
else /*Otherwise...*/
{
m_fCurrentTime = (float)timeGetTime(); /*Records the current time and stores it in m_fCurrentTime*/
m_fTimeDifference = (m_fCurrentTime-m_fLastTime)*0.001f;
p_bPointerToDisplayFunction(m_fTimeDifference); /*Call the display function after computing the above times*/
m_fLastTime = m_fCurrentTime; /*Set the value of m_fLastTime to the value stored in m_fCurrentTime so the process can be repeated*/
}
}
return m_msg.wParam; /*Return the message information to the program*/
}
DXGraphics.cpp
Code:
bool DXGraphics::bDisplay(float) /*Function Definition*/
{
if(m_d3dDevice) /*If the object exists*/
{
m_d3dDevice->Clear(0, /*Number of rectangles in the following array...*/
0, /*An array of screen rectanges to clear*/
D3DCLEAR_TARGET | /*The render target surface, most likely the backbuffer*/
D3DCLEAR_ZBUFFER, /*The depth(z) buffer*/
BLACK, /*Colour that we wish to clear the render targer to (black)*/
1.0f, /*The value that we wish to set the depth(z) buffer to*/
0); /*The value that we wish to set the stencil buffer to*/
/*Function to Present the contents of the next buffer*/
m_d3dDevice->Present(0, /*This must be NULL as we didn't specify the swap chain as "D3DSWAPEFFECT_COPY"
as it is NULL, the whole surface is presented*/
0, /*This must also be NULL for the same reason, as it is NULL, the entire client area is filled*/
0, /*This is the destination window, if NULL, then the handle from D3DPRESENT_PARAMETERS is taken*/
0); /*This must also be NULL as "D3DSWAPEFFECT_COPY" wasn't specified*/
}
return true; /*Return a true value, indicating that the program can continue*/
}
Yes, i've added another class - DXGraphics. I did this because I thought that my D3D class shouldn't contain the bDisplay() function, as it only set's up Direct3D, and isn't supposed to display anything. So, can you help me?