• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

144 Neutral

About StasB

  • Rank
  1. Hi! My question is pretty simple: What are some good ways to generate random N-dimensional gradients for Perlin noise?
  2. OpenGL Projecting Textures

    I didn't know texture coordinates had Z and W components. I think I get it now. I guess I should do some more reading about how OpenGL works. Thanks, guys.
  3. OpenGL Projecting Textures

    I don't understand. Getting the texture coordinate for a world vertex involves a division by the distance from the projector's near plane. That's a non-linear function. =S
  4. I need to project some textures to simulate sprite shadows but I can't wrap my head around how it's done in OpenGL. From what I understand, for each vertex of the projection surface, I need to calculate the coordinates on the projected texture and let OpenGL interpolate them automatically. This doesn't quite make sense to me because the interpolated function isn't even linear since it's basically a perspective projection. Pic related: [img]http://i.imgur.com/TFQ3F.png[/img] I'll be glad if someone could explain. Thanks. =)
  5. [quote name='Murdocki' timestamp='1331309022' post='4920696'] If you're going for a higher level graphics engine you should not think about how to wrap OpenGL. Instead you should think about how you'd like to make the calls to render something and then fill that in by using OpenGL. You might need a few iterations of adjusting requirements due to api specific limitations but you'll end up with a system that's easy to use, which is one of the most important things for anything high level. To answer your question, my glBindBuffer calls are checked in the implementation of the Renderer class just by comparing ints like suggested by the poster above. I'm not doing this in the state manager because i've defined that to be managing render states like cullmode, blend mode, alpha testing etc etc. I gues you could do that in the state manager aswell, it doesnt really matter. On a side note, maybe managing glBindBuffer calls isn't your biggest problem if you're worried about redundant state changes performance loss. Other state changes like shader and texture binds will probably be a lot more expensive and your buffer count will be very low when you've implemented batching. [/quote] What's wrong with an intermediate layer to ease up the task of writing a higher-level engine? I have no intentions of writing a big general-purpose graphics engine. If I wanted one, there are many available. I write small apps with widely varying requirements that don't usually fit a standard engine architecture and I find myself writing over and over again heaps of OGL code to handle low-level tasks like setting up and rendering FBOs, VBOs etc.
  6. [quote name='Yours3!f' timestamp='1331305753' post='4920683'] well, while wrapping the whole api is possible, in my opinion its rather pointless. You might want to write a state manager as suggested, but I think that you shouldn't wrap everything, but rather certain functionality (mesh loading, texture loading, shader loading etc.) which enables you to use OGL without making a single error, because the wrapper class takes care of it. for ex. you could say that the current buffer stored would be: struct buffer_state { GLuint buffer; GLenum target; } current_buffer_state; and you could implement a function that checks if the current buffer bound is the one you pass to it, and in that case it wouldn't call the OGL function: void my_bind_buffer(GLenum target, GLuint buffer) { if(current_buffer_state.buffer != buffer || current_buffer_state.target != target) //check the current state { if(glIsBuffer(buffer)) //check if it is really a buffer { glBindBuffer(target, buffer); } } } or something like this... you might want to check out pixellight for a whole api wrap example. when your app starts up you could just simply query the current gl state with glGet* to initialize your states [/quote] Basically, here's my problem: I need to write my own versions of the OGL state-setter functions I care for that check for redundant state changes. Some of those functions take a parameter that specifies which state to change, like glBindBuffer. Ideally, if I write a glBindBuffer wrapper, it better act like the original, accept a target parameter and handle it correctly. How do I do that without manually writing special code for every type of target?
  7. [quote name='Murdocki' timestamp='1331302390' post='4920669'] Yes it's possible, it's called object orientation. You create classes with specific responsibilities. This will add a very tiny mini overhead but it's more than worth it. The trick is to pull your classes to an as high as possible level of abstraction without creating overly complex class responsibilities. For example, who sais you're using VBOs, maybe you've just got some vertex data that needs to be rendered however the implementation sees fit. To counter the state changes you might end up with a state manager which only changes state if it is required. [/quote] I thought it was clear from my OP that object orientation is what I'm trying to achieve. I'm just worried about the performance penalties from redundant state changes. I just want a thin and convenient layer on top of plain OpenGL to ease up the task of writing a higher-level graphics engine. I thought about making a state manager, but I'm not sure how to go about it. How would you go about wrapping "void glBindBuffer( GLenum target, GLuint buffer)", for example?
  8. I'm tired of my code being littered with verbose GL calls. I've been wondering if there's any way to wrap things up in small classes without a serious loss of performance and generality. For example, if I want to have a VBO class, every member function that does something with a VBO needs to make sure it is bound first. If I want to render it, I need to make sure all the client states (e.g. glEnableClientState(GL_VERTEX_ARRAY)) and pointers (e.g. glVertexPointer(...)) are set up correctly. The only robust way to do that is to set all relevant global state in every member function call, even when it's unnecessary. Wouldn't all this state-changing cause some serious performance issues?
  9. It doesn't matter what _you_ are naturally inclined to consider. It's not a language-specific detail. It's the basic precedence rules of math, which, naturally, any sane programming language obeys, be it is C-like or not. This has nothing to do with memorizing programming language rules. Your post makes no valid points or any sense. Sometimes, there's some benefit from using brackets merely for clarity. Not in this trivial case. End of story.
  10. @allMadeFromCode: I'm confused... Isn't there a whole bunch of possible angle\velocity combinations to hit a target? @Fenrisulvur: Quote:It's not at all good practice to rely upon the order of operations imposed by a language when implementing these things. It's less readable since people typically end up having to consult some sort of reference to remind themselves, and it's a great way to introduce non-trivial bugs into your code. I see no real problem with relying upon the operator precedence defined by _math_. Last time I had to consult a reference to remind myself about it was in elementary school. By your logic, why stop at turning A / B * C into (A / B) * C? Maybe we should also turn A + B + C into (A + B) + C? =|
  11. Performance-wise, you have nothing to lose by using hierarchies... Unless, of course, your characters are more likely to overlap than not. The question is whether you have anything to gain. Personally, I kind of doubt it. Anyway, you know what they say: premature optimization is the root of all evil. Go get something working. If it's not fast enough, then start thinking about it.
  12. Convex collision

    First of all, what exactly are you interested in? Collision detection (checking whether two polygons collide), or collision response (separating two colliding polygons and making them bounce off each other)? In any case, your reference has little to do with polygon collision... You might want to read this: Separating Axis Theorem Explained
  13. Well, your algorithm is definitely faster than what I originally had in mind, but consider what happens when you randomly pick a small star that has some big stars around it that are "illegal"... They will be erased and their space will be wasted, even though you could fit smaller "legal" stars in there. You could run out of space and end up with less stars than you wanted, even though you have clearly visible empty spaces where starts could fit... At least in theory...
  14. Not sure what you mean, but glad I could help. =P
  15. Completely fill the grid with random stars. Randomly pick N of them. This algorithm depends only on the number of cells. The simplest and cheapest solution.
  • Advertisement