#includeint main() { // Initialize Angle Native ANGLE_init(); // Create an OpenGL context EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); EGLint major, minor; eglInitialize(display, &major, &minor); EGLint configAttribs[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_NONE }; EGLint numConfigs; EGLConfig config; eglChooseConfig(display, configAttribs, &config, 1, &numConfigs); EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs); EGLSurface surface = eglCreateWindowSurface(display, config, window, NULL); eglMakeCurrent(display, surface, surface, context); // Render // Release the context eglDestroySurface(display, surface); eglDestroyContext(display, context); eglTerminate(display); return 0; }
#includeThis example shows how to load a texture using the stb_image library and bind it to an OpenGL texture. The library used in this example is the OpenGL ES library, which is part of the Angle Native package.#include int main() { // Initialize Angle Native ANGLE_init(); // Create an OpenGL context // Load the texture int width, height, channels; unsigned char* image = stbi_load("texture.png", &width, &height, &channels, STBI_rgb_alpha); GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); stbi_image_free(image); // Render // Release the texture glDeleteTextures(1, &texture); // Release the context return 0; }