banner



How To Draw A Xmas Tree Java Opengl

Open Graphics Library (OpenGL) is a cross-language (language contained), cantankerous-platform (platform-independent) API for rendering 2D and 3D Vector Graphics(employ of polygons to correspond image). OpenGL API is designed by and large in hardware.

  • Design : This API is divers as a gear up of functions which may be called by the client program. Although functions are like to those of C language just it is language contained.
  • Development : Information technology is an evolving API and Khronos Group regularly releases its new version having some extended feature compare to previous one. GPU vendors may also provide some additional functionality in the grade of extension.
  • Associated Libraries : The earliest version is released with a companion library called OpenGL utility library. But since OpenGL is quite a complex process. So in order to go far easier other library such as OpenGL Utility Toolkit is added which is later superseded by costless glut. Later included library were GLEE, GLEW, and gliding.
  • Implementation : Mesa 3D is an open up source implementation of OpenGL. It can practice pure software rendering and it may too use hardware acceleration on BSD, Linux, and other platforms by taking reward of Direct Rendering Infrastructure.

Install OpenGL on Ubuntu
For installing OpenGL on Ubuntu, simply execute the following control (like installing any other thing) in final :

          sudo apt-get install freeglut3-dev        

For working on Ubuntu operating system:

          gcc filename.c -lGL -lGLU -lglut          where filename.c is the proper name of the file with which this program is saved.        

Install OpenGL on windows in Code::Blocks

  1. Download code block and install it
  2. Go to the link and download zip file from the download link that appears after freeglut MinGW package with having link name as Download freeglut 3.0.0 for MinGW and extract it.
  3. Open notepad with run as administrator and open file from
    1. This PC > C:(C-bulldoze) > Program Files(x86) > CodeBlocks > share > CodeBlocks > templates, (then click to show All Files)
    2. Adjacent, open glut.cbp and search all glut32 and replace with freeglut.
    3. Then, open from This PC > C:(C-drive) > Programme Files(x86) > CodeBlocks > share > CodeBlocks > templates > wizard > glut (then click to show All Files)
    4. Open wizard.script and here, also supercede all glut32 with freeglut
  4. Then become to freeglut binder (where it was downloaded) and
    1. Include > GL and copy all four file from in that location
    2. Become to This PC > C:(C-drive) > Program Files(x86) > CodeBlocks > MinGW > include > GL and paste it.
    3. So, from download folder freeglut > lib, copy two files and go to This PC > C:(C-drive) > Programme Files(x86) > CodeBlocks > MinGW > lib and paste it.
    4. Over again become to downloaded folder freeglut > bin and copy one file (freeglut.dll) from here and go to This PC > C:(C-drive) > Windows > SysWOW64 and paste this file.
  5. Now open Code::Blocks.
    1. Select File > New > Project > GLUT project > Side by side.
    2. Requite project championship anything and and then choose Side by side.
    3. For selecting Glut's location : This PC > C:(C-drive) > Programme Files(x86) > CodeBlocks > MinGW.
    4. Printing OK > Next > Cease.

At present, Code::Blocks is ready to examination for OpenGL File.

Demonstrate working with OpenGL

To show how OpenGL works, a simple program of circumvolve – drawing is added in C using OpenGL platform.

C

#include<stdio.h>

#include<GL/overabundance.h>

#include<math.h>

#define pi 3.142857

void myInit ( void )

{

glClearColor(0.0, 0.0, 0.0, 1.0);

glColor3f(0.0, 1.0, 0.0);

glPointSize(1.0);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(-780, 780, -420, 420);

}

void brandish ( void )

{

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_POINTS);

float 10, y, i;

for ( i = 0; i < (two * pi); i += 0.001)

{

x = 200 * cos (i);

y = 200 * sin (i);

glVertex2i(x, y);

}

glEnd();

glFlush();

}

int principal ( int argc, char ** argv)

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

glutInitWindowSize(1366, 768);

glutInitWindowPosition(0, 0);

glutCreateWindow( "Circle Drawing" );

myInit();

glutDisplayFunc(brandish);

glutMainLoop();

}

To compile the above program in Ubuntu,

          gcc filename.c -lGL -lGLU -lglut -lm          where filename.c is the name of the file with which this plan is saved.        

Output of above program is shown in below screenshot

Reference for installation in Code::Blocks : https://www.youtube.com/picket?v=NPcnymtP2SE

This commodity is contributed by Aditya Kumar. If you like GeeksforGeeks and would like to contribute, you tin can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. Encounter your article appearing on the GeeksforGeeks main page and assistance other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.


How To Draw A Xmas Tree Java Opengl,

Source: https://www.geeksforgeeks.org/getting-started-with-opengl/

Posted by: andersondadogiag.blogspot.com

0 Response to "How To Draw A Xmas Tree Java Opengl"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel