How to pass a surface?

Started by
1 comment, last by BergB 20 years, 6 months ago
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
Advertisement
A LPDIRECTDRAWSURFACE7 is no different than saying DirectDrawSurface7*

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.
Thanks for your help.

I did initialize it with CreateSurface in a seperate function, but obviously I did a mistake in this function which I didn''t found, so I was thinking the problem was the passing of the surface

This topic is closed to new replies.

Advertisement