Soundbomber's picture

Texture sizes

How do I scale the size of a texture?
I have the correct mapping of my texture but it is tiny, how can I make the size bigger?

        Dim iTextureID As Integer
       Dim oData As Imaging.BitmapData = Nothing
       Dim bmp As Bitmap = Nothing
       If m_bUseTextures Then
            oGL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest)
            oGL.GenTextures(1, iTextureID)
            oGL.BindTexture(TextureTarget.Texture2D, iTextureID)
            oGL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, _
                TextureMinFilter.Linear)
            oGL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, _
                TextureMinFilter.Linear)
            oGL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, _
                TextureWrapMode.Repeat)
            oGL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, _
                TextureWrapMode.Repeat)
            bmp = My.Resources.resResources.old_steel_big
            oData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), _
                Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            oGL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, oData.Width, _
                oData.Height, 0, OpenTK.Graphics.PixelFormat.Bgra, PixelType.UnsignedByte, oData.Scan0)
            oGL.Enable(EnableCap.Texture2D)
            oGL.Enable(EnableCap.TextureGenS)
            oGL.Enable(EnableCap.TextureGenT)
            oGL.TexGen(TextureCoordName.S, TextureGenParameter.TextureGenMode, _
                TextureGenMode.EyeLinear)
            oGL.TexGen(TextureCoordName.T, TextureGenParameter.TextureGenMode, _
                TextureGenMode.EyeLinear)
        End If

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

Could you draw a screenshot of what you are trying to do?

Soundbomber's picture

View1.png shows my object full size with the textures applied.
View2 shows a close up with many very small texture bitmaps instead of of one or two texture bitmaps drawn at full size and repeated.

AttachmentSize
View2.PNG241.04 KB
View1.PNG48.73 KB
objarni's picture

You should be able to multiply the texture matrix with a Scale matrix (0.1, 0.1, 0.1). At least that is my guess; I am not sure if the texture matrix is applied when you use TexGen functions, but I think so:

GL.MatrixMode(Texture);
GL.LoadIdentity();
GL.Scale(0.1, 0.1, 0.1); // or 10, 10, 10 I'm not sure which you want
GL.MatrixMode(ModelView);
Soundbomber's picture

That worked a treat, but now the texture isn't rotating a with the view. It just appears to be always rendering at a fixed point.

objarni's picture

Are you using TexGen?

Soundbomber's picture

Yes

martinsm's picture

Don't use TexGen. Specify texture coordinates manually with glTexCoord - like you specify vertex coordinates with glVertex. Or if you use VA or VBO, then use glTexCoordPointer.

Soundbomber's picture

I want to automatically generate my texture coords. My model is too complex to do it by hand.

objarni's picture

TexGen + texture matrix scaling should be possible, see for example this PDF:

http://developer.nvidia.com/attach/6750