General > Off Topic

Programming Fast circle code for OpenGL

<< < (2/3) > >>

ikke:

--- Quote from: peterb ---hmm i like to minimize cos and sin calls since these functions are complex and thus slow i think.
I'm not sure if darwin bots works with a bots direction, or rather with a deltaX & deltaY ( i think sin cos are only required when a collision occurs
Circle collisions might however be more complex, since a small circle can bump into a larger one... hmm collision checks must be a whole big topic..
--- End quote ---
Bots don't have a fixed heading and rotation (angles) equals sine & cosine, implicit or explicit

Numsgil:

--- Quote from: peterb ---hmm i like to minimize cos and sin calls since these functions are complex and thus slow i think.
I'm not sure if darwin bots works with a bots direction, or rather with a deltaX & deltaY ( i think sin cos are only required when a collision occurs
Circle collisions might however be more complex, since a small circle can bump into a larger one... hmm collision checks must be a whole big topic..
--- End quote ---

You would be fine to use sin and cos, since they're only called once when you build the display list.  After that the vertex positions end up being stored on the graphics card.  So it beats out trying to re-send the data across the bus for every circle for every frame.

Internally Havok uses vectors (deltaX, deltaY).  We only call sine or cosine when we convert things to angles for use in sysvars.

sin and cos are actually not as slow as you might think on a computer.  Only about the cost of 20 floating point multiplies or something like that.  It's a hardware call that gets evaluated by the FPU on the processor.  So if you can't get around sin/cos calls using vectors, you're almost always better off performance-wise just calling sin/cos instead of trying to approximate them in software.

peterb:

--- Quote ---You would be fine to use sin and cos, since they're only called once when you build the display list.  After that the vertex positions end up being stored on the graphics card.  So it beats out trying to re-send the data across the bus for every circle for every frame.
--- End quote ---

ehm .. ??
How does that work my routine uses a minimum of sin cos commands but their values, you can store them in the graphic card ???
the routine is a buildup of lines from 8 start points my circle (from top left right and bottem, in 2 directions makes 8)

Numsgil:

--- Quote from: peterb ---
--- Quote ---You would be fine to use sin and cos, since they're only called once when you build the display list.  After that the vertex positions end up being stored on the graphics card.  So it beats out trying to re-send the data across the bus for every circle for every frame.
--- End quote ---

ehm .. ??
How does that work my routine uses a minimum of sin cos commands but their values, you can store them in the graphic card ???

--- End quote ---

Yes.  More to the point, graphics cards can only draw things which are stored in a hardware buffer anyway.  So your openGL commands get converted in to that anyway.

peterb:

--- Quote from: Numsgil ---
--- Quote from: peterb ---
--- Quote ---You would be fine to use sin and cos, since they're only called once when you build the display list.  After that the vertex positions end up being stored on the graphics card.  So it beats out trying to re-send the data across the bus for every circle for every frame.
--- End quote ---

ehm .. ??
How does that work my routine uses a minimum of sin cos commands but their values, you can store them in the graphic card ???

--- End quote ---

Yes.  More to the point, graphics cards can only draw things which are stored in a hardware buffer anyway.  So your openGL commands get converted in to that anyway.

--- End quote ---

I'm not sure if i'm following this you mean that a 'drawn' object is stored in the graphics card
And so you can then adres a whole object like move all the lines by 1 vector ??  (moving a poly line)
(so no redraw of the complete circle ?), only have one command like move object(XXX) by vector(x,y,z)   //z=0
In my sample i just redraw each frame.
If move by vector is possible that would be way faster..



Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version