07-08-2010, 01:01 PM
I am wanted to use opengl libraries to send it my own 4x4 matrix, have opengl perform a rotation and then retrieve the resulting matrix from that operation for use back into my main program.
is there a way to use something like glGetFloat(GL_MODELVIEW_MATRIX, myMatrix) without having a windowing context? Perhaps there is an alternative way to do this.
I want to rotate around an arbitrary axis using transforms but there doesnt seem to be much detailed docs on how to do this without having tons of scaling issues. any help or links on this front would be helpful.
I just thought that perhaps just using the opengl libraries would provide me with faster and more reliable computations.
07-08-2010, 02:19 PM
A - Matrix operation are not harware accelerated
glRotatef(30.f, 1.f, 0.f, 0.f);
glTranslate(0.f, 1.f, 1.f);
is the same than:
modelView.translate(0.f, 1.f, 1.f);
probably the code of the driver that perform matrix operation is untouched by twenty years.
You also have the advantage that you have the matrix wherever you want, you don't need to ask openGL the current matrix.
If you don't draw anything is useless to use openGl only for matrix operation.
B- using glGet is a performance killer.
Driver is the interface between software and hardware. Every time you send an openGl command this should be sent to the GPU. But to interact with the hardware the driver must go in protected mode.. software interrupt, context switch, cache flush... ARGH.. a lot of wasted time.
To avoid of doing a context switch for every openGl command the driver put the command in a queue, when the queue is full it perform a context switch, probably once per frame. If you use a glGet you are asking the state of some value, so the driver must evaluate all the command in the queue and trigger a context switch. Doing many glGet can slow down your application a lot.
So, DON'T EVER USE glGetFloat if you care about performance.
If you want to rotate around and arbitrary axis you can simply go here
or study quaternion, and implement your own matrix library.
Otherwise, if you are lazy you can go on Google and look for a free linear algebra library (better if sse2 accelerated).
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.