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!

Erik Rufelt

Member Since 17 Apr 2002
Offline Last Active Today, 01:55 PM

#5204932 Porting my game to Linux

Posted by Erik Rufelt on 17 January 2015 - 10:07 AM

Will g++ suffice as my compiler? My game uses C and C++. I'm also a bit of a noob to makefiles...


I haven't done any extensive Linux development, but I ported a game to Linux using this IDE: http://codelite.org/

It feels reasonably close to VC++ and Xcode in general.

#5204736 How to properly switch to fullscreen with DXGI?

Posted by Erik Rufelt on 16 January 2015 - 10:59 AM

Your FPS don't matter as they're so high, and 670 to 630 means 95 microseconds which is nothing.

Display average frame-time in milliseconds or microseconds instead of the number of frames per second to get an accurate picture.


The GPU doesn't become faster in fullscreen. What it will do is use (usually) much better synchronization, to avoid artifacts from bad vsync etc.

It can often make sure that if one frame takes 10 ms, the next takes 13 ms, and then the third 10 ms again, they will all be displayed at 11 ms intervals if that matches the monitor refresh rate, instead of allowing such small random changes to cause stuttering.


DXGI can either be instructed to simply go into fullscreen mode on the current desktop resolution (default), or actually try to change the display mode to match your  back-buffer resolution (mode-switch). I would recommend against mode switching.


Lastly, if the back-buffer size doesn't match the monitor size, it will be stretched. I guess this is where your artifacts come from. You need to handle for example WM_SIZE or in some other way detect when your window is resized, and when that happens Release your render target(s) and references to the back-buffer. Then call ResizeBuffers to resize the back-buffer to the new correct size and re-create your render target views and reset the view-port to the new size etc.

#5201802 unexplainable errors? Ever have one of those?

Posted by Erik Rufelt on 04 January 2015 - 02:57 PM

I would guess outdated files in the build folder or similar. If you first do clean, then exit the IDE, delete all temporary object files and precompiled headers etc. and re-open the project it might fix it. I get such errors many times where I have to do clean and rebuild because the compiler doesn't understand something has changed so it uses for example an outdated version of an updated struct in one file so sizeof() doesn't match what is used in another file and similar.

#5201754 Is it a good idea to block android phones that cause lots of trouble?

Posted by Erik Rufelt on 04 January 2015 - 10:05 AM

Try to get a device like that and find the bug, or if your app has internet-permissions possibly add logging to a remote database so you can see what happens.

If that's not possible, then probably yes, block them.

#5200524 Text rendering and low FPS in game.

Posted by Erik Rufelt on 29 December 2014 - 05:40 AM

Try doing all FillEllipse within a single BeginDraw/EndDraw, and only do Create* functions in an Init function, and not during each frame.
In general D2D isn't that fast though.. but a few ellipses should be fine.

#5199442 Text rendering and low FPS in game.

Posted by Erik Rufelt on 21 December 2014 - 03:31 PM


#5197966 Text rendering and low FPS in game.

Posted by Erik Rufelt on 13 December 2014 - 06:40 AM

This largely depends on the strings and how they are formatted internally. Do the strings change each frame or are they static?


I wrote the FW1 library, and it uses DirectWrite to construct the text layouts which is quite slow if done each frame, as the whole internal layout is reconstructed each time. The solution is to save the geometry of strings that are static, and not do the whole text-layout again until the characters in a string changes.

If you use that library there are "Samples" projects to download including one called ManyStrings: http://fw1.codeplex.com/releases/view/75558


For the sprite-font class you need to check its internals, it should have some way of caching the results or similar. If the strings are truly static the best way is to save the vertex-buffer and just draw the same triangles again and only update the buffer when the characters change.


If you draw constantly changing strings, like some kind of matrix-effect where the characters flash really quickly, then you probably don't want any fancy text-layouts like DirectWrite uses, which is optimized to display text prettily and not fast, and rather write your own method.

The easiest is to treat each character as a quad with some texture coordinates and a fixed distance to the next character, which can be implemented with a table and a very simple and fast loop.

#5195645 NULL vs nullptr

Posted by Erik Rufelt on 01 December 2014 - 01:29 AM



As the value of nullptr is just 0, I'd say it's irrelevant for C functions as they can't be overloaded. I usually use NULL when I use an API with a specification that says NULL, and nullptr otherwise, just for consistency.

#5195223 Super Cool Effects

Posted by Erik Rufelt on 28 November 2014 - 11:02 AM

glBlendFunc(GL_ONE, GL_ONE) usually does it :)

#5194902 OpenGL 5 - Release?

Posted by Erik Rufelt on 26 November 2014 - 10:42 PM

From http://en.wikipedia.org/wiki/OpenGL#OpenGL_NG


This is a codename given by journalists to a grounds-up redesign effort (semi-officially called "The Next Generation OpenGL Initiative"), to unify OpenGL and OpenGL ES into one common API that will not be backwards compatible with existing OpenGL versions.


"to unify OpenGL and OpenGL ES into one common API" can be important to some developers.

At the same time I guess it will make a lot of features optional which could complicate things, though hopefully there will be some sort of IsDesktop() or IsES() so we don't have to handle too many different cases.

#5193918 Correct order to multiply matrices in 2D space

Posted by Erik Rufelt on 20 November 2014 - 11:53 PM

The order in which translate and scale is done is swapped when you swap the multiplication order.


So the first one first inverts Y, then moves the square, whereas the second first moves the square, and then flips the already moved square around Y.


I guess in your case, Y = 0 is at the edge of the screen, and if you first flip the square and then move it into the screen it will be visible.

If you instead move the square into the screen, and then afterwards flip it around Y, then it will be flipped with its translation so the final position will be in the opposite direction outside the screen.

#5185824 OpenSSL tutorials?

Posted by Erik Rufelt on 08 October 2014 - 01:38 PM

There is built-in support for it in Windows APIs, for handshakes and encrypt/decrypt. Found this for example, that wraps send/recv on a socket to properly encode the data: http://www.codeproject.com/Articles/24379/SSL-Convert-your-Plain-Sockets-to-SSL-Sockets-in-a

#5184463 float error that i cant fix, (d3d9 related)

Posted by Erik Rufelt on 01 October 2014 - 09:00 PM

The name "INFINITY" is probably already defined as something else (like in Windows.h or D3D9.h). Just use FLT_MAX instead of renaming it.

Also, "infinity" is a bad name for it, as they are not the same thing and you can do for example FLT_MAX / 2 and get a new number that is no longer FLT_MAX.

#5182110 frac(x) results in strange artifacts when x is close to zero

Posted by Erik Rufelt on 22 September 2014 - 09:03 AM

You'll have a discontinuity at the edge, where the texture coord hops from 0.999 to 0.001.. so it could be that when mipmaps are enabled the graphics card thinks that you're trying to draw the entire texture with minification so it fits in between those two pixels at the edge, which will cause it to always choose the smallest mip-level.

Such usage is probably better without mip-maps... or just skip the frac(), as it shouldn't be needed, you can just rely on repeating wrap mode for textures.

#5181963 Fear of replacement

Posted by Erik Rufelt on 21 September 2014 - 04:34 PM

Should I tomorrow correct that senior guy about the term ray casting that I was true in-front of everyone and clear up my image :/ ?


No, why in the world would you do something like that?

That actually might get you fired, or at the very least make people think badly of you, and would probably even make some idiot cause more problems just to see what you will do.


I mean think about how that will sound: "Last week you were an idiot to me for making me look bad, look here I was right!!!  Everyone look I was right!!". What would you think if someone else did that?

Being wrong isn't even that bad... if you can choose between people thinking you were wrong even though you were right, and people knowing you are right but thinking you care that much about it... just let them think you were wrong, it's better for you.


Smile and never say a thing and keep doing good work, and find your next job ASAP and try your luck elsewhere. And when you quit, still smile and thank everyone for a good time.


Also, you don't really seem to like it where you are... maybe try to go where you're happy and like people.