MCPcopy Create free account
hub / github.com/android/ndk-samples / InitFromRawRGB

Method InitFromRawRGB

endless-tunnel/app/src/main/cpp/texture.cpp:20–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include "common.hpp"
19
20void Texture::InitFromRawRGB(int width, int height, bool hasAlpha,
21 const unsigned char* data) {
22 GLenum format = hasAlpha ? GL_RGBA : GL_RGB;
23
24 glGenTextures(1, &mTextureH);
25 glBindTexture(GL_TEXTURE_2D, mTextureH);
26
27 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
28 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
29 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
30 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
31 glPixelStorei(GL_PACK_ALIGNMENT, 1);
32
33 glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
34 GL_UNSIGNED_BYTE, data);
35 glBindTexture(GL_TEXTURE_2D, 0);
36}
37
38void Texture::Bind(int unit) {
39 glActiveTexture(unit);

Callers 1

OnStartGraphicsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected