#### Archived

This topic is now archived and is closed to further replies.

# How to pass a surface?

This topic is 5179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites

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

• ### Forum Statistics

• Total Topics
628676
• Total Posts
2984172

• 13
• 12
• 9
• 10
• 9