Basic OpenGL / SDL 2 app - Source

Started by
1 comment, last by Aliii 9 years, 12 months ago

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.

Advertisement

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 smile.png

A small question..

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


#define nullptr nullptr

Is there a reason for this?

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

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.

This topic is closed to new replies.

Advertisement