How to add some pixels on the texture in OpenGL ES

Harry

I'm making an Android application to add a line like a header which is like this for example:

Header

(it's a line of some colored pixels, it was kinda zoomed in)

on top left of this:

Main texture

I don't know if it's possible to add some pixels on top of a texture with OpenGL or not. Or we must put it in an Bitmap, load it to texture and then combine it with the main texture.

Reto Koradi

To draw a row of pixels, the best way is to create a texture from them, and then draw them just like any other texture. Depending on your exact use case, there are at least two approaches:

  1. If you always want to render that row of pixels over the existing texture, and in the same place relative to the original texture content, you can modify that texture with glTexSubImage2D(). Say you have an array of bytes rowBytes, that contains the RGB values for the row of nPixels pixels you want to add. Bind the existing texture, and then call:

    GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, nPixels, 1,
                           GLES20.G_RBB, GLES20.GL_UNSIGNED_BYTE,
                           ByteBuffer.wrap(rowBytes));
    
  2. Create a new texture for the row, using the standard calls you use for any other texture (glGenTextures, glBindTexture, glTexImage2D). For just a single row of pixels, specify the height as 1. Then render the texture the same way you already render your existing textures, which is typically by rendering a textured quad for the area you want covered.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Problem with texture not showing in screen. OpenGL ES

From Dev

opengl texture mapping off by 5-8 pixels

From Dev

OpenGL ES 3.0. Floating point texture

From Dev

OpenGL ES texture atlas distortion

From Dev

Android drawing texture with OpenGL ES 2.0 slow on some devices

From Dev

OpenGL ES 2.0 render to texture with transparent background

From Dev

OpenGL ES draws a black texture

From Dev

How to properly texture a quad in opengl

From Dev

OpenGL ES render to texture bound to shader

From Dev

How to render to a depth texture in OpenGL ES on Android

From Dev

How to texture of a glutSolidTorus in OpenGL?

From Dev

how to load android camera frame into opengl es texture via ndk?

From Dev

OpenGL ES texture degrades in quality

From Dev

How to invert texture colours in OpenGL

From Dev

OpenGL ES 2.0 - How to efficiently copy a Texture into Frame Buffer

From Dev

OpenGL ES 2.0 - Render to texture is all black

From Dev

How to put a texture on object in OpenGL?

From Dev

OpenGL ES 2.0, how to animate texture's opacity

From Dev

Android drawing texture with OpenGL ES 2.0 slow on some devices

From Dev

OpenGL ES: Texture a plane

From Dev

Add texture to QT OpenGL scene graph

From Dev

How to change the color of some colored pixels on a texture?

From Dev

How to add some pixels on the texture in OpenGL ES

From Dev

Opengl ES texture is not applied to object

From Dev

how to load android camera frame into opengl es texture via ndk?

From Dev

how to assign one texture to another efficiently in OpenGL ES for Android

From Dev

How to check an uploaded texture in OpenGL ES 2.0 in Android?

From Dev

How to draw OpenGL pixels with the GPU

From Dev

How to add texture in PlaneGeometry

Related Related

HotTag

Archive