下面的案文是比喻的,因为我想确保有类似问题的人们,例如,本页可以很容易地关注具体问题及其解决办法。 但我现在谈谈我的问题:
我最近开始在安乐施会电话上制定开放式教育计划,并遇到一些问题,了解如何使用蓝.和蓝.。 页: 1 我理解他们做些什么,但我看不出三角。 我在我活动的方法上采用了以下守则。 Said activity Implements GLSurfaceView. Renderer with the on DrawFramemark with @Override. 我的法典是:
gl.glViewport(0, 0, screen_width, screen_height);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); //set background to black
gl.glClearDepthf(1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_PROJECTION); // Change PROJECTION matrix
gl.glLoadIdentity();
float aspect_ratio = (float) screen_width / screen_height;
GLU.gluPerspective(gl, 67, aspect_ratio, 1, 100);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glMatrixMode(GL10.GL_MODELVIEW); // Change MODELVIEW matrix
gl.glLoadIdentity();
GLU.gluLookAt(gl, 0, 0, 20, 0, 0, 0, 0, 1, 0);
// make triangle with vertices (-2,0,0), (2,0,0), and (0,.5,0)
float[] vertices = { -2f, 0, 0, 2f, 0, 0, 0, .5f, 0 };
ByteBuffer buffer = ByteBuffer.allocateDirect(vertices.length * 4);
buffer.order(ByteOrder.nativeOrder());
FloatBuffer vertex_buffer = buffer.asFloatBuffer();
for (int i = 0; i < 9; i++) {
vertex_buffer.put(vertices[i]);
}
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertex_buffer);
gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisable(GL10.GL_DEPTH_TEST);
接下来的几点是关于我对上述法典中关于摄像设施的看法的简短说明。 如果我在以下解释中说错的话,PLEASE会纠正我,因为这可能已经解决我的所有问题!
- glMatrixMode(GL10.GL_PROJECTION) switches to changing the camera matrix (for which I load an identity matrix directly afterwards)
- GLU.gluPerspective(gl, 67, aspect_ratio, 1, 100) sets a perspective projection with a view frustrum of 67 degree view angle in the y-dimension. Using "aspect_ration=(float)width/height" OpenGL computes the view angle in the x-dimension. Further the "1" is the near clipping plane, while "100" is the value of the far clipping plane in this case.
- As far as I know it does not matter, where in the code gluLookAt is called, as long as it is done before the actual drawing (I m unsure about this though). In this example I change to the MODELVIEW matrix first, load an identity matrix, and then gluLookAt is called. 3.
- "GLU.gluLookAt(gl, 0, 0, 20, 0, 0, 0, 0, 1, 0)" actually consists of three 3-element vectors. The initial one ((0,0,20) in this example) sets the position of the camera in world coordinates (i.e. 20 units on the positive Z-axis, which means it is "sticking out" of the front of the phone s screen). The second vector determines the point in the world coordinate system the camera looks at (in this example the origin of the coordinate system, i.e. the camera looks along the negative z-axis). The third vector is the up-vector that defines the direction of the y-Axis of the cameras coordinate system (and therefore also the x-axis via cross product with the vector from camera position to the point it looks at).
三角制图法从辅导法中复制(但我发现其他辅导法也有类似规定,因此我认为这不是问题)。
只要我得到,该摄像机现在就位在(0,20美元)上,并着眼于协调系统的起源。 其绘画法从Z-值19开始,到80年(照相机在Z-轴20点,看着负Z-轴心;其视法鲁斯特鲁姆接近于1和100(在这起案件中分别看着Z-轴心)。 因此,三角形应当明显可见,因为它的vert在Z-axis=0架飞机(即Xy-plane)的原产地上,这显然是在看着疲软的。 此外,抽出的vert是按反锁定的;在开放式GL中缺席。
因此,在该问题如此长的介绍之后,我简单的问题是:我所想的是什么,这样,这部法律就没有我期望它做什么?