Showing posts with label OpenGL. Show all posts
Showing posts with label OpenGL. Show all posts

Sunday, May 6, 2018

Creating a QT C++ OpenGL project in Linux

I respect guys, who can configure Vim/Emacs or Sublime to complete IDE, using a ton of plugins, but I just want to download and work. I had enough virtual sex, configuring proprietary Nvidia drivers and Touchpad gestures in Linux (it is worthy of separate post).

I chose QtCreator.
sudo apt install qtcreator

New Project -> Non-Qt Project -> Plain C++ Application
Choose project location, and name it (for example opengl-qt)

Define build system - I chose CMake, I want to make platform-independent project, also I don`t know pros and cons of qmake.

Kit Selection I was surprised, that there are no kits in my laptop, and I don't even imagine, why we can't continue without this .....ing kit. But we can heal it:

sudo apt-get install qt5-default
(Thanks to the link)

Holy cow! It creates a project, moreover it can easily compile and run by pressing Ctrl + R !

Let's do the same OpenGL program, we created by native g++ compiler and text editor: https://s-march.blogspot.com/2018/05/creating-opengl-application-in-linux.html
  1. Copy and paste our code to main.cpp
  2. CMake. I used it before, to make project from sources, for example CMake made GLFW and GLM projects for theirs further compiling in Visual Studio in Windows.
    Now I started manually configure CMake file by myself. I had hated it for an hour until I understood, how to link libraries. Ask me how?
    Easy!

CMakeLists.txt

project(opengl-qt) #change to your project name
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 14)
#for -std=c++14 
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} GLEW GL glfw)


Look at the last line! That`s the way to link libraries.

AAAAA!! Happiness!


Now we can create classes and make our weird stuff more weird. I will create my program, based on learnopengl.com using classes and other C++ stuff.

1. If you have done the same stuff, but it does not work - ask me, maybe I`ll be able to help.
2. Feel free to improve my mistakes and explain something if my dumbness make you cry.

Thank you for watching!

Creating OpenGL application in Linux

I decided to start coding graphics for Linux
My system is Mint KDE 18.03 I just started using it.
I think, here is an easies way to start.

Packages, you need:

GLFW
Creates window, gets data from mouse and keyboard.

GLEW
Extension wrangler for OpenGL. GL commands are impossible to read and understand.

g++ - GNU C++ compiler


Let`s install them!

sudo apt install g++ libglew-dev libglfw3-dev

IMPORTANT!
write in terminal:
LD_LIBRARY_PATH=/usr/local/lib
sudo ldconfig
 


lets copy the triangle drawing code from learnopengl.com

Paste it in your file main.cpp, that you created in your project folder (for example Program/opengl-gcc).

COMPILE
g++ -std=c++14 main.cpp -lglfw -lGL -lGLEW
(C++ 11/14/17 features are turned off by default, so we must write -std=c++14, otherwise compiler will not understand, what nullptr is.)

RUN

./a.out

... ??
Profit!


Dreamfly

Alongside with BeamTheGame, me and Dmytro Makarenko develop the DreamFly (Steam link here) game. If you have VR headset with motion c...