Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem with OpenGL
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Fulgurance
l33t
l33t


Joined: 15 Feb 2017
Posts: 711

PostPosted: Sat Apr 18, 2020 10:07 pm    Post subject: Problem with OpenGL Reply with quote

Hello, today i would like to ask question. Is it normal now when i try to do:

Code:
MSI-GS73VR-6RF /home/zohran/Documents/Programmation/OpenGL # eselect opengl list
!!! Error: Can't load module opengl
exiting

I have nothing ???

And i have problem, i would like to work again to code OpenGL application, but impossible to link glfw, gl or other 3D library. Is it not -lGL -lGLFW to link it ??? I don't remember...
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2126
Location: Frankfurt, Germany

PostPosted: Sat Apr 18, 2020 11:01 pm    Post subject: Reply with quote

There are several toolkits that can be used to write OpenGL applications. One of them is GLFW.

If you want to use GLFW, make sure that media-libs/glfw is installed.

Commands to build OpenGL programs with GLFW are shown on this page: https://www.glfw.org/docs/latest/build_guide.html#build_link_pkgconfig
Back to top
View user's profile Send private message
Fulgurance
l33t
l33t


Joined: 15 Feb 2017
Posts: 711

PostPosted: Sat Apr 18, 2020 11:19 pm    Post subject: Reply with quote

Yes, i have already installed it
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2126
Location: Frankfurt, Germany

PostPosted: Sun Apr 19, 2020 3:14 am    Post subject: Reply with quote

That's great!

I was able to compile and run one of the FLGW demo programs:
  1. I installed media-libs/glfw-3.3.1. (*)

  2. I copied the source code from the bottom of https://www.glfw.org/docs/3.0/quick.html to a file named 'demo.c'

  3. I compiled 'demo.c' with:
    Code:
    gcc -O2 $(pkg-config --cflags glfw3) -o demo demo.c $(pkg-config --libs glfw3 gl)

  4. I started the demo program with './demo'. A window popped up and I saw a rotating colored triangle :)

(*) Note: on my machine, demo.c works only partially with media-libs/glfw-3.2.1 (stable) - presumably because I switched to Wayland.
Back to top
View user's profile Send private message
fedeliallalinea
Bodhisattva
Bodhisattva


Joined: 08 Mar 2003
Posts: 24067
Location: here

PostPosted: Sun Apr 19, 2020 5:12 am    Post subject: Re: Problem with OpenGL Reply with quote

Fulgurance wrote:
Code:
MSI-GS73VR-6RF /home/zohran/Documents/Programmation/OpenGL # eselect opengl list
!!! Error: Can't load module opengl
exiting

This is normal if you have set libglvnd use flag (by default is set). Now is this library that permit to switch opengl.
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Fulgurance
l33t
l33t


Joined: 15 Feb 2017
Posts: 711

PostPosted: Sun Apr 19, 2020 10:58 am    Post subject: Reply with quote

Quote:
This is normal if you have set libglvnd use flag (by default is set). Now is this library that permit to switch opengl.


Is it better to use libglvnd with nvidia cards ?

Quote:
gcc -O2 $(pkg-config --cflags glfw3) -o demo demo.c $(pkg-config --libs glfw3 gl)

Yes, i have already see that, but in past, i remember g++ can link OpenGL with just argument with this style: -lGL, no?


Last edited by Fulgurance on Sun Apr 19, 2020 12:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Bodhisattva
Bodhisattva


Joined: 08 Mar 2003
Posts: 24067
Location: here

PostPosted: Sun Apr 19, 2020 11:05 am    Post subject: Reply with quote

Fulgurance wrote:
Is it better to use libglvnd with nvidia cards ?

With all cards that support libglvnd library
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Fulgurance
l33t
l33t


Joined: 15 Feb 2017
Posts: 711

PostPosted: Sun Apr 19, 2020 6:28 pm    Post subject: Reply with quote

It's strange, but when i do this, i have the same error.For me, something is missing...

Code:
zohran@MSI-GS73VR-6RF ~/Documents/Programmation/OpenGL $ g++ `pkg-config --cflags glfw3` -o Main Main.cpp `pkg-config --libs glfw3`
Main.cpp:4:10: erreur fatale: GL/glfw3.h : Aucun fichier ou dossier de ce type
    4 | #include <GL/glfw3.h>
      |          ^~~~~~~~~~~~
compilation terminée.
Back to top
View user's profile Send private message
Fulgurance
l33t
l33t


Joined: 15 Feb 2017
Posts: 711

PostPosted: Sun Apr 19, 2020 6:41 pm    Post subject: Reply with quote

I have found source of problem, default example tutorial include with #include <GL/glfw3.h>, but it's #include <GLFW/glfw3.h>?
Now my command line work to compile with:

Code:
g++ -o Main Main.cpp -lGL -lGLEW -lglfw -lGLU


But now, the problem, when i try to test my code, i have this error:
Code:
Failed to initialize GLFW


This return come from this part of my code:
Code:
if( !glfwInit() )
    {
        fprintf( stderr, "Failed to initialize GLFW\n" );
        return -1;
    }


EDIT: Solved, i switch to SFML, i don't like this library. And it work with SFML
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum