Skip to content

Commit

Permalink
fix rendering of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Jaworski committed Oct 23, 2018
1 parent 43938a1 commit f47690b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 6 additions & 5 deletions doc/source/custom_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
import os
import re
from hashlib import sha1
import traceback

from sphinx.builders import Builder
from sphinx.ext.autodoc import AutodocReporter
from sphinx.util.console import bold

import imgui

try:
from gen_example import render_snippet
except ImportError:
except ImportError as error:
render_snippet = None
print (
"Could not import snippet renderer. "
"Will use static resources. Import error: %s" %
error
)


VISUAL_EXAMPLES_DIR = "visual_examples"
Expand Down
8 changes: 7 additions & 1 deletion doc/source/gen_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ def render_snippet(

if auto_layout:
imgui.set_next_window_size(width - 10, height - 10)
imgui.set_next_window_position(impl.io.DisplaySize.x * 0.5, implio.DisplaySize.y * 0.5, 1, pivot_x = 0.5, pivot_y = 0.5)
imgui.set_next_window_position(
impl.io.display_size.x * 0.5,
impl.io.display_size.y * 0.5,
pivot_x=0.5,
pivot_y=0.5
)

exec(code, locals(), globals())

Expand All @@ -156,6 +161,7 @@ def render_snippet(
gl.glClear(gl.GL_COLOR_BUFFER_BIT)

imgui.render()
impl.render(imgui.get_draw_data())

# retrieve pixels from framebuffer and write to file
pixels = gl.glReadPixels(0, 0, width, height, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE)
Expand Down

0 comments on commit f47690b

Please sign in to comment.