Wednesday, 15 April 2015

opengl - Is it possible in OpengGL to insert a transformation to a matrix before the existing transformations? (prefix multiplication) -



opengl - Is it possible in OpengGL to insert a transformation to a matrix before the existing transformations? (prefix multiplication) -

to give background on issue using box2d , trying utilize built in debug draw functionality create debug overlay allow me see physics bodys' actual shapes on game's graphics. issue arises in combination of moving view scheme implemented translating , rotating modelview matrix before rendering scene , fact box2d coordinates smaller scale factor of screen coordinates (in case of current project multiplying screen coordinates .05 box2d coordinates). both features work correctly independently.

when time utilize box2d's debug rendering can create scaling work scaling modelview matrix if has not transformed @ view system. after if apply same transformations scaled modelview did original using view scheme right results. know how can create work in rather costly way lot easier if there way insert transformation (aka utilize prefix multiplication instead of usual postfix) in opengl.

i using old opengl built in matrices without shaders, manipulating matrices using functions gltranslate , glrotate. there way of straight reading/writing values in matrix or else sort of opengl setting how apply transformations?

is there way of straight reading/writing values in matrix

yes there glgetdoublev (i recommend using double precision this) can query current matrices on individual stacks. see http://www.opengl.org/sdk/docs/man2/xhtml/glget.xml

then can use

glpushmatrix(); glloadidentity(); your_transformation(); glmultmatrix(queried_matrix);

to apply own transformation before on stack. utilize glpopmatrix clean after yourself.

opengl matrix box2d transformation

No comments:

Post a Comment