vurtun / nuklear

A single-header ANSI C gui library
13.67k stars 1.11k forks source link

Dependence on GLEW seam problematic #68

Closed chmike closed 7 years ago

chmike commented 8 years ago

To compile the example on Ubuntu 15.10 one has to install the libglew-dev and libglfw3-dev packages. $ sudo apt-get install libglew-dev libglfw3-dev. Of course you also need the C compiler gcc and associated development libraries.

To compile you have to be in the example directory and execute make, and to run examples you have to be in the bin directory created by the compilation if everything worked fine. $ cd nuklear/example && make && cd bin && ./extended

It works but fonts seam out of focus and difficult to read. Can this be fixed ?

vurtun commented 8 years ago

I can remove the GLEW dependency no problem but GLFW is required for the glfw demo :). I will probably use https://github.com/skaslev/gl3w for OpenGL bindings. I also have a pure linux demo (not polished for release) without any dependencies outside Xlib if wanted.

As for compiler you can use either gcc or clang (just have to call make with either argument 'clang' or 'gcc' to select the correct compiler. So gcc is not a must but a compiler is.

It works but fonts seam out of focus and difficult to read. Can this be fixed ?

I will look into it and see what I can do.

chmike commented 8 years ago

I have tested imGUI and I can change the size of the font to get an acceptable font size. In my case droid 18.0 was good. I looked into the extended.c source file and apparently the font size is set to 18.0. May be it's because it's not a true type font ? 

vurtun commented 8 years ago

The main reason why it is blurry was because I did not add oversample for the default font and used the wrong font height. It hopefully is now fixed at least for the standard height.

jimon commented 8 years ago

Honestly I don't see why we even need GLEW dependency here, I've tried compiling demos on OSX and we use gl3.h there - it works perfectly. For other *nix and windows it's should be fine to use glXGetProcAddress and wglGetProcAddress. I mean we only need a dozen gl functions to begin with, so it's not a big deal to just hardcode this.

vurtun commented 8 years ago

Personally I see no problem directly pulling all relevant functions (an old x11_opengl demo did exactly that). The reason why I removed it and didn't do it for all the other demos however was because I wanted to keep main.c as short as possible for all demos. So in this instance the question is should I have an additional dependency and keep main.c short or directly pull in everything and make main.c more complex but have no dependency?

jimon commented 8 years ago

IMHO if it's 50-100 LOC (and probably it is) - maybe just pull it in? We are already depend on glfw/sdl/etc to get most of OpenGL context creation for us.

dumblob commented 8 years ago

Well, if it's really so short (50-100 LOC), we should consider pulling it in. But under the condition, that it'll be explicitly emphasized in the source code, that the new 50-100 LOC can be easily substituted.

vurtun commented 8 years ago

I am working on a example version to show how much it takes. I am also adding a compiler flag to remove extension loading if not wanted.

vurtun commented 8 years ago

OK. I added an example in directory demo/x11_opengl3 which shows how a OpenGL demo would roughly look like without GLEW dependency.