Loading a texture?
BlitzMax Forums/OpenGL Module/Loading a texture?
| ||
How do you guys load textures? I'm having a problem using GLTexFromPixmap as it crashes trying to resize the pixmap (width and heights variables get changed when they are passed to another function - weird) anyway, are there other routes to loading textures I could take? |
| ||
I had this problem some time ago.. I can't recall what exactly solved the problem though.. Try resizing the texture to a ^2 size.. |
| ||
Texture is 512x512, and in the debugger it registers as such right until it is passed :( |
| ||
yeah.. that sounds familiar.. but could you try to resize to, say 256x256? just to try.. I'm not 100% sure what it was the last time, 'coz I tried all sorts of things.. but it's still worth a shot.. |
| ||
hang on.. try this:Method LoadTexture(file:String) Local tex:TPixmap = LoadPixmap(file) If tex self.texture = GLTexFromPixmap(tex) glBindTexture(GL_TEXTURE_2D, texture) self.CalcNormals() Else DebugLog "texture: " + file + " load fail!" EndIf EndMethod never mind the calcnormals thingy.. (unless you have a function doing that) |
| ||
Thanks Lars, unfortunately it still crashes on the same place: inside GLTexFromPixmap. The hard part is the crash is happening deep inside BRL's code, not in mine - so I'm having trouble figuring out how I'm causing it. What happens is GLTexFromPixmap gets the pixmap, and its width and height, correctly. It passes the width and height to GLAdjustTexSize(width Var, height Var) GLTexFromPixmap passes the correct values for width and height to GLAdjustTexSize, however GLAdjustTexSize receives 0 for both variables! I can't figure out how this could be caused by something in my code, since it is working for other people. (I am syncmods'd with the newest.) |
| ||
yeah... that sounds very familiar.. I'll check to see if I've got another complete texture test when I get home again..; if so, I'll post it here.. (what really drives me crazy, is that I remember it was something quite trivial, but I can't for the life of me remember what it was..) |
| ||
I've seen this happen when I messed up which framework and imports to use, it will compile and not run, with the problem in GLTexFromPixmap Double check you have a valid context, can you use gldrawtext and flip? |
| ||
Haha, I didn't have a valid context :p! Thanks Chris C! |
| ||
Its a *real* pain that one caught me out a number of times, glad I could help... |
| ||
I usually skip GlTexFromPixmap() and write my own direct OpenGL code to set up and upload texture date. You have more control of it that way. But if you just want it `as is` and don't care about the texture size or format etc then the helper function is ok. |