- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there.
I'm trying to speed up a Drawing routine in my GameEngine which traverses accross an std::vector of "Sprites"
The issue I have is that the Draw function that the Sprites can execute requires a parameter, a windows HDC in order to work properly, but I've not found a way of allowing that in without an error.
The final parameter in parallel_do is the problem:
"
error C2064: term does not evaluate to a function taking 0 arguments
[cpp]void GameEngine::DrawSprites(HDC hDC)
{
// Create a new instance of DrawList
DrawList m_DrawList;
m_DrawList.m_hDC = hDC; // me trying to plug the HDC in...
// Draw the sprites in the sprite vector
vector::iterator siSprite;
tbb::parallel_do(m_vSprites.begin(), m_vSprites.end(), m_DrawList());
// for (siSprite = m_vSprites.begin(); siSprite != m_vSprites.end(); siSprite++)
// (*siSprite)->Draw(hDC);
}[/cpp][sectionbody]Here's my "Body" object. It's Error free currently, though I can't pass it a variable from outside[/sectionbody]
[/sectionbody]
[cpp]class DrawList { public: HDC m_hDC; // My attempt at storing the HDC, and passing it into // the class seperately in GameEngine::DrawSprites DrawList() {}; void operator() (Sprite* siSprite) const { //siSprite comes from vector container (siSprite)->Draw(m_hDC); //need to pass the HDC in order to work } };[/cpp][sectionbody]Of course, I might be barking up the wrong tree trying to use parallel_do. Correct me if I'm wrong..[/sectionbody][sectionbody]
[/sectionbody]
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about passing just m_Drawlist, without the parentheses...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, thanks. That works now.
However, the sprites on screen are all flickering now. I suppose I need to figure out how to make things wait for all of them to be drawn?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I need to create a mute or semaphore out of the HWND - having only one sprite on the screen showed no flickering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or, more logically, a barrier the size of the number of elements in the vector before drawing... :P
That sounds good right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know, but make sure you have enough work per task not to drown in parallel overhead, or in overhead related to multiple drawing instructions if a single call could be used instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using the boost barrier. But have an issue with the whole "Function Object" system.
I've got a pointer to a barrier in the DrawList function object, and set the count to the current size of my Sprites Vector.
However, I end up with a deadlock issue...

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page