Skip to content

Instantly share code, notes, and snippets.

@weiancheng
Created May 5, 2020 09:00
Show Gist options
  • Save weiancheng/44d0f5224764d8ce2cbee7871c7d93bb to your computer and use it in GitHub Desktop.
Save weiancheng/44d0f5224764d8ce2cbee7871c7d93bb to your computer and use it in GitHub Desktop.
[Android OpenGL Texture] #android #opengl #texture2d
#include "render_frame.h"
void RenderFrame::initialize() {
glGenTextures(1, &colorAttachmentId);
glBindTexture(GL_TEXTURE_2D, colorAttachmentId);
glBindTexture(GL_TEXTURE_2D, 0); // unbind
}
void RenderFrame::submitFrame(void *frame) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, frame);
glBindTexture(GL_TEXTURE_2D, 0);
}
#include <GLES3/gl3.h>
class RenderFrame {
public:
void initialize();
void submitFrame(void *frame);
private:
GLuint colorAttachmentId;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment