Jump to content
  • Advertisement

Darkilon

Member
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

123 Neutral

About Darkilon

  • Rank
    Newbie
  1. Sorry that you wasted time by typing something that got lost! I, again, forgot to mention (that's what you get when you post something half-asleep, I guess) that I'm using a persistently-mapped buffer (I had read this) as well. Anyway, thank you both for your suggestions, I'll try to work on them and profile.
  2. Excuse me, I forgot to mention that I AM triple-buffering. Also, probably it wasn't clear, but I'm updating the VBO ONLY when the data changes. Mind explaining me why? I'm only ever going to render the same type of object (a quad) whose copies are going to have different textures, positions and whatnot, so I thought instancing would be ideal in this case, without even mentioning the ease at which all the quads can be rendered (a single draw call). Thanks for the file, I'll make sure to read it later.
  3. I'm programming in C++ with OpenGL, but decided to post here since this is more of a technical, generic question; I'm not asking how to implement one in OpenGL but rather the idea behind it. Essentially, I'm batching quads using instancing and a texture 2D array which contains the textures of the quads. Now, my problem lies on how to effectively batch them, I'll explain myself better: previously, to batch quads, I was simply adding their instance data into a VBO, load it all into GPU and render the quads with a single rendering call, after which I would empty the VBO and start a-new (this time with updated quads' data). However, I found that to be slow, so I'm currently doing this: a new quad needs to be rendered, so I place its instance data into the VBO, which's going to stay there for as long as the quad needs to be rendered and, whenever it changes position, size or whatever, I'll update its current data into the VBO, overwriting its old data. Is this a good way? Or is there a better, more efficient way? I'd like to hear your thoughts on this. Also, how does XNA achieve its spritebatching? I read about it around and it seems to enclose its draw calls into some begin() and end() functions which respectively set up and flush the renderer. Does that mean that it acts like my previous batching method, albeit in a better, more performant way? Thanks to anyone who can shed some light upon this.
  4. Darkilon

    Function return type

    Thank you for your replies. @ Paradigm Shifter: I've revised my code and I'm using 2 different vectors now. Also, as for the spelling of "Depend(E/A)nt": I'm not a native english speaker, but as far as I know, they're equivalent: http://en.wikipedia.org/wiki/Dependant @ ApochPiQ: I've done something like that, but I used inheritance because I thought it was a good idea to keep the 2 different classes encapsulated, "BaseStat" (Which only needs modifiers) and "DependantStat" (Which also needs special kinds of modifiers, which DEPEND on the simple BaseStats). I really wouldn't want a "BaseStat" to depend on another "BaseStat". @ Servant of the Lord: Thanks for the heads up. I haven't learned lambdas yet, but I'll be sure to.
  5. Darkilon

    Function return type

    I know where you're coming from, and that's what I've been doing for quite a while, but I've encapsulated my stats in a class rather than a single variable because I want modifiers to them. Like, my "IndependantStat" (Or rather, I actually called it "BaseStat") has a vector of "Modifiers" (A struct which explains how to modify a specific attribute) and various functions like AddModifier(), RemoveModifier(), GetModifier() and a CalculateFinalValue() (Which takes into account ALL the modifiers applied to such stat), while my "DependantStat" HAS to be in a "is-a" relationship with "IndependantStat" because not can only it be modified by modifiers, but it has also got a vector of "IndependantStatBoost", which is nothing more than a struct with a pointer to a "BaseStat" and a "ratio" (float) variable. It works like this:   BaseStat VIT(30); //Base value of VIT set to 30 VIT.AddModifier(new Modifier(FLAT_MODIFIER, 100)); //Adds a flat modifier of 100 to VIT, now VIT = 130 DependantStat HP(100); //Base value of HP set to 100 HP.AddIndependantStatBoost(new IndependantStatBoost(&VIT, 0.5f)); //Now HP = 165
  6. Darkilon

    Function return type

    Yeah, I had thought of both solutions, although 1) would be quite redundant imho, I could just stick everything in one class, which isn't encapsulation-friendly, while for 2) I would need 2 different GetSomething() functions, which would work on 2 different vectors. What's your suggestion, then? Which one should be preferred over my design? EDIT: Also, 2) wouldn't work for me now, I guess, since I would need to know in advance which type of ClassType I need.
  7. Darkilon

    Function return type

    Well, I'm casting it because I want to use the derived class' functions, which is stored in a base class vector. What I'm trying to achieve is the following: #include <iostream> #include <vector> class Base{ int x; public: Base(int x) : x(x){} int GetX(){return x;} }; class Derived : public Base{ int y; public: Derived(int x, int y) : Base(x), y(y){} int GetY(){return y;} }; int main() { Base *b = new Base(3); Derived *d = new Derived(1, 7); std::vector<Base*> test; test.push_back(b); test.push_back(d); std::cout << test[0]->GetX() << "\n"; Derived *downCast = static_cast<Derived*>(test[1]); std::cout << downCast->GetX() << ", " << downCast->GetY() << "\n"; std::cin.get(); return 0; } All of which should go in a function which takes the "ClassType" as a parameter and if the chosen type is "Base", then simply return an element from the vector "test", else cast said element to "Derived" and return it. I know this isn't quite elegant, so, as I said earlier, if you know a better way to achieve something like this, please, tell me.
  8. Hi there, I'm developing a component-based engine, thus far, everything has gone well, however I've encountered a problem in my stat component: I'm using 2 types of stats, independant stats (The so called "attributes" (As of strength, agility, etc...)) and dependant stats (Physical attack, magic defense, etc...) and they're both stored in a polymorphic vector which I'm accessing through a function, and that's where the problem has arose. The "DependantStat" class is derived from "IndependantStat", but it has obviously got more functions which cannot be accessed from an "IndependantStat" pointer. What I've used so far is something like the following:   template<typename T = IndependantStat> T *GetStat(StatType type) { ...get the desired stat... if(type >= STAT_HP) { return static_cast<DependantStat*>(stats[i]); } else { return stats[i]; } } So, what I would like to do is make a function that can ONLY return either an "IndependantStat" or a "DependantStat". Obviously, if there's a better way to do this, please tell me. Thank you for your help.
  • 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!