PDA

View Full Version : Loading texture using csgl library In C#



MGS 2
11-30-2003, 03:47 PM
Hi , i was wonder how to load bmp images in C# and pass it as a pointer for GL.glteximage2d() ; for example i want to do like this :

Bitmap BMP = new Bitmap(FILE_Name);
GL.glTexImage2D (GL.GL_TEXTURE_2D ,0,4,BMP.Width ,BMP.Height ,0,GL.GL_RGBA ,GL.GL_UNSIGNED_BYTE ,&BMP );

But that not run ; please help me how to do that correctly case i need it in my project ; the latest parameter is a pointer and can,t know how to do that ; Thanks

simtap
11-30-2003, 04:54 PM
I was playing around with an engine, and I created a texture class as such. I believe that the OpenGLTexture2D function can handle various file formats.




using System;
using System.IO;
using System.Drawing;
using CsGL.OpenGL;

namespace Sage
{
/// <summary>
/// Summary description for Texture.
/// </summary>
public class Texture
{
private OpenGLTexture2D texture;

public Texture(string filename)
{
texture = new OpenGLTexture2D(filename);
}

public void Bind()
{
texture.Bind();
}
}
}


Cheers,
Brendan.

MGS 2
11-30-2003, 06:14 PM
Thanks simtap ; you saved me from long time with bugs ; i don,t know how to thanks you