Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Aug 2000
Offline Last Active Oct 08 2015 08:00 AM

#5205036 Problem with SDL

Posted by BitMaster on 18 January 2015 - 02:40 AM

First minor issue: You shouldn't start your variable names with an underscore. Variable names starting with underscores are reserved for the compiler.

That is incorrect like that. According to this post which reinforces my previous suspicion, his use of underscores is without issues. He is using a single underscore followed by a lower case letter which the standard allows him to.
I'm not a fan of that notation but those are stylistic complains, not technical. I am however rather annoyed whenever I see (void) as a function parameter. The code is obviously C++, could never be C, so there is absolutely no point in putting that there.

#5204522 100% New to Game Deving... 0% Idea Where to Start

Posted by BitMaster on 15 January 2015 - 12:04 PM

Considering your writing background you might also want to consider the field of interactive fiction where several solutions exist, for example Inform.

#5203868 Memory File Mapping?

Posted by BitMaster on 13 January 2015 - 03:47 AM

This should be the current documentation of boost::mapped_file. Although Google is sometimes a bit uncooperative there I don't think a documentation that is 19 releases behind is ideal.

#5203421 Very simple linking issue

Posted by BitMaster on 11 January 2015 - 03:12 AM

I'm doing this at work all the time with CMake across a project containing dozens of internal libraries and never had a problem. CMake correctly pulls in dependent libraries (even subdependencies only specified by the dependencies themselves some way down the line).

You appear to create a pure C library and then link it to a C++ program. That is not going to work, with or without CMake. Make the library a .cpp to make CMake auto-pick C++, force it to do that some other way or create a correct extern "C" wrapper in the include file.

Edit: Also, I would strongly recommend not to use FILE GLOBs to specify the implementation files to be added to a project. I'm guilty of that in my work project (but only for headers) since CMake was introduced later and there was never time to do it properly afterwards but a new project should not start that in your own interest.
I'm also not a fan a having another PROJECT() statement in a sub-CMakeLists (especially since it is dependent on stuff outside the subdirectory).

Edit 2: I'm also a bit miffed that after as little time as an hour you decided to reach the statement "CMake sucks" and calling it "crap", especially since it's pretty clear the problem it the user, not the tool. That is rather beginner behavior.

#5203418 About computer instruction in relation to RAM consumption

Posted by BitMaster on 11 January 2015 - 02:54 AM

What determines who can and can’t see them? Rating? Crossbones? Duration on the site?

To my knowledge once you cross a thousand reputation, you can see the votes.

For the record, I “undid” one of the original poster’s down-votes because intentions matter.
Yes, it was something of a terrible question, but it was legitimate. We punish people for intentionally being obnoxious, not for sincerely seeking help.

I also agree that the original poster could have answered some of these questions on his or her own via Google, but then again question #6 indicates the original poster was perhaps confused (to put it mildly), which is understandable when you literally have no scope of the details of the question you want to ask.

I'd like to respond to that a bit. warnexus' problem is that practically all of the threads I have read follow the same pattern also observed here. The majority of questions could be answered by quickly doing a search regarding it and reflecting for a few moments about it. Other questions suggest this important step has not been done for important prerequisites of the question.

Up to this thread I was more inclined to believe that it's just a person who seriously needs to work on the way he deals with problems and questions. Asking questions is good, but only after spending some time working on a problem. I often had the distinct impression he had completely outsourced thinking to this forum and probably other places.
However, after reading his point (6) above I decided I finally had to reevaluate my internal mapping. Personally I now consider it more likely that I'm trolled instead.

#5203095 Digital Tutors

Posted by BitMaster on 09 January 2015 - 09:29 AM

Is there are special reason why you feel the need to post so many of your thread titles in ALL CAPS?

#5202788 FBO Attachments and Rendering to a Texture

Posted by BitMaster on 08 January 2015 - 04:03 AM

This page should explain things. In a nutshell: it is often more efficient for the hardware to render to render buffers instead of textures. You cannot sample render buffers as input for a following shader stage though.

#5202604 Adding third party libraries to version control

Posted by BitMaster on 07 January 2015 - 09:01 AM

