OpenGL Graphics Library

Open Graphics Library is a standard graphics application for 2D and 3D visualization, developed in 1992. Opengl comes in two flavors. The first one is Microsoft OpenGL, which is often included in Windows for installing a graphics card. The second - Cosmo OpenGL - is designed for systems that do not have an accelerated graphics card. The OpenGL library is the main condition for the application to work.

OpenGL User Review

Opengl graphics library

Before OpenGL, any company developing a graphical application had to rewrite the graphical part for each platform of the operating system. With it, you can create the same effects in different operating systems using any graphics adapter that supports the program. OpenGL defines a set of “commands” or immediately executed functions, each of which directs a drawing action or causes special effects. A list of them can be created for repetitive effects.

OpenGL does not depend on the characteristics of the Windows of each operating system, but provides special routines for the OS. It comes with a huge list of built-in features requested through the API. These include:

  • hidden surface removal;
  • alpha blending (transparency);
  • smoothing;
  • texture mapping;
  • pixel operations
  • viewing and modeling of transformations;
  • atmospheric effects (fog and haze).

Silicon Graphics, developers of advanced graphics workstations, initiated the development of OpenGL. DEC, Intel, IBM, Microsoft, and Sun Microsystems joined the architecture review industry commission. Developing applications using the OpenGL API does not incur any costs other than training. Microsoft offers a free download of its libraries for its systems.

A set of modules for Windows

The application is available on many Win32 and Unix systems. And f90gl is an implementation of the public domain of official communications Fortran 90 for OpenGL, designed as a database of modules and libraries that defines the necessary interfaces for the program’s functionality. The f90gl itself was developed by William F. Mitchell of the Heiterberg Institute of Technology in the USA. Until recently, OpenGL LF9x could only be created in the form of statically linked programs oriented to Visual C.

A much friendlier method is currently available thanks to the migration efforts implemented by Lawson B. Wakefield from the UK. This implementation made the OpenGL interface available through WiSK and Winteracter and was implemented on a voluntary, non-profit basis. To connect the OpenGL library, you need certain OpenGL DLLs installed in the Windows SYSTEM32 directory. These include the following:

  • opengl32.dll;
  • glu32.dll;
  • glut32.dll.

The first two of these OpenGL libraries (it is necessary to study them before installation) are a standard part of Windows of various modifications and Me. The f90gl libraries and modules must be installed in the LF95 LIB directory:

  • F90GL.LIB;
  • F90GLU.LIB;
  • F90GLUT.LIB;
  • OPENGL32.LIB;
  • GLU32.LIB;
  • GLUT32.LIB;
  • OPENGL.MOD;
  • OPENGL2.MOD;
  • OPENGL_KINDS.MOD;
  • OPENGL_GLINTERFACES.MOD;
  • OPENGL_FWRAP.MOD;
  • OPENGL_GLUINTERFACES.MOD;
  • OPENGL_GLU.MOD;
  • OPENGL_GLUTINTERFACES.MOD;
  • OPENGL_GLUT.MOD;
  • OPENGL_GL.MODd.

Compiling and linking f90gl programs requires that the LF95 LIB directory be specified in the compiler module path and the f90gl library names for linking.

Image libraries

OpenGL for rendering

DevIL is used for developers. It supports many image formats for reading and writing, several compilers and OS (Windows, Linux, Mac). The library has the following syntax:

  1. FreeImage is a cross-platform OpenGL image download library with very wide support for formats (including some HDR formats such as OpenEXR).
  2. OpenImageIO (OIIO) is a library for reading and writing images, as well as many related classes, utilities, and applications. Widely used in animation and VFX studios around the world, as well as embedded in several commercial products.
  3. SOIL is a cross-platform shared image downloader that is extremely small. C ++, capable of loading DDS textures (DDS9 and DDS10) under the MIT license.
  4. Glraw provides a command-line tool that converts image files into raw files that directly contain simple texture data.

Import 3D asset files

