Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 Oct 2011
Offline Last Active Yesterday, 08:23 AM

Topics I've Started

How to handle states.

30 July 2014 - 06:23 AM

I've been writing an 2D engine and the problem came to mind of how to handle states. I was wondering what people would think of this solution.


The base state isn't removable and the link is just a header with comments on the purpose of each function.



SDL_Audio, questions about the format of the stream

14 June 2014 - 12:06 AM

Let's say I've set my stream to be signed 16 bit numbers, with 2 channels, would this mean that the stream that I'm populating is set up so that the first 16 bits will be the left channel and then the following 16 bits will be the right and the collection of 32 bits is the sample?

[L - 16][R - 16][L - 16][R - 16]
[ Sample - 32 ][ Sample - 32 ]


Thank you for any help :)

Templates and Function pointers

11 June 2014 - 03:57 AM

Okay so for a bit of background, I need to create a list of function names and their function pointers so I can tell Lua how to use the objects I create. How I've tried to do this is with a template which uses a dynamic_cast to see if it inherits from a class, if it does it'll add the function pointers to the vector and keep checking other classes. I did it like this because as an example I have a GUID class which basically everything will inherit from, if I didn't do it like this I'd have to repeat the function pointer and it's name for every metatable and I'd have a massive list for each class.


My issue is I had a method of doing this, that didn't compile

template<typename T> vector<luaL_Reg> createMetatable(){
	vector<luaL_Reg> out;
	T object;
	if (dynamic_cast<Component::ActiveState*>(&object)){
		out.push_back({ "activate", &T::lActivate });
		out.push_back({ "deactivate", &T::lDeactivate });
		out.push_back({ "isActive", &T::lIsActive });
	if (dynamic_cast<Component::Area*>(&object)){
		out.push_back({ "getDimensions", &T::lGetDimensions });			
                out.push_back({ "setDimensions", &T::lSetDimensions });

does anyone have a recommendation of an alternative or a way of getting this to work, your help would be much appreciated.


The exact issue with this code is that at compile time let's say you pass in Camera to the template, all those if statements that wouldn't run anyway because the dynamic cast will fail, will still have the Camera::lGetDimensions and that'll break the build because it can't find that function.

Why do large engines use their own string class

05 June 2014 - 09:24 AM

While looking through the CryEngine source code I found a file CryString.h



What I don't understand is why are they creating their own string class instead of using the std::string provided

are there benefits in doing so?

Location of data in the class

20 May 2014 - 02:02 AM

when I define a class with only these variables

float _m11, _m12, _m13;
float _m21, _m22, _m23;
float _m31, _m32, _m33;

is it safe to assume that to access _m13 from the pointer of _m11 I can



to get to _m21


to my understanding this should be allowed, but I was wondering if it'll always be placed in RAM like this or some systems might shuffle them for a reason I don't know.