mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- added handling for drawing with uniform vertices. It draws something but in the wrong place. Right now I have no idea what's happening...
This commit is contained in:
parent
7ba5acfb35
commit
250be72939
6 changed files with 32 additions and 25 deletions
|
@ -137,9 +137,9 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
||||||
: FVertexBuffer(gl.buffermethod == BM_PERSISTENT)
|
: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY)
|
||||||
{
|
{
|
||||||
if (gl.buffermethod == BM_PERSISTENT)
|
if (gl.buffermethod != BM_CLIENTARRAY)
|
||||||
{
|
{
|
||||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
|
@ -157,10 +157,10 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
||||||
vbo_shadowdata.Resize(mNumReserved);
|
vbo_shadowdata.Resize(mNumReserved);
|
||||||
|
|
||||||
// the first quad is reserved for handling coordinates through uniforms.
|
// the first quad is reserved for handling coordinates through uniforms.
|
||||||
vbo_shadowdata[0].Set(1, 0, 0, 0, 0);
|
vbo_shadowdata[0].Set(0, 0, 0, 0, 0);
|
||||||
vbo_shadowdata[1].Set(2, 0, 0, 0, 0);
|
vbo_shadowdata[1].Set(1, 0, 0, 0, 0);
|
||||||
vbo_shadowdata[2].Set(3, 0, 0, 0, 0);
|
vbo_shadowdata[2].Set(2, 0, 0, 0, 0);
|
||||||
vbo_shadowdata[3].Set(4, 0, 0, 0, 0);
|
vbo_shadowdata[3].Set(3, 0, 0, 0, 0);
|
||||||
|
|
||||||
// and the second one for the fullscreen quad used for blend overlays.
|
// and the second one for the fullscreen quad used for blend overlays.
|
||||||
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
|
|
||||||
FQuadDrawer()
|
FQuadDrawer()
|
||||||
{
|
{
|
||||||
if (gl.flags & RFL_QUADHACK)
|
if (gl.buffermethod == BM_DEFERRED)
|
||||||
{
|
{
|
||||||
p = buffer;
|
p = buffer;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public:
|
||||||
}
|
}
|
||||||
void Render(int type)
|
void Render(int type)
|
||||||
{
|
{
|
||||||
if (gl.flags & RFL_QUADHACK)
|
if (gl.buffermethod == BM_DEFERRED)
|
||||||
{
|
{
|
||||||
DoRender(type);
|
DoRender(type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
|
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//if (gl.buffermethod == BM_DEFERRED)
|
||||||
|
{
|
||||||
|
vp_comb << "#define USE_QUAD_DRAWER\n";
|
||||||
|
}
|
||||||
|
|
||||||
vp_comb << defines << i_data.GetString().GetChars();
|
vp_comb << defines << i_data.GetString().GetChars();
|
||||||
FString fp_comb = vp_comb;
|
FString fp_comb = vp_comb;
|
||||||
|
@ -276,6 +280,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(hShader);
|
glUseProgram(hShader);
|
||||||
|
if (quadmode_index > 0) glUniform1i(quadmode_index, 0);
|
||||||
|
|
||||||
// set up other texture units (if needed by the shader)
|
// set up other texture units (if needed by the shader)
|
||||||
for (int i = 2; i<16; i++)
|
for (int i = 2; i<16; i++)
|
||||||
|
|
|
@ -156,7 +156,15 @@ void gl_LoadExtensions()
|
||||||
|
|
||||||
gl.version = strtod(version, NULL) + 0.01f;
|
gl.version = strtod(version, NULL) + 0.01f;
|
||||||
|
|
||||||
// Don't even start if it's lower than 3.0
|
bool iscore = false;
|
||||||
|
if (gl.version >= 3.2)
|
||||||
|
{
|
||||||
|
int v;
|
||||||
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v);
|
||||||
|
iscore = !!(v & GL_CONTEXT_CORE_PROFILE_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't even start if it's lower than 2.0 or no framebuffers are available
|
||||||
if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0)
|
if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0)
|
||||||
{
|
{
|
||||||
I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n");
|
I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n");
|
||||||
|
@ -178,10 +186,10 @@ void gl_LoadExtensions()
|
||||||
if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object")))
|
if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object")))
|
||||||
{
|
{
|
||||||
gl.lightmethod = LM_DEFERRED;
|
gl.lightmethod = LM_DEFERRED;
|
||||||
// Only Apple requires the core profile for GL 3.x+.
|
if (iscore)
|
||||||
// #ifdef __APPLE__
|
{
|
||||||
// gl.buffermethod = BM_DEFERRED;
|
gl.buffermethod = BM_DEFERRED;
|
||||||
// #endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION;
|
if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION;
|
||||||
|
@ -256,7 +264,7 @@ void gl_LoadExtensions()
|
||||||
lm = Args->CheckValue("-buffermethod");
|
lm = Args->CheckValue("-buffermethod");
|
||||||
if (lm != NULL)
|
if (lm != NULL)
|
||||||
{
|
{
|
||||||
//if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
|
if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
|
||||||
if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY;
|
if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@ enum RenderFlags
|
||||||
RFL_NO_DEPTHSTENCIL = 64,
|
RFL_NO_DEPTHSTENCIL = 64,
|
||||||
RFL_NO_CLIP_PLANES = 128,
|
RFL_NO_CLIP_PLANES = 128,
|
||||||
|
|
||||||
RFL_INVALIDATE_BUFFER = 256,
|
RFL_INVALIDATE_BUFFER = 256
|
||||||
RFL_QUADHACK = 512
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TexMode
|
enum TexMode
|
||||||
|
|
|
@ -15,6 +15,7 @@ void main()
|
||||||
{
|
{
|
||||||
vec2 parmTexCoord;
|
vec2 parmTexCoord;
|
||||||
vec4 parmPosition;
|
vec4 parmPosition;
|
||||||
|
|
||||||
#ifndef USE_QUAD_DRAWER
|
#ifndef USE_QUAD_DRAWER
|
||||||
parmTexCoord = aTexCoord;
|
parmTexCoord = aTexCoord;
|
||||||
parmPosition = aPosition;
|
parmPosition = aPosition;
|
||||||
|
@ -26,8 +27,8 @@ void main()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parmPosition = uQuadVertices[int(aPosition.x)].st;
|
parmPosition = uQuadVertices[int(aPosition.x)];
|
||||||
parmTexCoord = uQuadTexCoords[int(aPosition.x)];
|
parmTexCoord = uQuadTexCoords[int(aPosition.x)].st;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -68,12 +69,6 @@ void main()
|
||||||
|
|
||||||
gl_Position = ProjectionMatrix * eyeCoordPos;
|
gl_Position = ProjectionMatrix * eyeCoordPos;
|
||||||
|
|
||||||
#if defined __GLSL_CG_DATA_TYPES && defined GLSL12_COMPATIBILE
|
|
||||||
gl_ClipVertex = eyeCoordPos;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (uClipHeightDirection != 0.0) // clip planes used for reflective flats
|
if (uClipHeightDirection != 0.0) // clip planes used for reflective flats
|
||||||
{
|
{
|
||||||
gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;
|
gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;
|
||||||
|
|
Loading…
Reference in a new issue