Okay, why isn't my PLANE being textured?
Blitz3D Forums/Blitz3D Beginners Area/Okay, why isn't my PLANE being textured?
| ||
Dear all, Just testing stuff (still) and I have a quick question; I have grabbed an image I have called TEXTURE, and I want to texture my plane with it. However, when I try to, it says that the texture doesn't exist! Can't I texture in this method, or does the graphic have to be loaded, rather than created? I've tried searching, but either return thousands or just one hit; either of which haven't helped me too much. Graphics3D 800,600,32,2 SetBuffer BackBuffer() ;2D texture stuff tex1=CreateImage(64,64) For f=0 To 250 Plot Rnd(64),Rnd(64) Next GrabImage texture,0,0 ;light light=CreateLight() ;camera cam=CreateCamera() PositionEntity cam,0,3,-5 RotateEntity cam,20,0,0 ;plane plane=CreatePlane() EntityTexture plane,texture ;player player=CreateCube() ScaleEntity player,.5,2,.5 ;main loop While Not KeyDown(1) RenderWorld Flip Wend End Sorry for being a dunce; we all start somewhere, eh! T |
| ||
Textures aren't the same as images. You create textures with CreateTexture and LoadTexture - their commands are documented in the "3D" section rather than "2D". Instead of GrabImage (there isn't a direct equivalent for textures) you'll need to use CopyRect. Or, if you're only using GrabImage for the sake of creating a random texture, you might prefer to go straight to using WritePixelFast. |
| ||
i guess me and yasha posted at about the same time...since his poat explains it better i have removed mine.... |
| ||
Lovely jubbly. Thanks, guys. This works... Graphics3D 800,600,32,2 SetBuffer BackBuffer() ;2D texture stuff tex1=CreateTexture(64,64) SetBuffer TextureBuffer(tex1) For f=0 To 250 Plot Rnd(64),Rnd(64) Next SetBuffer BackBuffer() ;light light=CreateLight() ;camera cam=CreateCamera() PositionEntity cam,0,3,-5 RotateEntity cam,20,0,0 ;plane plane=CreatePlane() EntityTexture plane,tex1 ;player player=CreateCube() ScaleEntity player,.5,2,.5 ;main loop While Not KeyDown(1) RenderWorld Flip Wend End It seems a lot of SETBUFFERing, is this method okay? T |
| ||
Nothing wrong there. As long as you remember to set the buffer back to BackBuffer() before rendering the 3D view, you can change it as much as you want. A note, though: it isn't important here, but if you want to draw in real time (ie. every frame), it's better to lock the buffer and use WritePixelFast (funnily enough, that has a buffer parameter so you don't actually need to SetBuffer, although you can anyway to make things clearer) as unlocked drawing commands like Plot can be quite slow by comparison. |