gltools.f90 の中のモジュールの改変。 cの助けを借りるw
http://www.dolfyn.net/dolfyn/f03gl_en.html
Bluebook用のルーチン。
このままではまずいことが判明。一部引数に VALUE 属性が必要。
module opengl_glext use opengl_gl use, intrinsic :: iso_c_binding integer(glenum), parameter :: GL_TEXTURE_COMPARE_FAIL_VALUE_ARB = z'80bf' integer(glenum), parameter :: GL_DEPTH_TEXTURE_MODE = z'884b' integer(glenum), parameter :: GL_TEXTURE_COMPARE_MODE = z'884c' integer(glenum), parameter :: GL_COMPARE_R_TO_TEXTURE = z'884e' integer(glenum), parameter :: GL_QUERY_COUNTER_BITS = z'8864' integer(glenum), parameter :: GL_CURRENT_QUERY = z'8865' integer(glenum), parameter :: GL_QUERY_RESULT = z'8866' integer(glenum), parameter :: GL_QUERY_RESULT_AVAILABLE = z'8867' integer(glenum), parameter :: GL_ARRAY_BUFFER = z'8892' integer(glenum), parameter :: GL_ELEMENT_ARRAY_BUFFER = z'8893' integer(glenum), parameter :: GL_READ_WRITE = z'88ba' integer(glenum), parameter :: GL_PIXEL_PACK_BUFFER = z'88eb' integer(glenum), parameter :: GL_PIXEL_UNPACK_BUFFER = z'88ec' integer(glenum), parameter :: GL_STREAM_DRAW = z'88e0' integer(glenum), parameter :: GL_STREAM_READ = z'88e1' integer(glenum), parameter :: GL_STREAM_COPY = z'88e2' integer(glenum), parameter :: GL_STATIC_DRAW = z'88e4' integer(glenum), parameter :: GL_STATIC_READ = z'88e5' integer(glenum), parameter :: GL_STATIC_COPY = z'88e6' integer(glenum), parameter :: GL_DYNAMIC_DRAW = z'88e8' integer(glenum), parameter :: GL_DYNAMIC_READ = z'88e9' integer(glenum), parameter :: GL_DYNAMIC_COPY = z'88ea' integer(glenum), parameter :: GL_SAMPLES_PASSED = z'8914' interface ! glGenBuffers etc is available only if the GL version is 1.5 or greater. ! glGenBuffers - generate buffer object names ! void glGenBuffers( GLsizei n, GLuint* buffers) subroutine glGenBuffers(n, buffers) bind(C, name="cglewGenBuffers") use opengl_gl integer(kind=GLsizei), value :: n integer(GLuint), dimension(n), intent(OUT) :: buffers end subroutine glGenBuffers ! glBindBuffer - bind a named buffer object ! void glBindBuffer( GLenum target, GLuint buffer) subroutine glBindBuffer(target, buffer) bind(C, name="cglewBindBuffer") use opengl_gl integer(GLenum), value :: target integer(GLuint), value :: buffer end subroutine glBindBuffer ! glBufferData - creates and initializes a buffer object's data store ! void glBufferData( GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) subroutine glBufferData(target, size, data, usage) bind(C, name="cglewBufferData") use opengl_gl integer(kind=GLenum), value :: target integer(kind=GLsizei), value :: size ! size in bytes type(C_PTR) :: data ! pointer to data that will be copied into the data store integer(kind=GLenum), value :: usage ! the expected usage pattern of the data store end subroutine glBufferData ! glMapBuffer - map a buffer object's data store ! void * glMapBuffer( GLenum target, GLenum access) function glMapBuffer(target, access) bind(C, name="cglewMapBuffer") use opengl_gl type(C_PTR) :: glMapBuffer integer(kind=GLenum), value :: target integer(kind=GLenum), value :: access end function glMapBuffer ! ! GLboolean glUnmapBuffer(GLenum target) subroutine glUnmapBuffer(target) bind(C, name="cglewUnmapBuffer") use opengl_gl integer(kind=GLenum), value :: target end subroutine glUnmapBuffer ! ! === chapter 13 ! ! glBeginQuery - delimit the boundaries of a query object ! void glBeginQuery(GLenum target, GLuint id) subroutine glBeginQuery(target, id) bind(C,name="glBeginQuery") use opengl_gl integer(kind=GLenum), value :: target integer(kind=GLuint), value :: id end subroutine glBeginQuery ! ! void glEndQuery(GLenum target) subroutine glEndQuery(target) bind(C,name="glEndQuery") use opengl_gl integer(kind=GLenum), value :: target end subroutine glEndQuery ! glGenQueries - generate query object names ! void glGenQueries(GLsizei n, GLuint * ids) subroutine glGenQueries(n, ids) bind(C,name="glGenQueries") use opengl_gl integer(kind=GLsizei), value :: n integer(kind=GLuint), dimension(n) :: ids end subroutine glGenQueries ! glGetQueryiv - return parameters of a query object target ! void glGetQueryiv(GLenum target,GLenum pname,GLint * params) subroutine glGetQueryiv(target, pname, params) bind(C,name="glGetQueryiv") use opengl_gl integer(kind=GLenum), value :: target integer(kind=GLenum), value :: pname integer(kind=GLint), dimension(*) :: params end subroutine glGetQueryiv ! glGetQueryObject - return parameters of a query object ! void glGetQueryObjectiv(GLuint id, GLenum pname, GLint * params) subroutine glGetQueryObjectiv(target, pname, params) bind(C,name="glGetQueryObjectiv") use opengl_gl integer(kind=GLenum), value :: target integer(kind=GLenum), value :: pname integer(kind=GLint), dimension(*) :: params end subroutine glGetQueryObjectiv end interface end module opengl_glext !MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
#include <GL/glew.h> #include <GL/glut.h> extern "C" void cglewGenBuffers(GLsizei n, GLuint* buffer) { glGenBuffers( n, buffer ); } extern "C" void cglewBindBuffer(GLenum target, GLuint buffer) { glBindBuffer( target, buffer ); } extern "C" void cglewBufferData(GLenum target, GLsizei size, const GLvoid * data, GLenum usage) { glBufferData(target, size, data, usage); } extern "C" void cglewMapBuffer(GLenum target, GLenum access) { glMapBuffer(target, access); } extern "C" void cglewUnmapBuffer(GLenum target) { glUnmapBuffer(target); }