Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 12 Mar 2011
Offline Last Active Feb 08 2015 11:48 PM

Topics I've Started

Voxel disk operations?

07 February 2015 - 06:19 PM

For a 2d voxel game, is it viable to store the procedurally generated mesh to file?


I know disk operations can be a bottleneck, but so can generated meshes on the fly. I'm wondering which generally has the least performance impact.


Minecraft saves a lot of data with its chunks but there is no mention of the actual meshes being saved afaik.

Pixel Perfect Sprites

21 January 2014 - 12:15 AM

In a texture I have a square sprite (though it does not take up the whole texture, just a small portion).


I set up my UV coordinates to target just the sprite.


Sampler code:

    oSamplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
    oSamplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
    oSamplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
    oSamplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    oSamplerDesc.MipLODBias = 0.0f;
    oSamplerDesc.MaxAnisotropy = 1;
    oSamplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    oSamplerDesc.BorderColor[0] = 0;
    oSamplerDesc.BorderColor[1] = 0;
    oSamplerDesc.BorderColor[2] = 0;
    oSamplerDesc.BorderColor[3] = 0;
    oSamplerDesc.MinLOD = 0;
    oSamplerDesc.MaxLOD = D3D11_FLOAT32_MAX;

When rendering the sprite to the screen using an orthographic projection with no rotating it renders perfectly.


However, if I scale the sprite non-uniformly (as it is being use as a frame that stretches) then the parts of the texture surrounding the sprite seem to be sampled.


I drew a coloured border around my square sprite and can see the red bleeding in to the edges of the texture in the above scenario.


A more detailed explanation...

Here are some frame pieces for a frame, a bar and a corner. The bar is to be stretched to accommodate the frame dimensions whereas the corner is not.


Here is the frame rendering in-game. Notice the coloured borders are ignored, they were not included using the UV coordinates I set.



Now here is the exact same example as the above except I've changed the overall scale for the frame to reduce its size. (I've re-shaped the frame as that is part of its functionality)



I get the positions for my texture sampling like this...

The squares represent pixels, the blue squares are pixels in a sprite, the red circles are the positions I use.



Why is there sampling around the sprite when the frame is scaled smaller?

Alpha blending fails unless Debug mode

13 March 2013 - 11:30 PM



Compiling with visual studio 2010...


If Compiling in DEBUG mode with D3D11_CREATE_DEVICE_DEBUG set for device creation, alpha blending works fine.

If Compiling in DEBUG mode with D3D11_CREATE_DEVICE_DEBUG NOT set for device creation, alpha blending works fine.

If Compiling in RELEASE mode with D3D11_CREATE_DEVICE_DEBUG set for device creation, alpha blending works fine.

If Compiling in RELEASE mode with D3D11_CREATE_DEVICE_DEBUG NOT set for device creation, alpha blending does not work... looks like alpha testing.

D3D11_BLEND_DESC oBlendStateDesc;

oBlendStateDesc.AlphaToCoverageEnable = 0;
oBlendStateDesc.IndependentBlendEnable = 0;

for (unsigned int a = 0; a < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++a)
	oBlendStateDesc.RenderTarget[a].BlendEnable = 1;
	oBlendStateDesc.RenderTarget[a].SrcBlend = D3D11_BLEND_SRC_ALPHA;
	oBlendStateDesc.RenderTarget[a].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
	oBlendStateDesc.RenderTarget[a].BlendOp = D3D11_BLEND_OP_ADD;
	oBlendStateDesc.RenderTarget[a].SrcBlendAlpha = D3D11_BLEND_ONE;
	oBlendStateDesc.RenderTarget[a].DestBlendAlpha = D3D11_BLEND_ONE;
	oBlendStateDesc.RenderTarget[a].BlendOpAlpha = D3D11_BLEND_OP_ADD;
	oBlendStateDesc.RenderTarget[a].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

HRESULT HResult = m_poDevice->CreateBlendState(&oBlendStateDesc, &m_poBlendState); //HResult returns S_OK

Anyone have any idea what may be causing this?


UPDATE: Tested on two different PC's... Both windows 7 64 bit, one has a GTX 460 & the other is a GTX 580. The one with the GTX 580 does not have any problems with alpha blending.


SOLVED: There was an initialized variable in there somewhere and I can only assume creating in debug mode caught the error. Another difference between the two tested machines is the visual studio version. So perhaps the later version machine (gtx 580) caught the error also.

Guidance Creating/Finding Framework/Engine

05 March 2013 - 06:19 PM

I'm interested in using a low-level c++ framework (engine?) for creating games in 2D while not costing much and containing the following cross-platform (across PC) functionality:

  • Graphics
  • Input
  • Networking
  • Physics
  • Sound

I haven't had much luck finding anything that matches this criteria... Torque2D seeming the closest. I couldn't find much documenation/tutorials about working with the engine on a core level (seems mostly scripting examples).

In my spare time I created a DirectX11 framework that suits most of my needs listed above (c++, 2D, graphics, Input, Physics(Box2D)). Since I couldn't find much else I'm thinking its best to continue developing the framework, making it cross-platform (across PC). At present I'm trying to do this with the graphics & input.

So I'm looking into openGL 3.3... I'm thinking it will match all of the functionality I'm using in dx11 (Currently using feature level for dx10) allowing games I created to be run on Windows XP/vista, Mac & Linux as well instead of just windows 7+.

Currently I'm focusing on making these components cross-platform:

  • Input (Keyboard and mouse)
  • Window (Will need to work with both dx11 and opengl 3.3)
  • Timing

...Followed by implementing opengl 3.3.

Research I've done so far:

  • Going cross platform in this way across PC means I can target roughly another 20% of people using PCs (according to steam surveys)
  • freeGlut - Stay away from, don't even have control over render loop
  • SDL - Input, Window (usable with dx11 & opengl 3.3?), Timing

I'm unsure if SDL is usable with opengl 3.3, especially since I'd be using an "unstable" version.

I'd like to control initialization of opengl directly if possible/reasonable and sending the handle of the window (if that is how it is done on other OS's besides Windows)

I'm thinking a good source of information would be the fifth edition of the OpenGL SuperBible.

Given all this... can anyone give advice of mention any other resources.

[Resolved] std::list clear() - Unhandled Exception

26 January 2013 - 08:31 PM

What are some common causes for unhandled exceptions from a std::list's Clear() call? Given...


*The list does not contain pointers, the resource is never released manually e.g std::list<int>


*It breaks here (inside list)

	void _Orphan_ptr(_Myt& _Cont, _Nodeptr _Ptr) const
		{	// orphan iterators with specified node pointers
		_Lockit _Lock(_LOCK_DEBUG);
		const_iterator **_Pnext = (const_iterator **)_Cont._Getpfirst();
		if (_Pnext != 0)
			while (*_Pnext != 0)
				if ((*_Pnext)->_Ptr == this->_Myhead
					|| _Ptr != 0 && (*_Pnext)->_Ptr != _Ptr) //!!BREAKS HERE - On second pass through loop (while (*_Pnext != 0)) )
					_Pnext = (const_iterator **)(*_Pnext)->_Getpnext();
					{	// orphan the iterator
					*_Pnext = *(const_iterator **)(*_Pnext)->_Getpnext();
 #endif /* _ITERATOR_DEBUG_LEVEL == 2 */