Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

justinwalsh

Quad based on size of texture loaded onto it?

This topic is 5232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am useing openGL for 2d application development, and see that usually a texture is loaded onto a quad, and stretched or shruken to fit the quad. How can i make it so the size of the texture determines the size of the quad? GL uses units and image formats are in pixels. I dont want much stretching takeing place... Is there a way to load a texture onto a qaud keeping the aspect the same? Do i make since? or is this really simple and i have over looked it? thanks in advance for your help.

Share this post


Link to post
Share on other sites
Advertisement
As far as I know there is no way to do what you said, automaticaly. When you load the texture you can probably easily retrieve the dimensions. Just scale your quad to those dimensions.

As for converting pixels to units, just make up an arbitary constant to mulitply by.

Share this post


Link to post
Share on other sites
when you load the image data ... save its dimentions somewhere and reference them when you draw the quad.

How hard is that?

eventaully you'll have to figure out what a good convertion is. Vert points to pixels ect





[edited by - Jenison on February 26, 2004 4:28:58 PM]

Share this post


Link to post
Share on other sites
i didnt think it would be too hard, but the converting the opengl units to a pixel format. I will be doeing most of this drawing if not all in an ortho perspective.

Share this post


Link to post
Share on other sites
Just set the width and height of the orthographic frustum to be the same dimensions as the viewport. That will produce a 1:1 mapping of OpenGL units to pixels.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!