Kfalcon's picture

Problem in UV display

Hello, I'm new to openTK but I have some experience in openGL (excluding textures)
Recently, I've been making a graphic engine for loading Re-Volt files. Theoretically the files are loaded successfully but render is messed up.
http://i.imgur.com/oi12N.png

I suspect it's an init problem.

Here is my InitGL()

 TexUtil.InitTexturing()
        Dim Width% = Form1.GlControl1.Width
        Dim Height% = Form1.GlControl1.Height
        GL.Viewport(New System.Drawing.Size(Width, Height))
        GL.MatrixMode(MatrixMode.Projection)
        GL.LoadIdentity()
        GL.Frustum(-Width / 2, Width / 2, -Height / 2, Height / 2, -1, 1)

And here is how textures are loaded

  Public Sub InitAllTextures(ByVal model As PRM)
        Textures(0) = -1 'Empty
 
        For i = 0 To 10
            If IO.File.Exists(model.Directory & model.DirectoryName & Chr(i + 65) & ".bmp") Then
                Textures(i + 1) = TexLib.TexUtil.CreateTextureFromFile(model.Directory & model.DirectoryName & Chr(i + 65) & ".bmp")
            Else
                Textures(i + 1) = -1
            End If
        Next
 
    End Sub

OnRender()

        GL.Clear(ClearBufferMask.ColorBufferBit Or ClearBufferMask.DepthBufferBit)
        GL.MatrixMode(MatrixMode.Modelview)
        GL.LoadIdentity()
 
 
 
        If Done Then myw.Render()
        GL.Flush()
 
        GlControl1.SwapBuffers()

as for myw.Render() it work like this: (Poly = triangle)

{
GL.Begin(BeginMode.Triangles)
For Each Poly {
GL.BindTexture(TextureTarget.Texture2D, Poly.Tpage)
for each vertex In Poly { //vertex count = 3
GL.Color4(vertex.Color)
GL.TexCoord2(vertex.U,vertex.V)
GL.Normal3(vertex.normals)
GL.Vertex3(vertex.position)
}
}
GL.End()

}

I'm so desperate to find an answer! It has been already two weeks and nothing was finished. I'm really grateful to any answer.

Thanks for reading


Comments

Comment viewing options

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

A common problem is that textures are upside-down when loading models, but I think you need to fix the GL error first that you are doing by calling GL.BindTexture inside begin/end block. Move it before begin?

Kfalcon's picture

Hello thanks for your answer, I forgot to mention that I have multiplied the uv map with bitmap's size, the real result look like a 1px uvmapped model.

I've tried to place BindTexture before Begin but results are same.
I am going to try to use the vertex buffer, it may work :-/ ....

Thanks again for your answer