polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 4a630c47a3e39dc9a567541d50534464b5e230fd
parent 03d8407c08528c43092d06ab83694188fed0044b
Author: William Casarin <jb55@jb55.com>
Date:   Sun,  4 Nov 2018 18:14:00 -0800

fixing build on desktop

Diffstat:
Msrc/fbo.c | 5+++++
Msrc/main.c | 15+++++++++++++++
Msrc/render.c | 15+++++++--------
3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/fbo.c b/src/fbo.c @@ -43,15 +43,20 @@ int fbo_attach_texture(struct fbo *fbo, GLint internalformat, GLint format, glBindFramebuffer(GL_FRAMEBUFFER, fbo->handle); glGenTextures(1, texture); + check_gl(); glBindTexture(GL_TEXTURE_2D, *texture); + check_gl(); glTexImage2D(GL_TEXTURE_2D, 0, internalformat, fbo->width, fbo->height, 0, format, type, NULL); + check_gl(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + check_gl(); if (attachment == GL_DEPTH_ATTACHMENT) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } + check_gl(); glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, *texture, 0); diff --git a/src/main.c b/src/main.c @@ -35,6 +35,21 @@ int main(void) int width = 640; int height = 480; + SDL_Init( SDL_INIT_VIDEO ); + + /* SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); */ + /* SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); */ + /* SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); */ + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); + + SDL_Window *window = SDL_CreateWindow( "SDL2/OpenGL Demo", 0, 0, width, height, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE); diff --git a/src/render.c b/src/render.c @@ -62,18 +62,17 @@ static const float bias_matrix[] = { void init_gl(struct resources *resources, int width, int height) { - struct shader vertex, terrain_vertex, terrain_geom, fragment, fragment_smooth; - struct shader terrain_teval, terrain_tc; - float tmp_matrix[16]; - int ok = 0; + struct shader vertex, terrain_vertex, terrain_geom, fragment, fragment_smooth; + struct shader terrain_teval, terrain_tc; + float tmp_matrix[16]; + int ok = 0; - glEnable(GL_DEPTH_TEST); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); - check_gl(); + glEnable(GL_MULTISAMPLE); +check_gl(); // Shaders ok = make_shader(GL_VERTEX_SHADER, SHADER("vertex-color.glsl"), &vertex);