mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- replaced builtin texture coordinate vertex attribute.
This commit is contained in:
parent
5a322742c3
commit
1b7f5a2e6a
6 changed files with 20 additions and 16 deletions
|
@ -115,9 +115,9 @@ FFlatVertexBuffer::FFlatVertexBuffer()
|
|||
glBindVertexArray(vao_id);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x);
|
||||
glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableVertexAttribArray(VATTR_TEXCOORD);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,7 @@ CVAR(Bool, gl_testbuffer, false, 0)
|
|||
|
||||
void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count)
|
||||
{
|
||||
#if 0
|
||||
if (!gl_testbuffer) // todo: remove the immediate mode calls once the uniform array method has been tested.
|
||||
{
|
||||
glBegin(primtype);
|
||||
|
@ -151,6 +152,7 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs
|
|||
glEnd();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (count > 20)
|
||||
{
|
||||
|
|
|
@ -117,7 +117,7 @@ FModelVertexBuffer::FModelVertexBuffer()
|
|||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableVertexAttribArray(VATTR_TEXCOORD);
|
||||
glEnableVertexAttribArray(VATTR_VERTEX2);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ FModelVertexBuffer::~FModelVertexBuffer()
|
|||
unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor)
|
||||
{
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u);
|
||||
glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x);
|
||||
return frame1;
|
||||
}
|
||||
|
|
|
@ -81,10 +81,10 @@ FSkyVertexBuffer::FSkyVertexBuffer()
|
|||
glBindVertexArray(vao_id);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u);
|
||||
glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableVertexAttribArray(VATTR_TEXCOORD);
|
||||
glEnableVertexAttribArray(VATTR_COLOR);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
|
|
@ -157,6 +157,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
|
||||
glAttachShader(hShader, hVertProg);
|
||||
glAttachShader(hShader, hFragProg);
|
||||
|
||||
glBindAttribLocation(hShader, VATTR_TEXCOORD, "aTexCoord");
|
||||
glBindAttribLocation(hShader, VATTR_COLOR, "aColor");
|
||||
glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2");
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@ extern bool gl_shaderactive;
|
|||
|
||||
enum
|
||||
{
|
||||
VATTR_COLOR = 14,
|
||||
VATTR_VERTEX2 = 15
|
||||
VATTR_VERTEX = 0,
|
||||
VATTR_TEXCOORD = 1,
|
||||
VATTR_COLOR = 2,
|
||||
VATTR_VERTEX2 = 3
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
in vec2 aTexCoord;
|
||||
in vec4 aColor;
|
||||
#ifndef SIMPLE // we do not need these for simple shaders
|
||||
in vec4 aVertex2;
|
||||
|
@ -15,26 +16,23 @@ uniform float fakeVB[100];
|
|||
|
||||
void main()
|
||||
{
|
||||
|
||||
#ifdef UNIFORM_VB
|
||||
vec4 vert;
|
||||
vec4 tc;
|
||||
|
||||
#ifdef UNIFORM_VB
|
||||
|
||||
if (gl_MultiTexCoord0.x >= 100000.0)
|
||||
{
|
||||
int fakeVI = int(gl_MultiTexCoord0.y)*5;
|
||||
int fakeVI = int(aTexCoord.y)*5;
|
||||
vert = gl_Vertex + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0);
|
||||
tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
vert = gl_Vertex;
|
||||
tc = gl_MultiTexCoord0;
|
||||
tc = vec4(aTexCoord, 0.0, 0.0);
|
||||
}
|
||||
#else
|
||||
#define vert gl_Vertex
|
||||
#define tc gl_MultiTexCoord0
|
||||
#endif
|
||||
|
||||
#ifndef SIMPLE
|
||||
vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor);
|
||||
|
|
Loading…
Reference in a new issue