Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Bregma

  1. Bregma

    Terminate std::thread

    If you detach the thread it should end itself when the function returns. By 'end itself' I mean it may go into a zombie state until the OS cleans it up, but detaching means you no longer have any control over it from the spawning thread. If you really want to clean up after it, don't detach it, join it instead.
  2. Have you tried Microsoft Visual Studio Code? I find it less of a massive waste of all available resources than most IDEs. It's well supported, and integrates with GDB and/or LLDB.
  3. OK, to be clear, C11 is an old version of the C programming language (originally created by Brian Kernighan and Dennis Ritchie in the early 1970s). The current version of C is C17 as defined in international standard ISO/IEC 9899:2017(E). C++11 is an ancient version of the C++ programming language (originally created by Bjarne Stroustrup in the mid-1980s). The current version is C++17 as defined in international standard ISO/IEC 14882:2017(E). Variable Length Arrays are not valid C++. They have never been valid C++. No recent C++ compiler supports VLAs in C++. Use a std:vector instead.
  4. Variable Length Arrays are perfectly legal and standard in C11 (C++ is not C -- they're not standard in C++ and even most compilers that used to support them as a vendor extension no longer do). A float is 32 bits, or 4 bytes. I would assume from the words you randomly arranged on the page that a vec3 is 3 floats, or 12 bytes. 128 of those beggars is 1536 bytes. I going to guess that TPlane has 5 floats and a vec3, for a total of 8x4 or 32 bytes. 128 of those daddies is 4096. That would make your poly3f 5632 bytes. If you allocate 128 of those babies, you're going to munch 720896 bytes out of the stack. That's 75% of the 1048576 default stack size reserved by Microsoft Windows for the initial thread. If you're deep in the call stack and ancestor functions have also been busy munching on auto storage then yeah, you're going to blow something real good. Other OSes can have much much smaller default stack sizes -- don't try this on your phone, folks. It's a rule of thumb, but avoid large memory allocations in automatic storage. Remember, "large" is a relative term, but 0.75 MB is definitely on the bariatric side and a candidate for dynamic allocation. Remember, C11 does not support the new operator: that's C++. In C11 you have to use the malloc family for dynamic allocation.
  5. "Open source" describes software for which you can read the source. Under copyright law in most jurisdictions, you are not allowed to copy or create a derived work from such source code unless granted permission by the copyright holder. The usual practice in today's software development world is to provide such open source under a license that grants the right to copy or create a derived work without further confirmation from the copyright holder, and some licenses grant those rights under limited conditions. For example, the Expat and Apache licenses grant copy right under the condition that the copyright holder be waived from all liability. In other words, you can use their code but you can't hold them responsible for anything resulting from the use of that code. A copyleft license such as the GPL adds additional restrictions: namely you must release all the code for your derived work under the same license. In additional, version 3 requires you to grant a license in any patent you hold that applies to the derived work. Some open source licenses restrict you from using the code in a commercial application. The big-name licenses, like Expat, Apache, or GPL, have no such restriction (in fact, the GPL prevents you from adding such a restriction). Many games use open source licenses and have non-free restrictive licenses on their asserts instead. You need to know and understand the implications of using licensed software in your projects. It's unlikely you can just grab someone else's work and claim it as your own without consequences. Do you due diligence and you'll be fine.
  6. Bregma

    Why Gaming in the Browser is Inevitable

    Upside: increased ongoing revenue stream through ad insertion and subscription fees Downside: ad insertion and subscription fees
  7. Bregma

    Ascii Table and some Links

    That's not ASCII (an international standard character set), it's Microsoft Windows codepage 437 (a proprietary character set owned by Microsoft and only found in some their commercial products). Just so you know, for when you move to something that's not your personal desktop.
  8. OOP. You keep using that term. I don't think i means what you think it means.
  9. One more suggestion to help with your analysis: perform only one expression per statement in your loop body so you can see where the slowdown is. Instead of this rgba.push_back(<static_cast<sf::Uint8>(spectrum.r * max)); break it into three separate expressions. auto rtemp1 = spectrum.r * max; sf::Uint8 rtmp2 = static_cast<sf::Uint8>(rtemp1); rgba.push_back(rtmp2); Then your timings will show where you should be concentrating your tuning efforts. Note that once you fix the problem you don't have to leave it like this, it's just an analysis technique. Also, try making "max" an appropriate floating-point number to avoid so many type conversions. Also, try making your loop variable an auto const& instead of a copy of the colour vector. That's unlikely to improve performance much but might eliminate a memory access or three at low optimization levels.
  10. Your 'addMessage()' function displays values from 'message'. What is actually sent by the server?
  11. The 'Undefined' comes from JavaScript. It's the result of invoking the undefined name 'addMessages' for each message returned by the server. The undefined name 'addMessages' is undefined, so JS returns 'Undefined' when it's used. Think of it as an error message.
  12. The simple answer is yes. Although there are no "standard" implementations, dynamic memory allocation and de-allocation is non-deterministic, and the only way to map a contiguous memory address space into non-deterministic allocations and de-allocations is to use something like a linked list or a mark-and-sweep algorithm (or some other non-O(1) strategy). Even more fraught is that a single central memory allocator on a multi-threaded multi-processor environment (and they all are these days, even your toaster) you can one big lock to slow things down further. If profiling reveals that memory allocation is an issue, the strategy is generally to allocate all memory up front on startup and never use the central system allocator again. This is the norm in real time and embedded systems where the vagaries of malloc() can not be tolerated, and has become standard practice in many games for the same reason.
  13. I'm closer to 60 than to 50 and I've been seen stuff over the decades. I can vouch that despite claims of being age blind, hiring managers like to hire people who are similar to themselves, in age, in sex, and in socio-cultural background. Yes, it's not legal and it's not necessarily to the company's advantage, but it's human nature and you;re going to run into it. Expect to get fewer opportunities than someone who is younger together with excuses like "someone your age will expect to be paid more than we can afford" or "we're a young and agile team that needs to be able to pick up new technologies on the fly." Ageism in the industry is alive and well and rumours of its demise are greatly exaggerated.
  14. Without knowing the language and what a String is, I would venture that it's probably safe to compare the last character to '/'. If you're using a C-family language and String is some sort of aggregation of chars, then it's safe because single-byte UTF-8 character always have their most significant bit clear and are equivalent to 7-bit ASCII. All multibyte UTF-8 characters have their high-order bit(s) set. If you're using a C-family language and String is some sort of aggregation of wider characters, the integral promotion rules will come into play and '/' will be promoted to the larger type before comparison. If the promotion involves sign extension, it's still safe because sign extension of a value with a clear MSB is safe. If you're not using a C-family language, I don't know because various languages have different rules.
  15. Bregma

    Symbol lookup error on Linux

    Try playing with adding -Wl,--whole-archive to the LDFLAGS when building the bullet DSO. You're only doing partial linking when you're building your plugin, and the linker doesn't see the static object being used outside the library so it gets left behind in the static library. You need to tell the linker to put all of what's in the archive into the dynamic library. Creating shared libraries from static archives is tricky, that's why most build tools are a little goofy when dealing with that.
  16. Seems to me you changed your project from "multi-threaded" to "multi-threaded DLL" and now you need to change all the DLL binaries you supply to match, otherwise the linker will ignore them. No one ever said Microsoft Windows was easy on developers (and was telling the truth). All the binaries you link together in Microsoft Windows have to have the same [debug|multi-threaded|DLL] settings or you will get failure.
  17. Bregma

    calculating normal vectors

    Yes. It says the equation for the surface of the thing is f(p), and the equation for the normal to the surface f(p) is perpendiculart to grad f(p). The upside-down triangle thingie (nabla) is the symbol used to represent the gradient operator, and it refers to a vector-valued derivative. In other words it expresses how the normal is a parametric function of the surface equation in three variables in about as simple and precise a way as possible, in a way that only a mathematician would love.
  18. If you XOR the string with itself byte--by-byte, it will consist of only 0 bytes. Since it's all a known length of zeroes, you just need to store the length. Then, at runtime, you just need to allocate the length amount of space on the stack and XOR it once again with the original string, and voila, no need to store the string in the DATA segment, it can go in the BSS segment instead. It's called the "turtles all the way down" method.
  19. Bregma

    Programming and Higher Mathematics

    All of it.
  20. How to reinvent virtual dispatch using C++? There are many ways, all of them wrong. Perhaps you should just simplify instead. Have an Item class. Store objects of the Item class in your inventory. Give items properties, such as `is_wearable` and `melee_damage`. Use them as appropriate. RInse and repeat.
  21. Bregma

    Overengeneering Modularity

    Of course, rewriting is an opportunity to learn from experience and make things better in many ways. Just be aware of second system syndrome. Don't worry too much though, your third attempt is usually that much better again.
  22. Maybe it's because you're using a GUI, but you seem to be overcomplicating things. Git was made by a very lazy developer for what he considered idiots; don't second guess it. If you were on the command line, you would use two commands. First, add a remote repo named 'github'. git remote add github Them push to it. git push github master The git command line is verb-object-subject, which is a little confusing for native English speakers, but these days is fairly consistent. Other than setting your name and email, you generally never have to mess with git internals, like anything using 'git config'. I guess you'll have to spend a lot of time playing with the GUI to figure out which 1000 words of picture it takes to do the action of two command, though. Good luck.
  23. Bregma

    Size of enum class? (c++)

    QFE. If you care at all about size, offset, or marshalling/unmarshalling, an enum is inappropriate. You need an integer of known fixed size, and you need to be able to convert between the two. I've just been dealing with a customer who lost a (multi-million-dollar-valued) safety certification because they thought they knew what they were doing by using enums in a hardware interface (this is obviously not in the game development industry). Do not treat enums as integers. If you treat enums as integers, you don't know what you're doing. If you don't know what you;re doing when you're writing software, you're going to end up sad sooner or later.
  24. Bregma

    Is this OpenGL Modern Enough?

    Another data point to consider is that OpenGL 3 is not API-compatible with OpenGL ES. OpenGL ES is considerably more widespread: it's used on mobile and embedded devices rather than Linux PCs and a few Microsoft Windows PCs. OpenGL ES 3 is pretty much a proper subset of OpenGL 4, so your best bet for a "modern" OpenGL is to learn OpenGL ES 3 -- but that said, starting with OpenGL 3 tutorials will not hurt because it sets up the programmable-pipeline concept. It's mostly that the API to set up the data transfer between CPU and GPU, and how the shader receives and processes those data, became much more generic with the newer versions.
  25. Great. Now I have the Gnomoria theme song running through my head. Again. Anyway, I would take a look at what they did in that game, see what they got right (most stuff) and what could be improved on (cursor control, more than cursor location). Have the current selection anchor stick to the "surface" of the current view and follow the cursor as a view-cursor-taget projection -- the "surface" may be the top of the current Z-slice in cutaway mode. Have the selection anchor glow around the edges of the square for feedback. I don't think people today have a lower IQ or are generally more incapable of grasping ideas than folks of years gone by. Why do you think they'd be confused by an isometric view? Heck, if there's a sustainable market for Dwarf Fortress and its UI (and there apparently is; I know I've gratefully sent them my money), you may want to revise your judgement of humanity.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!