I don't agree with braindigitalis. What happens when the current version of the external project does not build with your program anymore? If that happens incrementally during development, it's a minor annoyance (unless it's before an important deadline, then it's a huge annoyance). But what if you have to come back after a year or two to fix a bug? There can be a lot of changes in your 3rd party dependencies happening during that time. Worse, things might build but not work as intended (worst case, something that won't be noticed without a lot of testing). Where exactly is the problem coming from then?

At work, I'm depending on a lot of libraries, some of them very complex to build. Unless there is a very compelling reason (vulnerabilities, critical features, ...), libraries do not get updated just for fun and everyone uses the same library directory. Everyone uses the same (Windows) build system as well. Even something as 'simple' as moving from one version of MSVC to the next is a huge operation that is not started lightly. Interestingly enough that is much simpler for all parts of the project which build under Linux.

At home I'm moving towards putting dependencies into my repository (but clearly marked as 3rd party) and integrating them into my CMake build system there (very simple for some libraries, not so much for others). Begin edit: I still don't add the 3rd parties repositories here. Updates only happen when I decide I have the time to deal with it. End edit.

If you obtained the libraries via SVN, you can just SVN export them into your source tree and then add them again into your own SVN.

#5202535 Silly question about classes/libraries/headers

Posted by BitMaster on 07 January 2015 - 03:18 AM

I'm not sure I get what you are asking. Do you believe everything you write has to be in a class for the sole purpose of being in a class? It does not, it should not. Classes are a tool. Free functions are tool. Several other things are a tool. The hallmark of a good programmer is picking the right tool for the right job.

For example std::tuple is a (template) class and there is a very useful free function right next to it: std::make_tuple. Since template argument deduction works on free functions but never on classes that can be extremely convenient.
At the same time free function like std::sort exist as well.

#5201891 A good engine for a space game?

Posted by BitMaster on 05 January 2015 - 03:43 AM

If you're looking for quality free/open source engines, I wouldn't hold my breath. A lot of them are licensed under viral licenses such as the GPL that prohibit releasing derived works without sharing your source code. This won't be an issue if you plan on releasing your source code, however.

I haven't made an exhaustive survey but I haven't found that many GPL game engine by quickly going through a few listed on Wikipedia. There are quite a few LGPL (unless you have to link statically that's not much of an issue, especially for any kind of beginner) and several even less restrictive licenses (MIT, BSD, Apache, Eclipse). The ones I found with GPL usually seemed to have a commercial alternative licensing model or are free (but GPLed) versions of older purely commercial engines.

#5201799 unexplainable errors? Ever have one of those?

Posted by BitMaster on 04 January 2015 - 02:39 PM

I had all of the libraries linked properly.

If you hadn't linked properly you would have gotten linker errors. But you need the dynamic libraries available to program to load when you start it. For example MinGW might need files like libgcc_s_dw2-1.dll and libstdc++-6.dll in a location that follows Windows' rules for dynamic libraries.

And the code had no problems as far as debugging.

So what exactly do you mean by 'ran the code' above? Do you mean you started it from outside the IDE (for example via Explorer or a command line? Is it possible the program was just missing some resources you are trying t load because the IDE adjusted the working directory in a way you did not replicate from outside?

I think I may have accidentally typed an invisible character, by holding down alt and pressing a number while I was typing.

I find that very hard to believe. An unexpected and invalid character should generate a compile error.

#5201704 "List iterator not incrementable", error enhanced for loop and remove

Posted by BitMaster on 04 January 2015 - 03:26 AM

That looks like a lot of unnecessary code, ankhd. You do not need void as a function parameter in C++, that's a C-ism that has no place in C++. The assignment operator is completely unnecessary (the default operator does the same without a single line of code and if the compiler needs to copy it, it would need the copy-constructor not the assignment operator). If a constructor and destructor are empty, they should be omitted unless some special situation requires them (none does here).

And with C++11, none of that is needed because lambdas do it right out of the box without so much verbosity:
DropPodsList.erase(std::remove_if(DropPodsList.begin(), DropPodsList.end(), [&] (const cDropPodSate &dropPod) -> bool
return /* some value based on calculatons using anything accessible in the enclosing scope */
}), DropPodsList.end());

#5200222 Should I use std::cout or have using namespace std; ?

Posted by BitMaster on 27 December 2014 - 03:21 AM

I know this rule makes things annoying if you have long C#-style namespaces like company::project::component and have to write code in your headers (templates, etc...) but this is in the interest of the other programmers' sanity! smile.png

Insanely long namespaces can be abbreviated without pulling them into the global namespace as well:
namespace cpc = company::project::component

That said, I personally never ever apply any kind of using directive to std. It's short and adds a lot of clarity on a glance when you look at things. For the reasons already mentioned other using directives are completely out at header scope. What I will sometimes do is abbreviate the namespace as shown above (not at header scope either). Very occasionally I will add a using directive at function scope.

#5198731 constructor for class that contains another class and constructor C++

Posted by BitMaster on 17 December 2014 - 02:57 AM

While I personally don't think what you are doing is a good idea, why are you trying to initialize members of the base class in the derived class? The base class is responsible for initializing them and it already does. Why are you trying to assign 0 to something which is already guaranteed to be 0?

That aside, please try to get better formatting for your code snippets. The extra newlines and randomized indentation caused me quite a bit of problems trying to understand what you are doing.

#5198142 Wouldn't this cause a memory leak?

Posted by BitMaster on 14 December 2014 - 11:05 AM

If the nodes are never freed, that would indeed leak memory. If you reached that conclusion by searching for 'delete newNode' in the file, that would not mean anything. Nodes would have to be deleted when a node is removed or inside LinkedLists destructor. In neither of these situations you would normally call the local variable newNode though.