Jump to content

  • Log In with Google      Sign In   
  • Create Account

TheUnnamable

Member Since 20 Aug 2009
Offline Last Active May 24 2016 10:40 AM

Posts I've Made

In Topic: "check before flight" list - for OpenGL

26 February 2016 - 03:44 PM

-Are your matrices correctly set? ( world, view, and most importantly, projection)

 

Edit: Also, if I'm unsure if things are working, I usually change the clear color from frame to frame. That way I know that the window and the context is working, and the draw calls are actually happening. This can also show that buffers are swapped if necessary.


In Topic: Criticism of C++

04 January 2016 - 06:50 AM

 

"You cannot print enum values": by writing the enum with clever macros and templates you can (any particularly good example to recommend?)

Here's one.


In Topic: [GMS] Need help with overlapping sprites

30 December 2015 - 10:54 AM

If those sprites are two different objects, just set their depths. The lower the value, the "higher up" the sprite will be. 


In Topic: Glut & opengl only for 2D [Question]

28 September 2015 - 08:11 AM

Hi!

To use OpenGL, you need a window to draw to. This means you'll always need some kind of window manager. Either use the OS's native one, or a cross-platform one, like SDL. The benefit of the latter is that it abstracts away a lot of platform-specific details you won't have to bother with, and a lot of work is already done for you.

If simply not using SDL or any other "library", you could do fine with using a native window handler ( WinAPI for example ). Technically that's another library, but I think that's okay, you can't really go lower-level from there.

 

Now, I'm not entirely sure about this one, but technically you could do "without a window" on some Linux distros when no GUI is present. Then again, you still need to request a surface, which is pretty close to using a window manager. I could be wrong on this one, and I don't advise going this route.

 

On the other hand, if SDL seems like an overkill, try GLFW. It handles windows and input to some limited extent. You'll have to do anything else by yourself.


In Topic: How can I save/flush the offline data to disk and start it from there next ti...

08 September 2015 - 12:19 AM

Yes, the quickest and dirty-ish solution would be to use a conditional branch. Something like this: 

void Grid::calculateActualCosts() {
	unsigned last_i = 0;
	unsigned last_j = 0;
	if(readingFromFile())
	{
		last_i = getLastI();
		last_j = getLastJ();
	}
	
	unsigned i = 0;
	unsigned j = 0;
	for (auto& walkable : m_walkables) {
		j = 0;
		if(i++ < last_i)
			continue; 
		
		for (auto& walkables : m_walkables) {
			if(j++ < last_j)
				continue; 
			
			AStarNode* fromNode = acquireNode(...);
			AStarNode* toNode = acquireNode(...);
			AStarNodePair pair(fromNode, toNode);
			///
			astar(fromNode, toNode, totalCost);
			actualCosts.insert(std::make_pair(pair, totalCost));	 
		}
	}
}

Or, you could keep an std::set<std::pair<walkable, walkable>>. If a pair of any two walkables is in the set, it has been processed already and you can just do a continue, like this: 

for (auto& walkables : m_walkables) {
	if(progressSet.count({walkable, walkables}))
		continue; 
	
	AStarNode* fromNode = acquireNode(...);
	AStarNode* toNode = acquireNode(...);
	AStarNodePair pair(fromNode, toNode);
	///
	astar(fromNode, toNode, totalCost);
	actualCosts.insert(std::make_pair(pair, totalCost));	

        progressSet.insert({walkable, walkables});
}

At the beginning of the function you'd start with an empty set, and if you are continuing, read the set from a file. 

 

Your update2 also sounds valid, if it is practical to sort your data. 

At first, a VM sounds like an overkill, but if it's something you only run on your dev computer ( I assume so ), it is the fastest way to having a solution. 


PARTNERS