Get develop_gl working again

This commit is contained in:
Kovid Goyal 2016-11-22 08:32:31 +05:30
parent 204411e5b8
commit 8572fd05e9
2 changed files with 23 additions and 7 deletions

View File

@ -3,6 +3,7 @@
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import glfw
import glfw_constants
import sys
import ctypes
@ -68,7 +69,8 @@ class Renderer:
c.bg = (bg << 8) | 3
c.x = x
line.set_text('%d' % (i % 10), 0, 1, c)
self.sprites.update_cell_data(line, 0, sg.xnum - 1, self.color_profile, 0xffffff, 0, ctypes.addressof(data))
self.sprites.backend.update_cell_data(line, 0, sg.xnum - 1, self.color_profile, 0xffffff, 0, ctypes.addressof(data))
self.sprites.render_dirty_cells()
self.sprites.set_sprite_map(data)
def render(self):
@ -106,11 +108,11 @@ def _main():
# These Window hints are used to specify
# which opengl version to use and other details
# for the opengl context that will be created
glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION[0])
glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, GL_VERSION[1])
glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE,
glfw.GLFW_OPENGL_CORE_PROFILE)
glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, True)
glfw.glfwWindowHint(glfw_constants.GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION[0])
glfw.glfwWindowHint(glfw_constants.GLFW_CONTEXT_VERSION_MINOR, GL_VERSION[1])
glfw.glfwWindowHint(glfw_constants.GLFW_OPENGL_PROFILE,
glfw_constants.GLFW_OPENGL_CORE_PROFILE)
glfw.glfwWindowHint(glfw_constants.GLFW_OPENGL_FORWARD_COMPAT, True)
window = glfw.glfwCreateWindow(
1024, 1024, "Trying this crap".encode('utf-8'), None, None)

View File

@ -131,7 +131,6 @@ position_for(SpriteMap *self, PyObject *args) {
bool
update_cell_range_data(SpriteMap *self, Line *line, unsigned int xstart, unsigned int xmax, ColorProfile *color_profile, const uint32_t default_bg, const uint32_t default_fg, unsigned int *data) {
#define update_cell_data_doc "update_cell_data(line, xstart, xmax, color_profile, default_bg, default_fg, data_pointer) -> Update the range [xstart, xmax] in data_pointer with the data from line"
SpritePosition *sp;
char_type previous_ch=0, ch;
color_type color;
@ -159,6 +158,20 @@ update_cell_range_data(SpriteMap *self, Line *line, unsigned int xstart, unsigne
return true;
}
static PyObject*
update_cell_data(SpriteMap *self, PyObject *args) {
#define update_cell_data_doc "update_cell_data(line, xstart, xmax, color_profile, default_bg, default_fg, data_pointer) -> Update the range [xstart, xmax] in data_pointer with the data from line"
unsigned int xstart, xmax;
uint32_t default_fg, default_bg;
Line *line; ColorProfile *color_profile;
PyObject *data_pointer;
if (!PyArg_ParseTuple(args, "O!IIO!IIO!", &Line_Type, &line, &xstart, &xmax, &ColorProfile_Type, &color_profile, &default_bg, &default_fg, &PyLong_Type, &data_pointer)) return NULL;
unsigned int *dp = PyLong_AsVoidPtr(data_pointer);
if (!update_cell_range_data(self, line, xstart, xmax, color_profile, default_bg, default_fg, dp)) return NULL;
Py_RETURN_NONE;
}
static PyObject*
render_dirty_cells(SpriteMap *self, PyObject *args) {
#define render_dirty_cells_doc "Render all cells that are marked as dirty"
@ -208,6 +221,7 @@ static PyMethodDef methods[] = {
METHOD(layout, METH_VARARGS)
METHOD(position_for, METH_VARARGS)
METHOD(render_dirty_cells, METH_VARARGS)
METHOD(update_cell_data, METH_VARARGS)
{NULL} /* Sentinel */
};