Followers 0

# Basic OpenGL / SDL 2 app - Source

## 2 posts in this topic

Ive tried to use SDL2 recently. Before I use it in my existing projects I wanted to write a basic app that puts something minimal on the screen using the "old" and "modern" OpenGL. It turned out fine, so I thought Im sharing the source. (plus Ive added some comments to it.) I hope Im not posting this to the wrong place.

It uses GLLoad to get the GL functions but you can replace it with GLEW or any other library.

It works for me on both Linux and Windows.(compiled with GCC, using C++11 standard). ....you have to install/add the necessary libraries to your project of course.

I hope it helps someone to start using OpenGL or SDL.

2

##### Share on other sites

This is a nice example which is not bogged down with any OOP. I will likely refer people to this when they are starting out with SDL2 and GL. Thanks

A small question..

Inside main cpp (OLD and NEW) you have the define

#define nullptr nullptr


Is there a reason for this?

Edited by Karsten_
1

##### Share on other sites

Inside main cpp (OLD and NEW) you have the define
#define nullptr nullptr
Is there a reason for this?

Basically not, ....other than my IDE sometimes marks "nullptr" as "undefined variable". This way it sees it as a defined thing.

There are some other weird things in the code like glPointSize( 2000) when Im not even drawing points:) I didnt really review it.

0

## Create an account

Register a new account