Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 May 2008
Online Last Active Today, 04:09 PM

Topics I've Started

Dll reload: adding local code causes buffer overflow?

27 September 2015 - 01:46 PM

Edit: Solved the problem. Didn't reload some of my functions. Please delete.

c++11 lambdas: best practices for 0 dynamic heap allocation?

26 June 2015 - 12:08 AM

I've been finding that using c++11 lambdas has some nice benefits, due to these facts:

1) The limitation of the lambda's scope where it can be used

2) Hence no need to declare/define another function in another scope, eliminating distractions.


I mainly use lambdas as inlined c-style function callbacks, example:

auto callback = [](void* userdata)


 //do something..




I also use lambdas as small repeatable functions within a loop and I have some concerns about the dynamic allocations when I capture local variables. I've heard that the larger the size of the local variables you capture the more likely it is to dynamically allocate(need a source on this if someone can provide), so keeping the captured variables as minimal as possible is -probably- good practice.

So, as a guide:

1) Capture as few variables as possible

2) If you need to capture variables, capture by reference if it reduces the memory footprint captured. Avoid capturing by value.

3) It might even be wise to substitute captured variables as input parameters to the lambda (example: instead of [captured_var](...), use [](..., captured_var_input) if it reduces the chance of a heap allocation.


Now, what are your experiences and best practices with lambdas? Anything wrong with my conclusions? I'd like to hear them.


Different types of meshes and how to structure them in code

28 February 2012 - 01:03 PM

Hi, I'm trying to design a class hierarchy that different types of meshes will use.
They all will share a base class cMesh, and different types will derive from them.

So far, I've heard of these kinds of meshes that are different from the normal onces:
Skinned mesh
Rigged meshes (does this count?)

What other subsystems are needed to say, get a skeleton mesh working? (physics rigid body dynamics?)
In the case of a skinned mesh, I've been told it blends between vertex weights, and so need an animation system.

Also, is it wise to integrate animation components into my mesh classes? Or should they be seperate?
Plus, would appreciate it if you guys can bring up some other kinds of meshes that might matter.


'Mixing' Shaders and code to shader organization

25 February 2012 - 02:14 AM

I've been exposed to shaders for a short stint, and have been exposed to a number of lighting techniques.
I have a couple of questions regarding shaders:
1) What are some kinds of techniques that can be integrated into existing shader techniques?
Example: I have a basic Per-pixel lighting shader up. Can I integrate shadows into the lighting equation with minimal effort?
How about deferred shading, HDR lighting, etc? Can all these be combined into one shader that is used for objects that need to be
lit up? Or are there some kinds of techniques that if 'you choose technique A, you forgo technique B'? (Would love it if you can give an
example here)

2) How costly can setting uniform variables per frame be? I'm thinking of supplying some constant variables(example: WorldViewProjectionMatrix) to all shaders so there's no need to write extra code to constantly supply that uniform variable.

[DX9]Controlled runtime alpha texture blending with restrictions

05 July 2011 - 11:09 AM

Hi, I'm looking for ways to do controlled alpha blending with textures with DX9.
It has to work like this:
I specify an alpha value from 0 to 255, and the sprite will change its opacity accordingly.

I cannot use D3DXSprite, so please do not tell me about that.

From google/gamedev.net, the solutions I found are:
1) Shaders ( too complicated for now )
2) Have 1 Light source and a material for each sprite (leaning towards this one)
3) Texture Alpha blending - LockRect and set the alpha values (disgustingly slow)
Msdn article
4) Add a diffuse colour member into the FVF, then somehow set some blending render states to
achieve the alpha blending effect. To change the opacity, I'll have to lock the vertex buffer
and change the appropriate alpha values. I'm not very clear on this method(tried as many
combinations of renderstates/blending as I could), so it would be nice if someone linked a tutorial on this.