Enthused_Dragon's picture

Loading Textures without SDL?

I want to use this function to load textures.
But I'm getting an error that img->pixels is void* and cannot be converted into IntPtr.
And when I do set it to System::IntPtr(img->pixels) I get a ton load of unresolved externals.
Any help?
Code here at bottom.
I'll leave comments where I'm having trouble.

//load the filename textures (only BMP, R5G6B5 format)
unsigned int objloader::loadTexture(const char* filename)
{
	unsigned int num;
	GL::GenTextures(1,&num);
	SDL_Surface *img = SDL_LoadBMP(filename);
	GL::BindTexture(TextureTarget::Texture2D,num);
	GL::TexParameter(TextureTarget::Texture2D,TextureParameterName::TextureMinFilter,1);
	GL::TexParameter(TextureTarget::Texture2D,TextureParameterName::TextureMagFilter,1);
/*HERE*/GL::TexImage2D(TextureTarget::Texture2D,0,PixelInternalFormat::CompressedRgb,img->w,img->h,0, PixelFormat::Rgb,PixelType::UnsignedShort565,img->pixels);
	GL::TexEnv(TextureEnvTarget::TextureEnv,TextureEnvParameter::TextureEnvMode,(float)1.0);       //maybe just this
	SDL_FreeSurface(img);
	texture.push_back(num);
	return num;
}

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture
Enthused_Dragon wrote:

And when I do set it to System::IntPtr(img->pixels) I get a ton load of unresolved externals.
Any help?

This means that you are not correctly linking against libsdl. Are you using a specific binding like cs-sdlor are you consuming sdl directly (i.e. #include "SDL.h")?

Alternatively, you can use System.Drawing.Bitmap to load images without going through sdl. There is example code on this site and in the OpenTK release zip.

Enthused_Dragon's picture

Thanks I'm going to try and use it without SDL.
Yea I only included SDL.h