From d90cb92bd9029713b421b64c850ca263a6cb7ee4 Mon Sep 17 00:00:00 2001 From: bl1nc Date: Fri, 2 Feb 2024 07:01:41 +0600 Subject: [PATCH] OpenGL GetProcAddress function Make reset_gl_context function callable from python https://github.com/kivy/kivy/issues/8457 --- kivy/graphics/cgl_backend/__init__.py | 0 kivy/graphics/cgl_backend/cgl_sdl2.pyx | 7 +++++++ kivy/graphics/fbo.pyx | 5 +++++ kivy/graphics/instructions.pxd | 2 +- kivy/graphics/instructions.pyx | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) delete mode 100644 kivy/graphics/cgl_backend/__init__.py diff --git a/kivy/graphics/cgl_backend/__init__.py b/kivy/graphics/cgl_backend/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/kivy/graphics/cgl_backend/cgl_sdl2.pyx b/kivy/graphics/cgl_backend/cgl_sdl2.pyx index f63c707ba7..e9fd1b0611 100644 --- a/kivy/graphics/cgl_backend/cgl_sdl2.pyx +++ b/kivy/graphics/cgl_backend/cgl_sdl2.pyx @@ -6,12 +6,19 @@ include "../common.pxi" include "../../include/config.pxi" from kivy.graphics.cgl cimport * +from libc.stdint cimport intptr_t IF USE_SDL2: cdef extern from "SDL.h": void *SDL_GL_GetProcAddress(const char*) +def gl_get_proc_address(name): + cdef char *c_name = name + cdef void * p = SDL_GL_GetProcAddress(c_name) + return p + + cpdef is_backend_supported(): return USE_SDL2 diff --git a/kivy/graphics/fbo.pyx b/kivy/graphics/fbo.pyx index cbed0416dc..27922a0ea0 100644 --- a/kivy/graphics/fbo.pyx +++ b/kivy/graphics/fbo.pyx @@ -430,6 +430,11 @@ cdef class Fbo(RenderContext): self.observers.remove(cb) continue + @property + def gl_id(self): + '''OpenGL id of framebuffer + ''' + return self.buffer_id @property def size(self): diff --git a/kivy/graphics/instructions.pxd b/kivy/graphics/instructions.pxd index f24f233cf2..e089905c89 100644 --- a/kivy/graphics/instructions.pxd +++ b/kivy/graphics/instructions.pxd @@ -14,7 +14,7 @@ from .shader cimport * from .texture cimport Texture from kivy._event cimport ObjectWithUid -cdef void reset_gl_context() +cpdef void reset_gl_context() cdef class Instruction cdef class InstructionGroup(Instruction) diff --git a/kivy/graphics/instructions.pyx b/kivy/graphics/instructions.pyx index db170144e4..20925b6203 100644 --- a/kivy/graphics/instructions.pyx +++ b/kivy/graphics/instructions.pyx @@ -27,7 +27,7 @@ cdef int _need_reset_gl = 1 cdef int _active_texture = -1 cdef list canvas_list = [] -cdef void reset_gl_context(): +cpdef void reset_gl_context(): global _need_reset_gl, _active_texture _need_reset_gl = 0 _active_texture = 0