Convert Figma logo to code with AI

McNopper logoOpenGL

OpenGL 3 and 4 with GLSL

2,329
669
2,329
2

Top Related Projects

12,827

A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input

9,089

OpenGL Mathematics (GLM)

26,312

stb single-file public domain libraries for C/C++

60,541

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

3,722

Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.

Quick Overview

McNopper/OpenGL is a comprehensive GitHub repository containing OpenGL examples and tutorials. It covers a wide range of OpenGL topics, from basic rendering to advanced techniques, and includes implementations in various programming languages such as C, C++, and Java.

Pros

  • Extensive collection of OpenGL examples covering many aspects of 3D graphics programming
  • Implementations in multiple programming languages, making it accessible to a broader audience
  • Well-organized structure with separate folders for different topics and languages
  • Includes both basic and advanced OpenGL techniques, suitable for beginners and experienced developers

Cons

  • Some examples may be outdated or use deprecated OpenGL features
  • Limited documentation for some of the more complex examples
  • Not actively maintained, with the last update being several years ago
  • May require additional setup or dependencies for certain examples

Code Examples

Here are a few short code examples from the repository:

  1. Basic OpenGL window setup (C++):
#include <GL/glew.h>
#include <GLFW/glfw3.h>

int main()
{
    glfwInit();
    GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL Window", NULL, NULL);
    glfwMakeContextCurrent(window);
    glewInit();

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}
  1. Loading a shader (C++):
GLuint loadShader(GLenum shaderType, const char* shaderSource)
{
    GLuint shader = glCreateShader(shaderType);
    glShaderSource(shader, 1, &shaderSource, NULL);
    glCompileShader(shader);
    return shader;
}
  1. Drawing a simple triangle (C++):
GLfloat vertices[] = {
    -0.5f, -0.5f, 0.0f,
     0.5f, -0.5f, 0.0f,
     0.0f,  0.5f, 0.0f
};

GLuint VBO, VAO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (void*)0);
glEnableVertexAttribArray(0);

glDrawArrays(GL_TRIANGLES, 0, 3);

Getting Started

To get started with the McNopper/OpenGL repository:

  1. Clone the repository: git clone https://github.com/McNopper/OpenGL.git
  2. Navigate to the desired example folder (e.g., cd OpenGL/Example01)
  3. Follow the specific build instructions in the README file for the chosen example
  4. Compile and run the example using the provided build system (usually CMake)

Note that you may need to install additional dependencies such as GLEW, GLFW, or other libraries depending on the specific example you're working with.

Competitor Comparisons

12,827

A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input

Pros of GLFW

  • More widely used and actively maintained
  • Cross-platform support for Windows, macOS, and Linux
  • Extensive documentation and community support

Cons of GLFW

  • Focused solely on window creation and input handling
  • Requires additional libraries for advanced graphics functionality

Code Comparison

OpenGL:

#include "GL/glus.h"

GLUSboolean init(GLUSvoid)
{
    // OpenGL initialization code
}

GLFW:

#include <GLFW/glfw3.h>

int main(void)
{
    if (!glfwInit())
        return -1;
    // GLFW initialization code
}

Summary

GLFW is a lightweight, cross-platform library for creating windows with OpenGL contexts and handling input and events. It's widely used and well-maintained, making it a popular choice for OpenGL development.

OpenGL, on the other hand, is a more comprehensive graphics library that includes additional utilities and examples. It may be better suited for those looking for a more complete graphics solution out of the box.

While GLFW excels in its focused approach and cross-platform support, OpenGL offers a broader range of graphics-related functionality. The choice between the two depends on the specific needs of your project and your familiarity with OpenGL development.

9,089

OpenGL Mathematics (GLM)

Pros of GLM

  • Specialized mathematics library for graphics programming
  • Header-only, making it easy to integrate into projects
  • Extensive documentation and community support

Cons of GLM

  • Focused solely on mathematics, lacking broader OpenGL functionality
  • May require additional libraries for complete graphics programming

Code Comparison

GLM:

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

glm::mat4 model = glm::rotate(glm::mat4(1.0f), glm::radians(45.0f), glm::vec3(0.0f, 1.0f, 0.0f));

OpenGL:

#include "GL/glus.h"

GLUSfloat matrix[16];
glusMatrix4x4Identityf(matrix);
glusMatrix4x4Rotatef(matrix, 45.0f, 0.0f, 1.0f, 0.0f);

Summary

GLM is a specialized mathematics library for graphics programming, offering easy integration and extensive documentation. However, it focuses solely on mathematics and may require additional libraries for complete graphics programming. OpenGL provides a broader range of functionality but may be less specialized in mathematics operations. The code comparison demonstrates the difference in syntax and approach between the two libraries for matrix operations.

26,312

stb single-file public domain libraries for C/C++

Pros of stb

  • Single-file header libraries, making integration extremely simple
  • Wide range of functionality (image loading, audio, fonts, etc.) in a lightweight package
  • No external dependencies, enhancing portability

Cons of stb

  • Less comprehensive OpenGL coverage compared to OpenGL
  • May require more manual setup for complex rendering tasks
  • Limited to C, while OpenGL supports C++

Code Comparison

OpenGL (setting up a window):

#include <GL/glew.h>
#include <GLFW/glfw3.h>

