Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

OpenGL Programming

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

right|100px|OpenGL logo Welcome to the OpenGL Programming book. OpenGL is an API used for drawing 3D graphics. OpenGL is not a programming language; an OpenGL application is typically written in C or C++. What OpenGL does allow you to do is draw attractive, realistic 3D graphics with minimal effort. The API is typically used to interact with a GPU, to achieve hardware-accelerated rendering. You are free, and encouraged, to share and contribute to this wikibook: it is written in the spirit of free documentation, that belongs to humanity. Feel free to make copies, teach it in school or professional classes, improve the text, write comments or even new sections. We're looking for contributors. If you know about OpenGL, feel free to leave comments, expand TODO sections and write new ones! GLSL Programming OpenGL __TOC__ Introduction About this book History and Evolution of OpenGL Setting Up OpenGL Installation on GNU/Linux Installation on Macintosh Installation on Windows with Code::Blocks Installation for Android NDK development with a GLUT-like wrapper to follow the exercises Installation for iPhone development Installing GLUT Modern OpenGL "Modern" OpenGL is about OpenGL 2.1+, OpenGL ES 2.0+ and WebGL, with a programmable pipeline and shaders. At the time of this book's writing, OpenGL had made its big leap to OpenGL 2.0, or "Modern OpenGL". This update introduced pivotal changes to the standard - notably, the introduction to shaders and the initial release for GLSL. Rather than using the "fixed-function pipeline", programmers were able to create their own shaders. Since then, OpenGL has gone through a number of overhauls - another notable one occurring with OpenGL 3.0, which deprecated much of the fixed-function pipeline and the direct-mode rendering (glBegin and glEnd). This is notable because this book was written with OpenGL 2.0 in mind. As such, many of the snippets within, while by-large still supported via the "compatibility profile" in OpenGL 3.2+, are not considered "best practice" by today's standards. The basics arc 01thumb|150px|link=/Modern_OpenGL_IntroductionTutorial 01: newcomer's introduction, first dive into shaders02thumb|150px|link=/Modern_OpenGL_Tutorial_02Tutorial 02: adding more robustness to our code, transparency03thumb|150px|link=/Modern_OpenGL_Tutorial_03Tutorial 03: passing information to shaders: attributes, varying and uniforms04thumb|150px|link=/Modern_OpenGL_Tutorial_04Tutorial 04: transformation matrices: positioning and rotating05thumb|150px|link=/Modern_OpenGL_Tutorial_05Tutorial 05: adding the 3rd dimension: a cube, plus a camera06thumb|150px|link=/Modern_OpenGL_Tutorial_06Tutorial 06: textures: displaying a wooden cube07thumb|150px|link=/Modern_OpenGL_Tutorial_Load_OBJOBJ format: loading Suzanne the monkey from Blender08thumb|150px|link=/Modern_OpenGL_Tutorial_NavigationNavigation: navigate in 3D space and manipulate objects in our model viewer Tutorial_drafts: ideas and notes for upcoming tutorials The lighting arc This series of tutorials is a C++ port of the GLSL wikibook Basic Lighting tutorials. 01thumb|150px|link=GLSL_Programming/GLUT/Diffuse ReflectionDiffuse Reflection: about per-vertex diffuse lighting and multiple light sources of different kinds02thumb|150px|link=GLSL_Programming/GLUT/Specular HighlightsSpecular Highlights: about per-vertex lighting03thumb|150px|link=GLSL_Programming/GLUT/Two-Sided SurfacesTwo-Sided Surfaces (about two-sided per-vertex lighting)04thumb|150px|link=GLSL_Programming/GLUT/Smooth Specular HighlightsSmooth Specular Highlights (about per-pixel lighting)05thumb|150px|link=GLSL_Programming/GLUT/Two-Sided Smooth SurfacesTwo-Sided Smooth Surfaces (about two-sided per-pixel lighting)06thumb|150px|link=GLSL_Programming/GLUT/Multiple LightsMultiple Lights (about for-loops for handling multiple light sources) This series of tutorials is a C++ port of the GLSL wikibook Basic Texturing tutorials. 01thumb|150px|link=GLSL_Programming/GLUT/Textured_SpheresTextured Spheres: about texturing a sphere02thumb|150px|link=GLSL_Programming/GLUT/Lighting_Textured_SurfacesLighting Textured Surfaces: about textures for diffuse lighting03thumb|150px|link=GLSL_Programming/GLUT/Glossy_TexturesGlossy Textures: about gloss mapping04thumb|150px|link=GLSL_Programming/GLUT/Transparent TexturesTransparent Textures: about using alpha textures for discarding fragments, alpha testing, and blending05thumb|150px|link=GLSL_Programming/GLUT/Layers of TexturesLayers of Textures: about multitexturing This series of tutorials is a C++ port of the GLSL wikibook tutorials about Textures in 3D. 01thumb|150px|link=GLSL_Programming/GLUT/Lighting_of_Bumpy_SurfacesLighting of Bumpy Surfaces: about normal mapping02thumb|150px|link=GLSL_Programming/GLUT/Projection_of_Bumpy_SurfacesProjection of Bumpy Surfaces: about parallax mapping03thumb|150px|link=GLSL_Programming/GLUT/CookiesCookies: about projective texture mapping for shaping light04thumb|150px|link=GLSL_Programming/GLUT/Light_AttenuationLight Attenuation: about texture mapping for light attenuation and lookup tables in general05thumb|150px|link=GLSL_Programming/GLUT/ProjectorsProjectors: about projective texture mapping for projectors There are more tutorials to port at the GLSL wikibook! The scientific arc 01thumb|150px|link=OpenGL_Programming/Scientific OpenGL Tutorial 01Graph 01: plotting a simple function, using vertex buffer objects and point sprites02thumb|150px|link=OpenGL_Programming/Scientific OpenGL Tutorial 02Graph 02: plotting a graph from data in a texture03thumb|150px|link=OpenGL_Programming/Scientific OpenGL Tutorial 03Graph 03: plotting borders and axes, clipping04thumb|150px|link=OpenGL_Programming/Scientific OpenGL Tutorial 04Graph 04: plotting a three-dimensional graph05thumb|150px|link=OpenGL_Programming/Scientific OpenGL Tutorial 05Graph 05: plotting a surface with hidden line removal And more to come. Selected topics 01thumb|150px|link=/Modern_OpenGL_Tutorial_Virtual_TrackballVirtual Trackball: intuitive object rotation with the mouse02thumb|150px|link=/Bounding boxBounding box: draw a cube around your object for editing or debugging purposes03thumb|150px|link=/Modern_OpenGL_Tutorial_2D2D-on-3D: hardware-accelerated 2D programming04thumb|150px|link=/Video_CaptureVideo Capture: capture your animation using apitrace (C++) or JavaScript (WebGL)05thumb|150px|link=/Modern_OpenGL_Tutorial_07Tea time: generating an HD teapot from Bézier surfaces06thumb|150px|link=/Stencil bufferStencil buffer: masking and combining07thumb|150px|link=/QuadricsQuadrics: creating simple shapes with a bit of maths08thumb|150px|link=/Modern_OpenGL_Tutorial_Text_Rendering_01Basic text: rendering text using the FreeType library09thumb|150px|link=/Modern_OpenGL_Tutorial_Text_Rendering_02Optimized text rendering: using a texture atlas containing all glyphs10thumb|150px|link=/Object selectionObject selection: unprojecting coordinates and object identification using the stencil buffer11thumb|150px|link=/Anti-AliasingAnti-Aliasing: smoothing lines12thumb|150px|link=/Particle systemsParticle systems: differents kinds of particle systems The post-processing arc 01thumb|150px|link=/Post-ProcessingConcepts: how to perform full-screen post-processing, first example with a simple animated wave02thumb|150px|link=/Post-Processing_??????: next effect to be decided! Mini-portal This series shows how to implement a teleportation system similar to Valve's Portal, step-by-step, using OpenGL. 01thumb|150px|link=/Mini-PortalMini-Portal: a first working see-through portal02thumb|150px|link=/Mini-Portal_SmoothMini-Portal Smooth: smooth transition, understanding the camera03thumb|150px|link=/Mini-Portal_RecursiveMini-Portal Recursive: recursive portals - display portals within portals04thumb|150px|link=/Mini-Portal_OptimizationMini-Portal Optimization: optimization with scissors Glescraft This series shows how to render a voxel based world, similar to Minecraft. 01thumb|150px|link=/Glescraft_1Glescraft 1: basic voxel rendering02thumb|150px|link=/Glescraft_2Glescraft 2: removing unnecessary voxel faces03thumb|150px|link=/Glescraft_3Glescraft 3: texturing, lighting, fog, transparency04thumb|150px|link=/Glescraft_4Glescraft 4: first person camera controls05thumb|150px|link=/Glescraft_5Glescraft 5: drawing only what is on screen06thumb|150px|link=/Glescraft_6Glescraft 6: adding and removing voxels07thumb|150px|link=/Glescraft_7Glescraft 7: using geometry shaders Using the accumulation buffer 01thumb|150px|link=/Motion_BlurTutorial 01: motion blur02thumb|150px|link=/SupersamplingTutorial 02: full-screen supersampling anti-aliasing03thumb|150px|link=/Depth_of_FieldTutorial 03: depth of field04thumb|150px|link=/TransparencyTutorial 04: order-independent transparency Note: not all videocards support accumulation buffer Cutting-edge OpenGL If you do not target old mobile devices or the web, you can upgrade to OpenGL (ES) 3.x / 4.x. It notably introduces new kinds of shaders: Geometry, Tessellation Control and Tessellation Evaluation, and Compute. 01thumb|150px|link=/Geometry_ShaderTutorial 01: modify and create vertices on the fly with geometry shaders02thumb|150px|link=/TesselationTutorial 02: dynamic mesh quality with tesselation and lots of other features. Code quality 01thumb|150px|link=/DebuggingDebugging: tips to help debug your OpenGL code02thumb|150px|link=/PerformancePerformance: measuring and improving your application performance. Appendices OpenGL ES 2.0 Overview: OpenGL ES 2.0 (OpenGL for Embedded Systems 2.0) concepts and its differences to normal OpenGL Migrating from 1.x to 2.x: how to upgrade your code to use modern OpenGL Glossary: what do all those new weird words mean? APIs, Libraries and acronyms: how all acronyms relate to each others OpenGL Shading Language: elements of GLSL programming Shaders reference: input and output variables list Team: contributors to this wikibook Download code: wikibooks-opengl code repository Legacy OpenGL 1.x "Legacy" OpenGL is about OpenGL 1.x and OpenGL ES 1.x, with a fixed pipeline and no shaders. Starting Tutorial Setting Up A Programming Environment On WindowsFile:75%.svg Setting Up OpenGL In The Programming EnvironmentFile:75%.svg Drawing PrimitivesFile:75%.svg Immediate Mode Display Lists Vertex Arrays Basic TransformationsFile:75%.svg Translation Rotation Scaling Custom Transformations Basics Structure of a Typical OpenGL Application File:100%.svg Drawing Rectangles File:75%.svg Drawing Lines and Points Drawing Simple 2D Shapes File:100%.svg OpenGL Naming Conventions File:75%.svg Using Color File:75%.svg Viewing Transformations File:25%.svg Drawing Simple 3D Objects Perspective versus Orthographic Projections Intermediate Smoothing Polygons with Normals Adding Lights Using Materials Using Textures Using Mipmaps Drawing Complex Polygons Using Tessellation Advanced Optimizing OpenGL Code Drawing Shadows Drawing Using Quadrics Drawing Using NURBS and Curves Ambient Occlusion Appendices Coordinate Transformations Understanding Transformation Matrices OpenGL Library Reference. functions and type reference for gl.h glu.h and glut.h Why OpenGL Exists and What It's Good For Migrating from 1.x to 2.x: how to upgrade your code to use modern OpenGL External links GLSL Programming Wikibooks GLSL Programming: book on the use of the OpenGL Shading Language (GLSL) in Unity 3 and Blender 2.5, with much information on lighting and texturing. Blender 3D: Noob to Pro: comprehensive book on using the Blender 3D modeling environment Open source, cross-platform IDE's for exploring pixel-based graphics on the GPU using GLSL: Fragmentarium Shadertoy Ports The following websites provide conversion of the tutorials to other programming languages or platforms: https://gitlab.com/wikibooks-opengl/modern-tutorials/tree/master Official code repository contains the main SDL2 version, but also GLUT and WebGL ports https://github.com/alihelmy/lwjglTutorial port to Lightweight Java Game Library (LWJGL) (http://onehandstand.blogspot.com/search/label/OpenGL%20Wikibook%20LWJGL%20Port blog) http://littlefootlandmines.blogspot.com/search/label/opengl%20tutorials not really a port, but commented, progressive version of the tutorials code as the author follows them Freely-licensed documentation and samples OpenGL 3.0+ https://paroj.github.io/gltut/ Learning Modern 3D Graphics Programming: another modern OpenGL tutorial, requiring v3.3 or later, MIT license (https://bitbucket.org/alfonse/gltut/src source repository) http://www.mechcore.net/wiki/index.php?title=OpenGL_Examples Introduction and examples for OpenGL 3.3 http://www.g-truc.net/project-0026.html#menu OpenGL Samples Pack: written in C++ based on the "core profile" specifications, aimed at easing upgrades to new OpenGL versions and features, MIT license (http://ogl-samples.git.sourceforge.net/git/gitweb.cgi?p=ogl-samples/ogl-samples;a=tree source repository) OpenGL 2.x OpenGL 1.x http://www.paulsprojects.net/tutorials/tutorials.html Paul's projects: OpenGL 1.x, two tutorials on shadow mapping and bump mapping, with code under the MIT license OpenGL ES 2.0 https://www.khronos.org/registry/OpenGL-Refpages/es2.0/ OpenGL ES 2.0 Reference Pages: official reference man pages, SGI Free Software B License http://www.learnopengles.com/ Learn OpenGL ES: Detailed, step-by-step OpenGL ES tutorials in Java for Android, and a bit of WebGL as well, CC BY-SA 3.0 license (https://github.com/learnopengles/Learn-OpenGLES-Tutorials source repository − Apache License 2) https://www.khronos.org/opengl/wiki/FAQ A modern OpenGL FAQ: GFDL license http://pyopengl.sourceforge.net/context/tutorials/index.html OpenGLContext Python Tutorials: basic tutorials using PyOpenGL (http://bazaar.launchpad.net/~mcfletch/openglcontext/trunk/view/head:/license.txt BSD-style licenses) WebGL http://greggman.github.io/webgl-fundamentals/webgl/lessons/webgl-fundamentals.html Gregg Tavares’ WebGL articles: detailed 2D and 3D basics with emphasing on matrix operations; lots of diagrams and interactive animations (https://github.com/greggman/webgl-fundamentals source code − MIT license) https://developer.mozilla.org/en-US/docs/Web/WebGL WebGL at Mozilla Developer Network: WebGL overview, including embedding videos; CC BY-SA for articles, MIT and public domain for source code http://threejs.org/ three.js: collection of demos using the three.js WebGL framework; source code is MIT but models/data may be non-free Non-freely-licensed documentation http://nehe.gamedev.net/lesson.asp?index=01 NeHe's OpenGL tutorial: OpenGL 1.x http://www.falloutsoftware.com/ Collection of OpenGL fundamentals tutorials using C++ and Windows API: OpenGL 1.x http://www.zeuscmd.com/ ZeusCMD OpenGL Tutorials: OpenGL 1.x https://tutorialsplay.com/opengl/ OpenGL Programming Examples: OpenGL 1.x, Websites http://www.falloutsoftware.com/tutorials/gl/gl8.htm OpenGL Lighting Model Tutorial with Examples http://opengl.org/ Official OpenGL Website http://mesa3d.org/ Mesa, an open-sourced 3D graphics library almost identical to OpenGL Further reading OpenGL Architecture Review Board, et al: OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 2, Fifth Edition, Addison-Wesley, 0-321-33573-2 OpenGL Architecture Review Board, et al: OpenGL Reference Manual: The Official Reference Document to OpenGL, Version 1.4, Addison-Wesley, 0-321-17383-X Wright, Richard S. Jr and Lipchak, Benjamin: OpenGL SuperBible, Third Edition, Sams Publishing, 0-672-32601-9 computer programming libraries O 50% __NOTOC__