Monday, September 12, 2011

Opencv with OpenGL (installation and trials)

so i needed to install opengl for a 2D/3D test using opencv

since Opengl libraries come preinstalled just needed to download GLUT from:
http://www.xmission.com/~nate/glut.html

since im running on a 64bit machine i need to place the GLUT32.dll in the C:\Windows\SysWOW64 instead of C:\Windows\System32

i then place the GLUT.h in the:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include

and the GLUT32.lib in the
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib

in the visual studio dependencies i just add the following:
opengl32.lib
glut32.lib
glu32.lib








and im all set and good to go with the test program


/**********************************
  Simple.cpp
  A simple GLUT program.

****************************************************************************/

#include <string.h>
#include <glut.h>

void mydisplay( void )
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);

    /* set drawing/fill  color to white */

    glColor3f(1.0, 1.0, 1.0);

    /* set up standard orthogonal view with clipping */
    /* box as cube of side 2 centered at origin */
    /* This is default view and these statement could be removed */

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    /* define unit square polygon */

    glBegin(GL_POLYGON);
    glVertex2f(-0.5, -0.5);
    glVertex2f(-0.5, 0.5);
    glVertex2f(0.5, 0.5);
    glVertex2f(0.5, -0.5);
    glEnd();

    /* flush GL buffers */

    glFlush();}


/**************************************** main() ********************/
void init()
{
    glClearColor (0.0, 0.0, 0.0, 1.0);

    glColor3f(1.0, 1.0, 1.0);

    glMatrixMode (GL_PROJECTION);   
    glLoadIdentity ();   
    glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); 
}

void main(int argc, char* argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(0,0);
    glutCreateWindow("simple");
    glutDisplayFunc(mydisplay);

    init();

    glutMainLoop();

}

1 comment: