Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


NightCreature83

Member Since 21 Feb 2008
Offline Last Active Today, 01:42 PM

#5147059 tinyxml2 and how to read files

Posted by NightCreature83 on 15 April 2014 - 01:56 AM

There is no need for you to call ToElement on child, because the for loop makes sure its an element already. And with FirstAttribute on an element you can actually iterate over the attributes of an element cleaning this code up a bit. Also it is better to use FindAttribute on element than just Attribute, you are not trying to match an Attribute with name and value, so FindAttribute actually expresses your intent better and makes your code more maintainable.




#5146964 Great laptop for game development? (Budget of +1200,- euros)

Posted by NightCreature83 on 14 April 2014 - 01:43 PM

Not sure where you from but if you can read this Dutch Tweakers bi-montly laptop guide might be a good start for you. http://tweakers.net/reviews/3479/laptop-best-buy-guide-april-2014.html the ranges you are looking at this would be either a multi-media laptop or main stream laptop. Do you mean to have 8 real cores in the CPU or is a hyper threaded quad core good enough, because there are no 8 core(as in not hyper threaded) intel chips at the moment.




#5145590 Trying to understand vertex shaders better

Posted by NightCreature83 on 09 April 2014 - 01:28 AM

If you need an online math resource this one is decent: http://www.euclideanspace.com/maths/algebra/index.htm




#5145291 directxmath osx/linux?

Posted by NightCreature83 on 08 April 2014 - 05:15 AM

I expect you will run in to some compile issues with WORD, DWORD and such, also probably you will have to do something about the intrinsics and compiler support in the header files which try to figure out if your CPU supports SSE2, but other than that it should be possible.




#5141953 What programming skills for Unreal 4

Posted by NightCreature83 on 25 March 2014 - 04:01 AM

Unreal has always had source licenses for people who could pay about 1M - 500.000 USD for it. Gameplay scripting is done through Blueprint in UE4, Unreal Script doesn't exist anymore. If you do need to add new behaviours it is C++ that you need to code that in.

 

Shaders will likely be in HLSL or CG.




#5139508 Framework or game engine with highest cross platform index?

Posted by NightCreature83 on 16 March 2014 - 12:30 PM

Unreal Engine, runs from mobile phones and browsers all the way up to the next gen consoles.




#5137737 Computer Science vs Software Engineering

Posted by NightCreature83 on 10 March 2014 - 02:20 AM

They are pretty much the same, software engineering might be more oriented on the work space where Computer Science  might be more focused on theory, this is not a hard rule though.




#5137431 How does your Pseudocode look?

Posted by NightCreature83 on 08 March 2014 - 04:41 PM

Mine mostly looks like decision diagrams so that it is easy to translate in to real code, or it just takes the shape of english text. When it is code time it is time to write it in a language :)




#5134068 Operator overloading, passing class a automatically convert to class b

Posted by NightCreature83 on 24 February 2014 - 04:42 AM

If I'm not mistaken, a temporary can't be passed as a reference to another function, only a const reference.

 

However, any solution seems a little meaningless. Isn't this a problem that would require inheritance to make any sense?

 

Even with a const reference that will not work, because the temporary will scope out at the function call. I have been bitten by this stuff before and its not an easy bug to detect.

 

To transform the object you will want to overload the constructor, to take in a B and construct an A from it. I don't recommend this though, implicit conversions lead to weird errors later on, so if you do this mark the constructor with "explicit". This makes it so that you explicitly have to construct on object on the function line, and pass by value instead of reference to make it work correctly.

 

In code the explict does this:

class Test
{
public:
    explicit Test(int x) : m_value(x) {}
 
    int m_value;
}
 
void foo(Test test) { std::cout << test.m_value << std::endl; }
 
void main()
{
    int x = 5
    foo(x); //Compile error due to explicit on the constructor, not having explicit would allow an implicit conversion here.
    foo(Test(x)); //Works fine now.
}



#5132595 I don't get c++11.

Posted by NightCreature83 on 19 February 2014 - 05:00 AM

Pretty comfortable with my c++ code now; I get classes, I get using templates and STL, smart pointers, and to an extent, exceptions. What I don't get is most of the new 2011 standard. Lambdas confuse me, in both their syntax and their purpose.

 

I've looked up articles trying to show practical uses for them, but they seem to go even further above my head than just the word 'lambda'. Rvalue / moving seems confusing just as well; decltype... gah. None of the new stuff makes much of any sense. The only thing I've understood so far is auto, and to a half-way extent: the new for loop style.

 

I've read through a third of C++ Primer 5th, and so far it's not really shed any new light to me. The frustration of these new features and my inability to grasp them has me concerned... How is it some clicked onto the new concepts rather fast? And where can I go to get to that point?

Other people grokked them fast because lambdas aren't new other languages already had these, lambdas in C# for example, they started as nameless delegates. I see lambdas as a delegate/callback function that you specify in the same line as where you pass them to a function that needs a callback. The lambdas in C++11 have a more function approach and I find them easier to read then their C# counterparts, its the capture that is hard.

 

A good use for a lambda is when you want to extend a std::find or std::find_if or std::sort, instead of passing it a functor or callback, you pass it a lambda that specifies what you want the predicate for the function to be. This keeps the code for the predicate and call of that predicate closer together than the functor or callback options.

 

RValue/Move semantics is something that was sorely missed and you had to program around this like reserving the size of your vector if you knew how big it was going to be to avoid an array copy. Move semantics will allow you to care a little less about copy performance if implemented correctly.

 

Decltype is a way in which we can access the type of an expression, this is useful in meta template programming and generic programming where you had to hack around these things before.

 

auto and the new intialiser lists are the most useful features added in C++11 because it allows you to write your code in an easier fashion and avoid a parsing problem.

class Foo
{
};
 
void Bar()
{
    Foo foo(); //The compiler sees this as a function prototype not the instantiation of an instance of Foo
    Foo foo {}; //This is now always seen as creating and instance of Foo
}



#5128821 Gathering information on input systems

Posted by NightCreature83 on 04 February 2014 - 02:41 PM

Hi NightCreature83,

 

thank you for your reply.

Your offered links are pretty interesting and cover a lot of things i was thinking about.

Unfortunately it is based on Windows and i want the input system to be running on other platforms as Linux and Mac as well (sry, i didn't mention this in my initial post).

So in order to this there is a need for some standard that needs to be supported by all of these platforms and USB seems to get it right (on a low level).

 

While looking for some HID APIs, i came across the following one:

http://libusbx.org/

It looks right for testing some stuff and trying to implement a prototype using it.

Actually only the first part is windows only the second link is platform agnostic an can be applied to all platforms, and it is also at that level that you make this code platform unaware.

 

Btw if you want multi-platform in input, you are going to have to write platform specific code, dealing with hardware devices is pretty hardwired into the platforms. Even between console generations of the same manufacturer this is different. The only other way out is writing your own HID interface but even then you run into platform differences, when dealing with hardware on different OSes sadly you will always have to write platform specific code.




#5128784 Gathering information on input systems

Posted by NightCreature83 on 04 February 2014 - 12:52 PM

http://molecularmusings.wordpress.com/2011/09/05/properly-handling-keyboard-input/

http://molecularmusings.wordpress.com/2011/09/29/wiring-physical-devices-to-abstract-inputs/

 

There is no need to have a HWND, the RawInput API on windows allows you to grab the input on the fly. XINPUT doesnt need a hwnd either and is porbably the easiest way to get a controller to work on windows.




#5128546 intrinsics/no intrinsics (in mingw)

Posted by NightCreature83 on 03 February 2014 - 03:31 PM

I think you are misunderstanding what an intrinsic is, it is a specially instruction to the compiler that it should use a particular instruction or group of instructions to transform the code in to asm. For example __m128 as an intrinsic telling the Compiler that if the target you are compiling for supports SSE2 instructions that this should be stored in a SSE2 register instead of normal registers. And yes for intrinsics you need to include headers as well, and they can be compiler specific so look in the help files of your compiler or the online help page.

 

Sin is a function defined in the C runtime and is used to calculate a value that approaches a sin value, how that is implemented and optimised by the compiler depends on the used version of the C runtime and the compile settings you are compiling with.




#5127578 CreateBuffer returns E_INVALIDARG

Posted by NightCreature83 on 30 January 2014 - 04:00 PM

XMMath is a newer version of the math library based of the Xbox math library, So basically it is meant to supersede D3DX math.

Or that is my understanding of it.

Not only is XNAMath (XM, which is now renamed to DirectXMath already) newer it also supports SSE2 by default where D3DXMath didnt, it did if you turned the compile options in VS for it on. DirectXMath actually in the header detects whether the target it is being compiled for supports SSE2 and if so starts using SSE2 intrinsics and all the proper ways of using these.

 

As already pointed out the structure must be 16byte-aligned, this is not the cast with your vector3. You should change it to:

struct ConstantBuffer
{
	D3DXMATRIX matWorld;
	D3DXMATRIX matView;
	D3DXMATRIX matProjection;
	D3DXVECTOR3 vLightDir;
        float padding; // unused
	D3DXVECTOR4 vLightCol;
};

or

struct ConstantBuffer
{
	D3DXMATRIX matWorld;
	D3DXMATRIX matView;
	D3DXMATRIX matProjection;
	D3DXVECTOR4 vLightCol;
	D3DXVECTOR3 vLightDir;
        float padding;
};

or simply modify the return of sizeof(ConstantBuffer) to be a multiple of 16.

You dont need to add padding just :

__declspec( align ( 16 ) ) float;
#define ALIGN16 __declspec( align(16) )
ALIGN16 float

When using the declspec or macro the compiler will automatically add padding when needed without you having to write this explicitly, it keeps your code slightly cleaner and easier to understand.

 

As an example

struct MaterialContent
{
    MaterialContent()
    {
        m_ambient[0] = 0.2f;
        m_ambient[1] = 0.2f;
        m_ambient[2] = 0.2f;
        m_ambient[3] = 1.0f;

        m_diffuse[0] = 0.8f;
        m_diffuse[1] = 0.8f;
        m_diffuse[2] = 0.8f;
        m_diffuse[3] = 1.0f;

        m_specular[0] = 0.0f;
        m_specular[1] = 0.0f;
        m_specular[2] = 0.0f;
        m_specular[3] = 1.0f;

        m_emissive[0] = 0.0f;
        m_emissive[1] = 0.0f;
        m_emissive[2] = 0.0f;
        m_emissive[3] = 1.0f;
        m_shininess = 1000.0f;
    }

    float m_ambient[4];
    float m_diffuse[4];
    float m_specular[4];
    float m_emissive[4];
    ALIGN16 float m_shininess;
};



#5125756 Branching in switch statement

Posted by NightCreature83 on 22 January 2014 - 06:17 PM

You should be able to embed a switch in the code block of a case label if that is what you mean to do.

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int condition = 0;
            switch (condition)
            {
                case 0:
                    {
                        switch (condition)
                        {
                            case 0:
                                Console.Write("Switch in a Switch");
                                break;
                        }
                    }
                    break;
                default:
                    break;
            }
        }





PARTNERS