Skip to content

Commit

Permalink
More examples
Browse files Browse the repository at this point in the history
  • Loading branch information
BSVino committed Aug 19, 2014
1 parent 604fbf2 commit a35f5b9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions html/examples/fbo_blit.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{%glBindFramebuffer}(GL_READ_FRAMEBUFFER, source_fbo);
{%glBindFramebuffer}(GL_DRAW_FRAMEBUFFER, destination_fbo);

{%glBlitFramebuffer}(0, 0, source_fbo_width, source_fbo_height, 0, 0, destination_fbo_width, destination_fbo_height, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT, GL_NEAREST);
16 changes: 16 additions & 0 deletions html/examples/texture_create.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
GLuint texture_id;
{%glGenTextures}(1, &texture_id);
{%glBindTexture}(GL_TEXTURE_2D, texture_id);

{%glTexParameteri}(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
{%glTexParameteri}(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

{%glTexParameteri}(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
{%glTexParameteri}(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// texture_data is the source data of your texture, in this case
// its size is sizeof(unsigned char) * texture_width * texture_height * 4
{%glTexImage2D}(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_data);
{%glGenerateMipmap}(GL_TEXTURE_2D); // Unavailable in OpenGL 2.1, use gluBuild2DMipmaps() insteads.

{%glBindTexture}(GL_TEXTURE_2D, 0);
5 changes: 5 additions & 0 deletions html/examples/texture_read.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{%glBindTexture}(GL_TEXTURE_2D, texture_id); // texture_id was given by {%glGenTextures}

// texture_data must be large enough to hold the entire texture, in this case
// sizeof(float) * width * height * 3
{%glGetTexImage}(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, texture_data);
13 changes: 13 additions & 0 deletions opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@
'description': 'Create a framebuffer object with a renderbuffer-based color attachment and a renderbuffer-based depth attachment.',
'commands': [ 'glGenRenderbuffers', 'glBindRenderbuffer', 'glRenderbufferStorage', 'glGenFramebuffers', 'glFramebufferRenderbuffer' ],
},
'fbo_blit': {
'versions': [ 'gl3', 'gl4', 'es3' ],
'description': 'Create a framebuffer object with a renderbuffer-based color attachment and a renderbuffer-based depth attachment.',
'commands': [ 'glBindFramebuffer', 'glBlitFramebuffer' ],
},
'texture_create': {
'description': 'Create a texture object with linear mipmaps and edge clamping.',
'commands': [ 'glGenTextures', 'glBindTexture', 'glTexParameteri', 'glTexImage2D', 'glGenerateMipmap' ],
},
'texture_read': {
'description': 'Read the texture from GPU memory into a buffer.',
'commands': [ 'glGetTexImage' ],
},
}

def get_major_versions(all_versions):
Expand Down

0 comments on commit a35f5b9

Please sign in to comment.