Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Drawing a Texture into a Grid

This topic is 2961 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

void ocvCaptureApp::draw()

if( ! mTexture )
gl::clear( Color::black() );
gl::multModelView( mCubeTranslation );

int x1 = BLOCK_ORIGIN_X, // used to track current position

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

// 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)

// draw block
gl::drawCube( Vec3f(x1-1.0f,-1,y1+1.0f), Vec3f( 2.0f, 2.0f, 2.0f ) );

} // end if
// advance column position

} // end for col

// advance to next row position

} // end for row




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
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!