Re: [PyOpenGL-Users] OpenGL textures
Brought to you by:
mcfletch
From: altern <al...@gm...> - 2007-03-29 17:27:16
|
thanks andrew, i dont know how i did not find this myself, i was looking in wxBitmap class for this type of function. still i dont get the images properly displayed. I can see it has similar colors as the original but it is heavily pixelated. Is there any difference in the format of the image data array itself between wx and pygame? Andrew Wilson(e)k dio: > Hello, > You may want to try, > > bin = image.GetData() > > > Thanks > andrew > > > > On 3/29/07, *altern* < al...@gm... <mailto:al...@gm...>> wrote: > > hi > > I am trying to translate a pygame+opengl application to wx+opengl. > And I > am stuck at the function to import images to create OpenGL textures. > > I already asked for help on the wxpython list, but nobody seemed to be > interested on my problem, so i thought there might be some wx-pyopengl > users in the pyopengl list. > > This is the pygame code: > > surface = pygame.image.load(path) > if surface.get_alpha is None: > surface = surface.convert() > else: > surface = surface.convert_alpha () > bin = pygame.image.tostring(surface, "RGBA", 1) > w, h = surface.get_width(), surface.get_height() > textid = glGenTextures(1) > glBindTexture(GL_TEXTURE_2D, textid) > gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE, > bin) > ... and so on ... > > and this is the wx code i am using : > > image = wx.Image(path, wx.BITMAP_TYPE_ANY, -1) > bin = image.ConvertToBitmap() > w,h = image.GetWidth(), image.GetHeight() > textid = glGenTextures(1) > glBindTexture(GL_TEXTURE_2D, textid) > gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE, > bin) > ... etc ... > > It doesnt crash but the texture that OpenGL displays in not at all the > image i am importing but some weird random colors. I guess this is the > bit that i am missing, since printing "image.ConvertToBitmap()" returns > a wxBitmap instance and not the image data > bin = pygame.image.tostring(surface, "RGBA", 1) > > I have been trying to find out how to access the data an looking for > examples on the net but did not find anything. > > any tips? thanks! > > enrike > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net <http://pyopengl.sourceforge.net> > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > <mailto:PyO...@li...> > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > |