Jump to content

  • Log In with Google      Sign In   
  • Create Account

BitMaster

Member Since 08 Aug 2000
Offline Last Active Today, 03:14 PM

#5134477 GLSL

Posted by BitMaster on 25 February 2014 - 12:00 PM

In general you will want to calculate the value in the application. For normal triangles the geometry shader could be used to calculate a normal (but that would only be equivalent to flat shading, so it's pretty useless in most cases). For other types of primitives (like GL_TRIANGLES_ADJACENCY) something more interesting would be possible. Usually however, normals are calculated by the modeler.

There are countless approaches to generate normal data though. Which is best will depend on how much energy you want to invest into the implementation and the kind of models you work with. A simple approach is assigning to each vertex the averaged normal of all faces it is part of.




#5134470 Inheritance question

Posted by BitMaster on 25 February 2014 - 11:52 AM

The problem is well known as slicing and there is no way to avoid that without storing pointers instead of instances.

 

However, modern C++ has plenty of tools to avoid the memory management pitfalls of that (std::unique_ptr/std::shared_ptr among others).




#5134426 C++ IDEs for Linux

Posted by BitMaster on 25 February 2014 - 08:56 AM

I thought QTCreator was a really nice IDE as well. I am thinking about using it to develop my GUI tools for my engine when it comes down to that point since the only tools I've developed were for Windows using c-based winapi's back in high school haha... I had a few gripes I have with QTCreator. I haven't figured out the licensing, or what kind of royalties I'd have to pay Nokia if it came down to me producing a commercial produce. From what I've seen from tutorials, there seems to be quite a bit of OpenGL wrappers involved with QT. I'm not sure if I could link to standard libraries that are already installed on my system that weren't built from QT.


QtCreator does not force you to use Qt. If you don't, you are only bound to the license of the compiler you use (if you use a bundled version, usually MinGW derivative or MSVC; otherwise whichever compiler you chose to setup).
If you use Qt you can buy a commercial license or use the LGPL license (see here). Since I'm not even sure there is a viable Qt 5 build which links statically that seems to be almost a restrictionless license.

Also, whichever way you go, Nokia does not factor in there at all. Qt is now in the hands of Digia.


#5132930 Help with GLFW?

Posted by BitMaster on 20 February 2014 - 04:30 AM

I heard about Glew, but it seemed GLFW 3 didn't require it.
 
At this point, it wasn't so much link errors as compile errors.  After much flail, I managed to convince it to use the glcorearb.h file, and it seems happy with the prototypes.


I strongly recommend not playing around that way. Even if you manage to avoid compiler errors, you will then risk linker errors. If you don't run into those you might end up having problems on different Windows versions and different drivers.

Microsoft has fixed the OpenGL version on Windows at 1.1. Anything above that needs to be queried by the extension mechanism. Trying to work around the extension querying invokes undefined behavior.

On Windows, there is no real way around GLEW or something like it. GLFW offers a platform independent way of opening Windows and doing basic GL context management. What GLFW does and what GLEW does is pretty much orthogonal (and as such does not belong into a library which strives to be lean).


#5132900 RefCount pattern ended ?

Posted by BitMaster on 20 February 2014 - 02:16 AM

Nice to know about std::shared_ptr, but it's a c++11, maybe it's better actually to have own RefCount class since c++11 is young.


First, as others have said calling C++11 young is a misnomer. Even compilers with suboptimal C++11 support (like MSVC) still implement std::shared_ptr and its friends.
That said, Boost had its own shared_ptr implementation (which is for almost all purposes identical to std::shared_ptr) for years and years already. It also contains the often forgotten intrusive_ptr which avoids several of the problems pointed out with (std|boost)::shared_ptr.


#5132569 I don't get c++11.

Posted by BitMaster on 19 February 2014 - 02:26 AM

Maybe my coffee hasn't kicked in yet but that looks to me like the function syntax I have been using for years (starting with boost::function, nowadays std::function). It's simply std::function<ReturnType (ParameterType1, ParameterType2, ...)>.

Edit: Boost used to warn that while it's the preferred syntax not all compilers support it. But all the MSVCs I have used it with never complained.


#5132326 Why C++?

Posted by BitMaster on 18 February 2014 - 07:52 AM



// C++11
std::for_each(std::begin(movingObjs), std::end(movingObjs), [](MovableObject* obj)
{
// do something with obj
});

While this is obviously valid code, why do this over
for (auto* obj : movingObjs)
{
    // do something with obj
}
? Or am I missing something?


#5131237 small inline lib for math in mingw

Posted by BitMaster on 14 February 2014 - 05:04 AM

GLM


#5131061 Modify functions from generic class? (c++)

Posted by BitMaster on 13 February 2014 - 09:52 AM

Since the question is extremely generic the answers will end up being extremely generic:
- use composition
- use polymorphism despite your reservations
- use compile-time polymorphism
- embed a scripting language


#5130271 SFML 2.1 Setup Problem

Posted by BitMaster on 10 February 2014 - 06:53 AM

That does not appear to be a problem directly related to SFML. All of the random samples I checked were Windows API functions. You don't seem to be linking to User32.lib. More platform libraries might be the culprit, but linking to that one will probably reduce the number of errors a lot.


#5129310 Ask for Opinion

Posted by BitMaster on 06 February 2014 - 08:23 AM

1. how you read a statement "for" to a logic or human languange? example

Starting from one, add one to i until i is equal to, or greater than, ten.

Actually, no. The loop as given will never run. It's "starting from one, while the value is greater than 9, increment by one".
Edit: actually, not sure about that anymore since I missed the C# part on the first pass.
 

2. what difference a game programming and graphic programming?

 
Graphics programming is a part of game programming.


Not really. A part of graphics programming is part of game programming. There are applications of graphics programming which have (for the time being) no intersection with game programming. Some examples are rendering techniques used for medical purposes or rendering techniques which are very, very far from real-time.


#5129298 C++ SDL - Deleting dynamically allocated objects

Posted by BitMaster on 06 February 2014 - 07:35 AM

MinGW 4.7 onward (if i remember the version correctly) supports most of C++11, if not all of it, and unique_ptr is part of that.


Yes, however std::make_unique requires C++14. If and how much C++14 is supported will depend on what version of MinGW is used. Of course it can't hurt to specify -std=c++14 instead of -std=c++11 and just try it out.


#5129248 c++11 move constructor question

Posted by BitMaster on 06 February 2014 - 01:56 AM

Since Test does not implement an explicit move constructor, it's just copy constructed. And since Test has no members, that's a no-op.


Setting aside the empty-class test case problem, according to this page the compiler should implicitly generate a move constructor. So in my understanding, if the test class contained expensive to copy members (like complex std::containers) the compiler would have generated a move constructor which could have been used.

I'm happy to be corrected though.


#5128720 SFML 2.1

Posted by BitMaster on 04 February 2014 - 07:36 AM

texture coordinates are defined in pixels (they are not normalized (between 0.0 and 1.0f), as people who are used to graphics programming would expect).


Firstly, according to the TheComet's link to the documentation, using pixel or normalized coordinates is a choice. Secondly, since SFML has a strong focus on being a reasonable library for 2D game development, having a default value of pixel-based sounds extremely reasonable.


#5128712 replacing sprintf_s trouble

Posted by BitMaster on 04 February 2014 - 07:01 AM

If you are confident viPrintf is indeed not changing anything (that is, it's missing a const but behaves as it is there), then you don't have any problems. Something like a const_cast should always be properly commented though.

If you are not sure and viPrintf might change some characters then it will (most likely) still work on all compilers and standard libraries although it's technically invoking undefined behavior. If viPrintf tries messing with characters beyond the C string length (for example because it assumes it always has at least 20 characters to work with) then you are in troubles.

If you want to be on the safe side, allocate a new C string of the correct size (plus safety margin as desired), copy the content of cmdstr.str() in there, and pass that C string to viPrintf.




PARTNERS