Skip to main content
gamedev.net
🔒 Locked

Help needed

Started by clabinsky 3 replies 200+ views
Original Post
clabinsky
clabinsky
Hi. I have a class that handles the creation of surfaces and puts them in a linked list with a structure as below. I know I do not need the surface description in the struct but convince me why not. struct SurfList { LPDIRECTDRAWSURFACE7 lpddSurface; DDSURFACEDESC2 ddSurfDesc2; SurfList *lpNext; SurfList *lpPrev; }; As for the question: When the class(g_cSurface) creates a new surface it returns LPDIRECTDRAWSURFACE7. I want to destroy this surface. Since the surface is declared first in the struct, does the address of the surface correspond to the start of the structure (dumb question), I mean if I declare a new pointer of type SurfList in the delete function: could I use the same address as what the surface has? ie SurfList *lpCurrent=lpddSurfaceToDelete; What should I do, please? Edited by - clabinsky on December 18, 2001 10:13:11 PM Edited by - clabinsky on December 18, 2001 10:14:09 PM Edited by - clabinsky on December 18, 2001 10:39:51 PM
Why make it simple when you can make it sooo nice and complicated?
clabinsky
clabinsky
Oops! Sorry the below is mine

Edited by - clabinsky on December 18, 2001 10:38:29 PM
Why make it simple when you can make it sooo nice and complicated?
clabinsky
clabinsky
Thanks for the reply.

I guess I could do something like

...
bool CSurface::DeleteSurface(LPDIRECTDRAWSURFACE7 lpddSurf)
{
SurfList *lpCurrent; //Temporary struct pointer
lpCurrent=(SurfList *)lpddSurf;
...

if so, this saves a lot of time since I do not need to traverse the list at all. I know which structure by knowing the surface and thus can de reference straight away, first making sure if it is the first or last, and only one or middle of the list struct huh!

I´ll look into the STL but I figure knowing how to make it myself will give me an advatage using someone else´s
Why make it simple when you can make it sooo nice and complicated?

Topic Locked

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

Sign in to reply to this topic.