DS Log
In my blog, I delve into the world of programming web technologies, Linux, Unix-like, and graphic design using free tools on Linux.
KINGCODE
KingCode Editor (ex Texty Editor) is my project developed using Java Swing. Project is still in development and in beta version. I plan to add additional features focused for PYTHON, PHP, JAVA, C, JS and BASH.
Read more ↗
VUE on Linux
In this guide, I'll walk you through the step-by-step process of setting up Vue.js on your Linux system, empowering you to create dynamic and interactive web applications. Let's harness the power of Vue.js together on the Linux platform!
Read more ↗
Symfony PHP
Dive into the world of Symfony PHP with this comprehensive introduction. In this guide, you'll learn the essential steps to create and manage posts and users, empowering you to build dynamic web applications with ease.
Read more ↗
Trying Linux from Windows
How to set up a PHP development server on Ubuntu 22.04
Text editors
List of text editors for developers.
Read more ↗
Fonts
Important fonts everyone needs to know.
Read more ↗
Try Linux from Windows
Here are some quick videos I made showing how to try out Linux Mint on Windows.
Read more ↗
Wednesday, February 19, 2025
OPENGL intro
OpenGL (Open Graphics Library) is a cross-platform, low-level graphics API (Application Programming Interface) used for rendering 2D and 3D vector graphics. It provides a set of functions that allow developers to create graphics applications, such as video games, simulations, and visualizations, by interacting with the graphics hardware. We will use Ubuntu or LinuxMint for this tutorial.
Basically it's API that we use to work with 3D graphic cards.
GLEW
GLEW (OpenGL Extension Wrangler Library). GLEW is a cross-platform library that helps manage OpenGL extensions and core functionality. It simplifies the process of accessing OpenGL features, especially extensions, which are not part of the core OpenGL specification.
Key Features of GLEW
Feature |
Description |
Extension Loading |
GLEW provides a way to dynamically load OpenGL extensions at runtime. This is important because different graphics hardware and drivers may support different sets of OpenGL extensions. It allows you to check whether a specific extension or OpenGL version is supported by the current system.
|
Core OpenGL Functions |
GLEW also provides access to core OpenGL functions, making it easier to write portable OpenGL code.
|
Cross-Platform |
GLEW works on multiple platforms, including Windows, macOS, and Linux.
|
Automatic Initialization |
GLEW automatically initializes itself and queries the available OpenGL extensions when you call glewInit() .
|
GLFW
GLFW (Graphics Library Framework) is a cross-platform library designed to create windows, handle input (keyboard, mouse, joystick), and manage OpenGL contexts. It is commonly used in OpenGL applications to simplify the process of setting up a rendering environment.
Key Features of GLFW
Feature |
Description |
Window and Context Management |
GLFW creates windows and OpenGL contexts, making it easier to set up a rendering environment. It supports multiple monitors and full-screen mode.
|
Input Handling |
GLFW provides functions to handle keyboard, mouse, and joystick input. It supports callbacks for events like key presses, mouse movement, and window resizing.
|
Cross-Platform |
GLFW works on Windows, macOS, and Linux, making it a popular choice for cross-platform OpenGL applications.
|
Integration with OpenGL |
GLFW is designed to work seamlessly with OpenGL, allowing you to focus on rendering rather than platform-specific details.
|
Minimalistic and Lightweight |
GLFW is simple to use and does not impose a heavy framework on your application.
|
Preparing system
We need to prepare our Linux system for development.
Check that your system supports OpenGL and that the necessary drivers are installed:
🚀 glxinfo | grep "OpenGL version"
If yes then let's install following packages:
🚀 sudo apt-get update
🚀 sudo apt-get install build-essential automake autoconf cmake git checkinstall pkg-config g++ libtool
Test program
Now open your favorite editor (use Geany) and save this to "test.c" file:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <stdio.h>
int main() {
// Initialize GLFW
if (!glfwInit()) {
fprintf(stderr, "Failed to initialize GLFW\n");
return -1;
}
// Set OpenGL version to 3.3 (core profile)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Create a windowed mode window and its OpenGL context
GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL Test", NULL, NULL);
if (!window) {
fprintf(stderr, "Failed to create GLFW window\n");
glfwTerminate();
return -1;
}
// Make the window's context current
glfwMakeContextCurrent(window);
// Initialize GLEW
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
// Print OpenGL version
printf("OpenGL Version: %s\n", glGetString(GL_VERSION));
// Main loop
while (!glfwWindowShouldClose(window)) {
// Clear the screen to red
glClearColor(1.0f, 0.0f, 0.0f, 1.0f); // Red background
glClear(GL_COLOR_BUFFER_BIT);
// Swap front and back buffers
glfwSwapBuffers(window);
// Poll for and process events
glfwPollEvents();
}
// Clean up and exit
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
To compile the code open terminal where your code is and type:
🚀 gcc test.c -o test -lglfw -lGLEW -lGL
If everything is compiled, run the binary:
🚀 ./test