By bestguigui
Date 2011-02-01 19:10
Edited 2011-02-02 19:47
Great work ! Thanks !
By the way, I found a quick and easy way to solve the texture repetition and croping problem :
require "rubygems"
require "gosu"
require "opengl"
include Gl, Glu
class GLTexture
# GOSU IMAGE -> OPENGL TEXTURE FIX
# SOLVES PROBLEM WITH REPETITION / CROPING
def initialize(p_win, filename)
gosu_image = Gosu::Image.new(p_win, filename, true)
array_of_pixels = gosu_image.to_blob
@texture_id = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, @texture_id[0])
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gosu_image.width, gosu_image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, array_of_pixels)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
gosu_image = nil
end
def get_id
return @texture_id[0]
end
end
That way I can easily get a proper texture id and use it in an OpenGL drawing. All that thanks to your new method, Gosu::Image#to_blob ! So, again, thank you !