OpenGL Texture Atlas with short?
Can you create a OpenGL Texture Atlas with short & if so How?
Because right not I am using float value of 0.0625 for (16x16 TileSet of a 512x512 Image) An I can't figure out how to create tiles with short & I have read that short & unsigned byte are best for texturing.
Because right not I am using float value of 0.0625 for (16x16 TileSet of a 512x512 Image) An I can't figure out how to create tiles with short & I have read that short & unsigned byte are best for texturing.
Your options depend on which API you're using.
TexCoordPointer treats bytes/shorts as unnormalized values, so you're passing integral (0, 1, 2...) texture coordinates to the vertex transformation. You can scale them arbitrarily before you sample the texture, for example with the texture matrix. In this case, you're trading off submitting fewer bytes per vertex for a couple extra operations per vertex, so benchmark carefully.
VertexAttribPointer takes a "normalized" flag which lets you convert the byte/short to a float in the range [0,1]. You're still able to transform the data before using it.
TexCoordPointer treats bytes/shorts as unnormalized values, so you're passing integral (0, 1, 2...) texture coordinates to the vertex transformation. You can scale them arbitrarily before you sample the texture, for example with the texture matrix. In this case, you're trading off submitting fewer bytes per vertex for a couple extra operations per vertex, so benchmark carefully.
VertexAttribPointer takes a "normalized" flag which lets you convert the byte/short to a float in the range [0,1]. You're still able to transform the data before using it.
So do I have to use a certain Function to change them into a decimal value or something. Sorry I am a little bit confused by all this.
You would think that if you are going to use int value it would be used like
0->32 by 0->32 for a 32x32 TileSprite
if you could show me an Example or value of a apart of a image I think i could figure out faster
Thanks so far for letting me know there is a way to make a Texture Atlas with short.
You would think that if you are going to use int value it would be used like
0->32 by 0->32 for a 32x32 TileSprite
if you could show me an Example or value of a apart of a image I think i could figure out faster
Thanks so far for letting me know there is a way to make a Texture Atlas with short.
Graphic Ace Wrote:0->32 by 0->32 for a 32x32 TileSpriteMost of the time, texture coordinates in OpenGL are treated as floats where the range [0,1] maps to the entire texture image.
It's done this way because of how texture sampling works-- a texture is not just a 2D array of pixels. It can be a mipmap with multiple images, and/or a cubemap where the texture coordinate is used as a 3D vector. Only after the texture sampler has chosen the appropriate cubemap face and/or mipmap level is the float coordinate scaled to the dimension of the texture to fetch texels. Textures also have a set of parameters to control how texels are filtered when fetched, how coordinates outside [0,1] are handled, and various other options.
It's also possible to use denormalized texture coordinates, with ARB_texture_rectangle or with the texelFetch() samplers in EXT_gpu_shader4 and GL3.
All of that discussion is separate from how you actually pass coordinates in, though.
Quote:if you could show me an ExampleWhat API are you using, and what hardware are you targeting?
I am using Cocoa & OpenGL an I programming for
All Mac Computers
MacBook
iMac
iPhone
an so on..
All Mac Computers
MacBook
iMac
iPhone
an so on..
In that case, stick to the lowest common denominator, OpenGL ES1.1 on the iPhone:
TexCoordPointer() to pass in coordinates as bytes or shorts
MatrixMode() and Scalef() etc to transform the coordinates to a range you like
DrawArrays() or DrawElements() to submit vertex data
but keep in mind what works best on the iPhone won't necessarily be best for the other renderers.
TexCoordPointer() to pass in coordinates as bytes or shorts
MatrixMode() and Scalef() etc to transform the coordinates to a range you like
DrawArrays() or DrawElements() to submit vertex data
but keep in mind what works best on the iPhone won't necessarily be best for the other renderers.
Graphic Ace Wrote:Because right not I am using float value of 0.0625 for (16x16 TileSet of a 512x512 Image) An I can't figure out how to create tiles with short & I have read that short & unsigned byte are best for texturing.
Well a 'short' in C/C++ is an integer value, so you could not have the value 0.0625 (well... it's a fixed-point value, you can interpret that fixed point wherever you want it.)
If you want to make things easier on yourself, you can transform the texture matrix.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
OpenGL ES Texture Masking | airfire | 6 | 22,760 |
Mar 17, 2014 07:07 PM Last Post: baioses |
|
OpenGL ES Texture Compression | ajrs84 | 9 | 11,153 |
May 7, 2013 03:36 PM Last Post: ajrs84 |
|
OpenGL ES Texture Masking | dalasjoe sin | 0 | 5,273 |
Apr 13, 2012 12:17 AM Last Post: dalasjoe sin |
|
Texture in OpenGL ES 2 looks pixelated | vunterslaush | 18 | 38,465 |
Aug 30, 2011 09:44 PM Last Post: Frogblast |
|
Lighting and changing texture colors in OpenGL | agreendev | 2 | 10,877 |
Aug 13, 2010 03:47 PM Last Post: agreendev |