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 21 Feb 2008
Offline Last Active Today, 03:24 PM

#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.

#5162492 Direct3D 11 Swap-Chain Madness

Posted by NightCreature83 on 24 June 2014 - 02:39 AM

Have you turned the Debug runtime on, because as of WIN8 SDK this has to be done through the VS2012 and up window or through executing the settings window from the WinSDK directory. It will not turn your debug runtime on other wise even though you did set it on in the D3D june SDK. http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx

#5160808 Untransformed vertices coordinates.

Posted by NightCreature83 on 16 June 2014 - 03:51 AM

In D3D9 you control the culling mode with D3DRS_CULLMODE and set it to CCW, CW or No culling. You sometimes might want to change this value because of how you are rendering things.

#5155183 Templates causing linker errors.

Posted by NightCreature83 on 22 May 2014 - 02:44 AM

template <class T>
void list_add_end( node_t<T>** list, T data );

If all you do is modify what the list pointer needs to point at please write this in the C++ way, which looks like this:

template <class T>
void list_add_end( node_t<T>*& list, T data );

Also means you don't have to write your pointer modification code like this anymore:

node_t<t>* newNode = new node_t<T>();
*list = &newNode;
//instead you can just write this
node_t<t>* newNode = new node_t<T>();
list = newNode;

#5154786 Location of data in the class

Posted by NightCreature83 on 20 May 2014 - 05:31 AM

Not what I wanted to hear, but thank you anyway :3

there's no way to ensure no padding is there? 

guess it's back to my  float _m[3][3] then

Using these kind of trick, will work but it is also how you write unmaintainable code. And code readability is often more important than ease of writing your code, because in six months time you are going to be wondering why you wrote it that way.


The other way of doing this is

class Matrix44
        float f[16];
        float mm[4][4];
        Vector4  v[4]; //Assuming vector4 is stored as 128 bytes contiguously
    } matrix;

You can now access matrix.f as an array, matrix.mm as a 2D array or as an array of vector4, if you add 16 float variables in the union you get 16 slot access options.

#5154635 c++ class vs struct+functions

Posted by NightCreature83 on 19 May 2014 - 09:01 AM


So just as a reminder to the OP, but a struct is a class in C++, only difference is default visibility level, struct = public, class = private

Heh, this was my first answer-reflex, too. However, on closer inspection, that's not what the OP is asking. The question is not whether there is a difference in having member functions in a struct or class, but rather whether there is a difference between

struct foo{....};
void func1(foo* f);
void func2000(foo* f, type bar);


class foo
    void func1();
    void func2000(type bar);

Jeff8j: Did I understand that you are basically trying to write a C++ decompiler? Knoweth that this is a daunting endeavour, next to impossible.

Decompiling Java bytecode or such into a human-readable source file is easy (the language is kind of specifically made for that, too). Decompiling C or C++ is harsh. While it is certainly possible to identify things as function prologs and such, there is no way of determining a meaningful variable name of any kind, or a function name (unless these are exported as symbols), no way to reproduce something like template instantiations into something that even vaguely ressembles the original, and no way to restore variables (or sub-expressions) which have been eliminated by compiler optimizations.

In one word, it's pretty much a nightmare...


Still the answer to that question is no, effectively this is what a member function does, its first param is the this pointer. So it comes down to how the structure is passed in those functions. If it is by value it is more expensive, because of the copy of the structure, pass by pointer or reference on the first argument to the function it would be the same as a member function.

#5154283 Wonderfully simple OpenGL UI

Posted by NightCreature83 on 17 May 2014 - 10:09 AM

Well where are the cpp files that implement all of the features with just the interface there isn't much to discuss to be honest. Also this will only work for 2d UI, what about 3d UI like this:


What about controller input?


How is the UI constructed, from code, other filed, can I override how a button is drawn easily or which shader is being used to render with?

#5152284 Books (Long post sorry)

Posted by NightCreature83 on 08 May 2014 - 05:23 AM

General programming courses can help in designing code and structure to, MIT and Standford have some awesome open courses you can watch on the internet about this stuff. This also shows you what most university educated programmers have seen so that you can increase your knowledge in areas you werent aware you might needed to know. One of the best topics to read about is logic and set algebra and general algorithm construction and design.

#5151569 Using Directx11 without using a Microsoft math library

Posted by NightCreature83 on 05 May 2014 - 03:56 AM

Yeah D3D doesn't come with a math library so has no requirements really.


The way that you construct your matrices will have an effect on your HLSL code.


By default, matrices in HLSL are stored in column-major element order - e.g. for [column,row], the floats are stored in the order [0,0], [0,1], [0,2], [0,3], [1,0], [1,1], etc....

You can explicitly state the storage convention you want to  use by using the appropriate keyword in front of your declaration, like this:

column_major float4x4 myMat;


row_major float4x4 myMat;


If you use the column-vector convention in your maths, then you'll write mul(myMat, myVec), otherwise if you're using the row-vector convention you'll write mul(myVec, myMat).


You can also just tell the runtime when compiling your shaders which order to use with a compile flag.