Jump to content
airfighter

Use part of a texture

Recommended Posts

My plan is to use a big texture with all HSI staff (rose, arc, needles, static elements, etc.) and then load each part with its own id and use it via gfx.useTexture().

Am I missing something? Or this is possible only via OpenGL? 

Edited by airfighter

Share this post


Link to post
Share on other sites

"gfx.useTexture" IS  a Gizmo API to a part of OpenGL.  Doing what you want is certain;y possible, but you will need to learn/use Gizmo/OpenGL APIs to achieve your goal.

Share this post


Link to post
Share on other sites
56 minutes ago, JGregory said:

"gfx.useTexture" IS  a Gizmo API to a part of OpenGL.  Doing what you want is certain;y possible, but you will need to learn/use Gizmo/OpenGL APIs to achieve your goal.

Probably me not been properly educated to programming, and inexperienced with Gizmo API, do not allow me to express exactly what I'm asking. I know/understand exactly what you've said. I was looking if I missed something like gfx.loadPng(..., x,y,w,h) to load part of the texture, which obviously does not exist.

As for how to do it, already I'm using this to load charts on MFD. --for testing only, clipping the edges. ;)

 

 

Edited by airfighter
Code snippet removed...was wrong, see below.

Share this post


Link to post
Share on other sites

Yes, you have to load the texture (only once, not as part of your draw function).  You load the entire texture and then use gl.TexCoord and gl.Vertex to "define" which part of the texture to use for drawing your quad.

  • Upvote 1

Share this post


Link to post
Share on other sites
5 minutes ago, JGregory said:

Yes, you have to load the texture (only once, not as part of your draw function).  You load the entire texture and then use gl.TexCoord and gl.Vertex to "define" which part of the texture to use for drawing your quad.

Right. By the way I have pasted the code from an old file, where winding is wrong (making mistakes = learning)! Here is the correct one I'm using now. Just for reference.

gl.PushMatrix()
        gl.Translate(600, 1365, 0)
        gfx.setColor(1.0, 1.0, 1.0, display_br[3])
        gfx.useTexture(chart01)
        gfx.texOn()
            gl.Begin('QUADS');
                gl.TexCoord(0.085,0.04);        gl.Vertex(0,0,0);
                gl.TexCoord(0.085,0.95);        gl.Vertex(0,500,0);
                gl.TexCoord(0.945,0.95);        gl.Vertex(375,500,0);
                gl.TexCoord(0.945,0.04);        gl.Vertex(375,0,0);

         gl.End();
         gfx.texOff()
gl.PopMatrix()

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×