mojoshader.h
branchtrunk
changeset 200 5085c788f769
parent 199 03463c4621ad
child 201 c0ba05ee09d9
equal deleted inserted replaced
199:03463c4621ad 200:5085c788f769
   366 int MOJOSHADER_glInit(const char *profile,
   366 int MOJOSHADER_glInit(const char *profile,
   367                       void *(*lookup)(const char *fnname),
   367                       void *(*lookup)(const char *fnname),
   368                       MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
   368                       MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
   369 
   369 
   370 /*
   370 /*
   371  * "Shaders" refer to individual vertex or fragment programs, and are created
   371  * "Shaders" refer to individual vertex or pixel programs, and are created
   372  *  by "compiling" Direct3D shader bytecode. A vertex and fragment shader are
   372  *  by "compiling" Direct3D shader bytecode. A vertex and pixel shader are
   373  *  "linked" into a "Program" before you can use them to render.
   373  *  "linked" into a "Program" before you can use them to render.
   374  *
   374  *
   375  * To the calling application, these are opaque handles.
   375  * To the calling application, these are opaque handles.
   376  */
   376  */
   377 typedef struct MOJOSHADER_glShader MOJOSHADER_glShader;
   377 typedef struct MOJOSHADER_glShader MOJOSHADER_glShader;
   388  */
   388  */
   389 MOJOSHADER_glShader *MOJOSHADER_glCompileShader(const unsigned char *tokenbuf,
   389 MOJOSHADER_glShader *MOJOSHADER_glCompileShader(const unsigned char *tokenbuf,
   390                                                 const unsigned int bufsize);
   390                                                 const unsigned int bufsize);
   391 
   391 
   392 /*
   392 /*
   393  * Link a vertex and fragment shader into an OpenGL program.
   393  * Link a vertex and pixel shader into an OpenGL program.
   394  *  (vertex_shader) or (fragment_shader) can be NULL, to specify that the
   394  *  (vshader) or (pshader) can be NULL, to specify that the GL should use the
   395  *  GL should use the fixed-function pipeline instead of the programmable
   395  *  fixed-function pipeline instead of the programmable pipeline for that
   396  *  pipeline for that portion of the work. You can reuse shaders in various
   396  *  portion of the work. You can reuse shaders in various combinations across
   397  *  combinations across multiple programs, by relinking different pairs.
   397  *  multiple programs, by relinking different pairs.
   398  *
   398  *
   399  * It is illegal to give a vertex shader for (fragment_shader) or a fragment
   399  * It is illegal to give a vertex shader for (pshader) or a pixel shader
   400  *  shader for (vertex_shader).
   400  *  for (vshader).
   401  *
   401  *
   402  * It is illegal to delete a shader while there is still a linked program
   402  * It is illegal to delete a shader while there is still a linked program
   403  *  using it. Delete the programs before the shaders.
   403  *  using it. Delete the programs before the shaders.
   404  *
   404  *
   405  * Once you have successfully linked a program, you may render with it.
   405  * Once you have successfully linked a program, you may render with it.
   406  *
   406  *
   407  * Returns NULL on error, or a program handle on success.
   407  * Returns NULL on error, or a program handle on success.
   408  */
   408  */
   409 MOJOSHADER_glProgram *MOJOSHADER_glLinkProgram(
   409 MOJOSHADER_glProgram *MOJOSHADER_glLinkProgram(MOJOSHADER_glShader *vshader,
   410                                     MOJOSHADER_glShader *vertex_shader,
   410                                                MOJOSHADER_glShader *pshader);
   411                                     MOJOSHADER_glShader *fragment_shader);
       
   412 
   411 
   413 /*
   412 /*
   414  * This binds the program (using, for example, glUseProgramObjectARB()), and
   413  * This binds the program (using, for example, glUseProgramObjectARB()), and
   415  *  disables all the client-side arrays so we can reset them with new values
   414  *  disables all the client-side arrays so we can reset them with new values
   416  *  if appropriate.
   415  *  if appropriate.