made web compatible
This commit is contained in:
parent
3d41defaf9
commit
fdfb5b8032
|
@ -7,7 +7,9 @@
|
|||
|
||||
static f32 screen_rect[12] = {
|
||||
-1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f};
|
||||
static u32 sw_screen_vao, vbo;
|
||||
|
||||
u32 sw_screen_vao;
|
||||
static u32 vbo;
|
||||
|
||||
struct sw_framebuffer *sw_framebuffer_create(struct sw_vec2i size) {
|
||||
struct sw_framebuffer *fb;
|
||||
|
@ -60,7 +62,7 @@ void sw_framebuffer_render(struct sw_framebuffer *fb) {
|
|||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 12);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
@ -84,13 +86,15 @@ void sw_framebuffer_resize(
|
|||
);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, fb->_fbtex, 0);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->_fbtex, 0
|
||||
);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fb->_fbdepth);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_DEPTH_COMPONENT,
|
||||
GL_DEPTH_COMPONENT16,
|
||||
new_size.x,
|
||||
new_size.y,
|
||||
0,
|
||||
|
@ -101,5 +105,7 @@ void sw_framebuffer_resize(
|
|||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, fb->_fbdepth, 0);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, fb->_fbdepth, 0
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ static void _tick();
|
|||
static struct sw_window *_tick_window;
|
||||
static void (*_tick_fn)();
|
||||
static void win_callback(GLFWwindow *glfw_win, i32 width, i32 height);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
static void GLAPIENTRY gldebug(
|
||||
GLenum source,
|
||||
GLenum type,
|
||||
|
@ -24,6 +26,7 @@ static void GLAPIENTRY gldebug(
|
|||
const char *msg,
|
||||
const void *user
|
||||
);
|
||||
#endif
|
||||
|
||||
struct sw_window *sw_window_create(struct sw_vec2i size, char *title) {
|
||||
struct sw_window *win;
|
||||
|
@ -42,7 +45,9 @@ struct sw_window *sw_window_create(struct sw_vec2i size, char *title) {
|
|||
glfwMakeContextCurrent(win->_window);
|
||||
glewInit();
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
#ifndef __EMSCRIPTEN__
|
||||
glDebugMessageCallback(gldebug, 0);
|
||||
#endif
|
||||
glfwSwapInterval(1);
|
||||
sw_log("setup ogl defaults");
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
@ -101,6 +106,7 @@ static void win_callback(GLFWwindow *glfw_win, i32 width, i32 height) {
|
|||
win->window_size = sw_vec2i(width, height);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
void GLAPIENTRY gldebug(
|
||||
GLenum source,
|
||||
GLenum type,
|
||||
|
@ -122,3 +128,4 @@ void GLAPIENTRY gldebug(
|
|||
sw_log("%s", msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue