Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Feb 2008
Offline Last Active Jun 26 2016 11:19 AM

#5197750 C++ | DirectX | Class system ?!

Posted by NightCreature83 on 12 December 2014 - 04:39 AM

std::list might not be the most appropriate data structure to use in C++ depending on what you're doing. I don't know if Java's 'list' is a linked list or not either. Google says Java's List by itself is just an interface so you probably mean either ArrayList or LinkedList . std:list is most like LinkedList and std::vector is most like ArrayList. There are many other data structures to look into. std::deque never gets as much attention as it should since it can be a good compromise between std::list and std::vector.

I know you are trying to link std containers to how they work in C# or Java, but what you are saying is incorrect.

  • std::list is implemented as a double linked list, and thus is always a linked list, a list in C# or Java is only an access interface the container underneath can be anything.
  • std::vector is always an array, and it has more in common with a naked array in any language than any other container.
  • std::deque is implementation dependant on how it works, for small queues it usually is an std::vector, but it could also be a more complicated datastructure, where it conceptually resembles a linked list of arrays, but this is usually stored as an array of pointers to those memory blocks

std::deque should be used when you need to be able to add or remove elements from both ends of the queue with O(1) access time, usually these things are used for commandlists where you get from the front and add at the back.

#5197615 Efficiently when compressing char* to std::string

Posted by NightCreature83 on 11 December 2014 - 11:13 AM

Or just link to the ZLib library yourself and avoid the overhead of boost completely. The ZLib library is not that hard to use and the documentation is clear.



#5196840 C++ | DirectX | Class system ?!

Posted by NightCreature83 on 07 December 2014 - 02:39 PM


#5196769 C++ | DirectX | Class system ?!

Posted by NightCreature83 on 07 December 2014 - 05:29 AM

In C++ you have header(.h) and implementation files(.cpp, .c, .cxx) you need to create these files yourself and add them to the project. In the header file you specify how the class looks, so which methods and variables it has, in the cpp file you actually implement the methods, this is split from how Java or C# does it. When you want to use a class thats defined in another file you include the header file , with a #include statement, into the file where you want to use the class name.


Be careful with including headers in other headers because you can create loops and the compiler can't deal with that. there are other ways to deal with that, forward declarations, but this is a more advanced topic.


PS you can use COM in other files as well they dont have to be in the main.cpp file, the main.cpp is usually just the file that defines and implements the main function so the application can start.

#5193759 C# .Net Open Source

Posted by NightCreature83 on 20 November 2014 - 03:42 AM

I don't like Mono but might try C# when it will be integrated fully in Ubuntu. When speed is comparable to C++ and doesn't pose install fuss for users, I might use it or simply stick to C++. I'm curious if Unity3D will move to MS C# as they didn't update to the latest Mono.


C# is generally speaking only slower on first boot, because the runtime is compiling the application down to native instructions based on the environment setup.


Poor cache awereness in the application code however might hurt the performance more, but then again if you dont do this in C++ you will have the a similar slowdown.

#5193434 Disassembly and assembly links

Posted by NightCreature83 on 18 November 2014 - 08:41 AM

As I was gathering info on how to learn to read disassembly today I figured I would place the results on here as well for anyone who is interested.


First Up is Alex Darby's series on C/C++ disassembly, he teaches you how to read disassembly by going from C/C++ source code to disassembly generated by the MSVC compiler:



If altdevblogaday ever comes back you can find the whole series there.

Another good series on x64 assmebly are these youtube videos:


He starts from the other direction and shows you how you can call asm code from C++, the reason why you need to do this in a different manner from x86 is because the 64 bit compiler doesnt allow inline asm anymore. There is 65 videos in that link with an average runtime of 15 minutes and covers stuff from simple instructions all the way up to MMX, SSE and AVX.


I hope this information is useful for someone.

#5191535 Rate the code of my game!

Posted by NightCreature83 on 06 November 2014 - 10:37 AM

mah eyes they are bleeding!

#5190339 Why don't you use GCC on windows?

Posted by NightCreature83 on 31 October 2014 - 06:34 AM

Why are you not using Clang on Linux?

#5187131 c++ segmentation fault

Posted by NightCreature83 on 15 October 2014 - 05:58 AM

You could also modify the default stack size in your compile settings which will allow you to use larger stacks.


gcc: --stack=reserve, commit

MSVC: /STACK: reserve,commit


reserve is virtual memory size, commit is actual physical size


I couldnt find the clang version but it will be similar to gcc to be honest.


Be careful of messing with these settings because they are set to be small for a reason, large stack sizes will not detected endless recursion fast.

#5185257 D3DCompileFromFile

Posted by NightCreature83 on 06 October 2014 - 05:59 AM

its the function that the HLSL shader will use to set as the function to execute when you call this shader. Its the same as the main function in a C/C++ application and you need to provide this so that the HLSL compiler and runtime know where to start from.

#5184267 Updated from VC 8 To VC 10 and My App Has a Error in VC10 xstring Help

Posted by NightCreature83 on 01 October 2014 - 03:39 AM

Expect even more fun if you use custom allocators with STL, the allocator interface for STL changed with VC10.

#5181263 Multiples of 16B constant buffer or Microsoft gone mad.

Posted by NightCreature83 on 18 September 2014 - 07:37 AM



Also, alignment.


a-har a-har a-har... not.


seriously, one thing is to read documentation the other is reading hundreds of pages just to prevent something you have no idea of what. most functions and other programming instruments offer functionality that isn't needed most of the time. that's like reading about rocket science just because you are interested in a fuel tank that is also used in rockets by coincidence.


RTFM, when reading msdn documentation always, ALWAYS, read the remarks section! In this case the allignment of 16 bytes is done because you can nicely stuff 4 floats in there, or a vector4. Coincidentally CPUs like this allignement because the can now write a nice block to another nice block without having to do address computations.


By allowing you to specify your own buffers you can enforce the allignment by using __declspec( align( 16 ) ) before struct in MSVC.

__declspec( align( 16 ) ) struct MyStruct

This will pad your structure so it always lands on a 16 byte boundary.

And even in D3D9 times MS actually always wrote on a 16Byte boundary to the shaders in the effect code everything was sent as a float4 to the shader even if you called a setFloatParam on the effect or shader. MS has just made it easier for you to construct your buffers, without lifting this restriction.

#5178484 GOTO, why are you adverse to using it

Posted by NightCreature83 on 06 September 2014 - 04:45 AM




Let's not forget that goto fail; happened.

Braceless conditionals are eeeeevuuuuul!


This is true. Though with the goto fail example, shouldn't the compiler have produced an "unreachable code detected" warning? (Or do they still not have that kind of static analysis there?)

Maybe I'm just spoiled by C# compilers...


Who's to say the project doesn't compile with a bajillion warnings, or that particular warning is disabled?


That's the reason for always compiling with /w4 and treat warnings as errors.

#5166401 Fallout 3 Terminal in C++

Posted by NightCreature83 on 12 July 2014 - 06:59 AM

The other option is to use a mask that animates per line on the rendering. You can then just set the text of all lines and the mask animation will reveal text as goes a long untill it is finished.


Ignore this I missed the console app, my solution will only work if you are doing some fancy rendering

#5162965 Direct3D 11 Swap-Chain Madness

Posted by NightCreature83 on 26 June 2014 - 02:34 AM

I can’t use D3D11_CREATE_DEVICE_DEBUG without the Windows SDK 8 installed, something I fear doing considering apparently some things have to be done through Visual Studio 2012 (which I do not have).

L. Spiro


VS 2012 makes it easier to launch these applications, you can still just manually go into the SDK directory and launch the tool you need from there.