Skip to main content
gamedev.net
🔒 Locked

Beginner Help needed please

Started by ShayneC 3 replies 1k views
Original Post
ShayneC
ShayneC
I am new to Dx but am trying in vain to learn it, I have a selection of books and been reading tutorials. I have a problem with my code and cannot see what the problem is, can anyone help? BOOL CApplication::RenderFrame() { if ( !m_bIsActive ) { return TRUE; } m_graphics.Clear( D3DCOLOR_ARGB( 0, 0, 0, 0 ) ); m_graphics.BeginScene(); /* My code to put a sprite on the screen */ HRESULT hResult; IDirect3DSurface9* surface; hResult = CreateOffscreenPlainSurface( 800, 600, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL); if (FAILED(hResult)) return NULL; hResult = D3DXLoadSurfaceFromFile( surface, NULL, NULL, "coffee.jpg", NULL, D3DX_DEFAULT, 0, NULL ); if ( FAILED( hResult ) ) return NULL; m_graphics.EndScene(); m_graphics.Present(); return TRUE; } This is the error i keep getting error C3861: 'CreateOffscreenPlainSurface': identifier not found, even with argument-dependent lookup All I want to do is get a bitmap onto the screen.
DadleFish
DadleFish
CreateOffscreenPlainSurface is a function which belongs to the D3D Device, and you're calling it as if it was a global function. You should be calling -

m_pDevice->CreateOffscreenPlainSurface(...)


Or something like that, depending on how do you call your D3D device.


Dubito, Cogito ergo sum.
CHollman82
CHollman82
Yeah, what he said. You need to have an IDirect3D9 object. CreateOffscreenPlainSurface is a member function of the IDirect3D9 class, so you would have something like this:

IDirect3D9 d3d;
...a bunch of init stuff...
d3d->CreateOffscreenPlainSurface(etc...);
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
Skeleton_V@T
Skeleton_V@T
ShayneC: You probably want to put the initialization code for [surface] somewhere before the CApplication::RenderFrame (). Invoking D3DXLoadSurfaceFromFile () each frame is not necessary. But if this is a code snippet, that's okay, just something to remind you.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
ShayneC
ShayneC
Thanks to everyone that has replied, I see my Mistake now. If it was laid out properly in the book I would not of made it and I will have to more the surface creation part of the code.

Once again thanks to all.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.