I'm having some real problems using SOIL in Ubuntu 14.04. I have managed to get SOIL to work in a windows environment and am porting the code from windows to ubuntu.
I am sure I have managed to get SOIL to install on my Ubuntu machine. I have the libSOIL.a and libSOIL.so files as well as SOIL.h
When I come to use my code however, it all goes wrong. This is code that I have built up incrementally so I have tested pieces of the code before moving on and adding additional functionality.
The code I am developing is very simple (really this is just a check to try and get something that works across many platforms), it just renders a 3D cube that rotates around it's centre and has a texture map. I wish to use SOIL to load the texture. Previously I have checked this all works using my own routine to load the texture, which is fine. Once I change the line that loads the texture to a SOIL function it now fails.
The code i am using is
SOIL_load_OGL_texture("/home/ubuntu/Documents/OpenGL3/OpenGL_Basic_Engine/c2_4_DrawCubeTextureAdvanced/Textures/Crate.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS);
This is the only change that has been made since the previous incarnation of this code that works.
I have made sure this file is openable by doing a simple 'fopen' and 'if{}else{}' check, and I have even installed Code::Blocks so that I have a debugger that I can step through line by line. When my debugger gets to the SOIL function and I attempt to step into the function, the programme returns a segmentation fault and quits, without even sending me to the SOIL function.
If anyone has any ideas I would be most grateful as I have been wrestling with this problem for quite a few weeks now!
Cheers
*********EDIT***********
Let's see if I can get all of the required information here now (I've had to move machines to my ubuntu one for the source code)
Firstly my code is C++ (but I think SOIL is written in C? - hence the two tags)
The failing source file is as follows:
#include "CubeTextureAdvanced.h"
#ifdef _WIN32
#include <BasicEngine\Engine.h>
#include "soil\SOIL.h"
#elif __linux__
#include "../BasicEngine/Engine.h"
#include "/usr/local/include/SOIL.h"
#include <pthread.h>
#endif
using namespace BasicEngine;
#ifdef __linux__
void junk() { //dummy procedure to allow pthread to be linked
int i;
i = pthread_getconcurrency();
}
#endif
int main(int argc, char **argv)
{
std::cout << "create new engine" << std::endl;
Engine* engine = new Engine();
engine->Init();
std::cout << "get shader manager and create programme" << std::endl;
engine->GetShader_Manager()->CreateProgram("cubeShader", "/home/ubuntu/Documents/OpenGL3/OpenGL_Basic_Engine/c2_4_DrawCubeTextureAdvanced/Shaders/Cube_Vertex_Shader.glsl",
"/home/ubuntu/Documents/OpenGL3/OpenGL_Basic_Engine/c2_4_DrawCubeTextureAdvanced/Shaders/Cube_Fragment_Shader.glsl");
std::cout << "get shader manager and get shader" << std::endl;
CubeTextureAdvanced* cube = new CubeTextureAdvanced();
int program = engine->GetShader_Manager()->GetShader("cubeShader");
if (program != 0)
{
cube->SetProgram(program);
cube->Create();
}
else
{
std::cout << "invalid program..."; std::cin.get();
}
//this is the routine that works to load textures that i wish to replace with SOIL
//unsigned int texture = engine->GetTexture_Loader()->LoadTexture("Textures\\Crate.bmp", 256, 256);
//cube->SetTexture("Create", texture);
std::cout << "use SOIL to load an OpenGL Texture" << std::endl;
FILE * pFile;
pFile = fopen("/home/ubuntu/Documents/OpenGL3/OpenGL_Basic_Engine/c2_4_DrawCubeTextureAdvanced/Textures/Crate.bmp", "r");
if(pFile != NULL)
{
std::cout << "FILE OPEN" << std::endl;
fclose(pFile);
}
GLuint Texturetmp;
Texturetmp = SOIL_load_OGL_texture("/home/ubuntu/Documents/OpenGL3/OpenGL_Basic_Engine/c2_4_DrawCubeTextureAdvanced/Textures/Crate.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS);
std::cout << Texturetmp << std::endl;
std::cout << "loaded texture" << std::endl;
cube->SetTexture("Create", Texturetmp);
std::cout << "get the models manager and set the model" << std::endl;
engine->GetModels_Manager()->SetModel("cube", cube);
std::cout << "run the programme" << std::endl;
engine->Run();
delete engine;
return (0);
}
The compile command that I'm running in terminal is:
g++ -Wall -Wextra ./../BasicEngine/Engine.cpp ./../BasicEngine/Core/Init/Init_GLUT.cpp ./../BasicEngine/Core/Init/Init_GLEW.cpp ./../BasicEngine/Managers/Models_Manager.cpp ./../BasicEngine/Managers/Scene_Manager.cpp ./../BasicEngine/Managers/Shader_Manager.cpp ./CubeTextureAdvanced.cpp ./../BasicEngine/Rendering/Models/Model.cpp ./../BasicEngine/Rendering/Texture/TextureLoader.cpp main.cpp -lglut -lGL -lGLU -lGLEW -lpthread -lX11 -lSOIL -std=gnu++11 -o main
The warnings returned are a few type qualifiers ignored
or unused parameters
. But nothing that refers to the SOIL function call or anything that alludes to a problem before then that could stop SOIL working (that i am aware of).
The other source files that may be of some help are the init_GLUT and init_GLEW files as follows:
init_GLUT:
#include "../Init/Init_GLUT.h"
using namespace BasicEngine;
using namespace Core::Init;
Core::IListener* Init_GLUT::listener = NULL;
Core::WindowInfo Init_GLUT::windowInformation;
#ifdef __linux__
Display *dpy;
Window root;
GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
XVisualInfo *vi;
Colormap cmap;
XSetWindowAttributes swa;
Window win;
GLXContext glc;
XWindowAttributes gwa;
XEvent xev;
void Init_GLUT::linuxinit()
{
std::cout << "Linux detected" << std::endl;
dpy = XOpenDisplay(NULL);
if (dpy == NULL)
{
std::cout << "\n\tcannont connect to X server\n\n" << std::endl;
exit(0);
}
root = DefaultRootWindow(dpy);
vi = glXChooseVisual(dpy, 0, att);
if (vi == NULL)
{
std::cout << "\n\tno appropriate visual found\n\n" << std::endl;
exit(0);
}
else
{
printf("\n\tvisual %p selected\n", (void*)vi->visualid); //%p creates a hexadecimal output like in glxinfo
}
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
swa.colormap = cmap;
swa.event_mask = ExposureMask | KeyPressMask;
std::cout << "end of Linux compiler directives" << std::endl;
}
#endif
void Init_GLUT::init(const Core::WindowInfo& windowInfo,
const Core::ContextInfo& contextInfo,
const Core::FramebufferInfo& framebufferInfo)
{
windowInformation = windowInfo;
//i need some fake things here
int fakeargc = 1;
char* fakeargv[] = { "fake", NULL };
glutInit(&fakeargc, fakeargv);
if (contextInfo.core)
{
glutInitContextVersion(contextInfo.major_version,
contextInfo.minor_version);
glutInitContextProfile(GLUT_CORE_PROFILE);
}
else
{
//doesn't matter in compatibility mode
glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
}
//old functions from main.cpp now using info from the structures
glutInitDisplayMode(framebufferInfo.flags);
glutInitWindowPosition(windowInfo.position_x, windowInfo.position_y);
glutInitWindowSize(windowInfo.width, windowInfo.height);
glutCreateWindow(windowInfo.name.c_str());
std::cout << "GLUT:initialised" << std::endl;
#ifdef _WIN32
//Lets add some debug capability
glEnable(GL_DEBUG_OUTPUT);
#endif
Core::Init::Init_GLEW::Init();
#ifdef _WIN32
glDebugMessageCallback(DebugOutput::myCallback, NULL);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, TRUE);
#endif
//these call backs are used for rendering
glutIdleFunc(idleCallback);
glutCloseFunc(closeCallback);
glutDisplayFunc(displayCallback);
glutReshapeFunc(reshapeCallback);
//init GLEW (can be called in main.cpp)
//clean up
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
//our method to display some info. Needs contextInfo and windowinfo
printOpenGLInfo(windowInfo, contextInfo);
}
//starts the rendering loop
void Init_GLUT::run()
{
std::cout << "GLUT:\t Start Running" << std::endl;
glutMainLoop();
}
void Init_GLUT::close()
{
std::cout << "GLUT:\t Finished" << std::endl;
glutLeaveMainLoop;
}
void Init_GLUT::idleCallback(void)
{
//do nothing, just redisplay
glutPostRedisplay();
}
void Init_GLUT::displayCallback()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0, 0.0, 0.0, 1);
glutSwapBuffers;
if (listener)
{
listener->notifyBeginFrame();
listener->notifyDisplayFrame();
glutSwapBuffers();
listener->notifyEndFrame();
}
}
void Init_GLUT::reshapeCallback(int width, int height)
{
if (windowInformation.isReshapable == true)
{
if (listener)
{
listener->notifyReshape(width, height, windowInformation.width, windowInformation.height);
}
windowInformation.width = width;
windowInformation.height = height;
}
}
void Init_GLUT::closeCallback()
{
close();
}
void Init_GLUT::enterFullscreen()
{
glutFullScreen();
}
void Init_GLUT::exitFullscreen()
{
glutLeaveFullScreen();
}
void Init_GLUT::setListener(Core::IListener* iListener)
{
listener = iListener;
}
void Init_GLUT::printOpenGLInfo(const Core::WindowInfo& windowInfo,
const Core::ContextInfo& contextInfo)
{
const unsigned char* renderer = glGetString(GL_RENDERER);
const unsigned char* vendor = glGetString(GL_VENDOR);
const unsigned char* version = glGetString(GL_VERSION);
std::cout << "*******************************************************************************" << std::endl;
std::cout << "GLUT:\tVendor : " << vendor << std::endl;
std::cout << "GLUT:\tRenderer : " << renderer << std::endl;
std::cout << "GLUT:\tOpenGl version: " << version << std::endl;
std::cout << "GLUT:\tInitial window is '" << windowInfo.name << "', with dimensions (" << windowInfo.width
<< "X" << windowInfo.height;
std::cout << ") starts at (" << windowInfo.position_x << "X" << windowInfo.position_y;
std::cout << ") and " << ((windowInfo.isReshapable) ? "is" : "is not ") << " redimensionable" << std::endl;
std::cout << "GLUT:\tInitial Framebuffer contains double buffers for" << std::endl;
std::cout << "GLUT:\t OpenGL context is " << contextInfo.major_version << "." << contextInfo.minor_version;
std::cout << " and profile is " << ((contextInfo.core) ? "core" : "compatibility") << std::endl;
std::cout << "*****************************************************************" << std::endl;
}
init_GLEW:
#include "../Init/Init_GLEW.h"
using namespace BasicEngine;
using namespace Core;
using namespace Core::Init;
void Init_GLEW::Init(){
glewExperimental = true;
if (glewInit() == GLEW_OK)
{
std::cout << "GLEW: Initialised" << std::endl;
}
if (glewIsSupported("GL_VERSION_4_5"))
{
std::cout << "GLEW Version is 4.5 :) \n";
}
else
{
std::cout << "GLEW 4.5 not supported :( \n";
}
}
Finally the contents of my SOIL.h file is as follows:
/**
@mainpage SOIL
Jonathan Dummer
2007-07-26-10.36
Simple OpenGL Image Library
A tiny c library for uploading images as
textures into OpenGL. Also saving and
loading of images is supported.
I'm using Sean's Tool Box image loader as a base:
http://www.nothings.org/
I'm upgrading it to load TGA and DDS files, and a direct
path for loading DDS files straight into OpenGL textures,
when applicable.
Image Formats:
- BMP load & save
- TGA load & save
- DDS load & save
- PNG load
- JPG load
OpenGL Texture Features:
- resample to power-of-two sizes
- MIPmap generation
- compressed texture S3TC formats (if supported)
- can pre-multiply alpha for you, for better compositing
- can flip image about the y-axis (except pre-compressed DDS files)
Thanks to:
* Sean Barret - for the awesome stb_image
* Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts
* everybody at gamedev.net
**/
#ifndef HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
#define HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
#ifdef __cplusplus
extern "C" {
#endif
/**
The format of images that may be loaded (force_channels).
SOIL_LOAD_AUTO leaves the image in whatever format it was found.
SOIL_LOAD_L forces the image to load as Luminous (greyscale)
SOIL_LOAD_LA forces the image to load as Luminous with Alpha
SOIL_LOAD_RGB forces the image to load as Red Green Blue
SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha
**/
enum
{
SOIL_LOAD_AUTO = 0,
SOIL_LOAD_L = 1,
SOIL_LOAD_LA = 2,
SOIL_LOAD_RGB = 3,
SOIL_LOAD_RGBA = 4
};
/**
Passed in as reuse_texture_ID, will cause SOIL to
register a new texture ID using glGenTextures().
If the value passed into reuse_texture_ID > 0 then
SOIL will just re-use that texture ID (great for
reloading image assets in-game!)
**/
enum
{
SOIL_CREATE_NEW_ID = 0
};
/**
flags you can pass into SOIL_load_OGL_texture()
and SOIL_create_OGL_texture().
(note that if SOIL_FLAG_DDS_LOAD_DIRECT is used
the rest of the flags with the exception of
SOIL_FLAG_TEXTURE_REPEATS will be ignored while
loading already-compressed DDS files.)
SOIL_FLAG_POWER_OF_TWO: force the image to be POT
SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
SOIL_FLAG_MULTIPLY_ALPHA: for using (GL_ONE,GL_ONE_MINUS_SRC_ALPHA) blending
SOIL_FLAG_INVERT_Y: flip the image vertically
SOIL_FLAG_COMPRESS_TO_DXT: if the card can display them, will convert RGB to DXT1, RGBA to DXT5
SOIL_FLAG_DDS_LOAD_DIRECT: will load DDS files directly without _ANY_ additional processing
SOIL_FLAG_NTSC_SAFE_RGB: clamps RGB components to the range [16,235]
SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY
SOIL_FLAG_TEXTURE_RECTANGE: uses ARB_texture_rectangle ; pixel indexed & no repeat or MIPmaps or cubemaps
**/
enum
{
SOIL_FLAG_POWER_OF_TWO = 1,
SOIL_FLAG_MIPMAPS = 2,
SOIL_FLAG_TEXTURE_REPEATS = 4,
SOIL_FLAG_MULTIPLY_ALPHA = 8,
SOIL_FLAG_INVERT_Y = 16,
SOIL_FLAG_COMPRESS_TO_DXT = 32,
SOIL_FLAG_DDS_LOAD_DIRECT = 64,
SOIL_FLAG_NTSC_SAFE_RGB = 128,
SOIL_FLAG_CoCg_Y = 256,
SOIL_FLAG_TEXTURE_RECTANGLE = 512
};
/**
The types of images that may be saved.
(TGA supports uncompressed RGB / RGBA)
(BMP supports uncompressed RGB)
(DDS supports DXT1 and DXT5)
**/
enum
{
SOIL_SAVE_TYPE_TGA = 0,
SOIL_SAVE_TYPE_BMP = 1,
SOIL_SAVE_TYPE_DDS = 2
};
/**
Defines the order of faces in a DDS cubemap.
I recommend that you use the same order in single
image cubemap files, so they will be interchangeable
with DDS cubemaps when using SOIL.
**/
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
/**
The types of internal fake HDR representations
SOIL_HDR_RGBE: RGB * pow( 2.0, A - 128.0 )
SOIL_HDR_RGBdivA: RGB / A
SOIL_HDR_RGBdivA2: RGB / (A*A)
**/
enum
{
SOIL_HDR_RGBE = 0,
SOIL_HDR_RGBdivA = 1,
SOIL_HDR_RGBdivA2 = 2
};
/**
Loads an image from disk into an OpenGL texture.
\param filename the name of the file to upload as a texture
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_texture
(
const char *filename,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 6 images from disk into an OpenGL cubemap texture.
\param x_pos_file the name of the file to upload as the +x cube face
\param x_neg_file the name of the file to upload as the -x cube face
\param y_pos_file the name of the file to upload as the +y cube face
\param y_neg_file the name of the file to upload as the -y cube face
\param z_pos_file the name of the file to upload as the +z cube face
\param z_neg_file the name of the file to upload as the -z cube face
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_cubemap
(
const char *x_pos_file,
const char *x_neg_file,
const char *y_pos_file,
const char *y_neg_file,
const char *z_pos_file,
const char *z_neg_file,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 1 image from disk and splits it into an OpenGL cubemap texture.
\param filename the name of the file to upload as a texture
\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_single_cubemap
(
const char *filename,
const char face_order[6],
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads an HDR image from disk into an OpenGL texture.
\param filename the name of the file to upload as a texture
\param fake_HDR_format SOIL_HDR_RGBE, SOIL_HDR_RGBdivA, SOIL_HDR_RGBdivA2
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_HDR_texture
(
const char *filename,
int fake_HDR_format,
int rescale_to_max,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads an image from RAM into an OpenGL texture.
\param buffer the image data in RAM just as if it were still in a file
\param buffer_length the size of the buffer in bytes
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_texture_from_memory
(
const unsigned char *const buffer,
int buffer_length,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 6 images from memory into an OpenGL cubemap texture.
\param x_pos_buffer the image data in RAM to upload as the +x cube face
\param x_pos_buffer_length the size of the above buffer
\param x_neg_buffer the image data in RAM to upload as the +x cube face
\param x_neg_buffer_length the size of the above buffer
\param y_pos_buffer the image data in RAM to upload as the +x cube face
\param y_pos_buffer_length the size of the above buffer
\param y_neg_buffer the image data in RAM to upload as the +x cube face
\param y_neg_buffer_length the size of the above buffer
\param z_pos_buffer the image data in RAM to upload as the +x cube face
\param z_pos_buffer_length the size of the above buffer
\param z_neg_buffer the image data in RAM to upload as the +x cube face
\param z_neg_buffer_length the size of the above buffer
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_cubemap_from_memory
(
const unsigned char *const x_pos_buffer,
int x_pos_buffer_length,
const unsigned char *const x_neg_buffer,
int x_neg_buffer_length,
const unsigned char *const y_pos_buffer,
int y_pos_buffer_length,
const unsigned char *const y_neg_buffer,
int y_neg_buffer_length,
const unsigned char *const z_pos_buffer,
int z_pos_buffer_length,
const unsigned char *const z_neg_buffer,
int z_neg_buffer_length,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 1 image from RAM and splits it into an OpenGL cubemap texture.
\param buffer the image data in RAM just as if it were still in a file
\param buffer_length the size of the buffer in bytes
\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_single_cubemap_from_memory
(
const unsigned char *const buffer,
int buffer_length,
const char face_order[6],
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Creates a 2D OpenGL texture from raw image data. Note that the raw data is
_NOT_ freed after the upload (so the user can load various versions).
\param data the raw data to be uploaded as an OpenGL texture
\param width the width of the image in pixels
\param height the height of the image in pixels
\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_create_OGL_texture
(
const unsigned char *const data,
int width, int height, int channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Creates an OpenGL cubemap texture by splitting up 1 image into 6 parts.
\param data the raw data to be uploaded as an OpenGL texture
\param width the width of the image in pixels
\param height the height of the image in pixels
\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param face_order the order of the faces in the file, and combination of NSWEUD, for North, South, Up, etc.
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_create_OGL_single_cubemap
(
const unsigned char *const data,
int width, int height, int channels,
const char face_order[6],
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Captures the OpenGL window (RGB) and saves it to disk
\return 0 if it failed, otherwise returns 1
**/
int
SOIL_save_screenshot
(
const char *filename,
int image_type,
int x, int y,
int width, int height
);
/**
Loads an image from disk into an array of unsigned chars.
Note that *channels return the original channel count of the
image. If force_channels was other than SOIL_LOAD_AUTO,
the resulting image has force_channels, but *channels may be
different (if the original image had a different channel
count).
\return 0 if failed, otherwise returns 1
**/
unsigned char*
SOIL_load_image
(
const char *filename,
int *width, int *height, int *channels,
int force_channels
);
/**
Loads an image from memory into an array of unsigned chars.
Note that *channels return the original channel count of the
image. If force_channels was other than SOIL_LOAD_AUTO,
the resulting image has force_channels, but *channels may be
different (if the original image had a different channel
count).
\return 0 if failed, otherwise returns 1
**/
unsigned char*
SOIL_load_image_from_memory
(
const unsigned char *const buffer,
int buffer_length,
int *width, int *height, int *channels,
int force_channels
);
/**
Saves an image from an array of unsigned chars (RGBA) to disk
\return 0 if failed, otherwise returns 1
**/
int
SOIL_save_image
(
const char *filename,
int image_type,
int width, int height, int channels,
const unsigned char *const data
);
/**
Frees the image data (note, this is just C's "free()"...this function is
present mostly so C++ programmers don't forget to use "free()" and call
"delete []" instead [8^)
**/
void
SOIL_free_image_data
(
unsigned char *img_data
);
/**
This function resturn a pointer to a string describing the last thing
that happened inside SOIL. It can be used to determine why an image
failed to load.
**/
const char*
SOIL_last_result
(
void
);
#ifdef __cplusplus
}
#endif
#endif /* HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY */
I have libSOIL.a
stored in /usr/lib
I have also tried having libSOIL.a
stored in usr/local/lib
as well, but this appeared to not help.
SOIL.h
is in usr/local/include
Hopefully this is now enough information for someone to spot my (rookie) error.
Apologies for the large amount of code.
Also credit must go to www.in2gpu.com whose tutorials I have been following to get me this far.
Cheers