Jump to content
  • Advertisement
Sign in to follow this  
DragonGeo2

How to redirect a pointer?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a LPDIRECT3DVERTEXBUFFER9* and I want to lock it. I cannot use VertexBuffer->Lock() because my compiler says "left of '->Lock' must point to class/struct/union" and then crashes with an error. How do I need to use the ampersand & operator or the asterick * operator in this case to resolve a pointer of a vertex buffer down into a vertex buffer object with which I can call functions from? All help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
(*VertexBuffer)->Lock(...);

First dereference the first pointer to get the second one, then call it's Lock function. Though I don't think you need to be using a double pointer in this case.

Share this post


Link to post
Share on other sites
"LP" means "Local Pointer", so if you've got a pointer to that, then you've essentially got a pointer to a pointer.

To call a member of such a monster, you need to dereference twice, then use the . operator. Or dereference once, then use the -> operator.

LPDIRECT3DVERTEXBUFFER9* _pie;
(**_pie).Lock();
(*_pie)->Lock();


I use the latter syntax myself, but its all personal preference.

Share this post


Link to post
Share on other sites
Just some advice: I can think of no good reason to have a pointer to an LPDIRECT3DVERTEXBUFFER9. Once you know that LPDIRECT3DVERTEXBUFFER9 is just a typedef'ed pointer, you can just pass around the LPDIRECT3DVERTEXBUFFER9 directly. Passing around the pointer to the LPDIRECT3DVERTEXBUFFER9 could be dangerous, too, depending on where and how you store the original LPDIRECT3DVERTEXBUFFER9.

Share this post


Link to post
Share on other sites
Quote:
Original post by BeanDog
Just some advice: I can think of no good reason to have a pointer to an LPDIRECT3DVERTEXBUFFER9. Once you know that LPDIRECT3DVERTEXBUFFER9 is just a typedef'ed pointer, you can just pass around the LPDIRECT3DVERTEXBUFFER9 directly. Passing around the pointer to the LPDIRECT3DVERTEXBUFFER9 could be dangerous, too, depending on where and how you store the original LPDIRECT3DVERTEXBUFFER9.


I've used a pointer to an LPDIRECT3DVERTEXBUFFER9 before - there are some cases where you may need it. Of course, chances are you've got a bad design, unless you're using a "mother" class to instantiate an abstract "rendering device", similar to the LPDIRECT3D9->CreateDevice() model of thought. Although I only use it because I'm using an API-independant library... I'll be quiet now.

Point is, there are places (place?) where you should/need to use it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!