[gameprogrammer] Re: OpenGL... Where are the calculations made?
- From: "richard sabbarton" <richard.sabbarton@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Wed, 7 May 2008 16:21:31 +0100
Hi Bob,
Thanks... That is exactly what I needed to know/hear. I have just
started working on a 3D Space Shooter type project and there are many
reasons for me to make calculations based on the current camera/player
position. I also need to make the calculations for other ships as
well.
Each ship (including camera/player) is defined by its location,
direction vector and up vector (to avoid gimbal lock). Each movement
will require motion along or rotation around an axis based on the
orientation. Additionally, I will need to be able to find a point
relative to the ships orientation and origin. An example would be the
starting point of a missile fired. It may be below and to the side of
the players position and not at the position itself.
Regards
Richard
2008/5/7 Bob Pendleton <bob@xxxxxxxxxxxxx>:
>
>
>
> On Wed, May 7, 2008 at 2:32 AM, richard sabbarton
> <richard.sabbarton@xxxxxxxxx> wrote:
> > Hi Guys,
> >
> > I have another question regarding OpenGL and I am hoping you can clear
> > something up for me. If I run matrix manipulation functions using
> > OpenGL (e.g. glTranslate(), glRotate(), gluLookAt(), etc.) I am
> > assuming that the calculations required to perform these functions are
> > performed by the GPU on the Graphics adapter rather than the CPU. Is
> > this correct? Does that mean that the glMatrix is stored in the
> > memory of the graphics adapter or in my system RAM? I am asking
> > because I assume that the GPU can process these calculations quicker
> > and more efficiently than the CPU can.
>
> It is implementation dependent, but for any modern graphics add
>
> >
> >
> > For example, if I want to calculate a cross-product or face normal I
> > can use sin(), cos(), etc to perform the calculations but, IMO, these
> > can be quite costly as far as CPU time. So what if, instead of using
> > sin() & cos() I was to use glXxxx functions instead. I could load an
> > identity matrix and then use gluLookAt() to look at point A and supply
> > point B as an Up Vector. I can then translate 1.0 along the X axis
> > and pluck my normalised cross-product from the matrix. No sin(),
> > cos() or sqrt() in sight. Do you think this will be quicker? Also, I
> > am not sure about the overhead of pulling the values from the Matrix
> > as (another assumtion) would this involve copying the matrix from the
> > Graphics Memory into the System Memory?
>
> Do not do that. The cost of moving the data back and forth from system
> memory and the GPU is very high and is much more costly than just doing the
> computation you want in the CPU. If the math your are doing is slowing you
> project down, then you should first see if the math can be done faster in
> the CPU. You can often skip many steps in your math and speed it up a lot.
> In some cases you can't and then you might want to look at shader
> programming to solve your problem.
>
> Here is a suggestion: instead of asking if and idea is a good idea for
> solving a low level problem, step back a bit and ask us how to solve your
> high level problem. We can be a lot more helpful when we know what you are
> trying to do rather than just who you are trying to do it.
>
> Bob Pendleton
>
> >
> >
> > Regards
> >
> > Richard
> >
> > ---------------------
> > To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >
> >
> >
>
>
>
> --
>
> + Bob Pendleton: writer and programmer
> + email: Bob@xxxxxxxxxxxxx
> + web: www.GameProgrammer.com
> + www.Wise2Food.com
>
> +--------------------------------------+
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: OpenGL... Where are the calculations made?
- From: Bob Pendleton
- References:
- [gameprogrammer] OpenGL... Where are the calculations made?
- From: richard sabbarton
- [gameprogrammer] Re: OpenGL... Where are the calculations made?
- From: Bob Pendleton
Other related posts:
- » [gameprogrammer] OpenGL... Where are the calculations made?
- » [gameprogrammer] Re: OpenGL... Where are the calculations made?
- » [gameprogrammer] Re: OpenGL... Where are the calculations made?
- » [gameprogrammer] Re: OpenGL... Where are the calculations made?
- [gameprogrammer] Re: OpenGL... Where are the calculations made?
- From: Bob Pendleton
- [gameprogrammer] OpenGL... Where are the calculations made?
- From: richard sabbarton
- [gameprogrammer] Re: OpenGL... Where are the calculations made?
- From: Bob Pendleton