Jump to content
  • Advertisement
Sign in to follow this  
noodleBowl

OpenGL OpenGL ES 2: Scale texture on creation?

This topic is 1089 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 was wondering how is it possible to scale a texture by some X and some Y at the creation of a texture?
 
I'm currently am creating textures like:
 

final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options);

GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

bitmap.recycle();

Share this post


Link to post
Share on other sites
Advertisement

Why do you want to scale it during creation. What is wrong with letting opengl scale it for you during drawing? Unless you want to implement your own scaling algorithm or use a library to get slow but better quality scaling you are betteroff just letting opengl do it during drawing.

Share this post


Link to post
Share on other sites

Why do you want to scale it during creation. What is wrong with letting opengl scale it for you during drawing? Unless you want to implement your own scaling algorithm or use a library to get slow but better quality scaling you are betteroff just letting opengl do it during drawing.


Maybe its the wrong approach (this idea is probably bad), but the reason I wanted to scale my textures during creation was because of different screen resolutions.

I plan onto make my graphics for a 640 x 360 resolution. Then when it comes to my app I can calculate the aspect ratio and scale up by some integer value. If I were to scale everything at creation then wouldn't have to pass some scale factor through all the objects I need to draw.


Actually, couldn't I just scale my projection matrix and that would have the same effect? Edited by noodleBowl

Share this post


Link to post
Share on other sites

 

Actually, couldn't I just scale my projection matrix and that would have the same effect?

Yup. That's the easy and correct way of doing this.

 

 

Just want to double check when I say projection matrix, I'm really talking about the final MVP matrix. That is the one I should scale right?

 

 

While we are on the topic of this.

As I mentioned before, I plan on drawing everything targeted at a 640 x 360 resolution and then scaling up by some integer value.
Calculate the aspect ratio, the find out the scale factor, and scale my projection matrix

Now my question is more of not how do I scale, but what should I scale? Do I scale everything? Do I scale only game content and leave HUD/UI alone? I'm kind of lost when it comes to all of this. What do other people do? I know its app dependent, but if this has any weight I would like to avoid letter boxing

Edited by noodleBowl

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!