Wednesday, September 28, 2016

Play a video or video capture of webcam - texture on cube #OpenGL #OpenCV

Just visit this awesome site where there is this awesome code which needed a few modifications to play back any video or capture video from the webcam. Now you won't believe this but it was as simple as that. With OpenCV I feel I just turned a pro.


The mouse can be used as a trackball and you can rotate the scene which consists of a cube on both sides of which texture of video frames is mapped. That snapshot was not still image, it is me sitting in front of the computer poring over the monitor.

Monday, September 26, 2016

Add an image opened using #OpenCV as a texture in OpenGL

Image result for what is OpenCVI was toying with OpenCV since a long time. Here is a tutorial on how to download and configure eclipse for OpenCV. OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel's research center in Nizhny Novgorod (Russia), it was later supported by Willow Garage and is now maintained by Itseez.

In this C++ project in Eclipse an image is opened using imread method of OpenCV tool and the opened image is used as a texture to map to a polygon drawn across the screen. Actually this image in the window is itself a snapshot of another program which does texture mapping inside a 3D house scene program. I could have chosen any other image.


Here is the source.

Sunday, September 18, 2016

#JOGL Various Textures to Polygons

Some textures of size 10 x 10 have been created from scratch using formulas such as

//Use this formula to create texture in the program- Tex1
int red=(0xff)*(x%2);
int green=(0xff)*(y%2);
int blue=(0xff);//*(x^y);

Resulting Snapshot:

//Use this formula to create texture in the program- Tex2
int red=(int)((0xff)*Math.sin(10*x*Math.PI/180));
int green=(0xff);
int blue=(0xff);
Resulting Snapshot:                       
Going any further I feel would kill your drive to do something yourself and get exhilarating textures. So I hope I have shown the way to create beautiful patterns with sin,cos,modulus and other mathematical operations.

If you are knowledgeable about MipMaps and filtering in jogl then you may note that I have used following Magnification filter.


Here is the source which you can modify and tinker.

#JOGL Lighting - An Animation

In this project the light source is moving in a circular path around the eight spheres. The position of GL_LIGHT0 is changed by a call to the method glLightfv().


Here is the source.

#JOGL Setting Material Properties

In this program LIGHTING has been enabled and the material properties have been set.
A glutSolidSphere() has been drawn eight times each time the SHININESS component has been increased by 16.

Here is the source.

Friday, September 9, 2016

#JOGL Cubes with Vertex Arrays

Here is a simple program to draw a cube with vertex arrays that is shared as a demo program by the author David J Eck in his site of Hogwarts and William Smith college.

I am sharing this program as is and all copyrights rest with the original author.


Here is the source.

#JOGL Program to create and apply a one dimensional texture on a cube

In this program I am applying a one dimensional texture on a cube.


Here is  the source.