You are on page 1of 2

int newi;

int ncurves = count;/* the number of times to


partition the function */;
float sp = start.x; /* starting point of the interval
*/;
float ep = end.x;/* end point of the interval */;

float x;
float y;
CGPoint q0, q1, q2, q3, p1, p2;

float size = (sp - ep) / ncurves;

for(newi = 0; newi < ncurves; newi++)


{
x = sp + newi * size;
y = sp + newi * size;

q0 = CGPointMake(x, (y));
q1 = CGPointMake(x + size / 3, (y + size / 3));
q2 = CGPointMake(x + 2 * size / 3, (y + 2 * size /
3));
q3 = CGPointMake(x + size, (y + size));

p1.x = (-5 * q0.x + 18 * q1.x - 9 * q2.x + 2 *


q3.x) / 6;
p1.y = (-5 * q0.y + 18 * q1.y - 9 * q2.y + 2 *
q3.y) / 6;
p2.x = (2 * q0.x - 9 * q1.x + 18 * q2.x - 5 *
q3.x) / 6;
p2.y = (2 * q0.y - 9 * q1.y + 18 * q2.y - 5 *
q3.y) / 6;

NSLog(@"P1, P2 %@
%@",NSStringFromCGPoint(p1),NSStringFromCGPoint(p2));

vertexBuffer[multiplier*newi+0] =p1.x;
vertexBuffer[multiplier*newi+1] = p1.y;

vertexBuffer[multiplier*newi+2] =p2.x;
vertexBuffer[multiplier*newi+3] = p2.y;

glVertexPointer(2, GL_FLOAT, 0, vertexBuffer);


glDrawArrays(GL_POINTS, 0, vertexCount);

glBindRenderbufferOES(GL_RENDERBUFFER_OES,
viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];

You might also like