English 中文(简体)
实际上,在现代开关3.x/4.x中,矩阵模式转换发生在哪里(或以何种方式)?
原标题:Actually where (or what way ) matrix mode switching takes place in modern opengl 3.x/4.x?

我读过很多关于矢量、缓冲物体等的内容,并审查了许多实施旧/新开放操作的示例应用。我的应用程序,包括物体装载、变换和顶部/分层遮光镜,总的来说,我理解如何将各种变数传递给遮光器,以及如何绘制阵列和元素阵列,迄今为止一切都很好。

但有一点我不明白——最后 gl_position 矩阵使用I 生成的矩阵,通过某些数学操作(实际上我使用SDL, glew and glm s 函数,如 LookAt, 翻译, 旋转等),传递到顶层阴影处。

what I do is shader

#version ...
uniform mvp..
main ..
{
   gl_Position = mvp * ...;
}

cpp, cpp, cpp, cpp, cpp, cpp, cpp, cpp, cpp, cpp, cpp, cpp, cpp

load_object_vertices_indexes_etc;
install_shaders;
bind_buffers;
buffer_data;
enable_vertex_array_elements_etc;
mat4 aaa_proj = perspective(persp_params);
mat4 bbb_view = lookAt(look_params);
mat4 ccc_model = translate(translate_params);
mat4 ddd_anim = rotate(rotate_params);
/* then I do matrix multiply */
mat4 some_final = ..proj * ...view * ..model * anim;
glUniformMatrix4fv(location_in_shader, 1, GL_FALSE, ..val_pointer_of_some_final)
glClear(appropriate_bitfield);

glDraw...(spec);

The point is, that, actually, final matrix I can, of course, generate by any combination. Shader calls gl_Position with valid result matrix, no matter how it was generated. Now, where exactly do I switch from projection to view to model to anim? Of course matrix names doesn t matter, is there a switching somewhere inside perspective, lookAt, translate and rotate? I mean - if the stack contains actually four stages, each one of these stages can be translated, rotated, scaled, etc. As I understand it by now, actions I take would not matter, if there would be only one stage of matrix stack.

从理论上讲,在三维场景中,如果我(向左旋转45度,然后向右旋转45度),或者我(向右旋转45度,然后向左旋转45度),我就能取得类似的效果。

当我身体站在茶壶前面时,我可以将茶壶右转45, 绕着桌子走(翻译和旋转我自己)到桌子左转45, 从前面看它, 或者把它左转45, 从右边走45, 从前面看它。对世界其他国家来说,它会有所不同(我会看到茶壶后面的左边或右边房间墙 ), 但显然我会看到锅的前面。

因此,最后,如果我想执行两个常规程序- A( obj_ turn_ left, me_ turn_ right) 和 B( obj_ turn_ right, me_ turn_ left), 两种模式先旋转, 然后再旋转, 我( 眼睛, 相机) 。 我如何指定特定旋转或变换的矩阵模式适用于哪个矩阵模式? 我是否应该使用 glMatrix Mode( APPROPRIATE_ CONST) 强制进入特定阶段? glMatrixMode 至今还没有在我的代码中使用 。

最佳回答

根本无法转换。 您可以将整个转换链乘以一个复合矩阵。

为了在先进材料方面让事情更加容易,您通常将转换成 modelview project ,这样您就可以在视野中进行照明计算。但这不是一个“em>witch ,这只是一个中间步骤。

问题回答

暂无回答




相关问题
OpenGL 3D Selection

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it ...

CVDisplayLink instead of NSTimer

I have started to implement cvDisplayLink to drive the render loop instead of nstimer, as detailed in this technical note https://developer.apple.com/library/archive/qa/qa1385/_index.html Is it ...

Can the iPhone simulator handle PVR textures?

I have a really weird problem with PVR textures on the iPhone simulator- the framerate falls through the floor on the iPhone simulator, but on the iPhone itself it works just fine. Has anyone had any ...

Calculate fps (frames per second) for iphone app

I am using an opengl es iphone application. What is the most accurate way to calculate the frames per second of my application for performance tuning?

Java - Zoom / 3D Data Visualization Libraries

What are the best libraries/frameworks for doing 3D and/or Zoom interfaces in Java? I d like to be able to do some prototyping of creating new types of interfaces for navigating within data and ...

FLTK in Cygwin using Eclipse (Linking errors)

I have this assignment due that requires the usage of FLTK. The code is given to us and it should compile straight off of the bat, but I am having linking errors and do not know which other libraries ...

热门标签