welcome to Fog-Framework mailing list.
If you want to compile Fog-Framework, you need to install cmake
(www.cmake.org/) and run script included in Fog/Util - For example
configure-windows-vs2010-x64.bat for VS2010 and 64-bit mode
compilation. You can check whether you are successful by trying one of
samples provided.
Including Fog within another projects is trivial if you know C++
tooling. The simplest way is to create new cmake project which include
compiled Fog library, or it's also possible to include Fog into your
project and to link statically. Generally the way of including Fog
depends on your project and the way you are maintaining it. Please
don't try to just add Fog files into your project, the build is not
easy because of cross-platform nature of the project (and the way how
cpu specific optimizations and handled).
After you finish all of this, there is another question. How Juce
works with raster graphics and which compatible pixel formats you can
use to map Juce<->Fog imaging. I have currently not idea of this, but
I can create some wiki pages where the information related to
interoperability with another libraries.
If you have another questions, just ask;)
Best regards
Petr Kobalicek
On Wed, Mar 7, 2012 at 7:51 PM, Donald Le Duck <andersa...@gmail.com> wrote:
> Hi Peter,
>
> First of all, thank you very much for a nice welcoming to the list! I
> am used to being yelled at when asking for help, so this was a really
> nice surprise!
You are welcome! I have no problem with helping others to start with Fog;)
> I managed to download Fog and run the script, but unfortunately I hit
> some errors when I opened the resulting .sln-file and tried to build
> (visual c++ 2008 express, win 7 32).
> These were the errors:
>
> RasterInit_C.cpp
> ..\Src\Fog\G2d\Painting\RasterInit_C.cpp(260) : error C2440: '=' :
> cannot convert from 'void (__cdecl *)(uint8_t *,const uint8_t
> *,int,const Fog::RasterClosure *)' to 'Fog::RasterVBlitLineFunc'
> This conversion requires a reinterpret_cast, a C-style cast or
> function-style cast
> ..\Src\Fog\G2d\Painting\RasterInit_C.cpp(291) : error C2440: '=' :
> cannot convert from 'void (__cdecl *)(uint8_t *,const uint8_t
> *,int,const Fog::RasterClosure *)' to 'Fog::RasterVBlitLineFunc'
> This conversion requires a reinterpret_cast, a C-style cast or
> function-style cast
>
> Am I doing something wrong here?
It was a bug and it should be fixed now, thanks!
(I'm using mainly 64-bit compilation where I was unable to catch it)
> "Including Fog within another projects is trivial if you know C++
> tooling. The simplest way is to create new cmake project which
> include
> compiled Fog library, or it's also possible to include Fog into your
> project and to link statically"
>
> - I do not know how to use cmake so the static linking option you
> mentioned sounds more realistic (even that will be a challenge with my
> limited skills!). Then I will need to compile some .obj files,
> tell the linker where they are and include one or more .h-files, is
> that correct?
Basically the way how to do static linking and dynamic linking is very
similar. I prefer dynamic linking, because you can just compile Fog
using cmake, basically you only need to create a project file and
build it, and then you can add the 'dll' library into your own
project. The only thing you need to setup is to add Fog into your
project's include directory (I think that it's -I command line option,
or use project settings in Visual Studio, look for include
directories)
> "After you finish all of this, there is another question. How Juce
> works with raster graphics and which compatible pixel formats you can
> use to map Juce<->Fog imaging. I have currently not idea of this, but
> I can create some wiki pages where the information related to
> interoperability with another libraries. "
>
> - I don't know either, but I do know that people have used AGG to draw
> paths and stuff to images in juce, so I am hoping it will be possible
> to do the same with Fog.
If people successfully used to draw using AGG then Fog shouldn't be a
problem. I'm planning to add some information to the wiki and Juce can
be nice addition;)
> All the best,
> Donald
Best regards
Petr Kobalicek
It's a lot of stuff so I try to reply as best as possible :)
1) Libraries - Fog on Windows typically compiles to Fog.dll and
Fog.lib (to include it in VS). So you need only to add this single
library into your visual studio project.
2) Include path - Fog require only one include path that points to
Fog/Src directory, all other include paths are useless, because you
always reference include files like #include <Fog/Module.h>, in your
case it would be <Fog/Core.h> and <Fog/G2d.h>.
3) Fog tutorial was on my fog-blog, but it's outdated, I'd like to
move all tutorial like things into Wiki on project page. I'm sorry
about this, I did large refactorization after the tutorial has been
written.
4) ssize_t - it's quite problem, because juce defines it differently.
This type shouldn't be a problem on non-windows platforms where it's
defined in stdint.h. I looked at Juce and the typedef there is a bit
different, I will explore this, but I think that definition in Fog
better matches MSCV compiler. I will probably fill an issue for this.
5) Doxygen - Today I worked on documentation sections so the generated
documentation should be quite okay, but many classes/functions are not
documented so you can only guess what they do (the naming should be,
however, straightforward).
6) Imaging/Painting stuff - Fog::Image is the way to go. If you have
Juce image in some format, you can map this image into Fog image. You
only need to fill ImageBits structure and then to call
Image::adopt(imageBits, flags). This call is used to 'adopt' data into
image container so for some time it will be shared between Juce and
Fog. Adoption is powerful, but when used incorrectly it can be also
dangerous, because if you destroy your Juce image without releasing
Fog-Image then application may crash when Fog will try to access the
data (it's basically a dangling pointer problem). I'm not sure whether
you can do the opposite, map Fog image into Juce image - in such case
it could be better, because you can use Fog to manage images and paint
into them, and Juce to blit the result on the screen (for me better
solution).
There is also solution that you can fill ImageBits and then pass it to
the Fog::Painter, in this case you don't need intermediate Fog::Image
as a container. Ideal to draw to Juce image, I think.
From the Juce documentation I think that only Fog::IMAGE_FORMAT_PRGB32
and Juce::Image::ARGB are compatible, I'm not sure about
Juce::Image::RGB, because I think that Fog uses different byte
ordering here (Fog uses always native endian byte-order).
So to use Fog::Image on top of JuceImage, you can do something like this:
// You need to fill these variables, stride means bytes per one line.
uint32_t width;
uint32_t height;
uint32_t format;
ssize_t stride;
uint8_t* data;
Fog::Image fi;
err_t err = fi.adopt(Fog::ImageBits(Fog::SizeI(width, height), format,
stride, data));
if (FOG_IS_ERROR(err))
{
// Something failed.
}
or create a painter:
Fog::Painter p(fi);
// ... painting.
p.end();
7) I fixed some warnings you posted, but I think that some wrong
warning options are set during a compilation. For example MSVC
shouldn't complain about 'override' keyword and stuff which comes from
C++0x.
8) I'm from Zlin, it's in the opposite side of Czech Republic as Prague:)
I hope that some my hints can help you to solve your problems, I will
look at ssize_t issue. Write here about your progress :)
Best regards
Petr Kobalicek
I'm sorry for slow reply, I completely forgot about this thread.
Your code seems to be valid, please check for error code returned by
Image::adopt() and Painter::begin() (you can use Painter::begin()
instead of constructor to be able to get possible error). For me it
seems strange that you have bitmap and juce graphics context at the
same time on the image.
I would try to simplify the code, for example:
// Fill the background with red color
g.setColour(Colours::red);
g.fillAll();
// Create a juce image
int width = 100;
int height = 100;
Image im(Image::ARGB, width, height, true, SoftwareImageType());
Image::BitmapData bmp(im, 0, 0, width, height, Image::BitmapData::readWrite);
// Create a fog image, adopt the pixel data from the juce image
uint32_t w = width;
uint32_t h = height;
uint32_t format = Fog::IMAGE_FORMAT_PRGB32;
juce::ssize_t stride = bmp.lineStride;
uint8_t* data = bmp.getLinePointer(0);
Fog::Image fi;
err_t err = fi.adopt( Fog::ImageBits(Fog::SizeI(width, height),
format, stride, data));
if (FOG_IS_ERROR(err))
{
printf("Error %u in Fog::Image::adopt()\n", err);
}
// Fill the image with a new color
Fog::Painter p;
err = p.begin((fi);
if (FOG_IS_ERROR(err))
{
printf("Error %u in Fog::Paiter::begin()\n", err);
}
p.setSource(Fog::Argb32(0xAAFF0066));
p.fillAll();
p.end();
// Here I'm not sure about juce Image::BitmapData, I think
// that it should be destroyed before im is used.
// draw the image on the background
g.drawImageAt(im, 0, 0);
Hope that helps.
Best regards
Petr Kobalicek
I tried to reproduce the issue with empty painter constructor, but I
didn't have a luck. Could you try the latest SVN version so we are
sure that we are using the same?
I'd like also to try to isolate the code which paints using Fog into
one function so we will be sure that all states are correct, for
example try moving painting code to one function:
// --------------------------------------
static void paint(juce::Image& jImage)
{
// Juce stuff.
int width = jImage.getWidth();
int height = jImage.getHeight();
Image::BitmapData jBitmap(jImage, 0, 0, width, height,
Image::BitmapData::readWrite);
// Create Fog::Image which adopts juce image.
uint32_t fFormat = Fog::IMAGE_FORMAT_PRGB32;
Fog::Image fImage;
err_t err = fi.adopt( Fog::ImageBits(Fog::SizeI(width, height),
fFormat, jBitmap.lineStride, jBitmap.getLinePointer(0)));
if (FOG_IS_ERROR(err))
{
printf("Error %u in Fog::Image::adopt()\n", err);
return;
}
// Create Fog::Painter.
Fog::Painter p(fImage);
p.setSource(Fog::Argb32(0xFF000000));
p.fillAll();
// Here everything will be destroyed in correct order, juce image
should contain the painting.
}
// --------------------------------------
It's also possible to skip creating Fog::Image if you plan to use it
only for painting, for example this should work like the previous
sample:
// --------------------------------------
static void paint(juce::Image& jImage)
{
// Juce stuff.
int width = jImage.getWidth();
int height = jImage.getHeight();
Image::BitmapData jBitmap(jImage, 0, 0, width, height,
Image::BitmapData::readWrite);
uint32_t fFormat = Fog::IMAGE_FORMAT_PRGB32;
// Create Fog::Painter.
Fog::Painter p;
p.begin(Fog::ImageBits(Fog::SizeI(width, height), fFormat,
jBitmap.lineStride, jBitmap.getLinePointer(0)));
p.setSource(Fog::Argb32(0xFF000000));
p.fillAll();
// Here everything will be destroyed in correct order, juce image
should contain the painting.
}
// --------------------------------------
Hope that helps, I'd like to solve this so you can continue trying Fog:)
Best regards
Petr Kobalicek
Hi guys.
See the attached source code and binary demo files for (win32 x86 Net4).
I googled for some code project that allow bindings from Fog to C#, but found none, so I cooked one up -- hope ya don't mind.
private void timer_Tick( object sender, System.EventArgs e ) {
x++;
gfx.Draw( x, y );
this.Invalidate(); // trigger
}
Petr --- your Fog library is awesome. I can't wait for new features and optimization.
I'm very sorry that this issue is still not yet resolved. To be
honest, I have no idea why it happens, I tried to reproduce, but no
luck. There is however one thing we can test. What kind of linking do
you use? Static linking or dynamic linking? If you are using static
linking then there is one C++ issue which can be fixed by calling
_fog_init_static() in your application`s main().
Hi Petervy,
I tried the demo and it looks nice, thanks for this effort. When I get
more free time I'd like to start working more on wiki so it wouldn't
be so hard to make Fog working or to use it from different language.
Best regards
Petr Kobalicek
Thanks for sharing.
Jerry
we should go deeply here so I will try to explain the issue and the
solution. If you are using static linking then it means that Fog is
compiled statically. Static linking is different to dynamic linking
and C++ compiler tries to remove all code which "it thinks" is not
used. The code removal is based on .cpp files where no function was
called by your application. The problem is that Fog contains one entry
point which is needed to initialize the library so you are able to use
it. Without calling _fog_init_static() the initialization won't
happen, this means that any call to exported Fog function (not inlined
function) will fail due to null pointer exception (access violation).
The solution for static linking is to define one dummy function used
in Init.cpp which you call through your code - this ensures that C++
compiler won't remove the initialization process, because you used
(referenced by _fog_init_static() call) the .cpp module where the
initialization happens.
So the problem here is, I think, that Fog things that it's build
dynamically, but it's not. You can try to add -DFOG_BUILD_STATIC
argument to cmake so Fog will know that it's statically linked.
BTW: The best thing to ensure whether everything is okay is to build
Fog and examples using standard way (scripts in Util directory). If
you can successfully build Fog this way and examples work then you
should concentrate on building your app.
Best regards
Petr Kobalicek
Ensure the following options are set for both FOG and JUCE:
1. Configuration Properties >> General >> Configuration type
Application (.exe) for JUCE if this contains main() or equivalent
Static Library for FOG if you have defined
-DFOG_BUILD_STATIC=1
2. Configuration Properties >> General >> Character set
should be either MBCS or UNICODE for *both*
3. Configuration Properties >> C++ >> Code Generation >> Runtime library
For static linking of Fog and Juce select multi-threaded debug.
4. Make sure the JUCE project is dependent on FOG.
Right-click in Solution Explorer, select Project dependencies and tick
the right box.
Then clean everything out and rebuild.
If this fails post the output from the project as it builds.
Good luck.
On 31/03/2012 17:23, Donald Le Duck wrote:
> Jerry - Win 7 32 bit Visual C++ 2008 express.
>
> Petr - I added "-DFOG_BUILD_STATIC=1" to the file configure-windows-
> vs2008-x86.bat and ran it. Opened the generated Fog solution, it
> contained Fog, ALL_BUILD and ZERO_CHECK. Built the solution, got some
> warnings. One in particular looked sinister:
>
> Painter.obj : warning LNK4221: no public symbols found; archive member
> will be inaccessible
>
> Opened the other solution with my test application, tried to build it
> but it now failed:
>
> 1>Linking...
> 1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall
> type_info::type_info(class type_info const&)" (??
> 0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
> 1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info
> & __thiscall type_info::operator=(class type_info const&)" (??
these warnings are fine - files they point to are empty for now.
Changing Fog to multibyte shouldn't be a problem, but it's year 2012,
so I don't think you want an application without proper unicode
support:) Fog uses WinAPI functions with 'W' suffix everywhere so I
don't think this should be a problem. Btw is there an option to build
juce with unicode support?
I'm included an attachment where is a cmake project which includes Fog
and adds one executable linked statically with Fog. I tested it now
and it works fine for me. Included are also various 'cmake' scripts
for simplicity.
password to the archive is 'fog' without single quotes (google doesn't
allow to post zip files including shell scripts, so I encrypted it).
Best regards
Petr Kobalicek
You do not (and should not) alter any linker/librarian flags. It is
still impossible to know what is happening unless you attach the build
log for the entire solution.
Zip *all* the source code in the most compact form possible. Ensure no
binary files. Attach and send to me:
ipp _encircled_A_ chordia _dot_ co _dot_ uk