How to pass a surface?
Hi,
I have a question regarding passing DirectDraw Surfaces to a function. For example if I declare a LPDIRECTDRAWSURFACE7 as a variable and I want to pass it to a function, how do I do it correctly?
I tried it like this:
void foo(LPDIRECTDRAWSURFACE7 lpDDS)
and called the function like
LPDIRECTDRAWSURFACE7 lpDDSurface;
foo(lpDDSurface);
and it didn''t really work if I try to do something with the surface in the function.
I hope someone can help me with this problem
A LPDIRECTDRAWSURFACE7 is no different than saying DirectDrawSurface7*
If we change what you said around a bit, it would look like:
----
The foo function would be taking a pointer which is not initialized. You will need to make sure you do the CreateSurface command on that pointer in order to be able to use it. But otherwise your calling syntax is correct. You are just trying to access a bad pointer.
If we change what you said around a bit, it would look like:
void foo(DirectDrawSurface7* lpDDS){ lpDDS->Dosomething(); // KABOOM}
void main(void){ DirectDrawSurface7* lpDDSurface; foo(lpDDSurface);}
----
The foo function would be taking a pointer which is not initialized. You will need to make sure you do the CreateSurface command on that pointer in order to be able to use it. But otherwise your calling syntax is correct. You are just trying to access a bad pointer.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement