程序代写代做代考 compiler PowerPoint Presentation

PowerPoint Presentation

OpenGL: Installation

Computer Graphics
Instructor: Sungkil Lee

How to Use Third-Party Libraries

3

Precompiled Binary Distribution

• Most of binary distribution of 3rd-party libraries are
structured like this:

• include/libname.h

• lib/libname.lib (libname.a for Linux)

• bin/libname.dll (libname.so for Linux)

• DLL (or SO in Linux)?

• Dynamic Linking Library (Shared Object)

• Precompiled binary objects that can be used for other programs.

• Example:

• include/glfw3.h // have declaration of functions

• lib/glfw3dll.lib // have linking entry points of functions

• bin/glfw3.dll // have binary objects of functions

4

Installation

• Assumed platform:

• Windows + Visual Studio 2017 (32-bit builds)

• How to get Visual Studio 2017 (Community Edition)

• Download a community edition of Visual Studio from Microsoft, freely
available for college students.

• The community version is fully functional as a professional version does.

• Never use an illegal copy of the software.

5

Installation: Local Copy

• Global installation to VC’s h/lib/bin directories is not
recommended, because:

• You will not be able to re-compile the source code later or on other
platforms that do not have installed the libraries.

• You also need to distribute DLL files, too.

• Instead, copy your library files to your project directory.

• Put LIBNAME.h and LIBNAME.lib to .\hello\src\GL\

• Put LIBNAME.dll to .\hello\bin\

• This local copy is recommended, because:

• You do not need to worry about a compiler system where the libraries are
not installed; because your source directory keeps all necessary files in it.

• You can easily distribute your binaries in /bin/ directory (just copy it).

6

Things to Do in Visual Studio

• Add additional library directories that have *.lib files

• In Visual Studio:

7

Things to Do in Visual Studio

• Putting library binaries (*.dll)

• Binary files (*.dll) are loaded at run time.

• You can compile/link the libraries without DLL files, which means they are
nothing to do with compilation/linking steps.

• So, if you put the file in the same directory your program is placed,
the DLL files (*.dll) will be loaded automatically.

Installation of GL and 3rd-Party Libraries

9

OpenGL Software Organization

• OpenGL Software organization on Windows

OpenGL

application

program

GLAD

GL

GLFW

WGL
Graphics

Driver

10

OpenGL Core

• OpenGL core library

• It’s already installed on your compiler systems when your are installing
display drivers for your OS.

• Implementations are available through graphics drivers.

• Linking with window system

• WGL for Windows

• GLX for X window systems

• AGL for Macintosh

• In your code,

• #include

• Nonetheless, this is unnecessary when you are using GLFW and GLAD.

• #pragma comment( lib, “OpenGL32.lib” )

11

OpenGL Core Alternatives: MESA

• MESA: Open-Source Software Implementation of OpenGL

• In case your PC does not support OpenGL, you can alternatively use MESA.

• It is software implementation and so rather slow, but you can use the
minimal set of OpenGL shader functions (probably, up to GLSL 1.3).

• The only thing you have to do is put mesa DLL into your bin directory.

• How to get MESA driver (i.e., opengl32.dll)

• You can download the MESA driver at:

• http://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686/

• Find mingw-w64-i686-mesa-XX.X.X-X-any.pkg.tar.xz

• Extract it and copy opengl32.dll into your bin directory.

12

GLFW: http://www.glfw.org/

• GLFW: An Open Source, multi-platform library for

• creating windows with OpenGL contexts and receiving input and events.

• written in C and has native support for Windows, OS X and many Unix-like
systems using the X Window System, such as Linux and FreeBSD.

• Modern alternative to old-school OpenGL Utility Toolkit (GLUT)

• You can download the source and build on your own.

• However, the course example will provide in-house pre-built binaries.

• In your code,

• #include “GL/glfw3.h”

• #pragma comment( lib, “glfw3dll.lib” ) // or glfw3.lib for static lib

• copy “glfw3.dll” to your program binary directory (/bin/)

• This is only necessary when you are using dll version.

13

GLAD: https://github.com/Dav1dde/glad/

• GLAD: OpenGL Extension Loader Generator Library

• Web service: http://glad.dav1d.de/

• Makes it easy to access OpenGL extensions

• Avoids having to have specific entry points in Windows code

• In your code,

• #include “GL/glad.h”

• embed “glad.c” into your source project for implementation

• Application needs only to run a gladLoadGL()

• That’s it; very simple C library

cgconf: Hello OpenGL

15