Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » GLFW Package
GLFW Package [message #55703] Tue, 01 December 2020 19:51 Go to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Here is a GLFW package compatible Windows and Linux.

No flag have to be set to make it compatible with your operating system.

Default POSIX/LINUX implementation use X11. If you want to use Wayland or Mesa instead use flag MESA or WAYLAND

UPDATE : The package present in this post is up to date (at least until UppHub have been released)

A simple example code :
#include <Core/Core.h>
#include <GLFW/glfw.h>

const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;

CONSOLE_APP_MAIN{
    // glfw: initialize and configure
    glfwInit();
    //Major and Minor stand (in this case) for OpenGL 3.2
    //Make sure your OpenGL implemntation is compatible with the version exaplained here
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    
    //If you OpenGL version is higher than 3.2 :
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    //else if it's below :
    //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
#ifdef __APPLE__
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
    // glfw window creation
    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Ultimate++", NULL, NULL);
    if (window == NULL)
    {
        Upp::Cout() << "Failed to create GLFW window\n";
        glfwTerminate();
        Upp::Exit(-1);
    }
    glfwMakeContextCurrent(window);
    
    // Glew: load all OpenGL function pointers
    glewExperimental=true;
	if (glewInit() != GLEW_OK){
		Upp::Cout() << "Failed to initialize GLEW\n";
	    Upp::Exit(-1);
	}
	
	//the game loop
	glViewport(0,0, SCR_WIDTH, SCR_HEIGHT);
    while (!glfwWindowShouldClose(window)){
        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwTerminate();
}


EDIT: at the moment LINUX version have been tested on X11. Some Memory leaks have been reported. (probably due to a AMD driver bug)
EDIT2: Cocoa (MacOS) and Wayland and Mesa have not been tested yet.
  • Attachment: GLFW.7z
    (Size: 353.00KB, Downloaded 189 times)

[Updated on: Sun, 13 December 2020 03:18]

Report message to a moderator

Re: GLFW Package [message #55704 is a reply to message #55703] Tue, 01 December 2020 20:28 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1143
Registered: August 2007
Senior Contributor
Hello Xemuth,

Nice work! I hope it will mature well.

I have tested it on ArchLinux (Setup:)


Linux 5.9.8,
GCC 10.2.0, x86_64
CLANG 11.0.0 x86_64,
Gnome 3.38, WAYLAND/xwayland,
GL_VERSION: 4.5 (Compatibility Profile) Mesa 20.2.2
GL_RENDERER: AMD OLAND (DRM 2.50.0, 5.9.8-arch1-1, LLVM 11.0.0)
GL_VENDOR: X.Org


IT compiled just fine. A blank window with "Ultimate++" title is created. And on exit, heap leaks are reported (as expected, I presume?)

Best regards,
Oblivion




Re: GLFW Package [message #55705 is a reply to message #55704] Tue, 01 December 2020 20:54 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Thanks for testing !

heap leaks are reported (as expected, I presume?)


Indeed, I have heap leak aswell, I dont know why, I will dig it.

The fact you have wayland and Mesa implemented is awesome !
if you don't mind I will ask you later for testing it using them Very Happy

Thanks again !
Re: GLFW Package [message #55706 is a reply to message #55705] Tue, 01 December 2020 20:56 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1143
Registered: August 2007
Senior Contributor
Quote:
if you don't mind I will ask you later for testing it using them


Sure, I'll happily test it along the way. Smile


Re: GLFW Package [message #55707 is a reply to message #55703] Wed, 02 December 2020 01:31 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1085
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Xemuth,

I am glad it is working! I am also happy UppHub will have this awesome package for the premiere. Good job!

Also, please replace "int main()" with CONSOLE_APP_MAIN thanks to Core we are in U++ world Smile
return -1 can be replaced with Upp::Exit(). Also, you could consider adding description to GLFW package - what it is. It is very helpful information when you don't know anything about package and wants to try.

I tested it on my machine with Radeon GPU on Manjaro (X11) and in the window I saw only blinking artifacts Sad. This might be the library problem or something else. I will probably do not have time to dig more.

Small remark:
Upp::Cout() << "Failed to create GLFW window" << Upp::EOL;

Could be replace with
Upp::Cout() << "Failed to create GLFW window\n";


Oblivion the leak problem is related to leak in AMD drivers we (Mirek and I) fought with it in the past for GLCtrl but without success.

Klugier


U++ - one framework to rule them all.

[Updated on: Wed, 02 December 2020 01:33]

Report message to a moderator

Re: GLFW Package [message #55708 is a reply to message #55707] Wed, 02 December 2020 09:17 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1143
Registered: August 2007
Senior Contributor
Quote:
the leak problem is related to leak in AMD drivers we (Mirek and I) fought with it in the past for GLCtrl but without success.


Yes, I remember reporting the leak with GLCtrl. Thank you for your efforts! I guess it is an upstream issue at this point.

Best regards,
Oblivion


Re: GLFW Package [message #55710 is a reply to message #55707] Wed, 02 December 2020 10:58 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello Klugier,

Thanks for testing !



Klugier wrote on Wed, 02 December 2020 01:31

Also, please replace "int main()" with CONSOLE_APP_MAIN thanks to Core we are in U++ world Smile

The quick example I provided was taken from web. I had change the original post to make it U++

Klugier wrote on Wed, 02 December 2020 01:31

Also, you could consider adding description to GLFW package - what it is. It is very helpful information when you don't know anything about package and wants to try.

Yes, the next update (which will include Wayland and Mesa) will have a description

Klugier wrote on Wed, 02 December 2020 01:31

I tested it on my machine with Radeon GPU on Manjaro (X11) and in the window I saw only blinking artifacts Sad. This might be the library problem or something else. I will probably do not have time to dig more.

The example I provided only open a Window, acquire an OpenGL context and loop infinlty. the window is supposed to be fully black. In your case it probably come from lib. do you have a dedicated GPU ? or is it an integrated one ? do you know your OpenGL version ? (if you have Mesa, you can type commande glxinfo, see OpenGL version string)

Klugier wrote on Wed, 02 December 2020 01:31

Oblivion the leak problem is related to leak in AMD drivers we (Mirek and I) fought with it in the past for GLCtrl but without success.

I have dig up an old machine and put Lubuntu in it (so I'm running X11) with an intel CPU (pentium 4 + integrated intel GPU) and leak still happen. Maybe I'm naive but my system dont have amd driver, so the problem is may be related to my lib.

@Oblivion how have you retrieve system information you provided on this post ? is it a simple command ? (have not found it on web Crying or Very Sad)
Re: GLFW Package [message #55711 is a reply to message #55710] Wed, 02 December 2020 11:23 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1143
Registered: August 2007
Senior Contributor
Quote:
how have you retrieve system information you provided on this post ? is it a simple command ? (have not found it on web


There are several tools to retrieve GL information but by default I use glinfo (part of mesa-demos package):


https://www.archlinux.org/packages/extra/x86_64/mesa-demos/files/


Others are uname and gcc --version and clang --version Smile

Best regards,
Oblivion


[Updated on: Wed, 02 December 2020 11:24]

Report message to a moderator

Re: GLFW Package [message #55712 is a reply to message #55711] Wed, 02 December 2020 11:56 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Thanks Oblivion,

Well my machine is not Wayland / Mesa compliant apparently.

I have updated the package to implement WayLand and Mesa. Can you please test it on your machine ? same code just flag MESA or WAYLAND

I'm curious to see If you have a compilation error like "no member named 'null' in ..." or "no member named 'wl in ..."

Thanks in advance
  • Attachment: GLFW.7z
    (Size: 340.54KB, Downloaded 199 times)
Re: GLFW Package [message #55713 is a reply to message #55703] Wed, 02 December 2020 12:04 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Also, if someone with a MAC OSX could try the cocoa implementation it could be awesome ! (no flag needed)
Re: GLFW Package [message #55714 is a reply to message #55712] Wed, 02 December 2020 12:07 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1143
Registered: August 2007
Senior Contributor
With WAYLAND flag:
/home/testuser/GLFW/code/src/wl/wl_init.c (58): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (60): error: use of undeclared identifier 'topDecoration'
/home/testuser/GLFW/code/src/wl/wl_init.c (63): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (65): error: use of undeclared identifier 'leftDecoration'
/home/testuser/GLFW/code/src/wl/wl_init.c (68): error: no member named 'wl' in 'struct _GLFWwindow'
 (): if (surfaons.right.surface)
/home/testuser/GLFW/code/src/wl/wl_init.c (70): error: use of undeclared identifier 'rightDecoration'
/home/testuser/GLFW/code/src/wl/wl_init.c (73): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (75): error: use of undeclared identifier 'bottomDecoration'
/home/testuser/GLFW/code/src/wl/wl_init.c (103): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (104): error: no member named 'wl' in 'struct _GLFWlibrary'
/home/testuser/GLFW/code/src/wl/wl_init.c (105): error: no member named 'wl' in 'struct _GLFWlibrary'
/home/testuser/GLFW/code/src/wl/wl_init.c (107): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (109): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (118): error: no member named 'wl' in 'struct _GLFWlibrary'
/home/testuser/GLFW/code/src/wl/wl_init.c (123): error: no member named 'wl' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/wl/wl_init.c (125): error: no member named 'wl' in 'struct _GLFWlibrary'
/home/testuser/GLFW/code/src/wl/wl_init.c (126): error: no member named 'wl' in 'struct _GLFWlibrary'
/home/testuser/GLFW/code/src/wl/wl_init.c (128): error: no member named 'wl' in 'struct _GLFWlibrary'
/home/testuser/GLFW/code/src/wl/wl_init.c (136): error: no member named 'wl' in 'struct _GLFWlibrary'




With MESA flag:

/home/testuser/GLFW/code/src/mesa/null_window.c (36): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/glfwlib.c (47): In file included from /home/testuser/GLFW/glfwlib.c:47: (): window->null.width = wndconfig->width;
/home/testuser/GLFW/code/src/mesa/null_window.c (37): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/mesa/null_window.c (109): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/mesa/null_window.c (111): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/mesa/null_window.c (116): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/mesa/null_window.c (117): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/mesa/null_window.c (133): error: no member named 'null' in 'struct _GLFWwindow'
/home/testuser/GLFW/code/src/mesa/null_window.c (135): error: no member named 'null' in 'struct _GLFWwindow'



These are the errors I've encountered.


Re: GLFW Package [message #55715 is a reply to message #55714] Wed, 02 December 2020 12:16 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Thanks, this is what I was expecting
Re: GLFW Package [message #55743 is a reply to message #55715] Sun, 06 December 2020 21:33 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1085
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Xemuth,

Here is my graphic card information:
GL_VERSION: 4.6 (Compatibility Profile) Mesa 20.2.3
GL_RENDERER: Radeon RX 580 Series (POLARIS10, DRM 3.39.0, 5.9.11-3-MANJARO, LLVM 11.0.0)
GL_VENDOR: X.Org
GLU_VERSION: 1.3
GLUT_API_VERSION: 4
GLUT_XLIB_IMPLEMENTATION: 13

KDE Plasma 5.20.4 X11


I hope it helped.

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 06 December 2020 21:34]

Report message to a moderator

Re: GLFW Package [message #55781 is a reply to message #55743] Sun, 13 December 2020 03:15 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello, I have updated GLFW package, it now compile with MESA (but in my computer fail to init window, I will try to find why later).

It now also compile with Wayland but in my computer I got some linking errors. (I'm trying to find why...)
https://i.imgur.com/cYxbdwm.png

@Oblivion, if you don't mind you can try on your computer, (if you have libwayland-protocols link the code with it, it should work !)
  • Attachment: GLFW.7z
    (Size: 353.00KB, Downloaded 227 times)

[Updated on: Sun, 13 December 2020 03:44]

Report message to a moderator

Re: GLFW Package [message #55782 is a reply to message #55781] Sun, 13 December 2020 09:54 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1143
Registered: August 2007
Senior Contributor
Hello Xemuth,

A Quick try and I am getting the exact same linker errors with Wayland on ArchLinux (I have wayland-protocols already installed). (I'll have time to investigate it tonight...)

Best regards,
Oblivion


Re: GLFW Package [message #55783 is a reply to message #55782] Sun, 13 December 2020 15:06 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello Oblivion, Thanks for trying !
don't lose your time on this if you don't have so much ! I have asked about this problem on StackOverflow.
If nobody know then I will ask to GLFW community directly, I'm suspecting a problem from glfw (after all, all wayland file are marked 'unstable') maybe it can't be compiled using wayland at this time.
Previous Topic: bazaar -> UppHub
Next Topic: Flatbuffers package
Goto Forum:
  


Current Time: Sat Dec 14 13:37:52 CET 2024

Total time taken to generate the page: 0.03370 seconds