Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

503 Good

About SOL-2517

  • Rank
  1. This is an article from one of the Insomniac Games developers that discusses SIMD instructions and the problem with using vector classes: https://deplinenoise.files.wordpress.com/2015/03/gdc2015_afredriksson_simd.pdf
  2. SOL-2517

    C++ | Fixed Byte Size

        The size of these standard types also depend on the platform ABI. For example, the standard C type "long" is only 4 bytes on 64 bit Windows but 8 bytes on most other 64 bit platforms.         There are compiler switches and pragmas you can use but then you suddenly have to code to support different compilers and make sure that the size of the struct is the same as the ZIP header if you ever plan on reading and writing the entire struct at once. Reading or writing one field at a time using the integer types from the stdint header is guaranteed to work on platforms where those integer types exist so that's the option I would go for (don't forget to account for the endianness though). If you want maximum portability then you're in for a real headache since some platforms might not even have integer types of the same length as those in the ZIP header. It can be solved by messing around with bit masks but it's not something I would bother with unless I knew I was targeting esoteric platforms.
  3. SOL-2517

    default install folder for windows game

      I would put game saves in FOLDERID_SavedGames so that it's easy for the user to find them. Otherwise it might be hard for the average user to find the game saves since AppData is a hidden folder by default. If done properly you can just copy that folder to a new machine and resume the game as usual when needed. I don't consider machine specific settings like keyboard bindings etc to be a part of the game save so those go in FOLDERID_LocalAppData as suggested.
  4. Doing memory allocations in C++ with raw pointers is a disaster waiting to happen.
  5. SOL-2517

    My first (static) library

      Releasing the engine as a static library does not solve those issues. If you want to avoid all the issues that library writes have to deal with then you should release the engine as source code only. This will greatly affect the design of the public interface of your engine so you should keep that in mind when you design it.
  6. SOL-2517

    should WndProc process WM_QUIT?

        That's one way to do it. I prefer to not use WM_DESTROY and PostQuitMessage at all and instead use the window data (accessed with SetWindowLongPtr/GetWindowLongPtr) to determine when to quit. This is in my opinion the best way to do it if you're writing an engine that should support multiple windows since the window procedure doesn't need to keep track of when the application should quit. This way the user of the engine is completely in control of when the window should be closed and destroyed. That's how GLFW does it: while (!glfwWindowShouldClose(window)) { ... glfwPollEvents(); ... } glfwDestroyWindow(window); If you want to implement this yourself then you can do something like this (I've left out all the error checking etc to make it easier to read): // File: window.h typedef struct FOOAPI_Window; // File: window.c #include <FOOAPI/window.h> struct FOOAPI_Window { HWND window_handle; bool should_close; } FOOAPI_Window; FOOAPI_Window *FOOAPI_CreateWindow(...) { FOOAPI_Window *window = malloc(sizeof(FOOAPI_Window)); window->window_handle = CreateWindow(...); // Win32 API window->should_close = false; SetWindowLongPtr(window->window_handle, GWLP_USERDATA, (LONG)window); // Win32 API return window; } void FOOAPI_DestroyWindow(FOOAPI_Window *window) { DestroyWindow(window->window_handle); // Win32 API free(window); } void FOOAPI_SetWindowShouldClose(FOOAPI_Window *window) { window->should_close = true; } bool FOOAPI_WindowShouldClose(FOOAPI_Window *window) { return window->should_close; } static LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { FOOAPI_Window *window; switch (message) { case WM_CLOSE: window = (FOOAPI_Window *)GetWindowLongPtr(hwnd, GWLP_USERDATA); window->should_close = true; return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }
  7. It will be easier to debug the release build if you generate debug symbols for it: https://msdn.microsoft.com/en-us/library/fsk896zz.aspx   You can also enable or disable optimizations per file by right clicking on the file in the properties window, selecting "Properties" and then navigating to "C/C++ -> Optimization". Visual Studio 2013 update 3 added better support for debugging optimized code so if it runs too slow without optimizations then you can try to enable them and use the /Zo switch: https://msdn.microsoft.com/en-us/library/606cbtzs.aspx
  8. SOL-2517

    More variance with larger dice..

      I thought that the article did a good job explaining the basic concepts but the conclusion about rand() is not right as you have noted. It's worth pointing out that messing up the seed can be just as harmful as using a number generator with poor statistical properties. I've played console games where clever players somehow managed to find out how the game created the seed from in-game actions and then managed to manipulate it to get extremely rare drops whenever they wanted to.
  9. SOL-2517

    More variance with larger dice..

    There are other issues with your implementation as well. I recommend that you read this article: http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx
  10. SOL-2517

    Basic 2D array C problem

    How exactly did learning C first hinder your full embrace of the "C++ way" of doing things? Couldn't it just be that you were taught C++ the wrong way? None of the university courses I took brought up things like RAII, template metaprogramming or any of the common idioms that modern C++ makes heavy use of. Unless you have a good book or teacher then I would say that there's a good chance that you'll end up with bad practices regardless of if you come from a C background or not. OOP is a beast in itself that you can easily get wrong regardless of the language that you're using.
  11. SOL-2517

    Basic 2D array C problem

    I think he's exaggerating a bit. I learnt C first and I had no trouble learning C++ afterward. I don't recommend either one of them as your first programming language though but that's another issue. I still use C instead of C++ a lot of the time depending on what needs to be done. As long as you don't become fanatical about one particular language or a way of doing things then you will be fine.     That's funny because I've heard the same thing from people who have tried to move away from OOP to a data-oriented approach.
  12. It really boils down to what the programming language and hardware architecture supports. It's not possible to address individual bits in standard C/C++ but it's certainly possible for the compiler to add a non-standard type for platforms that support bit-addressing (there are a few architectures where that is possible).   If you want to conserve space then the portable solution is to use bit masks to pack individual bits into bytes. Keep in mind that a byte isn't necessarily 8 bits since it's defined to be the smallest addressable unit that is at least 8 bits. I've had to use platforms where a byte was 32 bits. Either use the types that are guaranteed to be a fixed length (uint8_t, uint16_t etc) or make sure you account for CHAR_BIT when doing bit manipulations using bit masks.
  13. SOL-2517

    "simple" equation confusion (a - b = c)

    B = 5 is the correct answer. The variable is B and not -B.   15 - B = 10 <=> -B = 10 - 15 = -5 <=> -B = -5 <=> B = (-)-5 = 5   My usual order of operations when doing it in the head is to isolate the variable I'm trying to solve for so that it's positive: A - B = C <=> A = C + B <=> B + C = A <=> B = A - C
  14. Using a scripting language like Lua for plugins is more portable since plugin writers can potentially use the same set of script files for all platforms. Compare that to dynamic linking where you need to compile the plugins for each platform that you intend to support and then make sure that the user gets the right version of them.   If you decide to go with dynamic linking then it will be helpful to know how to export C++ classes from a DLL in a way that avoids all the name mangling issues: http://eli.thegreenplace.net/2011/09/16/exporting-c-classes-from-a-dll
  15. Why not use the equation for the dot product directly?       The left hand side is easy to calculate and is 8. The vector norms |U| and |V| on the right hand side are also easy to calculate so that directly gives us the answer  or  if you prefer it that way.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!