ラベル openGL の投稿を表示しています。 すべての投稿を表示
ラベル openGL の投稿を表示しています。 すべての投稿を表示

2012年10月15日月曜日

openFrameworksでムービーテクスチャを3Dで使う


なんでできないんやろうって思ってたら、update()関数でidleMovie()してなかったわ。
これが諸悪の根源。昨日時間かなり使ってしまった。

てゆーかこれ、すごい楽。今までかなり回りくどいことしてテクスチャ生成してたな。
これやったら普通の画像でもつかえるやないかい。

/*---------------------------------------
テクスチャをgetTextureReference()でもってくる。
これをbind()するだけで普通のテクスチャと同じように扱えます。
当然UV座標もリソースの左上が原点です。
---------------------------------------*/
ofTexture &tex = MN_video.getTextureReference();// ←ofVideoPlayer()のインスタンス
tex.bind();

glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();

ofTextureData texData = tex.getTextureData();
if( texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB)
{
glScalef( tex.getWidth(), tex.getHeight(), 1.0f);
} else {
glScalef( tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f);
}
glMatrixMode(GL_MODELVIEW);


glColor4f(1.f, 1.f, 1.f, 1.f);

// UV座標が
// 0-1
// | |
// 3-2 というイメージ
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2d( 0.f, 0.f); glVertex3f( myPosition[3].x,  myPosition[3].y, myPosition[3].z);
glTexCoord2d( 1.f, 0.f); glVertex3f( myPosition[0].x,  myPosition[0].y, myPosition[0].z);
glTexCoord2d( 1.f, 1.f); glVertex3f( myPosition[1].x,  myPosition[1].y, myPosition[1].z);
glTexCoord2d( 0.f, 1.f); glVertex3f( myPosition[2].x,  myPosition[2].y, myPosition[2].z);
glEnd();
glDisable(GL_TEXTURE_2D);

MN_video.getTextureReference().unbind();

glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);




2012年4月28日土曜日

openGLメモ

OpenGLプログラミングメモ
http://www21.atwiki.jp/opengl/
細かいところまで載っていそうなブログ

ミクミクダンス+webGL をやってる人のブログ
http://d.hatena.ne.jp/edvakf/20111020/1319083256


collada形式についてやってる人のブログ(移転した)
http://pr0jectze10.blogspot.jp/2011/11/collada.html
移転先
http://nullorempry.jimdo.com/