# iOSOpenGL ES: Determining Texels in a Fragment

#### Blakeasd

##### macrumors 6502a
Original poster
Hello, Consider the following quote from this OpenGL ES for iOS Book:

OpenGL ES supports several different sampling modes: Consider what happens when fewer fragments are produced for a triangle than the number of texels available in the bound texture. That can happen any time the texture with a large number of texels is mapped to a triangle that covers only a few pixels in the frame buffer. The opposite can happen, too. A texture containing few texels might be mapped to a triangle that produces many fragments in the frame buffer.
And this quote:

If a texture is composed of alternating black and white texels
My question is how does one determine how many texels are in an image and how large those texels are. If I'm not mistaken 1 texel != 1 pixel, so you can't determine the number of texels by counting pixels. For example, the second quote describes an image with alternation black and white texels. How would you know if your image is composed of black and white texels.... who defines the texel size??

#### Duncan C

##### macrumors 6502a
Hello, Consider the following quote from this OpenGL ES for iOS Book:

And this quote:

My question is how does one determine how many texels are in an image and how large those texels are. If I'm not mistaken 1 texel != 1 pixel, so you can't determine the number of texels by counting pixels. For example, the second quote describes an image with alternation black and white texels. How would you know if your image is composed of black and white texels.... who defines the texel size??
Here's my understanding:

The term pixels means dots on the screen.

OpenGL uses the term "texels" to talk about dots in a source image (texture.) At display time, a texture gets mapped onto a 2D or 3D shape, and there is no longer a one-to-one mapping between texels and pixels.

Most of us think of pixels and texels interchangeably, but in OpenGL terms, they are not interchangeable.

A bitmap image is a grid of dots. The number of texels is simply image heightxwidth.

An image does not have a size, and so the dots on the image do not have a size. They're data. If you map the texture directly onto the screen, where 1 texel takes 1 pixel, then at that moment, each texel is displayed at the size of a screen pixel.

However, with OpenGL that's the exception rather than the rule. Usually you scale textures, wrap them around shapes, rotate them, skew them, etc, in ways that mean there is no single mapping from texel size to pixel size.

#### Blakeasd

##### macrumors 6502a
Original poster
Thanks.. What would the bounds of the texel be though? Take this for example: There is a 2x2 pixel image: 2 white pixels and 2 black pixels. If I drew this image to an OpenGL 4x4 square would 1 texel == 1 pixel? Furthermore, If I drew this with the mode being
Code:
``GL_LINEAR``
what would this end up looking like?

Thanks!

#### Duncan C

##### macrumors 6502a
Thanks.. What would the bounds of the texel be though? Take this for example: There is a 2x2 pixel image: 2 white pixels and 2 black pixels. If I drew this image to an OpenGL 4x4 square would 1 texel == 1 pixel? Furthermore, If I drew this with the mode being
Code:
``GL_LINEAR``
what would this end up looking like?

Thanks!
I don't do enough OpenGL to know the results of the different drawing modes off the top of my head. I'd have to go crack a manual or fire up a test program.

I would expect a 2x2 TEXEL texture drawn into an 4x4 PIXEL viewport would stretch the texture to twice the size, so each texel would occupy 2x2 pixels.

I suggest you do both things I mentioned (Read a good book on OpenGL ES 2.0, and find a simple GLKit based demo program and start modifying it.)

#### Blakeasd

##### macrumors 6502a
Original poster
Ahhhhhh!!! I think I've finally got it! I'm actually asking this question in accompaniment with an OpenGL ES 2 book that I'm reading. It is admittedly pretty confusing.

Thanks a Million!!!

#### Duncan C

##### macrumors 6502a
Ahhhhhh!!! I think I've finally got it! I'm actually asking this question in accompaniment with an OpenGL ES 2 book that I'm reading. It is admittedly pretty confusing.

Thanks a Million!!!
If you're studying OpenGL and your head isn't exploding, you are not paying attention.