Skip to content

harshini-20-05/graphics_programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebClub Demo - OpenGL C++ Project

A C++ OpenGL demo project showcasing modern graphics programming using popular libraries like GLFW, GLAD, and GLM.

Project Overview

This project serves as a foundation for OpenGL development in C++. It's currently a minimal setup that includes all the necessary dependencies and build configuration to start developing OpenGL applications.

Libraries Used

  • GLFW - Cross-platform library for creating windows, contexts, and handling input
  • GLAD - OpenGL Function Loader for loading OpenGL functions
  • GLM - OpenGL Mathematics library for graphics math operations

Prerequisites

Before building this project, ensure you have the following installed:

  • CMake (version 3.6 or higher)
  • C++ Compiler with C++11 support:
    • GCC 4.8+ (Linux)
    • Clang 3.3+ (macOS/Linux)
    • Visual Studio 2013+ (Windows)
  • OpenGL drivers (usually comes with graphics drivers)

Linux Dependencies

On Ubuntu/Debian systems, install the required packages:

sudo apt update
sudo apt install build-essential cmake libgl1-mesa-dev libglu1-mesa-dev

On Fedora/CentOS/RHEL systems:

sudo dnf install gcc-c++ cmake mesa-libGL-devel mesa-libGLU-devel

Additional Linux Dependencies for GLFW

# Ubuntu/Debian
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev

# Fedora/CentOS/RHEL
sudo dnf install libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel

Project Structure

webclub-demo/
├── CMakeLists.txt          # Main CMake configuration
├── README.md               # This file
├── src/                    # Source code directory
│   └── main.cpp           # Main application entry point
├── vendors/                # Third-party libraries
│   ├── glad/              # OpenGL function loader
│   ├── glfw/              # Window management library
│   └── glm/               # Mathematics library
└── build/                  # Build output directory (generated)

Build Process

This project uses CMake as the build system. Follow these steps to build the project:

1. Clone and Navigate

git clone --recursive <repository-url>
cd webclub-demo

2. Create Build Directory

mkdir build
cd build

3. Configure with CMake

cmake -S . -B build

4. Build the Project

cmake --build build

5. Run the Application

./build/Application

Development

Adding New Source Files

  1. Place .cpp and .c files in the src/ directory
  2. Place .h and .hpp files in the src/ directory
  3. CMake will automatically detect and include them in the build

CMake Configuration

The project is configured to:

  • Use C++11 standard
  • Build GLFW as a static library
  • Disable GLFW examples, tests, and documentation
  • Include all necessary headers and link required libraries

Adding Third-Party Dependencies

This project is structured to easily accommodate additional third-party libraries. Here are common approaches:

Method 1: Git Submodules (Recommended)

For libraries with CMake support:

  1. Add as Git Submodule

    git submodule add https://github.com/vendor/library.git vendors/library
    git submodule update --init --recursive
  2. Update CMakeLists.txt

    # Add to your CMakeLists.txt after existing add_subdirectory calls
    add_subdirectory(vendors/library)
    
    # Add include directories
    target_include_directories(Application PRIVATE vendors/library/include)
    
    # Link the library
    target_link_libraries(Application library_name)

Method 2: Header-Only Libraries

For header-only libraries (like most of GLM):

  1. Download and Extract

    cd vendors/
    wget https://github.com/vendor/library/archive/main.zip
    unzip main.zip
    mv library-main library
  2. Add Include Directory

    target_include_directories(Application PRIVATE vendors/library/include)

Method 3: Using CMake's FetchContent (Modern Approach)

For modern CMake (3.11+):

include(FetchContent)

FetchContent_Declare(
  library_name
  GIT_REPOSITORY https://github.com/vendor/library.git
  GIT_TAG        main  # or specific version tag
)

FetchContent_MakeAvailable(library_name)

target_link_libraries(Application library_name)

Troubleshooting

Common Issues

  1. CMake not found: Install CMake from cmake.org or using your package manager

  2. OpenGL headers not found: Install development packages for OpenGL

    # Ubuntu/Debian
    sudo apt install mesa-common-dev
  3. GLFW dependencies missing: Install X11 development libraries

    # Ubuntu/Debian
    sudo apt install libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
  4. Build fails on older systems: Ensure your compiler supports C++11

Clean Build

To perform a clean build:

rm -rf build/
mkdir build
cd build
cmake ..
cmake --build .

Next Steps

This project currently contains a minimal main.cpp file. To start developing:

  1. Add OpenGL context creation code
  2. Implement basic rendering pipeline
  3. Add shaders and geometry
  4. Implement user input handling

License

This project is licensed under the MIT License - see the LICENSE file for details.

Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published