Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 20 Jan 2013
Offline Last Active Jan 25 2013 02:09 PM

Posts I've Made

In Topic: Cloned Texture not displayed with Linked List

25 January 2013 - 12:48 PM

Are you sure that SetVertexBuffer will copy not only texture coords, but the texture resource too?

In Topic: Cloned Texture not displayed with Linked List

25 January 2013 - 09:17 AM

Aha here is the .log called in the Render() for 3 nodes:
*** Start Drawing Nodes ********************************
iNum = 1
m_pSquare->GetTexture() =39384576
pSprCurrent->GetTexture() =135168096

iNum = 2
m_pSquare->GetTexture() =39384576
pSprCurrent->GetTexture() =135170848

iNum = 3
m_pSquare->GetTexture() =39384576
pSprCurrent->GetTexture() =140321984


If you're setting same texture on all sprites, shouldn't those pointers be all the same then, or have I missed something?

In Topic: Cloned Texture not displayed with Linked List

25 January 2013 - 09:10 AM

Amortised growth dynamic arrays outperform linked lists for most typical use. This is due to cache coherency. 


This depends on the case you're testing for performance, whether it's access or management.

In most cases, where add/insert/delete are being called many times, it's not a correct statement, as every such call causes whole array to be reallocated. Random access on the other hand is much faster on an array than linked list, providing that the index is known, and iterator isn't being used to find the item.


It may not necessarily be noticed, as static_cast will call constructor on CSprTex, so the instance will appear correct, therefore, if all objects in linked list are invalid, then they are all gonna be created anew when statically cast.


This is incorrect. Using static_cast<> with a pointer type will not call any constructors for the pointed at type.

You're absolutely correct, not on a pointer.

In Topic: Killing AI

22 January 2013 - 06:20 PM

Without iterators:

for(std::size_t i = 0; i < v.size(); ++i)
			std::swap(v[i], v.back());

Remember that modification of the for-loop index inside the loop is one bad programming practice. It usually leads to infinite loops and computer hang ups.

In Topic: Cloned Texture not displayed with Linked List

22 January 2013 - 05:29 PM

Just one more question for clarity. How does SetTexture get called and m_Texture set in effect ?

I think there's either something wrong with the LinkedList, so that for some reason, things get reset.
EDIT: removed invalid statement.

Other than that, check pointers to m_Texture when calling Draw for every item on the list, and compare to the root one from m_pSquare (I believe).

It maybe easier if you could post complete code of the AddNode, CLinkedList constructor that is being used, and ==/!= overloads, only any code dealing with CNode and head/end objects.