Created
May 5, 2020 09:00
-
-
Save weiancheng/44d0f5224764d8ce2cbee7871c7d93bb to your computer and use it in GitHub Desktop.
[Android OpenGL Texture] #android #opengl #texture2d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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