From: Alexandro Kez Date: 2009-12-08T01:05:07+09:00 Subject: Re: Reading Images Ok, here's the code. I'm just trying to load it and put on a quad. 500 and 500 are the original width and height of pic. name = GL.GenTextures(1); data = File.open("grass.jpg", "rb") {|io| io.read} GL.PixelStorei(GL::UNPACK_ALIGNMENT, 1); GL.BindTexture(GL::TEXTURE_2D, name[0]); GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_S, GL::CLAMP); GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_T, GL::CLAMP); GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER,GL::NEAREST); GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER,GL::NEAREST); GL.TexImage2D(GL::TEXTURE_2D, 0, GL::RGBA, 500, 500, 0, GL::RGBA, GL::UNSIGNED_BYTE, data.unpack("C*")); GL.BindTexture(GL::TEXTURE_2D,name[0]); GL.Begin(GL::QUADS); GL.TexCoord(0.0, 0.0); GL.Vertex(-20.0, 0.0, -20.0); GL.TexCoord(0.0, 1.0); GL.Vertex(-20.0, 0.0, 20.0 ); GL.TexCoord(1.0, 1.0); GL.Vertex(20.0, 0.0, 20.0 ); GL.TexCoord(1.0, 0.0); GL.Vertex(20.0, 0.0, -20.0 ); GL.End(); The error I get: Length of specified data doesn't correspond to format and type parameters passed. Calculated length: 1000000 (ArgumentError) As I think it may be due to the fact it contains more data, like width and height in itself and the datatypes, just don't get it. By the way, if I read it, it's still a string, why? Why do I have to pack/unpack? thanks to every respond -- Posted via http://www.ruby-forum.com/.