Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Jun 2008
Offline Last Active Today, 01:30 AM

Posts I've Made

In Topic: Rendering a GUI efficiently

13 July 2013 - 03:06 AM

I dunno if it's optimal how I have my stuff set up, but I have a simple sprite batching class that I use to draw quads with. I don't really do anything special at all.


SpriteBatch manages the state, etc. It's really dead simple and really doesn't do that much work internally. Just tracking a few things, starting a new batch, finally issuing the draw call, etc. I pre-fill the index buffer and cap how large batches can get. Adding a sprite to the batch just needs a Rect for the position and another for the texture coordinates.


A batch is a simple struct like this

struct Batch
	Vertex2D*	verts;
	Texture*	texture;
	u32		numSprites;
	u32		numVerts;
	u32		numIndicies;

Then keep a vector of them. Batches hang around until you explicitly purge them, so once you add a bunch of quads, you don't need to re-add them and the only thing that needs to happen is the draw call (and prior memcpy() to push whatever batch verts to the underlying vertex buffer).


It's not fancy or super robust, but I don't see why I couldn't draw an entire UI with just one or two draw calls. Drawing thousands of textured quads costs practically nothing, and my framerate is still well into the thousands. What's GWEN doing that's taking so long?

In Topic: driver crashes and 1080p video makes pc shutdown

05 March 2013 - 09:03 PM

If you trip the thermal limit, the machine will just likely shut off instantly before the part is damaged. It's also not unusual for the driver to crash if the hardware is extremely hot.


When my GTX 260's fan died, I was pushing nearly 110c with even the most minor activity. The driver would crash continually and if it kept climbing, poof, computer would just turn off. The metal backing was actually so hot that I probably could of burned myself on it. Check your temperatures!

In Topic: In-Game Console

13 January 2013 - 01:34 AM

The actual logic behind a console system isn't too hard to put together, I have a simple Cvar class which uses template specializations for the argument types I support (float, int, string, and nothing) so when you create a Cvar object, it sets an internal flag accordingly for the type you tried to give it so it knows how to act on it later. It uses a FastDelegate internally for the function pointer stuff.


Then I just dump them into a map<string, Cvar> for the lookup. The Console class has an exec() function which just takes a string -- if there's 2 parts to it (like "test 500") then I split that into to name and argument, use the name for the lookup, and 500 is converted and handled accordingly. It's not really robust, but it's really tiny and simple, I think the whole thing is like around 150 lines.

In Topic: Shader semantics

30 December 2012 - 01:08 AM

Seems kind of weird that they just leave things off their list, but whatever, I guess it doesn't really matter.

Now that things are working, I made it into a starfield. Pretty neat how I can just draw the whole thing in one call, and they can all be uniquely scaled, rotated, etc.

edit: Also solving things shortly after I post seems to be a trend of mine. I'm apparently incapable of working things out before I get annoyed and go to ask for help. smile.png

In Topic: Shader semantics

29 December 2012 - 11:26 PM

Actually I'm retarded and solved that. I done goofed somewhere and I wasn't giving CreateInputLayout() the right number. I have pretty triangles spread about again.

Still curious as to why the MSDN list of semantics is apparently incomplete, and if I should be trying to pad stuff out to a certain size.