C++ | DirectX | Class system ?!

Started by
36 comments, last by Mate 9 years, 4 months ago

std::list might not be the most appropriate data structure to use in C++ depending on what you're doing. I don't know if Java's 'list' is a linked list or not either. Google says Java's List by itself is just an interface so you probably mean either ArrayList or LinkedList . std:list is most like LinkedList and std::vector is most like ArrayList. There are many other data structures to look into. std::deque never gets as much attention as it should since it can be a good compromise between std::list and std::vector.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

Advertisement


But DirectX is only avalable for C++ so .. you have to use C++ with DirectX.

laugh.png There are several thousand C# programmers using DirectX that will be surprised to hear that.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

If I were to be really blunt you might do well with a bit of humility, to me reading all your posts so far most of them seem to have this air of "Well this only works this way so I can't do this thing, I know it works this way!" when in reality a lot of the things you've said so far don't even make sense.

Java has negatives over C++ yes, if you had a team of AAA developers trying to squeeze every ounce of performance out of the language than C++ is probably going to give them a much wider range of control than something like Java or C# ever would, that's why we still use C++.

But Java isn't inherently just going to give your game 12 FPS, your game probably was performing badly because it needed to be optimized or it was trying to do way too much in way the wrong ways.

I also don't really get your confusion over COM, COM is weird yes but it's really just a bunch of references to hidden internal objects somewhere. There's no "main class" your COM objects do not have to be created in a main class, main is not a class it is a free function.

Even the stuff you said about static vs objects, a lot of how that works is almost identical between C++, C# and Java. If you were abusing the heck out of new in C++ I would at least understand, but I really don't understand a lot of your issues. Most of your issues just seem to come from you not having popped open a tutorial and trying to learn C++ first before you make a game.

You should stop making so many assumptions and actually ask some questions, it would make you sound less arrogant. Not to be rude but nobody really cares if you "worked on a bunch of big projects, very experienced blah blah blah" if you clearly don't even know what you're talking about.

std::list might not be the most appropriate data structure to use in C++ depending on what you're doing. I don't know if Java's 'list' is a linked list or not either. Google says Java's List by itself is just an interface so you probably mean either ArrayList or LinkedList . std:list is most like LinkedList and std::vector is most like ArrayList. There are many other data structures to look into. std::deque never gets as much attention as it should since it can be a good compromise between std::list and std::vector.

I know you are trying to link std containers to how they work in C# or Java, but what you are saying is incorrect.

  • std::list is implemented as a double linked list, and thus is always a linked list, a list in C# or Java is only an access interface the container underneath can be anything.
  • std::vector is always an array, and it has more in common with a naked array in any language than any other container.
  • std::deque is implementation dependant on how it works, for small queues it usually is an std::vector, but it could also be a more complicated datastructure, where it conceptually resembles a linked list of arrays, but this is usually stored as an array of pointers to those memory blocks

std::deque should be used when you need to be able to add or remove elements from both ends of the queue with O(1) access time, usually these things are used for commandlists where you get from the front and add at the back.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion


I don't know if Java's 'list' is a linked list or not either

I actually meant to say I don't know if the OP's 'list' is a linked list or not. I know that Java's list is just an interface (I said so in the following sentence). Other than that I don't think you contradicted anything I said so much as expand and clarified it so thanks for that. +1 to you.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

Sure DirectX has better performence IN GAMES.

Where did you read this?

On the websites of DirectX and OpenGL.

And even when it wouldn't be forced, C++ has more freedom and more freedom means more way to enhance the performence, in this case.

More freedom can also mean an easier way to break things + some things require more effort to do in C++.

More freedom can also mean an easier way to break things + some things require more effort to do in C++.

Yeah :)

You are looking for the stl library - that's why I said learn c++ before trying to code a 3d engine on it. std::list would do the job. Check out this: http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

You might find this useful too: http://www.cplusplus.com/reference/stl/

Thanks for the links. And to "that's why I said learn C++ before...".

I'm actually changing the language and I learned the basics of C++. So I'm at the point, where I can say "I got enough to work with, now I start and all I don't have, will be learned on the long, hard way."

Thats ... pretty realistic and .. I got a lot of this "Ahh I'm feeling so much more routined now in C++" - moments in the last time. Thats gonna work :)

Don't know why, but my awnser got deleted ?!

So thanks here for your help.

I try to make my code clean since a week now, as you know. Now I try to give a pointer to a COM object to a function.

But I can't use the members with the acces operator. Like

deviceContext->blablabla

when deviceContext is a pointer to a COM like:

void whatever(ID3D11DeviceContext **deviceContext)

But the acces operator works for all my other pointer-to-class's. Olny the COM's are making trouble. In the moment I solved it the bad way just for get it working till I got the solution.

If I were to be really blunt you might do well with a bit of humility, to me reading all your posts so far most of them seem to have this air of "Well this only works this way so I can't do this thing, I know it works this way!" when in reality a lot of the things you've said so far don't even make sense.

Java has negatives over C++ yes, if you had a team of AAA developers trying to squeeze every ounce of performance out of the language than C++ is probably going to give them a much wider range of control than something like Java or C# ever would, that's why we still use C++.

But Java isn't inherently just going to give your game 12 FPS, your game probably was performing badly because it needed to be optimized or it was trying to do way too much in way the wrong ways.

I also don't really get your confusion over COM, COM is weird yes but it's really just a bunch of references to hidden internal objects somewhere. There's no "main class" your COM objects do not have to be created in a main class, main is not a class it is a free function.

Even the stuff you said about static vs objects, a lot of how that works is almost identical between C++, C# and Java. If you were abusing the heck out of new in C++ I would at least understand, but I really don't understand a lot of your issues. Most of your issues just seem to come from you not having popped open a tutorial and trying to learn C++ first before you make a game.

You should stop making so many assumptions and actually ask some questions, it would make you sound less arrogant. Not to be rude but nobody really cares if you "worked on a bunch of big projects, very experienced blah blah blah" if you clearly don't even know what you're talking about.

Didn't I say at the beginning that english isn't my mother language. I can't rally write it so precision, that you fully get how I wanted to say it. And I don't want to say your dumb, I want to say, that my post sound. Thats why it sounds arrogant. With "I worked on other projects" I wanted to say, that i have enough experience with 3D programming and my "problem" is C++.

and my "problem" is C++.

And that's why I said you should work on your C++. Most of the questions you ask, you wouldn't need to ask if you had read a semi-decent book on C++. I highly recommend C++ primer 5th ed (not to be confused with primer plus). If you feel it's too hard, I'd recommend Sams teach yourself C++ in 24 hours. You could of course check this topic - http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list and decide what's best for yourself. I'll emphasize the fact that your issues stem not from DirectX's COM objects, but rather from your lack of a better knowledge of C++ (at least that's what your questions lead me to believe). While Java and C++ have some things in common, they are plenty different, so you should really study the language with dedication. I cannot imagine anybody making a decent 3d renderer/engine in C++ without actually having an idea of various design patters, class authoring concerns, paradigms etc. even less when he lacks understanding of the basics of the language (constructors and pointers are considered basics).

On a side note, I guess people would eventually get pissed at your comments, because they expect "actual questions" - not a step by step guide how to make every single detail work for your implementation. The general idea is that you should put in more effort before asking questions - as in learn the language - or at least the basics. There would be no use if the community writes your whole code for you. I like to regard gamedev as a place that can give you a basic idea where to go from a certain point, if you get stuck, or provide you with additional reading material (that you may or may not be aware of), or give you a relatively objective critique of your code, rather than a "tool" that can magically "fix" your code or write it for you.

and my "problem" is C++.

And that's why I said you should work on your C++. Most of the questions you ask, you wouldn't need to ask if you had read a semi-decent book on C++. I highly recommend C++ primer 5th ed (not to be confused with primer plus). If you feel it's too hard, I'd recommend Sams teach yourself C++ in 24 hours. You could of course check this topic - http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list and decide what's best for yourself. I'll emphasize the fact that your issues stem not from DirectX's COM objects, but rather from your lack of a better knowledge of C++ (at least that's what your questions lead me to believe). While Java and C++ have some things in common, they are plenty different, so you should really study the language with dedication. I cannot imagine anybody making a decent 3d renderer/engine in C++ without actually having an idea of various design patters, class authoring concerns, paradigms etc. even less when he lacks understanding of the basics of the language (constructors and pointers are considered basics).

On a side note, I guess people would eventually get pissed at your comments, because they expect "actual questions" - not a step by step guide how to make every single detail work for your implementation. The general idea is that you should put in more effort before asking questions - as in learn the language - or at least the basics. There would be no use if the community writes your whole code for you. I like to regard gamedev as a place that can give you a basic idea where to go from a certain point, if you get stuck, or provide you with additional reading material (that you may or may not be aware of), or give you a relatively objective critique of your code, rather than a "tool" that can magically "fix" your code or write it for you.

I buy it. I tried a couple of tutorials of C++ before, but they were too basic. Its just boring to read what integers and floats are. Thats why I tried to only ask for the differences of the two languages in here to fill the hole, without wasting time on things I know from Java. (And maybe this sounds arrogant aswell .. I can't change it !)

Now I'm searching a book exactly done for my "holes". I can't find something usefull yet, where the pleople I asked sayed its good aswell.

Know if you want a concrete question I'll give you. And I don't want you to write my code. Just filling holes.

Q:

I try to give a pointer to a COM object to a function.

But I can't use the members with the acces operator. Like

deviceContext->blablabla

when deviceContext is a pointer to a COM like:

void whatever(ID3D11DeviceContext **deviceContext)

But the acces operator works for all my other pointer-to-class's. Olny the COM's are making trouble.

This topic is closed to new replies.

Advertisement