The OpenGL Graphics Library for Asset Import (Assimp) is presented as an open source library for importing a wide variety of popular 3D models. The latest version exports 3d files and is suitable as a general purpose converter. There are several types of such libraries:

  1. It can read various formats of 3D files - COLLADA, native Blender3D files, Wavefront Obj (.obj) and many others. The lib3ds library is designed to read 3ds files.
  2. Open3mod is a Windows-based model viewer. It downloads all file formats that Assimp supports, and is ideal for quickly checking 3D assets.
  3. AssetKit (In Progress) - OpenGL library importer / exporter of 3D resources, a utility based on the COLLADA / glTF specifications. The focus here is on COLLADA and glTF. It will fully support formats 1.4, 1.4.1, 1.5+, as well as some others as a library for loading models in OpenGL.

High Performance 2D / 3D Graphics

Libraries for loading models

The OpenGL graphics library for Android includes support for high-performance 2D and 3D graphics with an open library, in particular the OpenGL ES API. Android supports it both through the infrastructure API and the Native Development Kit (NDK). The platform of the named operating system has two fundamental classes that allow you to create and manipulate graphics using the API: GLSurfaceView and GLSurfaceView.Renderer.

If you want to use OpenGL in an Android application, you need to understand how to implement these classes in action. So, GLSurfaceView can draw and manipulate objects using OpenGL API calls, similar to the SurfaceView function. This interface defines the methods needed to draw graphics in a GLSurfaceView. And the user must ensure that this interface is implemented as a separate class and attach an instance of GLSurfaceView.setRenderer to GLSurfaceView. After the container view for OpenGL ES, GLSurfaceView and GLSurfaceView.Renderer is created, you can start connecting the OpenGL library and use the API.

Mobile Graphics Set

Application implementations differ for Android devices with the supported API extensions and include texture compression and another set of functions. The Android Extension Pack (AEP) supports the standard extension database. Packing them together promotes a consistent set of functionality on all devices, allowing developers to make full use of the latest package of mobile graphic designs.

AEP also improves support for images, shader buffers, and counters. For an application to use AEP, the platform version must support it. You must also designate the AEP requirement as follows: <uses the function android: name = "android.hardware.opengles.aep" android: required = "true" />

Checking and selecting OpenGL ES version

There are several versions of the application available on Android devices. You can specify the minimum version of the API that the application on the phone requires. The opengl ES API version 1.0, version 2.0, and version 3.0 provide high-performance graphical interfaces for creating 3D games, visualizations, and user interfaces. The program for OpenGL ES 2.0 is in many ways similar to version 3.0, which is a superset of API 2.0 with additional features.

Programming for the 1.0 / 1.1 API is significantly different compared to 2.0 and 3.0, and therefore developers should carefully study some factors before starting development using these APIs. So, in general, 2 and 3 provide faster graphics performance than API ES 1 / 1,1. However, the difference in it may vary depending on the Android device on which the application is running, due to differences in the hardware implementation of the graphics pipeline.

Comparison with DirectX drivers

Opengl and directx libraries

On Windows, DirectX graphics drivers are better supported than OpenGL, despite the fact that developers manage from faster ones.

The OpenGL and DirectX libraries (their history and prospects) are associated with Microsoft, which actually opposed OpenGL. In 2003, Microsoft announced that it was no longer interested in OpenGL plans. Then in 2005, at a presentation at SIGGRAPH, they announced that Windows Vista would remove its support.

This campaign caused chaos in the OpenGL community, after which many professional graphics programmers switched to DirectX. After Vista was released, high-profile statements were not fulfilled - vendors created new productive drivers (ICDs) that restore the built-in feature. Open sent out newsletters with information, which is still the best application. Nevertheless, the damage has already been done, and public trust in OpenGL has been badly shaken.

In fact, OpenGL is more powerful than DirectX, supports more platforms and is of primary importance for the future of games. The history and prospects of the OpenGL and DirectX libraries indicate that the first of them is still more positive:

  1. Provides the ability to use graphics functions for operating systems, while DirectX provides only instant elements from them in the latest versions of Windows. The tessellation technology that Microsoft developed for DirectX 11 has been an extension of OpenGL for three years. Through painstaking work, DirectX 10 and 11 are now as fast as OpenGL and support almost as many features. However, there is one big problem: they do not work in Windows XP, which many people still use.
  2. Cross platform. Many Lugaru users run on Mac, Linux, and Windows XP and cannot play through DirectX. The only way to deliver the latest graphics to Windows XP gamers is through 32bits opengl libraries.
  3. Better for the future of games. This is a non-profit open standard created so that users on any platform can receive high-quality graphics that their equipment provides. Its development is being destroyed today by the monopolistic attack of a corporate giant trying to dominate the industry. This is why Direct3D is becoming the only gaming graphics API supported on Windows.

C ++ and Visual Studio customization

How to connect to dev

The OpenGL library for c has a free version. Experts recommend compiling ANSI C programs with OpenGL and GLUT using Dev-C ++.

Bloodshed Dev-C ++ is a free C ++ compiler and development environment for Windows operating systems. Like most of the same hardware, it can be used to compile ANSI C. After installing the GLUT header files and libraries, it is used to write programs. To implement this project, you can use 32-bit or 64-bit Windows.

Before connecting the OpenGL library to dev c, you will need the glew headers, which can be found on the sourceforge Extension Wrangler website, and the freeglut version for Visual Studio:

  1. Click the link inside the freeglut 3.0.0 MSVC package.
  2. Enter the name of the file to be downloaded.
  3. Download it, in the folder with freeglut.
  4. Extract and rename to freeglut.
  5. General installation directory: C: \ DEV.
  6. The directory where the projects are located: C: \ DEV \ visual-studio-c ++.
  7. The directory where the libraries are located: C: \ DEV \ Lib Visual Studio.
  8. Open it and create an empty project> Templates> Visual C ++> An empty project.
  9. Then write “Name”: Shapes2D.
  10. Location: C: \ dev \ visual-studio-c ++ \.
  11. Create a new solution in the OpenGL library for Visual Studio. Solution Name: BadprogTutorial OK.
  12. The Shapes2D project was created in the BadprogTutorial solution.
  13. Add main.cpp> Right-click “Project”> “Add”> “New Element”> Visual C ++> C ++ File. Write a name: main.cpp and add.
  14. Configure GL and OpenGL glut library configurations.
  15. Click on the Shapes2D> Properties project. In the upper left corner of the drop-down menu, find "Configuration" and select all the configurations (instead of Debug).
  16. Click on “Configuration Properties”> C / C ++> “General”> “Additional Attachment Directories”. On the right is a drop-down menu, click "Change ...".
  17. A new window appeared: "Additional Directories".
  18. Click the New Line icon> browse button and select the following two folders: C: \ DEV \ Lib \ Glew-1.12.0 \. C: \ DEV \ Lib \ freeglut-3.0.0 \.
  19. Click OK. Apply using OpenGL libraries, including libraries, library folders.
  20. Right-click the Shapes2D project> "Properties"> "Configuration Properties"> "Connector"> "General"> "Additional Library Directories".
  21. On the right is a drop-down menu. Click on "Change ...". A new window appeared: “Additional Libraries”.
  22. Click the New Line icon> click the browse button> select the following two folders for the 64-bit version: C: \ DEV \ Lib \ Glew-1.12.0 \ Lib \ Release \ x64 and C: \ DEV \ Lib \ freeglut-3.0 .0 \ lib \ x64.
  23. Click OK> apply library files. Click the Shapes2D project> Properties> Configuration Properties> Connector> Input.
  24. On the right is a drop-down menu, click "Change ...".
  25. A new window appeared: "Additional Dependencies." Click on the white area and write: freeglut.lib.
  26. Press Enter to go to the next line: glew32.lib.
  27. Click “Apply” and OK.

Now the Visual Studio IDE is ready to work with OpenGL.

Download Dev-C ++

These instructions have been tested on a wide variety of Windows systems that come with the files needed for OpenGL, but not the files needed for GLUT. Dev-C ++ does not work with Vista from Microsoft.

Boot procedure:

  1. Download Dev-C ++ and install it.
  2. Get Dev-C ++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw / GCC 3.4.2 (although this is a beta version, it works great).
  3. Now you need to click on SourceForge to go to the list of download sites, and select one.
  4. Save this file to a location such as C: \ Temp.
  5. When the download is complete, click the "open" button to start the installation process. Or go to C: \ Temp and double-click on devcpp4.9.9.2_setup.exe.
  6. Select a “typical” installation. Accept the proposed destination for installation.
  7. Reply: “Yes” when the installation asks if you want to install Dev-cpp for all users. A message appears on the screen that the installation is complete. Click Finish. The first configuration screen appears.
  8. Select “English” and “New Look”. On the next few screens, click Yes. The program starts automatically.
  9. Click “File”, then create a project.
  10. Select a name for the project (for example, “myProject”).
  11. Click “C Project”, “Empty Project” and OK.
  12. In the "Create a new project" window, click "Save."
  13. Click “File / New / Source File” and click “Yes” in “Add Source File to Current Project”.
  14. Click “File / Save As” and save the file as “hello.c” (or another name). It is important to ensure that the .c file extension. Any other extension (for example, suggested by .cpp) will have problems with compilation.
  15. Click Run / Compile and Run. The program compiles, starts and writes its output to the DOS window.
  16. Try another way to start the program (after compiling it) - run the DOS window outside the Dev-Cpp system.
  17. Go to the subdirectory containing the project and type hello.exe.
  18. Find Dev-C ++ specified in the "Programs" section from the start menu.

Now the user will be able to create, compile and run C (and C ++) programs. It will have files, libraries and dlls for OpenGL (and all other standard packages), but not GLUT. GLUT manages the windows and other components of the user interface necessary for it, and they are installed separately.

Installing and running the program on Windows 7

Opengl library for windows 7

The runtime platform for Visual Studio 2010 is Integrated. Environment (IDE) running Windows 7. You need to download and install Microsoft Visual C ++ 2010 Express. And after Visual C ++ is successfully installed, you must perform the following steps:

  1. Download and unzip the freeglut-MSVC-2.8.1-1 file.
  2. Open the welcome screen for Visual C ++ 2010 from the Start menu.
  3. Create a new project by choosing File -> New -> Project.
  4. Select Win32 in the "Installed Templates" panel, and then select "Win32 Console Application" from the next panel.
  5. Name your project and select the folder in which you want to save it.
  6. Uncheck "Create a directory for the solution."
  7. Click OK to open the wizard's welcome screen and “Application Settings” for the settings dialog box.
  8. Uncheck the “Precompiled header” checkbox, select the “Empty project” checkbox, and select “Console application”.
  9. Click Finish to see the new OpenGL library project window for Windows 7.
  10. Click on Source Files and select Add -> New Item to open a dialog box.
  11. Select "Code" in the "Installed Templates" and "C ++ File" (.cpp) panels from the next panel.
  12. Name your file and click “Add” to see a blank code panel in the project window with the name “Selected Name”.
  13. Save and create a project by going to Debug -> Build Solution. Then execute the program using Debug -> Start Debugging.

If the graphics card does not support OpenGL 4.3, then programs using it can compile but fail to execute, because the system cannot provide the OpenGL 4.3 rendering context specified by glutInitContextVersion (4.3) in the main procedure. In this case, you can replace Version 4.3 with 3.3 or even 2.1.

Although almost all platforms support the OpenGL API, developers still need to create customized applications for different platforms. This is because graphics are only part of the application, and other components are still different between platforms. To fix this, WebApp was designed to run entire programs in a web browser, such as Chrome and Firefox. So one program can work on all platforms with a compatible browser.

Opengl library to study

Meanwhile, on the client side, everything is transmitted on the fly from the servers, so further installation of the application is not required. A special API called WebGL was also created for the Internet and is based on ES, a subset of OpenGL designed specifically for mobile devices. To achieve a similar goal for VR, another API called WebVR was designed to easily bring the VR experience to browsers, regardless of platform.


All Articles