2016-03-08 18 views
0

我下载了一个显示带有某种纹理的正方形的项目。广场目前位于屏幕底部附近,我想将它移动到中间位置。这是代码。如何更改渲染对象放置在屏幕上的位置,OpenGL Es 2.0 iOS

Geometry.h

#import "GLKit/GLKit.h" 

#ifndef Geometry_h 
#define Geometry_h 

typedef struct { 
    float Position[3]; 
    float Color[4]; 
    float TexCoord[2]; 
    float Normal[3]; 
} Vertex 

typedef struct{ 
    int x; 
    int y; 
    int z; 
} Position; 

extern const Vertex VerticesCube[24]; 

extern const GLubyte IndicesTrianglesCube[36]; 

#endif 

这里是geometry.m代码

const Vertex VerticesCube[] = { 
// Front 
{{1, -1, 1}, {1, 0, 0, 1}, {0, 1},    {0, 0, 1}}, 
{{1, 1, 1},  {0, 1, 0, 1}, {0, 2.0/3.0},   {0, 0, 1}}, 
{{-1, 1, 1}, {0, 0, 1, 1}, {1.0/3.0, 2.0/3.0}, {0, 0, 1}}, 
{{-1, -1, 1}, {0, 0, 0, 1}, {1.0/3.0, 1},   {0, 0, 1}}, 
}; 

const GLubyte IndicesTrianglesCube[] = 
{ 
    // Front 
    0, 1, 2, 
    2, 3, 0, 
} 

什么部分的代码的确定屏幕上所呈现的对象的位置?

回答

1

您发布的任何代码都与屏幕位置无关。

VerticesCube指定任意三维空间的立体角。某处代码还没有发布,投影变换(也可能包括视图和模型变换)映射每个顶点剪辑空间和glViewport调用(这可能是暗示你做,如果你正在使用GLKView)地图剪辑空间屏幕/查看坐标。

在屏幕上重新排列的事情可能涉及这些变换中的任何一个,以及使用哪一个是取决于了解每一个和它如何融入你的应用程序设计的大背景下进行选择。

这是诸如此类的事情,你会从任何的OpenGL教程的早期阶段得到。 Here's a decent one.

+0

非常感谢。我还有一个问题,如果你能帮助我,那会很棒。 http://stackoverflow.com/questions/35873388/cannot-set-custom-class-to-glkview-inside-uiview –

相关问题