mojoshader.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 03 Feb 2009 17:16:32 -0500
changeset 548 b37cdacb50d5
parent 536 5af65fe6e917
child 552 40ca33bd5f88
permissions -rw-r--r--
Fixed parsing details of swizzles.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     1
/**
35
5749d174b537 [svn] Might as well keep the tradition alive.
icculus
parents: 20
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
5749d174b537 [svn] Might as well keep the tradition alive.
icculus
parents: 20
diff changeset
     3
 *  Direct3D shaders.
7
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     4
 *
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     6
 *
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     7
 *  This file written by Ryan C. Gordon.
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     8
 */
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
     9
35
5749d174b537 [svn] Might as well keep the tradition alive.
icculus
parents: 20
diff changeset
    10
#ifndef __INCL_MOJOSHADER_H_
5749d174b537 [svn] Might as well keep the tradition alive.
icculus
parents: 20
diff changeset
    11
#define __INCL_MOJOSHADER_H_
7
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
    12
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
    13
#ifdef __cplusplus
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
    14
extern "C" {
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
    15
#endif
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
    16
455
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    17
/* You can define this if you aren't generating mojoshader_version.h */
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    18
#ifndef MOJOSHADER_NO_VERSION_INCLUDE
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    19
#include "mojoshader_version.h"
461
892b408b5779 Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents: 458
diff changeset
    20
#endif
892b408b5779 Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents: 458
diff changeset
    21
892b408b5779 Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents: 458
diff changeset
    22
#ifndef MOJOSHADER_VERSION
455
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    23
#define MOJOSHADER_VERSION -1
461
892b408b5779 Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents: 458
diff changeset
    24
#endif
892b408b5779 Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents: 458
diff changeset
    25
892b408b5779 Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents: 458
diff changeset
    26
#ifndef MOJOSHADER_CHANGESET
455
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    27
#define MOJOSHADER_CHANGESET "???"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    28
#endif
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    29
20
bb2e8f285acc [svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents: 18
diff changeset
    30
/*
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    31
 * For determining the version of MojoShader you are using:
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    32
 *    const int compiled_against = MOJOSHADER_VERSION;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    33
 *    const int linked_against = MOJOSHADER_version();
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    34
 *
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    35
 * The version is a single integer that increments, not a major/minor value.
20
bb2e8f285acc [svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents: 18
diff changeset
    36
 */
35
5749d174b537 [svn] Might as well keep the tradition alive.
icculus
parents: 20
diff changeset
    37
int MOJOSHADER_version(void);
20
bb2e8f285acc [svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents: 18
diff changeset
    38
bb2e8f285acc [svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents: 18
diff changeset
    39
/*
455
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    40
 * For determining the revision control changeste of MojoShader you are using:
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    41
 *    const const *compiled_against = MOJOSHADER_CHANGESET;
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    42
 *    const char *linked_against = MOJOSHADER_changeset();
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    43
 *
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    44
 * The version is an arbitrary, null-terminated ASCII string. It is probably
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    45
 *  a hash that represents a revision control changeset, and can't be
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    46
 *  compared to any other string to determine chronology.
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    47
 *
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    48
 * Do not attempt to free this string; it's statically allocated.
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    49
 */
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    50
const char *MOJOSHADER_changeset(void);
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    51
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 454
diff changeset
    52
/*
20
bb2e8f285acc [svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents: 18
diff changeset
    53
 * These allocators work just like the C runtime's malloc() and free()
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    54
 *  (in fact, they probably use malloc() and free() internally if you don't
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    55
 *  specify your own allocator, but don't rely on that behaviour).
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
    56
 * (data) is the pointer you supplied when specifying these allocator
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
    57
 *  callbacks, in case you need instance-specific data...it is passed through
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
    58
 *  to your allocator unmolested, and can be NULL if you like.
20
bb2e8f285acc [svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents: 18
diff changeset
    59
 */
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
    60
typedef void *(*MOJOSHADER_malloc)(int bytes, void *data);
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
    61
typedef void (*MOJOSHADER_free)(void *ptr, void *data);
18
0dbdb2be8bf8 [svn] Bunch More Work. Cleanups, added app-supplied allocators, flexible output, etc.
icculus
parents: 14
diff changeset
    62
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    63
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    64
/*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    65
 * These are enum values, but they also can be used in bitmasks, so we can
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    66
 *  test if an opcode is acceptable: if (op->shader_types & ourtype) {} ...
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    67
 */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    68
typedef enum
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    69
{
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    70
    MOJOSHADER_TYPE_UNKNOWN  = 0,
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    71
    MOJOSHADER_TYPE_PIXEL    = (1 << 0),
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    72
    MOJOSHADER_TYPE_VERTEX   = (1 << 1),
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    73
    MOJOSHADER_TYPE_GEOMETRY = (1 << 2),  /* (not supported yet.) */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    74
    MOJOSHADER_TYPE_ANY = 0xFFFFFFFF   /* used for bitmasks */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    75
} MOJOSHADER_shaderType;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
    76
94
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
    77
/*
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    78
 * Data types for vertex attribute streams.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    79
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    80
typedef enum
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    81
{
240
a945af028366 Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents: 239
diff changeset
    82
    MOJOSHADER_ATTRIBUTE_UNKNOWN = -1,  /* housekeeping; not returned. */
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    83
    MOJOSHADER_ATTRIBUTE_BYTE,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    84
    MOJOSHADER_ATTRIBUTE_UBYTE,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    85
    MOJOSHADER_ATTRIBUTE_SHORT,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    86
    MOJOSHADER_ATTRIBUTE_USHORT,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    87
    MOJOSHADER_ATTRIBUTE_INT,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    88
    MOJOSHADER_ATTRIBUTE_UINT,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    89
    MOJOSHADER_ATTRIBUTE_FLOAT,
236
8e2fc535b210 Support for half-float attribute arrays.
Ryan C. Gordon <icculus@icculus.org>
parents: 219
diff changeset
    90
    MOJOSHADER_ATTRIBUTE_DOUBLE,
8e2fc535b210 Support for half-float attribute arrays.
Ryan C. Gordon <icculus@icculus.org>
parents: 219
diff changeset
    91
    MOJOSHADER_ATTRIBUTE_HALF_FLOAT,  /* MAYBE available in your OpenGL! */
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    92
} MOJOSHADER_attributeType;
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    93
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
    94
/*
94
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
    95
 * Data types for uniforms. See MOJOSHADER_uniform for more information.
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
    96
 */
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
    97
typedef enum
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
    98
{
240
a945af028366 Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents: 239
diff changeset
    99
    MOJOSHADER_UNIFORM_UNKNOWN = -1, /* housekeeping value; never returned. */
147
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   100
    MOJOSHADER_UNIFORM_FLOAT,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   101
    MOJOSHADER_UNIFORM_INT,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   102
    MOJOSHADER_UNIFORM_BOOL,
94
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   103
} MOJOSHADER_uniformType;
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   104
94
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   105
/*
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   106
 * These are the uniforms to be set for a shader. "Uniforms" are what Direct3D
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   107
 *  calls "Constants" ... IDirect3DDevice::SetVertexShaderConstantF() would
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   108
 *  need this data, for example. These integers are register indexes. So if
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   109
 *  index==6 and type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   110
 *  4-float vector to be specified for what would be register "c6" in D3D
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   111
 *  assembly language, before drawing with the shader.
280
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   112
 * (array_count) means this is an array of uniforms...this happens in some
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   113
 *  profiles when we see a relative address ("c0[a0.x]", not the usual "c0").
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   114
 *  In those cases, the shader was built to set some range of constant
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   115
 *  registers as an array. You should set this array with (array_count)
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   116
 *  elements from the constant register file, starting at (index) instead of
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   117
 *  just a single uniform. To be extra difficult, you'll need to fill in the
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   118
 *  correct values from the MOJOSHADER_constant data into the appropriate
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   119
 *  parts of the array, overriding the constant register file. Fun!
438
73492129c1af Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents: 431
diff changeset
   120
 * (constant) says whether this is a constant array; these need to be loaded
73492129c1af Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents: 431
diff changeset
   121
 *  once at creation time, from the constant list and not ever updated from
73492129c1af Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents: 431
diff changeset
   122
 *  the constant register file. This is a workaround for limitations in some
73492129c1af Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents: 431
diff changeset
   123
 *  profiles.
190
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   124
 * (name) is a profile-specific variable name; it may be NULL if it isn't
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   125
 *  applicable to the requested profile.
94
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   126
 */
462
af8c1ff58453 Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents: 461
diff changeset
   127
typedef struct MOJOSHADER_uniform
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   128
{
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   129
    MOJOSHADER_uniformType type;
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   130
    int index;
280
61b2abd9c927 Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 278
diff changeset
   131
    int array_count;
438
73492129c1af Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents: 431
diff changeset
   132
    int constant;
190
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   133
    const char *name;
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   134
} MOJOSHADER_uniform;
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   135
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   136
/*
278
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   137
 * These are the constants defined in a shader. These are data values
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   138
 *  hardcoded in a shader (with the DEF, DEFI, DEFB instructions), which
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   139
 *  override your Uniforms. This data is largely for informational purposes,
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   140
 *  since they are compiled in and can't be changed, like Uniforms can be.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   141
 * These integers are register indexes. So if index==6 and
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   142
 *  type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a 4-float vector
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   143
 *  to be specified for what would be register "c6" in D3D assembly language,
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   144
 *  before drawing with the shader.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   145
 * (value) is the value of the constant, unioned by type.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   146
 */
462
af8c1ff58453 Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents: 461
diff changeset
   147
typedef struct MOJOSHADER_constant
278
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   148
{
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   149
    MOJOSHADER_uniformType type;
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   150
    int index;
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   151
    union
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   152
    {
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   153
        float f[4];  /* if type==MOJOSHADER_UNIFORM_FLOAT */
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   154
        int i[4];    /* if type==MOJOSHADER_UNIFORM_INT */
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   155
        int b;       /* if type==MOJOSHADER_UNIFORM_BOOL */
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   156
    } value;
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   157
} MOJOSHADER_constant;
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   158
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   159
/*
148
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   160
 * Data types for samplers. See MOJOSHADER_sampler for more information.
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   161
 */
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   162
typedef enum
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   163
{
240
a945af028366 Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents: 239
diff changeset
   164
    MOJOSHADER_SAMPLER_UNKNOWN = -1, /* housekeeping value; never returned. */
148
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   165
    MOJOSHADER_SAMPLER_2D,
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   166
    MOJOSHADER_SAMPLER_CUBE,
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   167
    MOJOSHADER_SAMPLER_VOLUME,
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   168
} MOJOSHADER_samplerType;
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   169
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   170
/*
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   171
 * These are the samplers to be set for a shader. ...
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   172
 *  IDirect3DDevice::SetTexture() would need this data, for example.
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   173
 * These integers are the sampler "stage". So if index==6 and
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   174
 *  type==MOJOSHADER_SAMPLER_2D, that means we'd expect a regular 2D texture
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   175
 *  to be specified for what would be register "s6" in D3D assembly language,
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   176
 *  before drawing with the shader.
190
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   177
 * (name) is a profile-specific variable name; it may be NULL if it isn't
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   178
 *  applicable to the requested profile.
148
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   179
 */
462
af8c1ff58453 Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents: 461
diff changeset
   180
typedef struct MOJOSHADER_sampler
148
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   181
{
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   182
    MOJOSHADER_samplerType type;
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   183
    int index;
190
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   184
    const char *name;
148
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   185
} MOJOSHADER_sampler;
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   186
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   187
/*
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   188
 * Data types for attributes. See MOJOSHADER_attribute for more information.
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   189
 */
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   190
typedef enum
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   191
{
240
a945af028366 Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents: 239
diff changeset
   192
    MOJOSHADER_USAGE_UNKNOWN = -1,  /* housekeeping value; never returned. */
147
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   193
    MOJOSHADER_USAGE_POSITION,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   194
    MOJOSHADER_USAGE_BLENDWEIGHT,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   195
    MOJOSHADER_USAGE_BLENDINDICES,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   196
    MOJOSHADER_USAGE_NORMAL,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   197
    MOJOSHADER_USAGE_POINTSIZE,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   198
    MOJOSHADER_USAGE_TEXCOORD,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   199
    MOJOSHADER_USAGE_TANGENT,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   200
    MOJOSHADER_USAGE_BINORMAL,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   201
    MOJOSHADER_USAGE_TESSFACTOR,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   202
    MOJOSHADER_USAGE_POSITIONT,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   203
    MOJOSHADER_USAGE_COLOR,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   204
    MOJOSHADER_USAGE_FOG,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   205
    MOJOSHADER_USAGE_DEPTH,
98043daf5027 Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
   206
    MOJOSHADER_USAGE_SAMPLE,
240
a945af028366 Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents: 239
diff changeset
   207
    MOJOSHADER_USAGE_TOTAL,  /* housekeeping value; never returned. */
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   208
} MOJOSHADER_usage;
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   209
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   210
/*
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   211
 * These are the attributes to be set for a shader. "Attributes" are what
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   212
 *  Direct3D calls "Vertex Declarations Usages" ...
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   213
 *  IDirect3DDevice::CreateVertexDeclaration() would need this data, for
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   214
 *  example. Each attribute is associated with an array of data that uses one
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   215
 *  element per-vertex. So if usage==MOJOSHADER_USAGE_COLOR and index==1, that
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   216
 *  means we'd expect a secondary color array to be bound to this shader
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   217
 *  before drawing.
190
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   218
 * (name) is a profile-specific variable name; it may be NULL if it isn't
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   219
 *  applicable to the requested profile.
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   220
 */
462
af8c1ff58453 Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents: 461
diff changeset
   221
typedef struct MOJOSHADER_attribute
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   222
{
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   223
    MOJOSHADER_usage usage;
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   224
    int index;
190
2a2fb0f656cf Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents: 187
diff changeset
   225
    const char *name;
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   226
} MOJOSHADER_attribute;
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   227
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   228
/*
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   229
 * Use this if you want to specify newly-parsed code to swizzle incoming
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   230
 *  data. This can be useful if you know, at parse time, that a shader
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   231
 *  will be processing data on COLOR0 that should be RGBA, but you'll
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   232
 *  be passing it a vertex array full of ARGB instead.
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   233
 */
462
af8c1ff58453 Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents: 461
diff changeset
   234
typedef struct MOJOSHADER_swizzle
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   235
{
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   236
    MOJOSHADER_usage usage;
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   237
    unsigned int index;
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   238
    unsigned char swizzles[4];  /* {0,1,2,3} == .xyzw, {2,2,2,2} == .zzzz */
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   239
} MOJOSHADER_swizzle;
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   240
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   241
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   242
/*
524
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   243
 * MOJOSHADER_symbol data.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   244
 *
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   245
 * These are used to expose high-level information in shader bytecode.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   246
 *  They associate HLSL variables with registers. This data is used for both
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   247
 *  debugging and optimization.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   248
 */
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   249
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   250
typedef enum
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   251
{
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   252
    MOJOSHADER_SYMREGSET_BOOL,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   253
    MOJOSHADER_SYMREGSET_INT4,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   254
    MOJOSHADER_SYMREGSET_FLOAT4,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   255
    MOJOSHADER_SYMREGSET_SAMPLER,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   256
} MOJOSHADER_symbolRegisterSet;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   257
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   258
typedef enum
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   259
{
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   260
    MOJOSHADER_SYMCLASS_SCALAR,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   261
    MOJOSHADER_SYMCLASS_VECTOR,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   262
    MOJOSHADER_SYMCLASS_MATRIX_ROWS,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   263
    MOJOSHADER_SYMCLASS_MATRIX_COLUMNS,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   264
    MOJOSHADER_SYMCLASS_OBJECT,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   265
    MOJOSHADER_SYMCLASS_STRUCT,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   266
} MOJOSHADER_symbolClass;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   267
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   268
typedef enum
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   269
{
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   270
    MOJOSHADER_SYMTYPE_VOID,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   271
    MOJOSHADER_SYMTYPE_BOOL,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   272
    MOJOSHADER_SYMTYPE_INT,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   273
    MOJOSHADER_SYMTYPE_FLOAT,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   274
    MOJOSHADER_SYMTYPE_STRING,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   275
    MOJOSHADER_SYMTYPE_TEXTURE,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   276
    MOJOSHADER_SYMTYPE_TEXTURE1D,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   277
    MOJOSHADER_SYMTYPE_TEXTURE2D,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   278
    MOJOSHADER_SYMTYPE_TEXTURE3D,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   279
    MOJOSHADER_SYMTYPE_TEXTURECUBE,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   280
    MOJOSHADER_SYMTYPE_SAMPLER,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   281
    MOJOSHADER_SYMTYPE_SAMPLER1D,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   282
    MOJOSHADER_SYMTYPE_SAMPLER2D,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   283
    MOJOSHADER_SYMTYPE_SAMPLER3D,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   284
    MOJOSHADER_SYMTYPE_SAMPLERCUBE,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   285
    MOJOSHADER_SYMTYPE_PIXELSHADER,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   286
    MOJOSHADER_SYMTYPE_VERTEXSHADER,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   287
    MOJOSHADER_SYMTYPE_PIXELFRAGMENT,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   288
    MOJOSHADER_SYMTYPE_VERTEXFRAGMENT,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   289
    MOJOSHADER_SYMTYPE_UNSUPPORTED,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   290
} MOJOSHADER_symbolType;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   291
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   292
typedef struct MOJOSHADER_symbolStructMember MOJOSHADER_symbolStructMember;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   293
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   294
typedef struct MOJOSHADER_symbolTypeInfo
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   295
{
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   296
    MOJOSHADER_symbolClass parameter_class;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   297
    MOJOSHADER_symbolType parameter_type;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   298
    unsigned int rows;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   299
    unsigned int columns;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   300
    unsigned int elements;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   301
    unsigned int member_count;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   302
    MOJOSHADER_symbolStructMember *members;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   303
} MOJOSHADER_symbolTypeInfo;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   304
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   305
struct MOJOSHADER_symbolStructMember
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   306
{
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   307
    const char *name;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   308
    MOJOSHADER_symbolTypeInfo info;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   309
};
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   310
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   311
typedef struct MOJOSHADER_symbol
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   312
{
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   313
    const char *name;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   314
    MOJOSHADER_symbolRegisterSet register_set;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   315
    unsigned int register_index;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   316
    unsigned int register_count;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   317
    MOJOSHADER_symbolTypeInfo info;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   318
    void *default_value;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   319
} MOJOSHADER_symbol;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   320
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   321
536
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   322
typedef struct MOJOSHADER_error
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   323
{
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   324
    /*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   325
     * Human-readable error, if there is one. Will be NULL if there was no
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   326
     *  error. The string will be UTF-8 encoded, and English only. Most of
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   327
     *  these shouldn't be shown to the end-user anyhow.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   328
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   329
    const char *error;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   330
523
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 515
diff changeset
   331
    /*
536
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   332
     * Filename where error happened.
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   333
     */
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   334
    const char *filename;
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   335
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   336
    /*
523
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 515
diff changeset
   337
     * Position of error, if there is one. Will be -3 if there was no
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 515
diff changeset
   338
     *  error, -2 if there was an error before processing started, and
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 515
diff changeset
   339
     *  -1 if there was an error during final processing. If >= 0,
475
ea119c8ce5cd Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
   340
     *  MOJOSHADER_parse() sets this to the byte offset (starting at zero) into
ea119c8ce5cd Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
   341
     *  the bytecode you supplied, and MOJOSHADER_assemble() sets this to a
489
414b70b829d7 Actually, let's make assembly error positions be option base 1.
Ryan C. Gordon <icculus@icculus.org>
parents: 475
diff changeset
   342
     *  a line number in the source code you supplied (starting at one).
475
ea119c8ce5cd Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
   343
     */
ea119c8ce5cd Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
   344
    int error_position;
536
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   345
} MOJOSHADER_error;
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   346
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   347
/*
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   348
 * Structure used to return data from parsing of a shader...
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   349
 */
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   350
/* !!! FIXME: most of these ints should be unsigned. */
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   351
typedef struct MOJOSHADER_parseData
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   352
{
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   353
    /*
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   354
     * The number of elements pointed to by (errors).
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   355
     */
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   356
    int error_count;
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   357
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   358
    /*
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   359
     * (error_count) elements of data that specify errors that were generated
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   360
     *  by parsing this shader.
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   361
     * This can be NULL if there were no errors or if (error_count) is zero.
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   362
     */
5af65fe6e917 Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 524
diff changeset
   363
    MOJOSHADER_error *errors;
475
ea119c8ce5cd Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
   364
ea119c8ce5cd Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
   365
    /*
187
1c709f65cf1b Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
   366
     * The name of the profile used to parse the shader. Will be NULL on error.
1c709f65cf1b Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
   367
     */
1c709f65cf1b Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
   368
    const char *profile;
1c709f65cf1b Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
   369
1c709f65cf1b Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
   370
    /*
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   371
     * Bytes of output from parsing. Most profiles produce a string of source
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   372
     *  code, but profiles that do binary output may not be text at all.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   373
     *  Will be NULL on error.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   374
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   375
    const char *output;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   376
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   377
    /*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   378
     * Byte count for output, not counting any null terminator. Most profiles
113
8ebf445c5305 Print output in testparse.c byte-by-byte instead of as an ASCIZ string.
Ryan C. Gordon <icculus@icculus.org>
parents: 109
diff changeset
   379
     *  produce an ASCII string of source code (which will be null-terminated
8ebf445c5305 Print output in testparse.c byte-by-byte instead of as an ASCIZ string.
Ryan C. Gordon <icculus@icculus.org>
parents: 109
diff changeset
   380
     *  even though that null char isn't included in output_len), but profiles
8ebf445c5305 Print output in testparse.c byte-by-byte instead of as an ASCIZ string.
Ryan C. Gordon <icculus@icculus.org>
parents: 109
diff changeset
   381
     *  that do binary output may not be text at all. Will be 0 on error.
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   382
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   383
    int output_len;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   384
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   385
    /*
356
8e23d7eb90d9 Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents: 354
diff changeset
   386
     * Count of Direct3D instruction slots used. This is meaningless in terms
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   387
     *  of the actual output, as the profile will probably grow or reduce
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   388
     *  the count (or for high-level languages, not have that information at
356
8e23d7eb90d9 Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents: 354
diff changeset
   389
     *  all). Also, as with Microsoft's own assembler, this value is just a
8e23d7eb90d9 Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents: 354
diff changeset
   390
     *  rough estimate, as unpredicable real-world factors make the actual
8e23d7eb90d9 Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents: 354
diff changeset
   391
     *  value vary at least a little from this count. Still, it can give you
8e23d7eb90d9 Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents: 354
diff changeset
   392
     *  a rough idea of the size of your shader. Will be zero on error.
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   393
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   394
    int instruction_count;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   395
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   396
    /*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   397
     * The type of shader we parsed. Will be MOJOSHADER_TYPE_UNKNOWN on error.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   398
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   399
    MOJOSHADER_shaderType shader_type;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   400
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   401
    /*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   402
     * The shader's major version. If this was a "vs_3_0", this would be 3.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   403
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   404
    int major_ver;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   405
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   406
    /*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   407
     * The shader's minor version. If this was a "ps_1_4", this would be 4.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   408
     *  Two notes: for "vs_2_x", this is 1, and for "vs_3_sw", this is 255.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   409
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   410
    int minor_ver;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   411
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   412
    /*
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   413
     * The number of elements pointed to by (uniforms).
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   414
     */
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   415
    int uniform_count;
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   416
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   417
    /*
94
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   418
     * (uniform_count) elements of data that specify Uniforms to be set for
57adfb4769a0 Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents: 92
diff changeset
   419
     *  this shader. See discussion on MOJOSHADER_uniform for details.
145
5325c8d6077c Don't create unnecessary attributes.
Ryan C. Gordon <icculus@icculus.org>
parents: 113
diff changeset
   420
     * This can be NULL on error or if (uniform_count) is zero.
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   421
     */
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   422
    MOJOSHADER_uniform *uniforms;
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   423
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   424
    /*
278
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   425
     * The number of elements pointed to by (constants).
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   426
     */
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   427
    int constant_count;
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   428
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   429
    /*
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   430
     * (constant_count) elements of data that specify constants used in
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   431
     *  this shader. See discussion on MOJOSHADER_constant for details.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   432
     * This can be NULL on error or if (constant_count) is zero.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   433
     *  This is largely informational: constants are hardcoded into a shader.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   434
     *  The constants that you can set like parameters are in the "uniforms"
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   435
     *  list.
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   436
     */
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   437
    MOJOSHADER_constant *constants;
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   438
5c432d216078 Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 276
diff changeset
   439
    /*
148
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   440
     * The number of elements pointed to by (samplers).
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   441
     */
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   442
    int sampler_count;
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   443
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   444
    /*
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   445
     * (sampler_count) elements of data that specify Samplers to be set for
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   446
     *  this shader. See discussion on MOJOSHADER_sampler for details.
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   447
     * This can be NULL on error or if (sampler_count) is zero.
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   448
     */
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   449
    MOJOSHADER_sampler *samplers;
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   450
645003ec6623 Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents: 147
diff changeset
   451
    /*
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   452
     * The number of elements pointed to by (attributes).
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   453
     */
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   454
    int attribute_count;
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   455
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   456
    /*
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   457
     * (attribute_count) elements of data that specify Attributes to be set
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   458
     *  for this shader. See discussion on MOJOSHADER_attribute for details.
145
5325c8d6077c Don't create unnecessary attributes.
Ryan C. Gordon <icculus@icculus.org>
parents: 113
diff changeset
   459
     * This can be NULL on error or if (attribute_count) is zero.
100
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   460
     */
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   461
    MOJOSHADER_attribute *attributes;
2b88649b6f98 First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents: 97
diff changeset
   462
92
bc1bb138e855 Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents: 46
diff changeset
   463
    /*
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   464
     * The number of elements pointed to by (swizzles).
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   465
     */
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   466
    int swizzle_count;
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   467
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   468
    /*
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   469
     * (swizzle_count) elements of data that specify swizzles the shader will
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   470
     *  apply to incoming attributes. This is a copy of what was passed to
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   471
     *  MOJOSHADER_parseData().
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   472
     * This can be NULL on error or if (swizzle_count) is zero.
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   473
     */
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   474
    MOJOSHADER_swizzle *swizzles;
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   475
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   476
    /*
524
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   477
     * The number of elements pointed to by (symbols).
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   478
     */
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   479
    int symbol_count;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   480
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   481
    /*
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   482
     * (symbol_count) elements of data that specify high-level symbol data
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   483
     *  for the shader. This will be parsed from the CTAB section
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   484
     *  in bytecode, and will be a copy of what you provide to
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   485
     *  MOJOSHADER_assemble(). This data is optional.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   486
     * This can be NULL on error or if (symbol_count) is zero.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   487
     */
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   488
    MOJOSHADER_symbol *symbols;
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   489
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   490
    /*
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   491
     * This is the malloc implementation you passed to MOJOSHADER_parse().
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   492
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   493
    MOJOSHADER_malloc malloc;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   494
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   495
    /*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   496
     * This is the free implementation you passed to MOJOSHADER_parse().
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   497
     */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   498
    MOJOSHADER_free free;
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   499
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   500
    /*
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   501
     * This is the pointer you passed as opaque data for your allocator.
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   502
     */
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   503
    void *malloc_data;
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   504
} MOJOSHADER_parseData;
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   505
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   506
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   507
/*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   508
 * Profile string for Direct3D assembly language output.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   509
 */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   510
#define MOJOSHADER_PROFILE_D3D "d3d"
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   511
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   512
/*
109
48e95cf41505 Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents: 101
diff changeset
   513
 * Profile string for passthrough of the original bytecode, unchanged.
48e95cf41505 Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents: 101
diff changeset
   514
 */
469
b8cfaae6c4af Renamed "passthrough" profile to "bytecode"
Ryan C. Gordon <icculus@icculus.org>
parents: 465
diff changeset
   515
#define MOJOSHADER_PROFILE_BYTECODE "bytecode"
109
48e95cf41505 Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents: 101
diff changeset
   516
48e95cf41505 Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents: 101
diff changeset
   517
/*
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   518
 * Profile string for GLSL: OpenGL high-level shader language output.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   519
 */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   520
#define MOJOSHADER_PROFILE_GLSL "glsl"
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   521
323
b60c88ec8182 Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 284
diff changeset
   522
/*
407
620d48c5d13a Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents: 361
diff changeset
   523
 * Profile string for GLSL 1.20: minor improvements to base GLSL spec.
620d48c5d13a Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents: 361
diff changeset
   524
 */
620d48c5d13a Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents: 361
diff changeset
   525
#define MOJOSHADER_PROFILE_GLSL120 "glsl120"
620d48c5d13a Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents: 361
diff changeset
   526
620d48c5d13a Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents: 361
diff changeset
   527
/*
323
b60c88ec8182 Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 284
diff changeset
   528
 * Profile string for OpenGL ARB 1.0 shaders: GL_ARB_(vertex|fragment)_program.
b60c88ec8182 Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 284
diff changeset
   529
 */
b60c88ec8182 Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 284
diff changeset
   530
#define MOJOSHADER_PROFILE_ARB1 "arb1"
b60c88ec8182 Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 284
diff changeset
   531
361
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   532
/*
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   533
 * Profile string for OpenGL ARB 1.0 shaders with Nvidia 2.0 extensions:
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   534
 *  GL_NV_vertex_program2_option and GL_NV_fragment_program2
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   535
 */
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   536
#define MOJOSHADER_PROFILE_NV2 "nv2"
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   537
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   538
/*
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   539
 * Profile string for OpenGL ARB 1.0 shaders with Nvidia 3.0 extensions:
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   540
 *  GL_NV_vertex_program3 and GL_NV_fragment_program2
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   541
 */
421
bfd3d95273ec First piece of work on nv3 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 407
diff changeset
   542
#define MOJOSHADER_PROFILE_NV3 "nv3"
361
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   543
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   544
/*
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   545
 * Profile string for OpenGL ARB 1.0 shaders with Nvidia 4.0 extensions:
454
70c9818840eb Happy September. Minor comment tweak.
Ryan C. Gordon <icculus@icculus.org>
parents: 450
diff changeset
   546
 *  GL_NV_gpu_program4
361
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   547
 */
431
0d0cbe10db02 First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 422
diff changeset
   548
#define MOJOSHADER_PROFILE_NV4 "nv4"
361
9fa6652cacbd First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents: 356
diff changeset
   549
458
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   550
/*
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   551
 * Determine the highest supported Shader Model for a profile.
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   552
 */
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   553
int MOJOSHADER_maxShaderModel(const char *profile);
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   554
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   555
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   556
/*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   557
 * Parse a compiled Direct3D shader's bytecode.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   558
 *
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   559
 * This is your primary entry point into MojoShader. You need to pass it
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   560
 *  a compiled D3D shader and tell it which "profile" you want to use to
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   561
 *  convert it into useful data.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   562
 *
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   563
 * The available profiles are the set of MOJOSHADER_PROFILE_* defines.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   564
 *  Note that MojoShader may be built without support for all listed
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   565
 *  profiles (in which case using one here will return with an error).
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   566
 *
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   567
 * As parsing requires some memory to be allocated, you may provide a custom
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   568
 *  allocator to this function, which will be used to allocate/free memory.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   569
 *  They function just like malloc() and free(). We do not use realloc().
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   570
 *  If you don't care, pass NULL in for the allocator functions. If your
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   571
 *  allocator needs instance-specific data, you may supply it with the
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   572
 *  (d) parameter. This pointer is passed as-is to your (m) and (f) functions.
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   573
 *
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   574
 * This function returns a MOJOSHADER_parseData.
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   575
 *
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   576
 * This function will never return NULL, even if the system is completely
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   577
 *  out of memory upon entry (in which case, this function returns a static
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   578
 *  MOJOSHADER_parseData object, which is still safe to pass to
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   579
 *  MOJOSHADER_freeParseData()).
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   580
 *
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   581
 * You can tell the generated program to swizzle certain inputs. If you know
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   582
 *  that COLOR0 should be RGBA but you're passing in ARGB, you can specify
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   583
 *  a swizzle of { MOJOSHADER_USAGE_COLOR, 0, {1,2,3,0} } to (swiz). If the
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   584
 *  input register in the code would produce reg.ywzx, that swizzle would
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   585
 *  change it to reg.wzxy ... (swiz) can be NULL.
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   586
 *
187
1c709f65cf1b Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
   587
 * This function is thread safe, so long as (m) and (f) are too, and that
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   588
 *  (tokenbuf) remains intact for the duration of the call. This allows you
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   589
 *  to parse several shaders on separate CPU cores at the same time.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   590
 */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   591
const MOJOSHADER_parseData *MOJOSHADER_parse(const char *profile,
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   592
                                             const unsigned char *tokenbuf,
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   593
                                             const unsigned int bufsize,
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   594
                                             const MOJOSHADER_swizzle *swiz,
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   595
                                             const unsigned int swizcount,
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   596
                                             MOJOSHADER_malloc m,
97
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   597
                                             MOJOSHADER_free f,
4a41e3d17297 Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents: 94
diff changeset
   598
                                             void *d);
46
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   599
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   600
/*
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   601
 * Call this to dispose of parsing results when you are done with them.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   602
 *  This will call the MOJOSHADER_free function you provided to
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   603
 *  MOJOSHADER_parse multiple times, if you provided one.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   604
 *  Passing a NULL here is a safe no-op.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   605
 *
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   606
 * This function is thread safe, so long as any allocator you passed into
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   607
 *  MOJOSHADER_parse() is, too.
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   608
 */
ff5a0ec44f00 [svn] Lots and lots of work on the public API.
icculus
parents: 36
diff changeset
   609
void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *data);
7
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
   610
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   611
218
d3fac270bca1 Minor comment added.
Ryan C. Gordon <icculus@icculus.org>
parents: 217
diff changeset
   612
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   613
/* Assembler interface... */
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   614
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   615
/*
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   616
 * This function is optional. Use this to convert Direct3D shader assembly
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   617
 *  language into bytecode, which can be handled by MOJOSHADER_parse().
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   618
 *
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   619
 * (source) is an ASCII, NULL-terminated string of valid Direct3D shader
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   620
 *  assembly source code.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   621
 *
524
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   622
 * (comments) points to (comment_count) NULL-terminated ASCII strings, and
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   623
 *  can be NULL. These strings are inserted as comments in the bytecode.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   624
 *
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   625
 * (symbols) points to (symbol_count) symbol structs, and can be NULL. These
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   626
 *  become a CTAB field in the bytecode. This is optional, but
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   627
 *  MOJOSHADER_parse() needs CTAB data for all arrays used in a program, or
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   628
 *  relative addressing will not be permitted, so you'll want to at least
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   629
 *  provide symbol information for those. The symbol data is 100% trusted
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   630
 *  at this time; it will not be checked to see if it matches what was
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   631
 *  assembled in any way whatsoever.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   632
 *
470
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   633
 * This will return a MOJOSHADER_parseData(), like MOJOSHADER_parse() would,
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   634
 *  except the profile will be MOJOSHADER_PROFILE_BYTECODE and the output
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   635
 *  will be the assembled bytecode instead of some other language. This output
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   636
 *  can be pushed back through MOJOSHADER_parseData() with a different profile.
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   637
 *
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   638
 * This function will never return NULL, even if the system is completely
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   639
 *  out of memory upon entry (in which case, this function returns a static
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   640
 *  MOJOSHADER_parseData object, which is still safe to pass to
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   641
 *  MOJOSHADER_freeParseData()).
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   642
 *
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   643
 * As assembling requires some memory to be allocated, you may provide a
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   644
 *  custom allocator to this function, which will be used to allocate/free
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   645
 *  memory. They function just like malloc() and free(). We do not use
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   646
 *  realloc(). If you don't care, pass NULL in for the allocator functions.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   647
 *  If your allocator needs instance-specific data, you may supply it with the
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   648
 *  (d) parameter. This pointer is passed as-is to your (m) and (f) functions.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   649
 *
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   650
 * This function is thread safe, so long as (m) and (f) are too, and that
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   651
 *  (source) remains intact for the duration of the call. This allows you
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   652
 *  to assemble several shaders on separate CPU cores at the same time.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   653
 */
470
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 469
diff changeset
   654
const MOJOSHADER_parseData *MOJOSHADER_assemble(const char *source,
524
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   655
                             const char **comments, unsigned int comment_count,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   656
                             const MOJOSHADER_symbol *symbols,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   657
                             unsigned int symbol_count,
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   658
                             MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   659
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 462
diff changeset
   660
218
d3fac270bca1 Minor comment added.
Ryan C. Gordon <icculus@icculus.org>
parents: 217
diff changeset
   661
d3fac270bca1 Minor comment added.
Ryan C. Gordon <icculus@icculus.org>
parents: 217
diff changeset
   662
/* OpenGL interface... */
d3fac270bca1 Minor comment added.
Ryan C. Gordon <icculus@icculus.org>
parents: 217
diff changeset
   663
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   664
/*
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   665
 * "Contexts" map to OpenGL contexts...you need one per window, or whatever,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   666
 *  and need to inform MojoShader when you make a new one current.
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   667
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   668
 * "Shaders" refer to individual vertex or pixel programs, and are created
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   669
 *  by "compiling" Direct3D shader bytecode. A vertex and pixel shader are
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   670
 *  "linked" into a "Program" before you can use them to render.
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   671
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   672
 * To the calling application, these are all opaque handles.
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   673
 */
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   674
typedef struct MOJOSHADER_glContext MOJOSHADER_glContext;
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   675
typedef struct MOJOSHADER_glShader MOJOSHADER_glShader;
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   676
typedef struct MOJOSHADER_glProgram MOJOSHADER_glProgram;
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   677
262
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   678
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   679
/*
422
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   680
 * Get a list of available profiles. This will fill in the array (profs)
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   681
 *  with up to (size) pointers of profiles that the current system can handle;
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   682
 *  that is, the profiles are built into MojoShader and the OpenGL extensions
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   683
 *  required for them exist at runtime. This function returns the number of
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   684
 *  available profiles, which may be more, less, or equal to (size).
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   685
 *
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   686
 * If there are more than (size) profiles, the (profs) buffer will not
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   687
 *  overflow. You can check the return value for the total number of
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   688
 *  available profiles, allocate more space, and try again if necessary.
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   689
 *  Calling this function with (size) == 0 is legal.
262
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   690
 *
422
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   691
 * You can only call this AFTER you have successfully built your GL context
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   692
 *  and made it current. This function will lookup the GL functions it needs
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   693
 *  through the callback you supply. The lookup function is neither stored nor
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   694
 *  used by MojoShader after this function returns, nor are the functions it
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   695
 *  might look up.
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   696
 *
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   697
 * You should not free any strings returned from this function; they are
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   698
 *  pointers to internal, probably static, memory.
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   699
 *
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   700
 * This call is NOT thread safe! As most OpenGL implementations are not thread
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   701
 *  safe, you should probably only call this from the same thread that created
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   702
 *  the GL context.
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   703
 */
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   704
int MOJOSHADER_glAvailableProfiles(void *(*lookup)(const char *fnname),
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   705
                                   const char **profs, const int size);
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   706
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   707
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   708
/*
1d5eaf3a4c98 Added MOJOSHADER_glAvailableProfiles().
Ryan C. Gordon <icculus@icculus.org>
parents: 421
diff changeset
   709
 * Determine the best profile to use for the current system.
262
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   710
 *
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   711
 * You can only call this AFTER you have successfully built your GL context
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   712
 *  and made it current. This function will lookup the GL functions it needs
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   713
 *  through the callback you supply. The lookup function is neither stored nor
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   714
 *  used by MojoShader after this function returns, nor are the functions it
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   715
 *  might look up.
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   716
 *
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   717
 * Returns the name of the "best" profile on success, NULL if none of the
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   718
 *  available profiles will work on this system. "Best" is a relative term,
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   719
 *  but it generally means the best trade off between feature set and
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   720
 *  performance. The selection algorithm may be arbitrary and complex.
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   721
 *
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   722
 * The returned value is an internal static string, and should not be free()'d
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   723
 *  by the caller. If you get a NULL, calling MOJOSHADER_glGetError() might
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   724
 *  shed some light on why.
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   725
 *
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   726
 * This call is NOT thread safe! As most OpenGL implementations are not thread
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   727
 *  safe, you should probably only call this from the same thread that created
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   728
 *  the GL context.
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   729
 */
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   730
const char *MOJOSHADER_glBestProfile(void *(*lookup)(const char *fnname));
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   731
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 245
diff changeset
   732
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   733
/*
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   734
 * Prepare MojoShader to manage OpenGL shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   735
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   736
 * You do not need to call this if all you want is MOJOSHADER_parse().
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   737
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   738
 * You must call this once AFTER you have successfully built your GL context
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   739
 *  and made it current. This function will lookup the GL functions it needs
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   740
 *  through the callback you supply, after which it may call them at any time
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   741
 *  up until you call MOJOSHADER_glDestroyContext(). The lookup function is
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   742
 *  neither stored nor used by MojoShader after this function returns.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   743
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   744
 * (profile) is an OpenGL-specific MojoShader profile, which decides how
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   745
 *  Direct3D bytecode shaders get turned into OpenGL programs, and how they
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   746
 *  are fed to the GL.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   747
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   748
 * (lookup) is a callback that is used to load GL entry points. This callback
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   749
 *  has to look up base GL functions and extension entry points.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   750
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   751
 * As MojoShader requires some memory to be allocated, you may provide a
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   752
 *  custom allocator to this function, which will be used to allocate/free
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   753
 *  memory. They function just like malloc() and free(). We do not use
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   754
 *  realloc(). If you don't care, pass NULL in for the allocator functions.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   755
 *  If your allocator needs instance-specific data, you may supply it with the
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   756
 *  (d) parameter. This pointer is passed as-is to your (m) and (f) functions.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   757
 *
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   758
 * Returns a new context on success, NULL on error. If you get a new context,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   759
 *  you need to make it current before using it with
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   760
 *  MOJOSHADER_glMakeContextCurrent().
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   761
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   762
 * This call is NOT thread safe! It must return success before you may call
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   763
 *  any other MOJOSHADER_gl* function. Also, as most OpenGL implementations
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   764
 *  are not thread safe, you should probably only call this from the same
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   765
 *  thread that created the GL context.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   766
 */
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   767
MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile,
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   768
                                        void *(*lookup)(const char *fnname),
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   769
                                        MOJOSHADER_malloc m, MOJOSHADER_free f,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   770
                                        void *d);
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   771
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   772
/*
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   773
 * You must call this before using the context that you got from
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   774
 *  MOJOSHADER_glCreateContext(), and must use it when you switch to a new GL
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   775
 *  context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   776
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   777
 * You can only have one MOJOSHADER_glContext per actual GL context, or
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   778
 *  undefined behaviour will result.
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   779
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   780
 * It is legal to call this with a NULL pointer to make no context current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   781
 *  but you need a valid context to be current to use most of MojoShader.
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   782
 */
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   783
void MOJOSHADER_glMakeContextCurrent(MOJOSHADER_glContext *ctx);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   784
219
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   785
/*
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   786
 * Get any error state we might have picked up. MojoShader will NOT call
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   787
 *  glGetError() internally, but there are other errors we can pick up,
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   788
 *  such as failed shader compilation, etc.
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   789
 *
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   790
 * Returns a human-readable string. This string is for debugging purposes, and
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   791
 *  not guaranteed to be localized, coherent, or user-friendly in any way.
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   792
 *  It's for programmers!
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   793
 *
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   794
 * The latest error may remain between calls. New errors replace any existing
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   795
 *  error. Don't check this string for a sign that an error happened, check
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   796
 *  return codes instead and use this for explanation when debugging.
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   797
 *
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   798
 * Do not free the returned string: it's a pointer to a static internal
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   799
 *  buffer. Do not keep the pointer around, either, as it's likely to become
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   800
 *  invalid as soon as you call into MojoShader again.
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   801
 *
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   802
 * This call is NOT thread safe! As most OpenGL implementations are not thread
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   803
 *  safe, you should probably only call this from the same thread that created
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   804
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   805
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   806
 * This call does NOT require a valid MOJOSHADER_glContext to have been made
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   807
 *  current. The error buffer is shared between contexts, so you can get
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   808
 *  error results from a failed MOJOSHADER_glCreateContext().
219
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   809
 */
61167fc96790 Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents: 218
diff changeset
   810
const char *MOJOSHADER_glGetError(void);
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   811
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   812
/*
276
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   813
 * Get the maximum uniforms a shader can support for the current GL context,
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   814
 *  MojoShader profile, and shader type. You can use this to make decisions
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   815
 *  about what shaders you want to use (for example, a less complicated
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   816
 *  shader may be swapped in for lower-end systems).
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   817
 *
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   818
 * Returns the number, or -1 on error.
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   819
 *
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   820
 * This call is NOT thread safe! As most OpenGL implementations are not thread
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   821
 *  safe, you should probably only call this from the same thread that created
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   822
 *  the GL context.
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   823
 *
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   824
 * This call requires a valid MOJOSHADER_glContext to have been made current,
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   825
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   826
 */
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   827
int MOJOSHADER_glMaxUniforms(MOJOSHADER_shaderType shader_type);
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   828
1d7437469c94 Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents: 262
diff changeset
   829
/*
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   830
 * Compile a buffer of Direct3D shader bytecode into an OpenGL shader.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   831
 *  You still need to link the shader before you may render with it.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   832
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   833
 *   (tokenbuf) is a buffer of Direct3D shader bytecode.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   834
 *   (bufsize) is the size, in bytes, of the bytecode buffer.
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   835
 *   (swiz) and (swizcount) are passed to MOJOSHADER_parse() unmolested.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   836
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   837
 * Returns NULL on error, or a shader handle on success.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   838
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   839
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   840
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   841
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   842
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   843
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   844
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   845
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   846
 * Compiled shaders from this function may not be shared between contexts.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   847
 */
199
03463c4621ad Reduced const insanity in API spec.
Ryan C. Gordon <icculus@icculus.org>
parents: 198
diff changeset
   848
MOJOSHADER_glShader *MOJOSHADER_glCompileShader(const unsigned char *tokenbuf,
450
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   849
                                                const unsigned int bufsize,
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   850
                                                const MOJOSHADER_swizzle *swiz,
6a9faf398c1d Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents: 438
diff changeset
   851
                                                const unsigned int swizcount);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   852
245
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   853
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   854
/*
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   855
 * Get the MOJOSHADER_parseData structure that was produced from the
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   856
 *  call to MOJOSHADER_glCompileShader().
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   857
 *
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   858
 * This data is read-only, and you should NOT attempt to free it. This
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   859
 *  pointer remains valid until the shader is deleted.
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   860
 */
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   861
const MOJOSHADER_parseData *MOJOSHADER_glGetShaderParseData(
1f04b805a4f2 Added MOJOSHADER_glGetShaderParseData().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   862
                                                MOJOSHADER_glShader *shader);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   863
/*
200
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   864
 * Link a vertex and pixel shader into an OpenGL program.
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   865
 *  (vshader) or (pshader) can be NULL, to specify that the GL should use the
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   866
 *  fixed-function pipeline instead of the programmable pipeline for that
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   867
 *  portion of the work. You can reuse shaders in various combinations across
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   868
 *  multiple programs, by relinking different pairs.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   869
 *
200
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   870
 * It is illegal to give a vertex shader for (pshader) or a pixel shader
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   871
 *  for (vshader).
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   872
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   873
 * Once you have successfully linked a program, you may render with it.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   874
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   875
 * Returns NULL on error, or a program handle on success.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   876
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   877
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   878
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   879
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   880
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   881
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   882
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   883
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   884
 * Linked programs from this function may not be shared between contexts.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   885
 */
200
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   886
MOJOSHADER_glProgram *MOJOSHADER_glLinkProgram(MOJOSHADER_glShader *vshader,
5085c788f769 Removed references to "fragment" programs in header.
Ryan C. Gordon <icculus@icculus.org>
parents: 199
diff changeset
   887
                                               MOJOSHADER_glShader *pshader);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   888
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   889
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   890
 * This binds the program (using, for example, glUseProgramObjectARB()), and
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   891
 *  disables all the client-side arrays so we can reset them with new values
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   892
 *  if appropriate.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   893
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   894
 * Call with NULL to disable the programmable pipeline and all enabled
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   895
 *  client-side arrays.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   896
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   897
 * After binding a program, you should update any uniforms you care about
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   898
 *  with MOJOSHADER_glSetVertexShaderUniformF() (etc), set any vertex arrays
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   899
 *  you want to use with MOJOSHADER_glSetVertexAttribute(), and finally call
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   900
 *  MOJOSHADER_glProgramReady() to commit everything to the GL. Then you may
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   901
 *  begin drawing through standard GL entry points.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   902
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   903
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   904
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   905
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   906
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   907
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   908
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   909
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   910
void MOJOSHADER_glBindProgram(MOJOSHADER_glProgram *program);
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   911
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   912
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   913
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   914
 * Set a floating-point uniform value (what Direct3D calls a "constant").
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   915
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   916
 * There is a single array of 4-float "registers" shared by all vertex shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   917
 *  This is the "c" register file in Direct3D (c0, c1, c2, etc...)
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   918
 *  MojoShader will take care of synchronizing this internal array with the
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   919
 *  appropriate variables in the GL shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   920
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   921
 * (idx) is the index into the internal array: 0 is the first four floats,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   922
 *  1 is the next four, etc.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   923
 * (data) is a pointer to (vec4count*4) floats.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   924
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   925
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   926
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   927
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   928
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   929
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   930
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
239
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
   931
 *
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
   932
 * Uniforms are not shared between contexts.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   933
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   934
void MOJOSHADER_glSetVertexShaderUniformF(unsigned int idx, const float *data,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   935
                                          unsigned int vec4count);
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   936
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   937
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   938
 * Set an integer uniform value (what Direct3D calls a "constant").
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   939
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   940
 * There is a single array of 4-int "registers" shared by all vertex shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   941
 *  This is the "i" register file in Direct3D (i0, i1, i2, etc...)
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   942
 *  MojoShader will take care of synchronizing this internal array with the
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   943
 *  appropriate variables in the GL shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   944
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   945
 * (idx) is the index into the internal array: 0 is the first four ints,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   946
 *  1 is the next four, etc.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   947
 * (data) is a pointer to (ivec4count*4) ints.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   948
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   949
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   950
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   951
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   952
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   953
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   954
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
239
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
   955
 *
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
   956
 * Uniforms are not shared between contexts.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   957
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   958
void MOJOSHADER_glSetVertexShaderUniformI(unsigned int idx, const int *data,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   959
                                          unsigned int ivec4count);
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   960
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   961
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   962
 * Set a boolean uniform value (what Direct3D calls a "constant").
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   963
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   964
 * There is a single array of "registers" shared by all vertex shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   965
 *  This is the "b" register file in Direct3D (b0, b1, b2, etc...)
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   966
 *  MojoShader will take care of synchronizing this internal array with the
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   967
 *  appropriate variables in the GL shaders.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   968
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   969
 * Unlike the float and int counterparts, booleans are single values, not
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   970
 *  four-element vectors...so idx==1 is the second boolean in the internal
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   971
 *  array, not the fifth.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   972
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   973
 * Non-zero values are considered "true" and zero is considered "false".
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   974
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   975
 * (idx) is the index into the internal array.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   976
 * (data) is a pointer to (bcount) ints.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   977
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   978
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   979
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   980
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   981
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   982
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   983
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
239
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
   984
 *
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
   985
 * Uniforms are not shared between contexts.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   986
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   987
void MOJOSHADER_glSetVertexShaderUniformB(unsigned int idx, const int *data,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   988
                                          unsigned int bcount);
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
   989
198
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
   990
/*
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
   991
 * The equivalent of MOJOSHADER_glSetVertexShaderUniformF() for pixel
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
   992
 *  shaders. Other than using a different internal array that is specific
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
   993
 *  to pixel shaders, this functions just like its vertex array equivalent.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   994
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   995
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   996
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
   997
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   998
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
   999
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1000
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
239
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
  1001
 *
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
  1002
 * Uniforms are not shared between contexts.
198
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1003
 */
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1004
void MOJOSHADER_glSetPixelShaderUniformF(unsigned int idx, const float *data,
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1005
                                         unsigned int vec4count);
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1006
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1007
/*
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1008
 * The equivalent of MOJOSHADER_glSetVertexShaderUniformI() for pixel
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1009
 *  shaders. Other than using a different internal array that is specific
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1010
 *  to pixel shaders, this functions just like its vertex array equivalent.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1011
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1012
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1013
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1014
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1015
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1016
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1017
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
239
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
  1018
 *
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
  1019
 * Uniforms are not shared between contexts.
198
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1020
 */
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1021
void MOJOSHADER_glSetPixelShaderUniformI(unsigned int idx, const int *data,
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1022
                                         unsigned int ivec4count);
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1023
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1024
/*
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1025
 * The equivalent of MOJOSHADER_glSetVertexShaderUniformB() for pixel
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1026
 *  shaders. Other than using a different internal array that is specific
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1027
 *  to pixel shaders, this functions just like its vertex array equivalent.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1028
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1029
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1030
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1031
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1032
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1033
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1034
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
239
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
  1035
 *
9a9971a6828d Minor documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
  1036
 * Uniforms are not shared between contexts.
198
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1037
 */
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1038
void MOJOSHADER_glSetPixelShaderUniformB(unsigned int idx, const int *data,
e69f11a7b700 Added API to set pixel shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 197
diff changeset
  1039
                                         unsigned int bcount);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1040
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1041
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1042
 * Connect a client-side array to the currently-bound program.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1043
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1044
 * (usage) and (index) map to Direct3D vertex declaration values: COLOR1 would
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1045
 *  be MOJOSHADER_USAGE_COLOR and 1.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1046
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1047
 * The caller should bind VBOs before this call and treat (ptr) as an offset,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1048
 *  if appropriate.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1049
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1050
 * MojoShader will figure out where to plug this stream into the
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1051
 *  currently-bound program, and enable the appropriate client-side array.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1052
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1053
 * (size), (type), (normalized), (stride), and (ptr) correspond to
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1054
 *  glVertexAttribPointer()'s parameters (in most cases, these get passed
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1055
 *  unmolested to that very entry point during this function).
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1056
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1057
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1058
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1059
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1060
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1061
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1062
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1063
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1064
 * Vertex attributes are not shared between contexts.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1065
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1066
void MOJOSHADER_glSetVertexAttribute(MOJOSHADER_usage usage,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1067
                                     int index, unsigned int size,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1068
                                     MOJOSHADER_attributeType type,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1069
                                     int normalized, unsigned int stride,
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1070
                                     const void *ptr);
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1071
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1072
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1073
 * Inform MojoShader that it should commit any pending state to the GL. This
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1074
 *  must be called after you bind a program and update any inputs, right
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1075
 *  before you start drawing, so any outstanding changes made to the shared
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1076
 *  constants array (etc) can propagate to the shader during this call.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1077
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1078
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1079
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1080
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1081
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1082
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1083
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1084
 */
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1085
void MOJOSHADER_glProgramReady(void);
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1086
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1087
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1088
 * Free the resources of a linked program. This will delete the GL object
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1089
 *  and free memory.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1090
 *
197
2ad08d31ea93 API design change.
Ryan C. Gordon <icculus@icculus.org>
parents: 196
diff changeset
  1091
 * If the program is currently bound by MOJOSHADER_glBindProgram(), it will
2ad08d31ea93 API design change.
Ryan C. Gordon <icculus@icculus.org>
parents: 196
diff changeset
  1092
 *  be deleted as soon as it becomes unbound.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1093
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1094
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1095
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1096
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1097
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1098
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1099
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1100
 */
199
03463c4621ad Reduced const insanity in API spec.
Ryan C. Gordon <icculus@icculus.org>
parents: 198
diff changeset
  1101
void MOJOSHADER_glDeleteProgram(MOJOSHADER_glProgram *program);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1102
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1103
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1104
 * Free the resources of a compiled shader. This will delete the GL object
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1105
 *  and free memory.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1106
 *
197
2ad08d31ea93 API design change.
Ryan C. Gordon <icculus@icculus.org>
parents: 196
diff changeset
  1107
 * If the shader is currently referenced by a linked program, it will
2ad08d31ea93 API design change.
Ryan C. Gordon <icculus@icculus.org>
parents: 196
diff changeset
  1108
 *  be deleted as soon as all referencing programs are deleted, too.
217
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1109
 *
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1110
 * This call is NOT thread safe! As most OpenGL implementations are not thread
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1111
 *  safe, you should probably only call this from the same thread that created
611976ab1d25 Documentation update.
Ryan C. Gordon <icculus@icculus.org>
parents: 211
diff changeset
  1112
 *  the GL context.
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1113
 *
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1114
 * This call requires a valid MOJOSHADER_glContext to have been made current,
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1115
 *  or it will crash your program. See MOJOSHADER_glMakeContextCurrent().
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1116
 */
199
03463c4621ad Reduced const insanity in API spec.
Ryan C. Gordon <icculus@icculus.org>
parents: 198
diff changeset
  1117
void MOJOSHADER_glDeleteShader(MOJOSHADER_glShader *shader);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1118
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1119
/*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1120
 * Deinitialize MojoShader's OpenGL shader management.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1121
 *
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
  1122
 * You must call this once, while your GL context (not MojoShader context) is
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
  1123
 *  still current, if you previously had a successful call to
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
  1124
 *  MOJOSHADER_glCreateContext(). This should be the last MOJOSHADER_gl*
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
  1125
 *  function you call until you've prepared a context again.
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1126
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1127
 * This will clean up resources previously allocated, and may call into the GL.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1128
 *
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1129
 * This will not clean up shaders and programs you created! Please call
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1130
 *  MOJOSHADER_glDeleteShader() and MOJOSHADER_glDeleteProgram() to clean
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1131
 *  those up before calling this function!
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1132
 *
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1133
 * This function destroys the MOJOSHADER_glContext you pass it. If it's the
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1134
 *  current context, then no context will be current upon return.
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
  1135
 *
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1136
 * This call is NOT thread safe! There must not be any other MOJOSHADER_gl*
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1137
 *  functions running when this is called. Also, as most OpenGL implementations
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1138
 *  are not thread safe, you should probably only call this from the same
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1139
 *  thread that created the GL context.
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1140
 */
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
  1141
void MOJOSHADER_glDestroyContext(MOJOSHADER_glContext *ctx);
196
5715754e5549 Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents: 190
diff changeset
  1142
7
18bf77bb8c07 [svn] Cleanups, split things out.
icculus
parents:
diff changeset
  1143
#ifdef __cplusplus
18bf77bb8c07 [svn] Cleanups, split things out.
<