Eric Posted September 12, 2011 Share Posted September 12, 2011 How can I select and draw a portion of an Image. I have a 1024 x 1024 Image that consists of various buttons and display parts, Currently I use this code to Draw and Rotate an Image, but I am unsure how to select a section of my image to draw. Function DrawAndRotateImage(itr:TTexture, Ax:Int, Ay:Int, Sx:Int, Sy:Int, Ir:Float) glMatrixMode(GL_TEXTURE) glLoadIdentity() glTranslatef(0.5,0.5,0) glRotatef(Ir,0,0,1) glTranslatef(-0.5,-0.5,0) glMatrixMode(GL_MODELVIEW) glEnable itr.Target() itr.Bind() itr.Clamp(1,1,1) DrawRect(Ax,Ay,Sx,Sy) glDisable(GL_TEXTURE_2D) glMatrixMode(GL_TEXTURE) glLoadIdentity() glMatrixMode(GL_MODELVIEW) glScalef(1,1,1) End Function How can I add to this code to allow me to select a portion of the image. Thanks for any help. Eric Quote Link to comment Share on other sites More sharing options...
AnniXa Posted October 15, 2011 Share Posted October 15, 2011 How can I select and draw a portion of an Image. I have a 1024 x 1024 Image that consists of various buttons and display parts, Currently I use this code to Draw and Rotate an Image, but I am unsure how to select a section of my image to draw. Function DrawAndRotateImage(itr:TTexture, Ax:Int, Ay:Int, Sx:Int, Sy:Int, Ir:Float) glMatrixMode(GL_TEXTURE) glLoadIdentity() glTranslatef(0.5,0.5,0) glRotatef(Ir,0,0,1) glTranslatef(-0.5,-0.5,0) glMatrixMode(GL_MODELVIEW) glEnable itr.Target() itr.Bind() itr.Clamp(1,1,1) DrawRect(Ax,Ay,Sx,Sy) glDisable(GL_TEXTURE_2D) glMatrixMode(GL_TEXTURE) glLoadIdentity() glMatrixMode(GL_MODELVIEW) glScalef(1,1,1) End Function How can I add to this code to allow me to select a portion of the image. Thanks for any help. Eric You need the UV coordinates of the area that you want to draw, then you need the GL_TEXTURE_CORD_ARRAY state and you need to use glTexCoordPointer, and glVertexPointer and glDrawArrays to draw your image. You can use my little 2d library if you want, it gives alot of nice drawing functions, like frames of images like in blitzmax native 2d stuff, a fast image text system, and some other stuff that makes life easyer with 2d,bmx and leadwerks. PM me if you want it edit:ooops that thread is very old... Quote Whuts wroong? Link to comment Share on other sites More sharing options...
Eric Posted October 16, 2011 Author Share Posted October 16, 2011 You need the UV coordinates of the area that you want to draw, then you need the GL_TEXTURE_CORD_ARRAY state and you need to use glTexCoordPointer, and glVertexPointer and glDrawArrays to draw your image. You can use my little 2d library if you want, it gives alot of nice drawing functions, like frames of images like in blitzmax native 2d stuff, a fast image text system, and some other stuff that makes life easyer with 2d,bmx and leadwerks. PM me if you want it edit:ooops that thread is very old... Thanks... I sent you a message. Eric Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.