通过函数传递GLfloat数组

时间:2011-03-26 05:49:32

标签: iphone opengl-es

我正在尝试创建一个应用程序,您可以在其中键入坐标,并使用Open GL ES绘制内容。 这是数据收集器。它接受UITextField文本并创建和数组,然后将其发送到我的绘图函数。

 float sq[] = {
    [A1.text doubleValue],[B1.text doubleValue],
    [A2.text doubleValue], [B2.text doubleValue],
    [A3.text doubleValue], [B3.text doubleValue],
};  
[renderer render:sq];

这是我的绘图功能。它采用文本字段生成的数组,并将其转换为形状(不起作用)

- (void)render:(float)shape

{     //替换此方法的实现以执行您自己的自定义绘图

// Replace the implementation of this method to do your own custom drawing

float squareVertices = shape;



static const GLubyte squareColors[] = {
    255, 0,   0, 255,
    0,   255, 0, 255,
    0,     0,   255,   255,

};

// static float transY = 0.0f;

// This application only creates a single context which is already set current at this point.
// This call is redundant, but needed if dealing with multiple contexts.
[EAGLContext setCurrentContext:context];

// This application only creates a single default framebuffer which is already bound at this point.
// This call is redundant, but needed if dealing with multiple framebuffers.
glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
glViewport(0, 0, backingWidth, backingHeight);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// glTranslatef(0.0f,(GLfloat)(sinf(transY)/2.0f),0.0f);     // transY + = 0.075f;

glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

glVertexPointer(2, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
glEnableClientState(GL_COLOR_ARRAY);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);

// This application only creates a single color renderbuffer which is already bound at this point.
// This call is redundant, but needed if dealing with multiple renderbuffers.
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];

}

0 个答案:

没有答案