Unsolved The first example of OpenGL
-
Thanks. Great info.
If Cmake is that awesome so I too would like to use it.
What to do with that?
My OS is a Windows x64.
I think I should download that cmake and install it on my OS and create a project, paste that code there and hit the "run" button. :)Incidentally, I've started learning Ubuntu and will ask for whatever needed there for C++/QML/Qt/OpenGL programming.
-
@tomy You just grab cmake and install it, then it works just like qmake does for Qt.
It's not an ide or anything.
So for example, here is a qmake pro file:
TEMPLATE = app TARGET = tbutton INCLUDEPATH += . QT += widgets gui RESOURCES = tbutton.qrc # Input SOURCES += main.cpp
And here is the equivalent CMakeLists.txt file that would be used to build that project with cmake:
cmake_minimum_required(VERSION 3.4) project(tbutton) find_package(Qt5Gui required) set(SRCS main.cpp ) qt5_add_resources(RES_SRC tbutton.qrc) add_executable(${PROJECT_NAME} ${SRCS} ${RES_SRC}) qt5_use_modules(${PROJECT_NAME} Core Gui Widgets)
Hope that helps understand cmake a bit better. It's basically just qmake on steroids. Can be used truly cross platform with many different build systems. Qmake for instance only uses gnu make files, or visual studio. Cmake can use ninja, gnu make, vs, mingw, msys, etc. It has many more.
-
@ambershark
Well, thank you very much. I got some info by your post but it's still too complex for a new user of Cmake to make the code above run for the first time.Now I've installed Cmake (cmake-3.9.3-win64-x64.msi) on my Windows 7 x64 machine and also have the source code above. If I want for the time being use Windows to run that code on, what steps should I go through, please?
-
So if you wanted to use that project you referenced in visual studio you would do this (on the command line is my preferred but cmake has a windows gui too):
$ cd /path/to/project
$ mkdir build
$ cd build
$ cmake -G "Visual Studio 15 2017" ..Now you should have a sln file that you can open with visual studio.
I used Windows command prompt (cmd on start menu) and typed:
cd C:\Users\Abbasi\Desktop\OGLPG-9th-Edition\OGLPG-9th-Edition\buildcmake -G "Visual Studio 15 2017"
The output: 'cmake' is not recognized as an internal or external
Presumably some other command prompt was meant.Therefore, I went for the gui option:
It made the files onto the build folder and now have two .sln files, one in the *OGLPG-9th-Edition\OGLPG-9th-Edition\build folder named vermilion9.sln and the other in the OGLPG-9th-Edition\OGLPG-9th-Edition\build\lib\glfw folder named GLFW.sln.Which one should I open?
-
@tomy I'd open the vermillion one. That seems to be the overall project whereas the other one was just for a library.
As for the command not recognized, that's just because cmake isn't in your path for the cmd. You need to add your cmake binary directory to your PATH environment variable, or you need to call it via the whole path like:
> "c:\program files\cmake\bin\cmake.exe" -G "Visual Studio 15 2017" /path/to/your/source
Made assumption on folder, get the exact one for your install. :)
-
/path/to/your/source
Does it mean that I should save that source code in a C++ file, or any other file, and give its path to the cmd as above?
By the way, the method used here is much longer than the one using these cmd commands.
-
@tomy No.. so here's a quick little project I wrote for someone on these forums today, and I use cmake as the build system. Here is the directory structure:
rowcolor/ CMakeLists.txt src/ main.cpp window.cpp
Now given the above structure I could do this to build:
$ cd rowcolor $ mkdir build $ cd build $ cmake -G "Visual Studio 15 2017" .. $ cmake --build
That
..
in there is the/path/to/source
I mentioned. In this case it's one directory up from build which is indicated by 2 periods.Hope that helps makes sense.
As for that link you sent, the cmake they are using is with the cmake GUI. Which is fine, some people prefer that. It is still very simple you see the specify the generator and the path to the source. The variables on the right hand side of the screen shot are things that can be customized. You could do that on the command line as well. It's still very simple though.
Edit: here's a link to that thread if you want to see the cmakelists.txt file https://forum.qt.io/topic/83800/set-background-of-specific-row-in-qlistview/8
-
@ambershark
I looked at that post of you on that thread. The .cpp and .h files seem to be of Qt. My code, in the first post of this thread, is of OpenGL.Do you mean that I should save that code in a Win32 Console Application (by visual studio for example) and put it and that CMakeLists.txt in the directories above and then use the commands?
By the way, even using that Cmake GUI link I haven't been able to run my code yet! :( Take a look at here please.
-
@tomy No you don't need cmake for what you're doing. I mean you can use it, but it's not required or anything. The opengl stuff should work in Visual Studio.
You're in an area I'm not good with though. I'm not really a windows programmer so Visual Studio isn't something I use very often. And I've never done OpenGL stuff outside of using Qt's implementations for it.
I wish I could help you more but I just don't know that stuff.
From the sounds of that other thread, you do not have your include directories set properly though. If it can't find <glad/glad.h> you may have the directory set to the include that contains glad.h rather than the one above it. Just a guess. :)
-
I'm so much appreciative.
Thanks for both your intention of help and also the guess.
I will pursue the way you said.