Jump to content
  • Advertisement
Sign in to follow this  
AhmedSaleh

OpenGL Drawing a Texture into a Grid

This topic is 2589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All,
I've managed to drawing an n*n 3D Cubes, and I also got a frame from a webcam using opencv, I would like to map my webcam image into that n*n grids .

Here is how I drew my cubes
[code

void ocvCaptureApp::draw()
{

if( ! mTexture )
return;
gl::clear( Color::black() );
//mTexture.bind();
glPushMatrix();
gl::multModelView( mCubeTranslation );



int x1 = BLOCK_ORIGIN_X, // used to track current position
y1 = BLOCK_ORIGIN_Y;

// draw all the blocks
for (int row=0; row < NUM_BLOCK_ROWS; row++)
{
// reset column position
x1 = BLOCK_ORIGIN_X;

// draw this row of blocks
for (int col=0; col < NUM_BLOCK_COLUMNS; col++)
{
// draw next block (if there is one)
if (mCubes[row][col]!=0)
{

gl::color(234,33,44,11);
// draw block
gl::drawCube( Vec3f(x1-1.0f,-1,y1+1.0f), Vec3f( 2.0f, 2.0f, 2.0f ) );

} // end if
// advance column position
x1+=BLOCK_X_GAP;

} // end for col

// advance to next row position
y1+=BLOCK_Y_GAP;

} // end for row

glPopMatrix();

}

]


here is how I can get an opengl texture using OpenCV


void ocvCaptureApp::update()
{
if( mCap && mCap.checkNewFrame() ) {
mTexture = gl::Texture( mCap.getSurface() );
}
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!