Skip to content

Commit

Permalink
Merge pull request floooh#1 from floooh/master
Browse files Browse the repository at this point in the history
Bringing fresh from flooh
  • Loading branch information
martincohen authored Sep 3, 2019
2 parents 3eff120 + 7eab3f1 commit f6fb275
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
3 changes: 2 additions & 1 deletion util/sokol_fontstash.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_FONTSTASH_INCLUDED
/*
sokol_fontstash.h -- renderer for https://github.com/memononen/fontstash
on top of sokol_gl.h
Expand Down Expand Up @@ -180,6 +180,7 @@ SOKOL_API_DECL uint32_t sfons_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SOKOL_FONTSTASH_INCLUDED */

/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_FONTSTASH_IMPL
Expand Down
7 changes: 5 additions & 2 deletions util/sokol_gfx_imgui.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_GFX_IMGUI_INCLUDED
/*
sokol_gfx_imgui.h -- debug-inspection UI for sokol_gfx.h using Dear ImGui
Expand Down Expand Up @@ -157,6 +157,7 @@
3. This notice may not be removed or altered from any source
distribution.
*/
#define SOKOL_GFX_IMGUI_INCLUDED (1)
#include <stdint.h>
#include <stdbool.h>

Expand Down Expand Up @@ -583,9 +584,11 @@ SOKOL_API_DECL void sg_imgui_draw_capabilities_window(sg_imgui_t* ctx);
#if defined(__cplusplus)
} /* extern "C" */
#endif
#endif /* SOKOL_GFX_IMGUI_INCLUDED */

/*=== IMPLEMENTATION =========================================================*/
#if defined SOKOL_GFX_IMGUI_IMPL
#ifdef SOKOL_GFX_IMGUI_IMPL
#define SOKOL_GFX_IMGUI_IMPL_INCLUDED (1)
#if defined(__cplusplus)
#if !defined(IMGUI_VERSION)
#error "Please include imgui.h before the sokol_imgui.h implementation"
Expand Down
28 changes: 25 additions & 3 deletions util/sokol_gl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_GL_INCLUDED
/*
sokol_gl.h -- OpenGL 1.x style rendering on top of sokol_gfx.h
Expand Down Expand Up @@ -298,7 +298,8 @@
sgl_end()
This will record a new draw command in sokol-gl's internal command
list.
list, or it will extend the previous draw command if no relevant
state has changed since the last sgl_begin/end pair.
--- inside a sokol-gfx rendering pass, call:
Expand Down Expand Up @@ -386,10 +387,30 @@
sg_apply_uniforms()
- finally call sg_draw()
All other functions just modify the internally tracked state, add
All other functions only modify the internally tracked state, add
data to the vertex, uniform and command buffers, or manipulate
the matrix stack.
ON DRAW COMMAND MERGING
=======================
Not every call to sgl_end() will automatically record a new draw command.
If possible, the previous draw command will simply be extended,
resulting in fewer actual draw calls later in sgl_draw().
A draw command will be merged with the previous command if "no relevant
state has changed" since the last sgl_end(), meaning:
- no calls to sgl_apply_viewport() and sgl_apply_scissor_rect()
- the primitive type hasn't changed
- the primitive type isn't a 'strip type' (no line or triangle strip)
- the pipeline state object hasn't changed
- none of the matrices has changed
- none of the texture state has changed
Merging a draw command simply means that the number of vertices
to render in the previous draw command will be incremented by the
number of vertices in the new draw command.
LICENSE
=======
zlib/libpng license
Expand Down Expand Up @@ -556,6 +577,7 @@ SOKOL_API_DECL void sgl_draw(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SOKOL_GL_INCLUDED */

/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_GL_IMPL
Expand Down
3 changes: 2 additions & 1 deletion util/sokol_imgui.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_IMGUI_INCLUDED
/*
sokol_imgui.h -- drop-in Dear ImGui renderer/event-handler for sokol_gfx.h
Expand Down Expand Up @@ -232,6 +232,7 @@ SOKOL_API_DECL void simgui_shutdown(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SOKOL_IMGUI_INCLUDED */

/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_IMGUI_IMPL
Expand Down

0 comments on commit f6fb275

Please sign in to comment.