|
|
Home » Developing U++ » UppHub » GLFW Package
GLFW Package [message #55703] |
Tue, 01 December 2020 19:51 |
|
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 |
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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
|
|
|
|
|
Re: GLFW Package [message #55707 is a reply to message #55703] |
Wed, 02 December 2020 01:31 |
|
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
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 . 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 #55710 is a reply to message #55707] |
Wed, 02 December 2020 10:58 |
|
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
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 . 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 )
|
|
|
|
|
|
Re: GLFW Package [message #55714 is a reply to message #55712] |
Wed, 02 December 2020 12:07 |
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.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
|
|
|
|
Re: GLFW Package [message #55743 is a reply to message #55715] |
Sun, 06 December 2020 21:33 |
|
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
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Dec 14 13:47:29 CET 2024
Total time taken to generate the page: 0.02882 seconds
|
|
|