An issue with texture loading

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Blue Hampster
Posts: 39
Joined: Tue Apr 29, 2008 1:41 pm
Contact:

An issue with texture loading

Post by Blue Hampster »

Hey there, I have just been taking up some more programming and having trouble already. I am developing a program that does a nice smooth 3D display of my images, but every image I load comes up really weird, as if it has been shrunk then stretched. I was wondering if anyone knew what was wrong with my code. What I have written already is this:

Code: Select all

Imports IrrlichtNETCP
Imports IrrlichtNETCP.Inheritable

Module Main
    Dim device As IrrlichtDevice

    Sub Main()
        Dim dt As DriverType = DriverType.Direct3D8
        Dim aa As Boolean = True
        Dim width As Integer = My.Computer.Screen.Bounds.Width
        Dim height As Integer = My.Computer.Screen.Bounds.Height
        Dim colourdepth As Integer = 32
        Dim img As String = "C:/mypicture.png"

        device = New IrrlichtDevice(dt, New Dimension2D(width, height), colourdepth, True, True, True, aa)

        Dim smgr As SceneManager = device.SceneManager
        Dim driver As VideoDriver = device.VideoDriver

        Dim rectangle As IrrlichtNETCP.BillboardSceneNode = smgr.AddBillboardSceneNode(smgr.RootSceneNode, New Dimension2Df(width, height), 1)
        rectangle.Position = New Vector3D(0, 0, 550)

        rectangle.SetMaterialType(MaterialType.TransparentAddColor)
        rectangle.SetMaterialTexture(0, driver.GetTexture(img))
        rectangle.SetMaterialFlag(MaterialFlag.Lighting, False)
        rectangle.SetMaterialFlag(MaterialFlag.ZBuffer, False)

        Dim camera As CameraSceneNode = smgr.AddCameraSceneNode(smgr.RootSceneNode)
        camera.Position = New Vector3D(0, 0, 0)
        camera.Rotation = New Vector3D(0, 0, 0)

        While device.Run
            device.VideoDriver.BeginScene(True, False, New Color(0, 0, 0, 0))
            device.SceneManager.DrawAll()
            device.GUIEnvironment.DrawAll()

            device.VideoDriver.EndScene()

            Threading.Thread.Sleep(50)
        End While
    End Sub
End Module
If anyone could help, that would be great :)
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

NPOT texture(s) ?!?!? :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Blue Hampster
Posts: 39
Joined: Tue Apr 29, 2008 1:41 pm
Contact:

Post by Blue Hampster »

lets pretend i dont know what they are, lol
could ya tell me which bits of the code i need to change to make it work?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Resize your textures so they are a power of two in each dimension, for example 64x128 or 256x512
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

Blue Hampster
Posts: 39
Joined: Tue Apr 29, 2008 1:41 pm
Contact:

Post by Blue Hampster »

It was already in a power of two, it was an image 1920 by 1080. Are you saying i need to double it then reload it, or do i need to change it so that the values are to the power of two (i.e. 2048x2048)?
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

unfortunately 1920 isn't, nor is 1080

http://en.wikipedia.org/wiki/Power_of_two

edit:
2048x1024 is the closest to your original format
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Blue Hampster wrote:It was already in a power of two, it was an image 1920 by 1080.
you have "Multiple Of Two" and not "Power Of Two" there !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Blue Hampster
Posts: 39
Joined: Tue Apr 29, 2008 1:41 pm
Contact:

Post by Blue Hampster »

Kk, that does help, but could you suggest any coding that could be added so that the image would appear normally?
Blue Hampster
Posts: 39
Joined: Tue Apr 29, 2008 1:41 pm
Contact:

Post by Blue Hampster »

Hold ya horses. Just put in a piece of code that resizes the image to 4096x4096. This seems to work much better than before, unfortunatly its still a bit blurred. Is there anyway of clearing up the image any more?
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

are you upscaling the images ? sounds not so good, best would be to keep a 1:1 relation... whatever...
maybe

Code: Select all

driver->setTextureCreationFlag(video::E_TEXTURE_CREATION_FLAG::ETCF_CREATE_MIP_MAPS,false);
but if the image quality is really getting any better without mipmaps depends on how far away you are from it...

video::ETCF_CREATE_MIP_MAPS would be enough, but depending on your ide, this way you can take a look at the other E_TEXTURE_CREATION_FLAG's aswell and play around a little...

http://irrlicht.sourceforge.net/docu/na ... c5bf11876f
Blue Hampster
Posts: 39
Joined: Tue Apr 29, 2008 1:41 pm
Contact:

Post by Blue Hampster »

the billboard is the same size as the picture, and then its a fixed distance from the camera with mipmaps off. Ill have a play, if anyone has any ideas what too do, then do tell, and if i get a working version, ill shout all about it
Post Reply