Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Feb 29, 2024
1 parent 7eed2a9 commit 8d8a9b6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
15 changes: 9 additions & 6 deletions src/sokol/c/sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@
Before being used as Objective-C object, the void* must be converted
back with a (ARC) __bridge cast.
const void* sapp_win32_get_hwnd(void)
On Windows, get the window's HWND, otherwise a null pointer. The
HWND has been cast to a void pointer in order to be tunneled
through code which doesn't include Windows.h.
const void* sapp_d3d11_get_device(void)
const void* sapp_d3d11_get_device_context(void)
const void* sapp_d3d11_get_render_view(void)
Expand All @@ -305,6 +300,11 @@
render-target-view and depth-stencil-view may change from one
frame to the next!
const void* sapp_win32_get_hwnd(void)
On Windows, get the window's HWND, otherwise a null pointer. The
HWND has been cast to a void pointer in order to be tunneled
through code which doesn't include Windows.h.
const void* sapp_wgpu_get_device(void)
const void* sapp_wgpu_get_render_view(void)
const void* sapp_wgpu_get_resolve_view(void)
Expand All @@ -313,6 +313,10 @@
objects and values required for rendering. If sokol_app.h
is not compiled with SOKOL_WGPU, these functions return null.
const uint32_t sapp_gl_get_framebuffer(void)
This returns the 'default framebuffer' of the GL context.
Typically this will be zero.
const void* sapp_android_get_native_activity(void);
On Android, get the native activity ANativeActivity pointer, otherwise
a null pointer.
Expand Down Expand Up @@ -1489,7 +1493,6 @@ typedef struct sapp_range {
Note that the actual image pixel format depends on the use case:
- window icon pixels are RGBA8
- cursor images are ??? (FIXME)
*/
typedef struct sapp_image_desc {
int width;
Expand Down
14 changes: 11 additions & 3 deletions src/sokol/c/sokol_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4716,6 +4716,15 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
#endif
#endif

#if defined(SOKOL_GLES3)
// on WebGL2, GL_FRAMEBUFFER_UNDEFINED technically doesn't exist (it is defined
// in the Emscripten headers, but may not exist in other WebGL2 shims)
// see: https://github.com/floooh/sokol/pull/933
#ifndef GL_FRAMEBUFFER_UNDEFINED
#define GL_FRAMEBUFFER_UNDEFINED 0x8219
#endif
#endif

// ███████ ████████ ██████ ██ ██ ██████ ████████ ███████
// ██ ██ ██ ██ ██ ██ ██ ██ ██
// ███████ ██ ██████ ██ ██ ██ ██ ███████
Expand Down Expand Up @@ -8685,10 +8694,10 @@ _SOKOL_PRIVATE void _sg_gl_end_pass(void) {
invalidate_atts[att_index++] = (GLenum)(GL_COLOR_ATTACHMENT0 + i);
}
}
if (_sg.gl.depth_store_action == SG_STOREACTION_DONTCARE) {
if ((_sg.gl.depth_store_action == SG_STOREACTION_DONTCARE) && (_sg.cur_pass.atts->cmn.depth_stencil.image_id.id != SG_INVALID_ID)) {
invalidate_atts[att_index++] = GL_DEPTH_ATTACHMENT;
}
if (_sg.gl.stencil_store_action == SG_STOREACTION_DONTCARE) {
if ((_sg.gl.stencil_store_action == SG_STOREACTION_DONTCARE) && (_sg.cur_pass.atts->cmn.depth_stencil.image_id.id != SG_INVALID_ID)) {
invalidate_atts[att_index++] = GL_STENCIL_ATTACHMENT;
}
if (att_index > 0) {
Expand Down Expand Up @@ -16104,7 +16113,6 @@ _SOKOL_PRIVATE bool _sg_validate_begin_pass(const sg_pass* pass) {
_SG_VALIDATE(pass->swapchain.d3d11.render_view == 0, VALIDATE_BEGINPASS_SWAPCHAIN_D3D11_EXPECT_RENDERVIEW_NOTSET);
_SG_VALIDATE(pass->swapchain.d3d11.depth_stencil_view == 0, VALIDATE_BEGINPASS_SWAPCHAIN_D3D11_EXPECT_DEPTHSTENCILVIEW_NOTSET);
_SG_VALIDATE(pass->swapchain.d3d11.resolve_view == 0, VALIDATE_BEGINPASS_SWAPCHAIN_D3D11_EXPECT_RESOLVEVIEW_NOTSET);
// FIXME: resolve_view
#elif defined(SOKOL_WGPU)
_SG_VALIDATE(pass->swapchain.wgpu.render_view == 0, VALIDATE_BEGINPASS_SWAPCHAIN_WGPU_EXPECT_RENDERVIEW_NOTSET);
_SG_VALIDATE(pass->swapchain.wgpu.depth_stencil_view == 0, VALIDATE_BEGINPASS_SWAPCHAIN_WGPU_EXPECT_DEPTHSTENCILVIEW_NOTSET);
Expand Down
22 changes: 13 additions & 9 deletions src/sokol/c/sokol_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@
OVERVIEW
========
The sokol core headers should not depend on each other, but sometimes
it's useful to have a set of helper functions as "glue" between
two or more sokol headers.
This is what sokol_glue.h is for. Simply include the header after other
sokol headers (both for the implementation and declaration), and
depending on what headers have been included before, sokol_glue.h
will make available "glue functions".
sokol_glue.h provides glue helper functions between sokol_gfx.h and sokol_app.h,
so that sokol_gfx.h doesn't need to depend on sokol_app.h but can be
used with different window system glue libraries.
PROVIDED FUNCTIONS
==================
Expand Down Expand Up @@ -100,6 +95,10 @@
#endif
#endif

#ifndef SOKOL_GFX_INCLUDED
#error "Please include sokol_gfx.h before sokol_glue.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -117,10 +116,15 @@ SOKOL_GLUE_API_DECL sg_swapchain sglue_swapchain(void);
#define SOKOL_GLUE_IMPL_INCLUDED (1)
#include <string.h> /* memset */

#ifndef SOKOL_APP_INCLUDED
#error "Please include sokol_app.h before the sokol_glue.h implementation"
#endif

#ifndef SOKOL_API_IMPL
#define SOKOL_API_IMPL
#define SOKOL_API_IMPL
#endif


SOKOL_API_IMPL sg_environment sglue_environment(void) {
sg_environment env;
memset(&env, 0, sizeof(env));
Expand Down

0 comments on commit 8d8a9b6

Please sign in to comment.