mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Polymer GPU program management stuff.
git-svn-id: https://svn.eduke32.com/eduke32@1152 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
c95e53c2d0
commit
08923413f2
2 changed files with 142 additions and 2 deletions
|
@ -108,8 +108,34 @@ typedef struct s_pranimatespritesinfo {
|
||||||
int x, y, a, smoothratio;
|
int x, y, a, smoothratio;
|
||||||
} _pranimatespritesinfo;
|
} _pranimatespritesinfo;
|
||||||
|
|
||||||
extern _prsector* prsectors[MAXSECTORS];
|
#define PR_MAXLIGHTS 128
|
||||||
extern _prwall* prwalls[MAXWALLS];
|
|
||||||
|
typedef enum {
|
||||||
|
PR_LIGHT_POINT,
|
||||||
|
PR_LIGHT_SPOT,
|
||||||
|
PR_LIGHT_DIRECTIONAL
|
||||||
|
} prlighttype;
|
||||||
|
|
||||||
|
typedef struct s_prlight {
|
||||||
|
int x, y, z, horiz, range, faderange;
|
||||||
|
short angle, sector;
|
||||||
|
prlighttype type;
|
||||||
|
} _prlight;
|
||||||
|
|
||||||
|
#define PR_INFO_LOG_BUFFER_SIZE 512
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PR_BIT_DEFAULT, // must be just before last
|
||||||
|
PR_BIT_COUNT // must be last
|
||||||
|
} prbittype;
|
||||||
|
|
||||||
|
typedef struct s_prprogrambit {
|
||||||
|
int bit;
|
||||||
|
char* vert_def;
|
||||||
|
char* vert_prog;
|
||||||
|
char* frag_def;
|
||||||
|
char* frag_prog;
|
||||||
|
} _prprogrambit;
|
||||||
|
|
||||||
// CONTROL
|
// CONTROL
|
||||||
extern int updatesectors;
|
extern int updatesectors;
|
||||||
|
@ -123,6 +149,8 @@ void polymer_drawmasks(void);
|
||||||
void polymer_rotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2);
|
void polymer_rotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2);
|
||||||
void polymer_drawmaskwall(int damaskwallcnt);
|
void polymer_drawmaskwall(int damaskwallcnt);
|
||||||
void polymer_drawsprite(int snum);
|
void polymer_drawsprite(int snum);
|
||||||
|
void polymer_resetlights(void);
|
||||||
|
void polymer_addlight(_prlight light);
|
||||||
|
|
||||||
# ifdef POLYMER_C
|
# ifdef POLYMER_C
|
||||||
|
|
||||||
|
@ -160,6 +188,8 @@ static void polymer_drawskybox(short tilenum);
|
||||||
// MDSPRITES
|
// MDSPRITES
|
||||||
static void polymer_drawmdsprite(spritetype *tspr);
|
static void polymer_drawmdsprite(spritetype *tspr);
|
||||||
static void polymer_loadmodelvbos(md3model* m);
|
static void polymer_loadmodelvbos(md3model* m);
|
||||||
|
// GPU PROGRAMS
|
||||||
|
static void polymer_compileprogram(int programbits);
|
||||||
|
|
||||||
# endif // !POLYMER_C
|
# endif // !POLYMER_C
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,32 @@ GLuint skyboxdatavbo;
|
||||||
|
|
||||||
GLfloat artskydata[16];
|
GLfloat artskydata[16];
|
||||||
|
|
||||||
|
_prlight prlights[PR_MAXLIGHTS];
|
||||||
|
int lightcount;
|
||||||
|
|
||||||
|
_prprogrambit prprogrambits[PR_BIT_COUNT] = {
|
||||||
|
{
|
||||||
|
.bit = 1 << PR_BIT_DEFAULT,
|
||||||
|
.vert_def =
|
||||||
|
"\n"
|
||||||
|
"void main(void)\n"
|
||||||
|
"{\n",
|
||||||
|
.vert_prog =
|
||||||
|
" gl_Position = ftransform();\n"
|
||||||
|
"}\n",
|
||||||
|
.frag_def =
|
||||||
|
"\n"
|
||||||
|
"void main(void)\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 result = vec4(1.0, 1.0, 1.0, 1.0);\n",
|
||||||
|
.frag_prog =
|
||||||
|
" gl_FragColor = result;\n"
|
||||||
|
"}\n",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GLhandleARB prprograms[1 << PR_BIT_COUNT];
|
||||||
|
|
||||||
// CONTROL
|
// CONTROL
|
||||||
GLdouble spritemodelview[16];
|
GLdouble spritemodelview[16];
|
||||||
GLdouble rootmodelviewmatrix[16];
|
GLdouble rootmodelviewmatrix[16];
|
||||||
|
@ -619,6 +645,17 @@ void polymer_setanimatesprites(animatespritesptr animatesprites,
|
||||||
asi.smoothratio = smoothratio;
|
asi.smoothratio = smoothratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void polymer_resetlights(void)
|
||||||
|
{
|
||||||
|
lightcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void polymer_addlight(_prlight light)
|
||||||
|
{
|
||||||
|
if (lightcount < PR_MAXLIGHTS)
|
||||||
|
prlights[lightcount++] = light;
|
||||||
|
}
|
||||||
|
|
||||||
// CORE
|
// CORE
|
||||||
static void polymer_displayrooms(short dacursectnum)
|
static void polymer_displayrooms(short dacursectnum)
|
||||||
{
|
{
|
||||||
|
@ -2511,4 +2548,77 @@ static void polymer_loadmodelvbos(md3model* m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GPU PROGRAMS
|
||||||
|
static void polymer_compileprogram(int programbits)
|
||||||
|
{
|
||||||
|
int i, enabledbits;
|
||||||
|
GLhandleARB vert, frag, program;
|
||||||
|
GLcharARB* source[PR_BIT_COUNT * 2];
|
||||||
|
GLcharARB infobuffer[PR_INFO_LOG_BUFFER_SIZE];
|
||||||
|
|
||||||
|
// ========= VERTEX
|
||||||
|
vert = bglCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
||||||
|
|
||||||
|
enabledbits = 0;
|
||||||
|
while (i < PR_BIT_COUNT)
|
||||||
|
{
|
||||||
|
if (programbits & prprogrambits[i].bit)
|
||||||
|
{
|
||||||
|
source[i] = prprogrambits[i].vert_def;
|
||||||
|
enabledbits++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
while (i < PR_BIT_COUNT)
|
||||||
|
{
|
||||||
|
if (programbits & prprogrambits[i].bit)
|
||||||
|
source[enabledbits + i] = prprogrambits[i].vert_prog;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
bglShaderSourceARB(vert, enabledbits * 2, (const GLcharARB**)source, NULL);
|
||||||
|
|
||||||
|
bglCompileShaderARB(vert);
|
||||||
|
|
||||||
|
// ========= FRAGMENT
|
||||||
|
frag = bglCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
||||||
|
|
||||||
|
enabledbits = i = 0;
|
||||||
|
while (i < PR_BIT_COUNT)
|
||||||
|
{
|
||||||
|
if (programbits & prprogrambits[i].bit)
|
||||||
|
{
|
||||||
|
source[i] = prprogrambits[i].frag_def;
|
||||||
|
enabledbits++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
while (i < PR_BIT_COUNT)
|
||||||
|
{
|
||||||
|
if (programbits & prprogrambits[i].bit)
|
||||||
|
source[enabledbits + i] = prprogrambits[i].frag_prog;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
bglShaderSourceARB(frag, enabledbits * 2, (const GLcharARB**)source, NULL);
|
||||||
|
|
||||||
|
bglCompileShaderARB(frag);
|
||||||
|
|
||||||
|
// ========= PROGRAM
|
||||||
|
program = bglCreateProgramObjectARB();
|
||||||
|
|
||||||
|
bglAttachObjectARB(program, vert);
|
||||||
|
bglAttachObjectARB(program, frag);
|
||||||
|
|
||||||
|
bglLinkProgramARB(program);
|
||||||
|
|
||||||
|
bglGetInfoLogARB(program, PR_INFO_LOG_BUFFER_SIZE, NULL, infobuffer);
|
||||||
|
|
||||||
|
prprograms[programbits] = program;
|
||||||
|
|
||||||
|
OSD_Printf("Shader log info:\n%s\n", infobuffer);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue