Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Oct 2010
Offline Last Active May 24 2016 10:19 PM

#5183381 SDL vs SDL2

Posted by Chris_F on 27 September 2014 - 07:57 PM

Just use SDL 2. It's the current API and the one the developers suggest you use. SDL 1.2 exists for backwards comparability.

#5183031 problem with my text rendering

Posted by Chris_F on 25 September 2014 - 07:47 PM

Is your framebuffer the same size as your window client area?

#5183017 Nvidia GI Hardware Support

Posted by Chris_F on 25 September 2014 - 05:40 PM


I'm confused. Nvidia supports GL_ARB_sparse_texture with both Kepler and Fermi, so why is this a Maxwell only feature?


GL_ARB_sparse_texture extension only concerns 2D texture.



Read the spec. It supports 2D textures, array textures, cube maps, cube map arrays, 3D textures and rectangular textures.

#5174636 So... C++14 is done :O

Posted by Chris_F on 19 August 2014 - 01:48 AM

It is syntactic sugar, it is language bloat.


It can make code shorter and easier to read. C++ is already extremely large and complicated, removing the "bloat" of range-based for loops would not improve the situation in any noticeable way.

#5172415 Metallic Materials

Posted by Chris_F on 09 August 2014 - 12:19 AM

The only difference I see between the two is the environment map which is used.

#5171772 OpenGL ES on desktops

Posted by Chris_F on 05 August 2014 - 08:14 PM


#5171750 Creating a Linear Gradient with Java for a drop down menu

Posted by Chris_F on 05 August 2014 - 06:57 PM


If banding is noticeable you might want to consider adding a simple random dither to it.

do you mean just a random float that is less than what i subtracted added back into the amount or just subtracting a random float from the value to get the new value?



Normally you would use floor(value * 255.0f + 0.5f) to convert your [0, 1] value to a 24-bit image. Instead use floor(value * 255.0f + random), where random is a float in the range [0, 1]. You can see the effect this has here.

#5171496 Funniest line of code ever ?

Posted by Chris_F on 04 August 2014 - 03:22 PM

i'm curious if the compiler would be smart enough to optimize this out.


I'm sure a GCC or Clang/LLVM would. I'm less certain about a JIT language like Java.

#5171490 Funniest line of code ever ?

Posted by Chris_F on 04 August 2014 - 02:55 PM


int length= 0; for(int idx = 0; idx < a.length; i++){      length++;  }​System.out.println("length is : " + length);
Some Java code to get the length "cough" of the array 'a'. Nice!
See i could kinda understand someone doing this with a c++ iterator, but come on, was the programmer going "well if i go through the length of the array and count up then i'll get the length of the array!"

Edit: aldo nice infinite loop in there =-P



So that you can avoid unnecessary code duplication, why not put this in a function?


int getIntegerValue(int n)
    int ret = 0;
    for(int i = 0; i < n; i++) {
    return ret;
System.out.println("length is : " + getIntegerValue(a.length));


Work smarter, not harder.

#5171311 Funniest line of code ever ?

Posted by Chris_F on 03 August 2014 - 04:04 PM

public static DateTime getTommorowsDate()
    return DateTime.Now;

#5171156 potatoe

Posted by Chris_F on 02 August 2014 - 12:34 PM

1. Yes float usage is more expensive. May not be extremely obvious in small programs, but using the correct variable type in large ones is critical.


You can't say that as a fact as it is entirely dependent on the hardware in question. GPUs for example are often better at floating point.

#5170767 STL C++: iterator issue

Posted by Chris_F on 31 July 2014 - 07:51 PM

Why not use a lambda function instead? Even Visual Studio supports that.

auto findNodeIterator = std::find_if(myNodeContainer.begin(), myNodeContainer.end(), [](const MyItem* obj) { return obj->testID == 1234; });

#5170737 Protect Against Speed hack

Posted by Chris_F on 31 July 2014 - 05:39 PM

If this is a MMO, then preventing speed hacks should be done with server side checks. If this is a multiplayer game, then you should probably just implement a vote to kick player for cheating. If this is a single player game, then why are you even bothering?

#5170625 Reading linearized Texture as sRGB, then doing Gamma conversion: Different re...

Posted by Chris_F on 31 July 2014 - 10:06 AM

So a good solution would be to disable the sRGB sampler state, and do the pow(x, 1.0 / 2.2) manually in every pixel shader, right?


No, don't apply gamma in the pixel shader unless you have a good reason to. That's why sRGB formats exist.

#5169937 Declaring temporary variable to save 1 multiply?

Posted by Chris_F on 28 July 2014 - 09:01 PM

Really simply question, really. Is it worth declaring a temporary (float) variable to reduce an operation from 2 to 1 multiplies?


For example,

x = a * b / c;

y = a * b / d;




float ab = a * b;

x = ab / c;

y = ab / d;



I'm not very familiar with assembly language, or how everything breaks down when its compiled, so that's why I'm asking. I'm not trying to optimize (really), I'm actually hoping to do the opposite (avoid the temporaries). If the function wasn't part of my math library, I probably wouldn't even bother worrying about it. The method I'm writing generates the (matrix-like) direction vectors of a quaternion. In the method, there are 2 of 9 unique multiplies, which means I could either multiply 18 times, or declare 9 variables and multiply 9 times.


I originally wrote the function by declaring the temporary variables, but it would look a lot nicer to simply do the math twice, as long as the difference is negligible.


Thanks a bunch for any advice


Why ask us when you can ask your compiler? http://goo.gl/PcN9vz


You can see that both functions produce the same assembly.