int main() {
    glfwInit();
    GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", NULL, NULL);
    glfwMakeContextCurrent(window);
}

stb (loading an image):

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

int main() {
    int width, height, channels;
    unsigned char *image = stbi_load("image.png", &width, &height, &channels, 0);
}

Both repositories serve different purposes. OpenGL focuses on providing comprehensive OpenGL examples and utilities, while stb offers a collection of single-file libraries for various tasks, including some graphics-related functionalities. The choice between them depends on the specific needs of your project and your preferred development approach.

60,541

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Pros of imgui

  • Lightweight and easy to integrate into existing projects
  • Extensive documentation and examples
  • Active community and frequent updates

Cons of imgui

  • Limited to immediate mode GUI, less suitable for complex layouts
  • Requires more manual management of UI state

Code Comparison

imgui:

ImGui::Begin("My Window");
if (ImGui::Button("Click me!"))
    doSomething();
ImGui::End();

OpenGL:

glBegin(GL_TRIANGLES);
glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.0f);
glVertex3f(0.0f, 0.5f, 0.0f);
glEnd();

Key Differences

  • imgui focuses on GUI creation, while OpenGL is a graphics API
  • OpenGL provides low-level graphics rendering capabilities
  • imgui is built on top of graphics APIs like OpenGL

Use Cases

  • imgui: Rapid prototyping, debug interfaces, tools
  • OpenGL: 3D graphics, game development, scientific visualization

Learning Curve

  • imgui: Relatively easy to learn and use quickly
  • OpenGL: Steeper learning curve, requires understanding of graphics concepts

Performance

  • imgui: Efficient for GUI rendering, but may impact overall performance
  • OpenGL: High performance for graphics rendering when used correctly
3,722

Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.

Pros of glad

  • Easier to integrate into existing projects
  • More flexible and customizable OpenGL loader generation
  • Actively maintained with regular updates

Cons of glad

  • Requires additional setup and configuration
  • May have a steeper learning curve for beginners
  • Limited documentation compared to OpenGL

Code Comparison

glad:

#include <glad/glad.h>

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
    // Handle initialization error
}

OpenGL:

#include <GL/glew.h>

GLenum err = glewInit();
if (GLEW_OK != err) {
    // Handle initialization error
}

Both repositories provide OpenGL loading functionality, but glad offers more flexibility in terms of API selection and extension loading. OpenGL, on the other hand, provides a more straightforward setup process and extensive documentation, making it potentially easier for beginners to get started.

glad is generally considered more modern and actively maintained, while OpenGL offers a more traditional approach to OpenGL loading. The choice between the two depends on project requirements, developer experience, and desired level of customization.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

OpenGL

OpenGL 3 and OpenGL 4 with GLSL

Please read GLUS/README.txt

Please read Binaries/README.txt

======

Example01 - Basic window and OpenGL 3 initialization

Example02 - Rendering of a triangle

Example03 - Grey filter

Example04 - Perspective rendering of a cube

Example05 - Phong rendering of a sphere

Example06 - Texturing of a cube

Example07 - Normal mapping

Example08 - Environment/cube mapping

Example09 - GPU Particles

Example10 - Geometry shader

Example11 - Reflection and refraction

Example12 - Shadow mapping

Example13 - Simple tessellation (OpenGL 4.1)

Example14 - Terrain rendering (OpenGL 4.1)

Example15 - Water rendering

Example16 - Model loading and rendering

Example17 - Clipping planes and two sided rendering

Example18 - Using stencil buffer and clipping planes

Example19 - Render to texture and planar reflection

Example20 - Texture matrix, alpha blending and discarding

Example21 - Compute shader (OpenGL 4.3)

Example22 - Shadow volumes

Example23 - Displacement mapping (OpenGL 4.1, AMD hardware - not on Mac OS X - has artifacts but used to work)

Example24 - Erode effect using perlin noise

Example25 - Model with groups and materials

Example26 - Fur rendering

Example27 - Projection shadow for directional light

Example28 - Screen space ambient occlusion (SSAO) (OpenGL 4.1)

Example29 - CPU ray tracing

Example30 - GPU ray tracing using compute shader (OpenGL 4.3)

Example31 - Many lights using deferred shading (OpenGL 4.1)

Example32 - BRDF and IBL rendering (OpenGL 4.1)

Example33 - Real-Time BRDF and IBL rendering (OpenGL 4.1)

Example34 - Subsurface scattering

Example35 - Order independent transparency using depth peeling

Example36 - Order independent transparency using linked list (OpenGL 4.4, AMD hardware has artifacts)

Example37 - CPU ray marching

Example38 - Basic usage of program pipeline and separable programs(OpenGL 4.1)

Example39 - Basic usage of program pipeline, separable programs and shader subroutines (OpenGL 4.1, AMD hardware does not work properly)

Example40 - Cloth simulation using compute shader (OpenGL 4.3)

Example41 - Ocean wave height/normal map calculation with FFT using compute shader (OpenGL 4.3, NVIDIA hardware under Linux has artifacts)

Example42 - Fast Approximate Anti Aliasing - FXAA (OpenGL 4.3)

Example43 - Scene with several models having groups and materials

Example44 - Conservative rasterization

Example45 - GPU voxelization (OpenGL 4.4)