Fixed issues with opengl context version and minor bug with blinn-phong uniform bug

dev
Shariq Shah 9 years ago
parent 1ff8de31e3
commit 22684f22d5
  1. 1
      assets/shaders/blinn_phong.frag
  2. 10
      assets/shaders/commonVert.glsl
  3. 7
      orgfile.org
  4. 8
      src/material.c
  5. 7
      src/platform.c
  6. 2
      src/renderer.c
  7. 6
      src/texture.c

@ -36,7 +36,6 @@ vec3 calc_point_light(in Light light)
vec3 specular_comp = vec3(0.0); vec3 specular_comp = vec3(0.0);
vec3 light_direction = vertex - light.position; vec3 light_direction = vertex - light.position;
float dist = abs(length(light_direction)); float dist = abs(length(light_direction));
if(dist <= light.radius) if(dist <= light.radius)
{ {
light_direction = normalize(light_direction); light_direction = normalize(light_direction);

@ -7,13 +7,13 @@ in vec2 vUV;
out vec2 uv; out vec2 uv;
out vec3 normal; out vec3 normal;
out vec3 vertex; out vec3 vertex;
out vec3 vertCamSpace; // out vec3 vertCamSpace;
out vec4 vertLightSpace; // out vec4 vertLightSpace;
// Common uniforms // Common uniforms
uniform mat4 model_mat; uniform mat4 model_mat;
uniform mat4 inv_model_mat; uniform mat4 inv_model_mat;
uniform mat4 view_mat; // uniform mat4 view_mat;
uniform mat4 mvp; uniform mat4 mvp;
uniform mat4 lightVPMat; uniform mat4 lightVPMat;
@ -28,6 +28,6 @@ void setOutputs()
//Normal and vertex sent to the fragment shader should be in the same space! //Normal and vertex sent to the fragment shader should be in the same space!
normal = vec4(transpose(inv_model_mat) * vec4(vNormal, 0.0)).xyz; normal = vec4(transpose(inv_model_mat) * vec4(vNormal, 0.0)).xyz;
vertex = vec4(model_mat * vec4(vPosition, 1.0)).xyz; vertex = vec4(model_mat * vec4(vPosition, 1.0)).xyz;
vertCamSpace = vec4(view_mat * vec4(vPosition, 1.0)).xyz; // vertCamSpace = vec4(view_mat * vec4(vPosition, 1.0)).xyz;
vertLightSpace = vec4((lightVPMat * model_mat) * vec4(vPosition, 1.0)); // vertLightSpace = vec4((lightVPMat * model_mat) * vec4(vPosition, 1.0));
} }

@ -74,7 +74,9 @@ All the code in this repository is under GPLv3, see LICENSE for more information
** TODO Lights! ** TODO Lights!
** DONE Fix problems with texture units ** DONE Fix problems with texture units
- State "DONE" from "TODO" [2016-05-30 Mon 00:57] - State "DONE" from "TODO" [2016-05-30 Mon 00:57]
** TODO Draw light volumes ** CANCELED Draw light volumes
- State "CANCELED" from "TODO" [2017-02-26 Sun 15:39] \\
Deferred rendering on hold for now.
** TODO Fix problems with frustrum culling ** TODO Fix problems with frustrum culling
- Recalculate bounding boxes for rotated meshes? - Recalculate bounding boxes for rotated meshes?
** TODO 2d drawing routines ** TODO 2d drawing routines
@ -87,7 +89,8 @@ All the code in this repository is under GPLv3, see LICENSE for more information
** TODO Variant type ** TODO Variant type
** TODO Event Subsystem ** TODO Event Subsystem
** TODO Fix mouse bugs ** TODO Fix mouse bugs
** TODO Fix issues with opengl context showing 2.1 only ** DONE Fix issues with opengl context showing 2.1 only
- State "DONE" from "TODO" [2017-02-26 Sun 15:39]
** TODO Improve this readme ** TODO Improve this readme
** TODO ??? ** TODO ???
** TODO Profit! ** TODO Profit!

@ -100,10 +100,10 @@ void material_init(void)
uniform->type = UT_MAT4; uniform->type = UT_MAT4;
uniform->location = shader_get_uniform_location(blinn_phong_mat->shader, uniform->name); uniform->location = shader_get_uniform_location(blinn_phong_mat->shader, uniform->name);
uniform = array_grow(blinn_phong_mat->pipeline_params, struct Uniform); /* uniform = array_grow(blinn_phong_mat->pipeline_params, struct Uniform); */
uniform->name = str_new("view_mat"); /* uniform->name = str_new("view_mat"); */
uniform->type = UT_MAT4; /* uniform->type = UT_MAT4; */
uniform->location = shader_get_uniform_location(blinn_phong_mat->shader, uniform->name); /* uniform->location = shader_get_uniform_location(blinn_phong_mat->shader, uniform->name); */
uniform = array_grow(blinn_phong_mat->pipeline_params, struct Uniform); uniform = array_grow(blinn_phong_mat->pipeline_params, struct Uniform);
uniform->name = str_new("inv_model_mat"); uniform->name = str_new("inv_model_mat");

@ -44,8 +44,11 @@ struct Window* window_create(const char* title, int width, int height)
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
#ifdef GL_DEBUG_CONTEXT #ifdef GL_DEBUG_CONTEXT
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
#endif #endif

@ -28,7 +28,7 @@ void renderer_init(void)
{ {
glClearColor(0.3f, 0.6f, 0.9f, 1.0f); glClearColor(0.3f, 0.6f, 0.9f, 1.0f);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D); /* glEnable(GL_TEXTURE_2D); */
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
platform_windowresize_callback_set(on_framebuffer_size_change); platform_windowresize_callback_set(on_framebuffer_size_change);

@ -299,10 +299,12 @@ void texture_set_param(int index, int parameter, int value)
return; return;
GLint curr_texture = 0; GLint curr_texture = 0;
glGetIntegerv(GL_TEXTURE_2D, &curr_texture); glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_texture);
renderer_check_glerror("texture:set_param:glGetIntegerv");
glBindTexture(GL_TEXTURE_2D, texture->handle); glBindTexture(GL_TEXTURE_2D, texture->handle);
renderer_check_glerror("texture:set_param:glBindTexture");
glTexParameteri(GL_TEXTURE_2D, parameter, value); glTexParameteri(GL_TEXTURE_2D, parameter, value);
renderer_check_glerror("texture:set_param"); renderer_check_glerror("texture:set_param:glTexParameteri");
if(curr_texture != 0) if(curr_texture != 0)
glBindTexture(GL_TEXTURE_2D, curr_texture); glBindTexture(GL_TEXTURE_2D, curr_texture);
} }

Loading…
Cancel
Save