3 Replies Latest reply on Nov 5, 2013 4:22 AM by _falcan0

    use SOIL (Simple OpenGL Image Library) to load textures in flascc

    seanM Newcomer

      Hi I am trying to use SOIL (Simple OpenGL Image Library) to load textures in flascc (flash c++ compiler)

      SOIL library: http://www.lonesock.net/soil.html

      I succeeded in using SOIL in C++ and openGL to load textures on windows platform (Visual studio 2008, Windows 7, 32 bit), and make it a Win32 executable. And it works.


      I now want to port my C++ code to flash using flascc ( or Crossbridge, the new name).


      SOIL library does support windows/ *nix/ osx platform.


      Flascc use linux-like environment gcc/g++ compiler, so I use the in-house cygwin/g++ to compile the code on windows platform.


      Everything compiles, except that SOIL.c use glx.h in the code, and I believe glx.h is needed since flascc wants to use libGL.a (libGL library) instead of openGL library.


      Now I get error that SOIL.c needs glx.h when compiling.


      I found a version of glx.h and included in the project but it introduces more errors.


      For example, it needs X11/xutils.h, etc.


      Seems to me X11 is the X-windows platform on Linux, but I don't know how to include those files when using cygwin on windows.


      Anyone has experience successfully using SOIL loading textures in flascc ?


      I will attach screenshots and fill in code blocks later today.

      Thank you.

        • 1. Re: use SOIL (Simple OpenGL Image Library) to load textures in flascc
          twistedjoe Newcomer

          I am not sure what you are trying to do, especially without the actuals errors, you should dump them on a pastebin and copy the link here next time.


          By look of it, you are trying to give windows/linux headers (glx for example) to flascc for libraries that simply doesn't exist in flash. You have to treat flascc as a separate target, it's not linux, it's not windows, it's not bsd. It's something else. Flascc doesn't have opengl it has stage3D, so your opengl code won't compile directly you need the GLS3D project. Which you seems to already include, but am not quite sure. This library, will abstract stage3d to your app, make it look like opengl.


          That is for opengl, but there is no flascc abstraction of x11. If your lib does need x11, you are screwed. You'll have to find something else or get dirty and write it yourself. It's not that hard though and there is plenty of tutorial about it.


          Good luck!

          • 2. Re: use SOIL (Simple OpenGL Image Library) to load textures in flascc
            seanM Newcomer

            HI Joe ( or twistedjoe),


            Thanks for your quick reply! That's fantastic and it clears much of my doubts! Sorry I am new to flascc.


            You are right, SOIL was not designed for flascc, so trying to compile it directly might be an dead end.


            I am using Freeglut so it looks like opengl/glut.


              - Freeglut 2.8.0 ported to Flash with FlasCC and Stage3D.

              - https://github.com/alexmac/alcfreeglut


            I compared my codes and those examples in the demos folder, they are mostly identical, that's why majority of functionalities can be compiled under flascc as this freeglut 2.8.0 library already did lots of the dirty work of porting to Stage3D


            Anyway, I want to find the best way to load textures in flascc, the example in demo folder of freeglut, gives a way to load .tga files as texture, however, i would like some generic way of loading images such as jpg, png or bmp, that's why I was trying SOIL and hope it is also Stage3D ready, seems like it isn't!


            So, I have two more questions:

            1. I see the freeglut library was compiled as static lib (libglut.a) using the following command:


            @$(FLASCC)/usr/bin/ar crus install/usr/lib/libglut.a src/*.o


            and then linked to flascc.


            Is it possible to do the same thing, say compile static lib ( libSOIL.a) and then link to flascc in the same way? I saw in some of previous posts in this forum, it is said


            it is possible to statically link external library to flascc, however, the external static library must be flascc -compatible


            From here:  http://support.muse.adobe.com/message/4973401

            How to compile a static library that is compatible to flascc ? ( I do have all source of SOIL library)


            2. What is the best way to load texture images ( jpg, png, bmp) in flascc ?


            Thank you so much!


            • 3. Re: use SOIL (Simple OpenGL Image Library) to load textures in flascc
              _falcan0 Newcomer

              An old thread but I'll try to answer the remaining questions anyway


              1)  Your question should probably be "how to compile a static lib", because once you got that and you got your sources - AND your sources are "cross-platform", you can compile a static lib for FlasCC out of anything. The process should be the same on all platforms with gcc (or g++). Described for example here: http://www.adp-gmbh.ch/cpp/gcc/create_lib.html


              The idea is to compile the sources into individual .o files with -c switch, then use "ar" to connect them into .a. Of course you'll need to use gcc and "ar" from the FlasCC SDK to get FlasCC compatible library. That answers the part about FlasCC compatibility. If your library comes with configure, then you might (often with only few adjustments) compile the libs using that. I was able to compile the complete ffmpeg library for FlasCC (as well as libvorbis, libtheora etc.)


              2) I think the best way is to find libraries which will load these image formats for you. There are surely lots of those. Then once you'veg to the raw image (decompressed) in memory I guess it's only a matter of converting it into the format you need for the textures. It shouldn't be that hard really.