triangle textureScreenGrab for Kaleidscope?

Hi
I’m trying to make Kaleidscope on iPhone. I found that textureScreenGrab example and would like to make triangle shape to make Kaleidscope. How do you make triangle shape?

Here is cords I have now.

  
texScreen.loadScreenData(0,0,300,300);  
	  
	  
	glPushMatrix();  
	ofSetColor(0xffffff);  
	glTranslatef(100,300,0);  
	ofRotate(45);  
	texScreen.draw(-300,-220,300,300);  
	glPopMatrix();  

MSAShape3D wraps up glDrawArrays quite nicely. Just add your vertices and tex coords, bind your texture and hit draw and you’re done.

Thank you, DavidDC! I’ll try it! :smiley:

I tried to bind texture, but it shows this error (class MSA::Shape3D’ has no member named ‘bind’) and I don’t know how to bind texture to triangle…sorry I’m still new to opengl…

Here are the codes I used.

  
  
#include "testApp.h"  
#include "MSAShape3D.h"  
  
MSA::Shape3D	texScreen;  
  
....  
  
void testApp::draw(){  
	// 1st, draw on screen:  
	ofSetColor(0x66CC33);	  
	ofRect(0,0,300,300);  
	  
	ofSetColor(0xffffff);  
	glPushMatrix();  
	glTranslatef(200,200,0);  
	glRotatef(counter,0,0,1);  
	ofCircle(0,0,80);  
	ofCircle(100,0,10);	// a small one  
	glPopMatrix();  
	ofSetColor(0x333333);  
	ofDrawBitmapString("(a) on screen", 150,200);  
	  
	ofSetColor(0xFFCC33);	  
	ofCircle(mouseX, mouseY,20);  
  
        glEnable(GL_TEXTURE_2D);  
	  
	texScreen.bind();  
	texScreen.begin(GL_TRIANGLE_FAN);  
	glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );  
	  
	texScreen.addVertex(100, 0, 0);  
	texScreen.addVertex(0, 100, 0);  
	texScreen.addVertex(100, 100, 0);  
  
	texScreen.end();  
	glDisable(GL_TEXTURE_2D);  
	texScreen.unbind();  
  
}  
  

I think you misunderstood me.

Pseudocode off the top of my head (ie not tested):

  
  
  
setup:  
ofTexture *tex = new ofTexture  
tex->allocate(enough mem for screen capture)  
MSA::Shape3d *shape = new MSA::Shape3d  
shape->allocate(enough mem for vertices)  
  
draw:  
[draw your stuff to screen]  
  
tex->loadScreenData(...)  
  
shape->begin(GL_TRI_FAN)  
  
// origin  
shape->SetTexCoord(u,v)  
shape->AddVertex(x,y)  
  
// point 1  
shape->SetTexCoord(u,v)  
shape->AddVertex(x,y)  
  
// point 2  
shape->SetTexCoord(u,v)  
shape->AddVertex(x,y)  
  
tex->bind()  
shape->end() <- this calls the actual draw   
tex->unbind()  
  
  

Don’t forget to delete your shape and tex on exit!

It worked! Thank you very much, DavidDC! :smiley: