Loadtexture

Blitz3D Forums/Blitz3D Beginners Area/Loadtexture

Farflame(Posted 2005) [#1]
Strange one this. I'm loading in my textures from a folder - working fine. But I just put some pictures into the same folder (also in jpg format) and it won't load them. They're not true 'textures', just pictures that I put in for fun. I've done this before without problems.

Is there something about loadtexture that I don't understand? Surely it will load any graphic?


GfK(Posted 2005) [#2]
loadtexture will load anything in JPG, BMP or PNG format.

Your problem is most likely elsewhere. You need to be more specific with the error message you're getting, i.e. "they're not true textures" isn't a blitz error message.


Farflame(Posted 2005) [#3]
Yes you're right, sorry. And yes, it's definately a problem elsewhere, because I've now brought some other 'true' textures into the folder and it won't load them either.

What's happening is, it's loading the texture, but then when it tries to apply the texture with EntityTexture, I get a 'Texture does not exist' error. This would make some kind of sense, but it works on some textures and not on others. They're all in the same folder, and I'm definately spelling them correctly.

Only thing I can think of is that I've recently moved over to XP. Could the files be altered somehow? Still odd though, because I moved the whole folder(s) at the same time.


GfK(Posted 2005) [#4]
I suspect you're using absolute pathnames. This would explain why they worked on Win98/ME, but not on XP.

Other possibility is that you're setting graphics mode AFTER loading the textures.

You might have to post some code.


Farflame(Posted 2005) [#5]
Well, I am using pathnames, but only relative to the program. Here's the bit that's causing probs.

texture=LoadTexture("gfx/mercury.jpg")
For f=1 To NumberEntities
cube(f)=CreateCube()
EntityTexture cube(f),texture
Next

The bizarre thing is, if I replace the word 'mercury' with 'wood', it works. Wood and mercury are just two basic textures I have in the same folder, both jpg's. I have just added the mercury texture to the folder, so I can only assume something has happened to the folder system or something.


GfK(Posted 2005) [#6]
try putting 'DebugLog texture' after the line where you do the LoadTexture. It'll either show a pointer to the texture if its loaded, or 0 if it hasn't.


Farflame(Posted 2005) [#7]
Yes, well that's narrowed it down a bit. When I use the wood texture (which works), I do get a valid number, but when I use the ones which don't work, I get a zero. Which, presumably, means there's something wrong with them?

Odd thing is, they were all working before I moved over to XP. Ummmmmm. How could I check if they're faulty or whatever?


GfK(Posted 2005) [#8]
most likely problem is that you've got the path or filename wrong. i don't know of any other issue that would stop a jpeg from loading with loadtexture, other than its an unsupported format such as TIFF that's just been renamed to JPG.


Farflame(Posted 2005) [#9]
That's why it's weird. I can't possibly have the pathname wrong, because it's in the same folder. And I've checked 50 times that I've spelt 'mercury' properly (and besides, most of the others don't work, including one named 'ba'). And those texture loaded in fine before, and were never another format.

Something has to be corrupt in the files or something I guess. I can't think how I can resolve this :(

Interestingly, when I changed 'loadtexture' to 'loadimage', it loads them in properly as images :/


Farflame(Posted 2005) [#10]
Can anyone else think of ANYTHING that could be causing this? If an image loads in under loadimage, shouldn't it also load in under loadtexture?

I do have a new computer with one of these PCI Express cards. It's running games fine, but maybe Blitz doesn't recognise something about it?


big10p(Posted 2005) [#11]
Can you post the mercury.jpg here so we can investigate?


Ross C(Posted 2005) [#12]
Or, post the code and images that are causing problems.


Sledge(Posted 2005) [#13]

Can anyone else think of ANYTHING that could be causing this? If an image loads in under loadimage, shouldn't it also load in under loadtexture?



Are their width and height (i)powers of two and (ii)within the ranges your card can accept? Yes yes, Blitz is supposed to pad out wrongly-sized textures, but that didn't stop it failing to texture a b3d that someone once had problems with because the texture sizes weren't correct. Check your dimensions... at the very least you'll have ruled something else out.


Farflame(Posted 2005) [#14]
I just tried out the program on another PC, running XP and using the same bunch of textures, all in the same folder setup. It works fine, with ALL of the textures.

No, the textures aren't all powers of two (I didn't even know that was necessary for textures), but it doesn't seem to bother the other PC. Some of them are just large pictures, and most are rectangle. The wood one IS square, so I thought that might be part of the problem, but some of the square ones are failing too.

My graphics card should certainly accept it because it's a very good card - a Geforce 6600 GT. The only thing that I know about this card, apart from the fact that it's a pretty good one, is that it's a PCI Express card, which is apparently a new 'family' of cards - newer than the AGP cards.

I'm starting to suspect that Blitz simply isn't communicating properly with this card?

And before anyone asks, yes, I've updated the drivers a couple of weeks ago.

I'll happily put the texture up if anyone thinks it's worthwhile, but I'm certain now that that can't be a problem. Let me know how to attach a file if someone wants to see it.


Ross C(Posted 2005) [#15]
I think the size might be a problem too. WHat are the dimensions of the troublesome texture?


Ross C(Posted 2005) [#16]
The reason i'm thinking that, is you say it loads it fine as an image, so the dimensions must be buggering it in. Mind as well, blitz always scales up the texture i'm sure.


Farflame(Posted 2005) [#17]
Hmmm, well it doesn't seem to be the size, it seems to be the shape. Basically, it IS loading in anything that's square, but nothing that's rectangle, regardless of size. Which totally screws up most textures. Bearing in mind that I have a brand new 3d card, an expensive one at that, I can't say I'm happy.

Is this something that could be fixed in Blitz or am I screwed?


Ross C(Posted 2005) [#18]
it depends how your viewing the textures too mind. If you apply a texture to a square sprite, the texture will appear to be square. Blitz will auto resize the textures so the width and height and power of 2 numbers such as...

1,2,4,8,16,32,64,128,256,512,1024...etc etc

It always scales up. Post the textures that are giving you hassle, or email me them and i'll stick them on my webspace for a bit. Mind and don't email me them in .bmp format. People have done that before :D


Farflame(Posted 2005) [#19]
Well, on my other PC, Blitz has no problems with them whatsoever, regardless of shape or size. Even the rectangle ones, it just scales them onto the shape. It doesn't matter if it's cubes or spheres or irregular objects - never had any problems at all.

Now all of a sudden on this PC, it can ONLY handle squares with a height/width to a power of 2 :/


Sledge(Posted 2005) [#20]

I can't say I'm happy.

Is this something that could be fixed in Blitz or am I screwed?




Now all of a sudden on this PC, it can ONLY handle squares with a height/width to a power of 2 :/



I doubt it's Blitz. Opting for square textures has always been the safe way for developers to ensure compatibility across the widest range of cards - PCIE* is pretty new so maybe the drivers are unambitious and future revisions will be able to handle rectangles? If you're thinking commercially I'd stick with what's safest anyway... there are a number of quirky cards out there (thinks back to the 3DFX card that displayed total texture garbage from Blitz unless it was reset to its factory defaults).



*Or is it PCI-X? [No, it isn't, idiot. -Ed]


Farflame(Posted 2005) [#21]
Well, very strange indeed. You'd think a brand new style of card would be BETTER than older cards, but maybe it's some kind of strategy to get everyone to use squares or something (they're faster?)

Either way, it's not a commercial issue, and if I ever try to add 3d stuff to my commercial ventures, at least I know now to go with square textures.

Goddam PC's, I'm going back to my Spectrum :(


jfk EO-11110(Posted 2005) [#22]
btw did you try to load them as Images, using LoadImage() ?

And you don't need to use square textures in blitz, but the width and height needs to be "powers of two", aka 2,4,8,16,32,64,128,256,512,1024 while width and height don't have to be the same.

I still think it's some kind of unsupported JPG format. Maybe it's even Windows that thinks the JPG is a virus...

Suggestion: convert the JPGs to BMP and try to load them.


Farflame(Posted 2005) [#23]
Unfortunately, converting them to BMP's doesn't work either :(

Yes, they all load using LoadImage().

As I say, the exact same files work perfectly on my other computer which has a GF4 card. On that computer, Blitz seems happy to load any graphic in as a texture, regardless of size or shape (they're not powers of two). Unfortunately, I did all of my work on that computer, so wasn't aware of these limitations, so most of my textures are now obsolete.


Crazy4Code(Posted 2005) [#24]
Well, about the graphics card, I recently bought a new one and was having trouble with it for months. I won't go into the problem details, but it was fixed by downloading older drivers. The only thing I can think of is to download older drivers.


tonyg(Posted 2005) [#25]
Farflame, Could it be this...
Here


Farflame(Posted 2005) [#26]
Yes, it does seem to be the same thing. Luckily, the 3d projects were mainly learning projects and hadn't become commercial ideas yet, so it's more of an annoyance than anything. Hopefully something will be fixed in the future, either to make Blitz recognise this, or in the card drivers themselves.

The only thing that slightly concerns me is that I am programming a different project, which I do hope to go commercial with. It doesn't use 3d at all, but this has got me worried that there may be all sorts of issues out there that I'm not aware of.


Farflame(Posted 2005) [#27]
This one has been resolved when I recently upgraded to the latest version of Blitz. Because I'm using a new computer, I'd just installed Blitz from the CD's and hadn't yet put the latest versions in. Doh! Presumably it was noticed and fixed some time ago.

Strange thing is, now my mousexspeed() and mouseyspeed() commands don't work, but I'm sure I can figure it out......


Ross C(Posted 2005) [#28]
That might have something to do with mark changing the keyboard (and mouse?) to use the windows messaging system instead of direct input. I think you can change that back though...


Farflame(Posted 2005) [#29]
Still can't work this one out. I'm using a really simple.....

MoveMouse 400,300
TurnEntity camera,MouseYSpeed(),-MouseXSpeed(),0

.... to use the mouse to change the view. It works fine on my other computer which I haven't updated yet, but not with the new Blitz update.

Any ideas?


jfk EO-11110(Posted 2005) [#30]
you maybe need to position your flip (or vwait) command
a)
right before your two mentioned lines
or
b)
right after your two mentioned lines

:) I don't remember exactly, try both, maybe it helps.
BTW: this is a new topic and may be overseen since this thread "looks answered" because of the number of answers.


Ross C(Posted 2005) [#31]
your not giving the mousespeed anychance, because your resetting the position instantly. try it the other way round.

TurnEntity camera,MouseYSpeed(),-MouseXSpeed(),0
MoveMouse 400,300


It has the rest of the loop to move. :o)


Farflame(Posted 2005) [#32]
Thanks, that did work. I guess moving the program from my slower computer to a faster one caused timing problems (it worked fine on the slower computer, but I guess that's because it was taking longer to get from the mousemove to the turnentity commands - by the way, there were other commands between those two lines, but obviously not enough for this new computer to notice :) )