ofxMSASpline and iPhone

Hi,

I read on this-link that ofxMSASpline was compatible with ofxiPhone. When I popped the addon into my project, however, I got a lot of errors, most saying “‘glBegin’ was not declared in this scope”. This seems to make sense, since I heard that glBegin is not used in GL ES. Is there a newer version of MSASpline out there that is working, or is there something I’m doing wrong?

Thanks!

I looked into it and the problem was with the drawSmooth() and drawRaw() functions. They must be converted into OpenGL ES. Using an example on this-page, I converted the spline2D class:

  
/**************************** 2D Spline (of ofxVec2) ****************************/  
class ofxMSASpline2D : public ofxMSASpline<ofxVec2f> {  
public:  
	void drawRaw(int dotSize = 20, int lineWidth = 4){  
		int numItems = size();  
		  
  
		if(lineWidth) {  
			glLineWidth(lineWidth);  
			GLfloat vertcies[numItems * 2];  
			for(int i=0; i<numItems; i++) {  
				vertcies[i*2] = at(i).x;  
				vertcies[(i*2)+1] = at(i).y;  
			}  
			glEnableClientState(GL_VERTEX_ARRAY);  
			glVertexPointer(2, GL_FLOAT, 0, vertcies);  
			glDrawArrays(GL_LINE_STRIP, 0, numItems);  
		}  
		  
		if(dotSize) {  
			glPointSize(dotSize);  
			GLfloat dotVertcies[numItems * 2];  
			for(int i=0; i<numItems; i++) {  
				dotVertcies[i*2] = at(i).x;  
				dotVertcies[(i*2)+1] = at(i).y;  
			}  
			glEnableClientState(GL_VERTEX_ARRAY);  
			glVertexPointer(2, GL_FLOAT, 0, dotVertcies);  
			glDrawArrays(GL_POINTS, 0, numItems);  
		}  
		  
	}  
	  
	  
	void drawSmooth(int numSteps, int dotSize = 8, int lineWidth = 2) {  
		if(size() < 4) return;  
		  
		float spacing = 1.0/numSteps;  
		if(lineWidth) {  
			glLineWidth(lineWidth);  
			  
			GLfloat lineVertcies[numSteps * 2];  
			int i=0;  
			for(float f=0; f<1; f+= spacing) {  
				ofxVec2f v = sampleAt(f);  
				lineVertcies[i*2] = v.x;  
				lineVertcies[(i*2)+1] = v.y;  
				i++;  
			}  
			glEnableClientState(GL_VERTEX_ARRAY);  
			glVertexPointer(2, GL_FLOAT, 0, lineVertcies);  
			glDrawArrays(GL_LINE_STRIP, 0, numSteps);  
		}  
		  
		if(dotSize) {  
			glPointSize(dotSize);  
			GLfloat dotVertcies[numSteps * 2];  
			int i=0;  
			for(float f=0; f<1; f+= spacing) {  
				ofxVec2f v = sampleAt(f);  
				dotVertcies[i*2] = v.x;  
				dotVertcies[(i*2)+1] = v.y;  
				i++;  
			}  
			glEnableClientState(GL_VERTEX_ARRAY);  
			glVertexPointer(2, GL_FLOAT, 0, dotVertcies);  
			glDrawArrays(GL_POINTS, 0, numSteps);  
		}  
	   
	}  
};  
  

hey, thanks for this, next version will have this in (coming soon).