Duncan,
Have you tested image.fail() to see whether there was an error accessing the file, and what sort of error it was?
Phil.
Sent from Mail for Windows
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/b39d7665-fca3-4041-b5ce-16fba6581470n%40googlegroups.com.
I've spent hours staring at the stb_image version, I've used Mac/Preview toconvert the file to PNG and tried that instead, so I must be missing the obvious.Could anyone point me in the right direction, or at a working example on github,other than mcleary's pbr which is waaay too complicated for me at this stage,or even show how to create an OpenGL3 texture using the Fl_Image interface?
>2. The directory where CLion/CMake runs the executable is not the current> source directory, so neither stb_load nor Fl_*_Image could find the fileThis one keeps biting me too !!!
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/3C5B46A5-6297-4C8A-BF64-27B47D1BEC07%40gmail.com.
You can figure out a Unix executable from argv[0] and $PATH.
However on Linux itself there is a really nice shortcut, in /proc/self/exe is a symbolic link to the actual executable. Use readlink() to convert it. You need to run readlink() recursively if your purpose is to find the directory the executable is in.
Pretty sure on Linux and MacOS you can use realpath(3) on argv[0] to get the
absolute path to the running binary. e.g.#include <stdlib.h> // realpath()
#include <stdio.h>
int main(int argc, char *argv[]) {
// Get absolute path to self
{
const char *self = realpath(argv[0], NULL);
printf("realpath(%s) is %s\n", argv[0], self);
free((void*)self); // free string realpath() returned
}
return 0;
}
So for instance if I build that in /var/tmp and run it with ./foo, I get:
LINUX: realpath(./foo) is /var/tmp/foo
MacOS: realpath(./foo) is /private/var/tmp/foo
Which shows the real path to the binary, with symlinks followed and expanded,
and prevents any . and .. nonsense.
Read the manpage carefully for this POSIX function, esp. any caveats or bugs.
(Had to once go very deep down the realpath(3) rabbit hole once before researching STR #3441)
>2. The directory where CLion/CMake runs the executable is not the current> source directory, so neither stb_load nor Fl_*_Image could find the file
The official CMake docs have been updated to include a BUNDLE example
so that you can define which files are resources or assets that need to becopied into the cmake-build hierarchy as shown in the example below.
[ . . .]
Not sure what I have to do for the final install to run outside of CLion/CMakeon Linux and Windows will work yet. I'll cross that bridge when I get there.