github.com/gotranspile/cxgo@v0.3.7/libs/opengl.go (about)

     1  package libs
     2  
     3  const (
     4  	glH = "GL/gl.h"
     5  )
     6  
     7  func init() {
     8  	RegisterLibrary(glH, func(c *Env) *Library {
     9  		return &Library{
    10  			// TODO
    11  			Header: `
    12  #include <` + BuiltinH + `>
    13  
    14  typedef int GLint;
    15  typedef float GLfloat;
    16  typedef unsigned int GLuint;
    17  typedef unsigned int GLsizei;
    18  typedef unsigned int GLbitfield;
    19  typedef unsigned int GLsizeiptr;
    20  typedef int GLenum;
    21  typedef char GLchar;
    22  #define GLvoid void
    23  typedef int GLboolean;
    24  
    25  // fake enum values
    26  const int GL_FALSE = 0;
    27  const int GL_TEXTURE_2D = 0;
    28  const int GL_UNPACK_ROW_LENGTH = 0;
    29  const int GL_BGRA = 0;
    30  const int GL_RGBA = 0;
    31  const int GL_TEXTURE_WRAP_S = 0;
    32  const int GL_TEXTURE_WRAP_T = 0;
    33  const int GL_TEXTURE_MIN_FILTER = 0;
    34  const int GL_FRAMEBUFFER = 0;
    35  const int GL_COLOR_BUFFER_BIT = 0;
    36  const int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0;
    37  const int GL_UNSIGNED_SHORT_5_5_5_1 = 0;
    38  const int GL_LINEAR = 0;
    39  const int GL_ARRAY_BUFFER = 0;
    40  const int GL_FLOAT = 0;
    41  const int GL_TRIANGLE_STRIP = 0;
    42  const int GL_CLAMP_TO_EDGE = 0;
    43  const int GL_TEXTURE0 = 0;
    44  const int GL_VERTEX_SHADER = 0;
    45  const int GL_COMPILE_STATUS = 0;
    46  const int GL_FRAGMENT_SHADER = 0;
    47  const int GL_LINK_STATUS = 0;
    48  const int GL_STATIC_DRAW = 0;
    49  
    50  void glViewport(GLint x,  GLint y,  GLsizei width,  GLsizei height);
    51  void glBindTexture(GLenum target,  GLuint texture);
    52  GLenum glGetError( void);
    53  void glPixelStorei(GLenum pname,  GLint param);
    54  void glTexSubImage2D( 	GLenum target,
    55    	GLint level,
    56    	GLint xoffset,
    57    	GLint yoffset,
    58    	GLsizei width,
    59    	GLsizei height,
    60    	GLenum format,
    61    	GLenum type,
    62    	const GLvoid * pixels);
    63  void glTexParameteri( 	GLenum target,
    64    	GLenum pname,
    65    	GLint param);
    66  void glBindFramebuffer( 	GLenum target,
    67    	GLuint framebuffer);
    68  void glClear(GLbitfield mask);
    69  void glUseProgram( 	GLuint program);
    70  void glUniform1i( 	GLint location, GLint v0);
    71  void glUniform1f(GLint location,  GLfloat v0);
    72  void glUniformMatrix2fv(GLint location,  GLsizei count,  GLboolean transpose,  const GLfloat *value);
    73  void glBindBuffer( 	GLenum target,
    74    	GLuint buffer);
    75  
    76  void glVertexAttribPointer( 	GLuint index,
    77    	GLint size,
    78    	GLenum type,
    79    	GLboolean normalized,
    80    	GLsizei stride,
    81    	const GLvoid * pointer);
    82  
    83  void glDrawArrays( 	GLenum mode,
    84    	GLint first,
    85    	GLsizei count);
    86  
    87  void glGenTextures( 	GLsizei n,
    88    	GLuint * textures);
    89  void glActiveTexture( 	GLenum texture);
    90  void glTexImage2D( 	GLenum target,
    91    	GLint level,
    92    	GLint internalformat,
    93    	GLsizei width,
    94    	GLsizei height,
    95    	GLint border,
    96    	GLenum format,
    97    	GLenum type,
    98    	const GLvoid * data);
    99  GLuint glCreateShader( 	GLenum shaderType);
   100  void glShaderSource( 	GLuint shader,
   101    	GLsizei count,
   102    	const GLchar **string,
   103    	const GLint *length);
   104  void glCompileShader( 	GLuint shader);
   105  void glGetShaderiv(GLuint shader,  GLenum pname,  GLint *params);
   106  void glGetShaderInfoLog( 	GLuint shader,
   107    	GLsizei maxLength,
   108    	GLsizei *length,
   109    	GLchar *infoLog);
   110  GLuint glCreateProgram( 	void);
   111  void glAttachShader( 	GLuint program,
   112    	GLuint shader);
   113  void glLinkProgram( 	GLuint program);
   114  void glGetProgramiv(GLuint program,  GLenum pname,  GLint *params);
   115  GLint glGetAttribLocation( 	GLuint program,
   116    	const GLchar *name);
   117  void glEnableVertexAttribArray( 	GLuint index);
   118  GLint glGetUniformLocation( 	GLuint program,
   119    	const GLchar *name);
   120  void glGenBuffers( 	GLsizei n,
   121    	GLuint * buffers);
   122  void glBufferData( 	GLenum target,
   123    	GLsizeiptr size,
   124    	const GLvoid * data,
   125    	GLenum usage);
   126  `,
   127  		}
   128  	})
   129  }