mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
pipe color and texcoords thru the shaders
This commit is contained in:
parent
16df2d764a
commit
5b4703bf5f
@ -75,6 +75,10 @@ struct Renderer {
|
||||
vertexAttrib(2, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::uv1, "in_uv1")
|
||||
}} {
|
||||
shader_.Use();
|
||||
|
||||
// these are effectively just constants, for now
|
||||
shader_.setUniform1i("u_texture0", 0);
|
||||
shader_.setUniform1i("u_texture1", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -266,16 +270,6 @@ int opengl_InitCache(void) {
|
||||
GameLightmaps[i].flags |= LF_CHANGED | LF_BRAND_NEW;
|
||||
}
|
||||
|
||||
dglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
if (UseMultitexture) {
|
||||
#if (defined(_USE_OGL_ACTIVE_TEXTURES))
|
||||
dglActiveTextureARB(GL_TEXTURE0_ARB + 1);
|
||||
dglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
dglActiveTextureARB(GL_TEXTURE0_ARB + 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
CHECK_ERROR(3)
|
||||
|
||||
OpenGL_cache_initted = 1;
|
||||
@ -323,6 +317,9 @@ void opengl_SetDefaults() {
|
||||
dglScissor(0, 0, gpu_state.screen_width, gpu_state.screen_height);
|
||||
dglDisable(GL_SCISSOR_TEST);
|
||||
|
||||
gpu_BindTexture(BAD_BITMAP_HANDLE, MAP_TYPE_BITMAP, 0);
|
||||
gpu_BindTexture(BAD_BITMAP_HANDLE, MAP_TYPE_BITMAP, 1);
|
||||
|
||||
if (UseMultitexture) {
|
||||
#if (defined(_USE_OGL_ACTIVE_TEXTURES))
|
||||
dglActiveTextureARB(GL_TEXTURE0_ARB + 1);
|
||||
|
@ -174,6 +174,10 @@ struct ShaderProgram {
|
||||
dglUniformMatrix4fv(getUniformId(name), 1, GL_FALSE, glm::value_ptr(matrix));
|
||||
}
|
||||
|
||||
void setUniform1i(std::string const& name, GLint val) {
|
||||
dglUniform1i(getUniformId(name), val);
|
||||
}
|
||||
|
||||
private:
|
||||
GLint getUniformId(std::string const& name) {
|
||||
auto it = uniform_cache_.find(name);
|
||||
|
@ -202,10 +202,10 @@ DYNAEXTERN(glShaderSource);
|
||||
DYNAEXTERN(glTexCoord2f);
|
||||
DYNAEXTERN(glTexCoord4fv);
|
||||
DYNAEXTERN(glTexCoordPointer);
|
||||
DYNAEXTERN(glTexEnvf);
|
||||
DYNAEXTERN(glTexImage2D);
|
||||
DYNAEXTERN(glTexParameteri);
|
||||
DYNAEXTERN(glTexSubImage2D);
|
||||
DYNAEXTERN(glUniform1i);
|
||||
DYNAEXTERN(glUniformMatrix4fv);
|
||||
DYNAEXTERN(glUseProgram);
|
||||
DYNAEXTERN(glVertexAttribPointer);
|
||||
|
@ -18,9 +18,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
in vec4 vertex_color;
|
||||
in vec2 vertex_uv0;
|
||||
in vec2 vertex_uv1;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
uniform sampler2D u_texture0;
|
||||
uniform sampler2D u_texture1;
|
||||
|
||||
void main()
|
||||
{
|
||||
out_color = vec4(0);
|
||||
out_color = vertex_color * texture(u_texture0, vertex_uv0) * texture(u_texture1, vertex_uv1);
|
||||
}
|
@ -23,9 +23,16 @@ in vec4 in_color;
|
||||
in vec2 in_uv0;
|
||||
in vec2 in_uv1;
|
||||
|
||||
out vec4 vertex_color;
|
||||
out vec2 vertex_uv0;
|
||||
out vec2 vertex_uv1;
|
||||
|
||||
uniform mat4 u_transform;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_transform * vec4(in_pos, 1);
|
||||
vertex_color = in_color;
|
||||
vertex_uv0 = in_uv0;
|
||||
vertex_uv1 = in_uv1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user