From 12f0fc4181963d1dca712513ff1a8015395b1458 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sun, 25 Jun 2017 22:08:04 -0400 Subject: [PATCH] Update README.md --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index e95cc32..65c0bae 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,31 @@ # opengl An OpenGL function loader written in pure swift. To use it, `import OpenGL` in your swift file. + +*OpenGL* is a function loader which allows you to call OpenGL GPU functions from swift programs. These functions are loaded lazily at runtime by *OpenGL*. *OpenGL* also diagnoses invalid OpenGL function calls due to the function not being available on a particular GPU and OpenGL version. + +*OpenGL* provides access to OpenGL functions both with labeled and unlabeled arguments. This can help you avoid common argument ordering bugs. + +```swift +var tex_id:UInt32 = 0 +glGenTextures(1, &tex_id) +glBindTexture(GL_TEXTURE_2D, tex_id) +glTexImage2D(target : GL_TEXTURE_2D, + level : 0, + internalformat : GL_RGBA8, + width : h, + height : k, + border : 0, + format : GL_RGBA, + type : GL_UNSIGNED_BYTE, + pixels : pixbuf) +glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) +glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) +``` + +*OpenGL* also provides typealias definitions for OpenGL types. + +```swift +let tex_id1:GLuint +let tex_id2:UInt32 +```