Esempio n. 1
0
def url_prefill_from_blender():
    import bpy
    import bgl
    import struct
    import platform
    import urllib.parse
    import io

    fh = io.StringIO()

    fh.write("**System Information**\n")
    fh.write(
        "Operating system: {!s} {!s} Bits\n".format(
            platform.platform(),
            struct.calcsize("P") * 8,
        )
    )
    fh.write(
        "Graphics card: {!s} {!s} {!s}\n".format(
            bgl.glGetString(bgl.GL_RENDERER),
            bgl.glGetString(bgl.GL_VENDOR),
            bgl.glGetString(bgl.GL_VERSION),
        )
    )
    fh.write(
        "\n"
        "\n**Blender Version**\n"
    )
    fh.write(
        "Broken: version: {!s}, branch: {!s}, commit date: {!s} {!s}, hash: `rB{!s}`\n".format(
            bpy.app.version_string,
            bpy.app.build_branch.decode('utf-8', 'replace'),
            bpy.app.build_commit_date.decode('utf-8', 'replace'),
            bpy.app.build_commit_time.decode('utf-8', 'replace'),
            bpy.app.build_hash.decode('ascii'),
        )
    )
    fh.write(
        "Worked: (optional)\n"
        "\n"
        "\n"
        "**Short description of error**\n"
        "[Please fill out a short description of the error here]\n"
        "\n"
        "**Exact steps for others to reproduce the error**\n"
        "[Please describe the exact steps needed to reproduce the issue]\n"
        "[Based on the default startup or an attached .blend file (as simple as possible)]\n"
        "\n"
    )

    fh.seek(0)

    return (
        "https://developer.blender.org/maniphest/task/edit/form/1?description=" +
        urllib.parse.quote(fh.read())
    )
Esempio n. 2
0
def url_prefill_from_blender(addon_info=None):
    import bpy
    import bgl
    import struct
    import platform
    import urllib.parse
    import io

    fh = io.StringIO()

    fh.write("**System Information**\n")
    fh.write("Operating system: {!s} {!s} Bits\n".format(
        platform.platform(),
        struct.calcsize("P") * 8,
    ))
    fh.write("Graphics card: {!s} {!s} {!s}\n".format(
        bgl.glGetString(bgl.GL_RENDERER),
        bgl.glGetString(bgl.GL_VENDOR),
        bgl.glGetString(bgl.GL_VERSION),
    ))
    fh.write("\n" "**Blender Version**\n")
    fh.write(
        "Broken: version: {!s}, branch: {!s}, commit date: {!s} {!s}, hash: `rB{!s}`\n"
        .format(
            bpy.app.version_string,
            bpy.app.build_branch.decode('utf-8', 'replace'),
            bpy.app.build_commit_date.decode('utf-8', 'replace'),
            bpy.app.build_commit_time.decode('utf-8', 'replace'),
            bpy.app.build_hash.decode('ascii'),
        ))
    fh.write("Worked: (optional)\n")
    if addon_info:
        fh.write("\n" "**Addon Information**\n")
        fh.write(("Name: {name} {version}\n"
                  "Author: {author}\n").format(**addon_info))

    fh.write(
        "\n"
        "**Short description of error**\n"
        "[Please fill out a short description of the error here]\n"
        "\n"
        "**Exact steps for others to reproduce the error**\n"
        "[Please describe the exact steps needed to reproduce the issue]\n"
        "[Based on the default startup or an attached .blend file (as simple as possible)]\n"
        "\n")

    fh.seek(0)

    form_number = 2 if addon_info else 1
    return (
        "https://developer.blender.org/maniphest/task/edit/form/%i?description="
        % form_number + urllib.parse.quote(fh.read()))
Esempio n. 3
0
def register():
    global krom_found
    global glslver
    import importlib.util
    if importlib.util.find_spec('barmory') != None:
        krom_found = True
        import bgl
        glslver = int(bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION).split(' ', 1)[0].replace('.', ''))
Esempio n. 4
0
def register():
    global krom_found
    global glslver
    import importlib.util
    if importlib.util.find_spec('barmory') != None:
        krom_found = True
        import bgl
        glslver = int(bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION).split(' ', 1)[0].replace('.', ''))
Esempio n. 5
0
def _is_using_buggy_driver():
    import bgl
    # We need to be conservative here because in multi-GPU systems display card
    # might be quite old, but others one might be just good.
    #
    # So We shouldn't disable possible good dedicated cards just because display
    # card seems weak. And instead we only blacklist configurations which are
    # proven to cause problems.
    if bgl.glGetString(bgl.GL_VENDOR) == "ATI Technologies Inc.":
        import re
        version = bgl.glGetString(bgl.GL_VERSION)
        if version.endswith("Compatibility Profile Context"):
            # Old HD 4xxx and 5xxx series drivers did not have driver version
            # in the version string, but those cards do not quite work and
            # causing crashes.
            return True
        regex = re.compile(".*Compatibility Profile Context ([0-9]+(\.[0-9]+)+)$")
        if not regex.match(version):
            # Skip cards like FireGL
            return False
        version = regex.sub("\\1", version).split('.')
        return int(version[0]) == 8
    return False
Esempio n. 6
0
def _is_using_buggy_driver():
    import bgl
    # We need to be conservative here because in multi-GPU systems display card
    # might be quite old, but others one might be just good.
    #
    # So We shouldn't disable possible good dedicated cards just because display
    # card seems weak. And instead we only blacklist configurations which are
    # proven to cause problems.
    if bgl.glGetString(bgl.GL_VENDOR) == "ATI Technologies Inc.":
        import re
        version = bgl.glGetString(bgl.GL_VERSION)
        if version.endswith("Compatibility Profile Context"):
            # Old HD 4xxx and 5xxx series drivers did not have driver version
            # in the version string, but those cards do not quite work and
            # causing crashes.
            return True
        regex = re.compile(".*Compatibility Profile Context ([0-9]+(\.[0-9]+)+)$")
        if not regex.match(version):
            # Skip cards like FireGL
            return False
        version = regex.sub("\\1", version).split('.')
        return int(version[0]) == 8
    return False
Esempio n. 7
0
def write_sysinfo(op):
    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % (len(header) * "=")
    firstlilies = "%s\n" % (len(header) * "=")
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write("\nBlender:\n")
    output.write(lilies)
    if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
        output.write("version %s, branch %r, chage %r, hash %r, %r\n" %
            (bpy.app.version_string,
             bpy.app.build_branch,
             bpy.app.build_change,
             bpy.app.build_hash,
             bpy.app.build_type))
    else:
        output.write("version %s, revision %r. %r\n" %
            (bpy.app.version_string,
             bpy.app.build_change,
             bpy.app.build_type))

    output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time))
    output.write("platform: %r\n" % (bpy.app.build_platform))
    output.write("binary path: %r\n" % (bpy.app.binary_path))
    output.write("build cflags: %r\n" % (bpy.app.build_cflags))
    output.write("build cxxflags: %r\n" % (bpy.app.build_cxxflags))
    output.write("build linkflags: %r\n" % (bpy.app.build_linkflags))
    output.write("build system: %r\n" % (bpy.app.build_system))

    # python info
    output.write("\nPython:\n")
    output.write(lilies)
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % (p))

    output.write("\nDirectories:\n")
    output.write(lilies)
    output.write("scripts: %r\n" % (bpy.utils.script_paths()))
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write("\nFFmpeg:\n")
    output.write(lilies)
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write("%r:%r%r\n" % (lib, " " * (10 - len(lib)),
                         getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write("\nOpenGL\n")
        output.write(lilies)
        output.write("renderer:\t%r\n" % (bgl.glGetString(bgl.GL_RENDERER)))
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textWrap(glext, 70)
        for l in glext:
            output.write("\t\t%r\n" % (l))

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
def write_sysinfo(filepath):
    import sys

    import subprocess

    import bpy
    import bgl

    # pretty repr
    def prepr(v):
        r = repr(v)
        vt = type(v)
        if vt is bytes:
            r = r[2:-1]
        elif vt is list or vt is tuple:
            r = r[1:-1]
        return r

    with open(filepath, 'w', encoding="utf-8") as output:
        try:
            header = "= Blender %s System Information =\n" % bpy.app.version_string
            lilies = "%s\n\n" % ((len(header) - 1) * "=")
            output.write(lilies[:-1])
            output.write(header)
            output.write(lilies)

            def title(text):
                return "\n%s:\n%s" % (text, lilies)

            # build info
            output.write(title("Blender"))
            output.write(
                "version: %s, branch: %s, commit date: %s %s, hash: %s, type: %s\n" %
                (bpy.app.version_string,
                 prepr(bpy.app.build_branch),
                 prepr(bpy.app.build_commit_date),
                 prepr(bpy.app.build_commit_time),
                 prepr(bpy.app.build_hash),
                 prepr(bpy.app.build_type),
                 ))

            output.write("build date: %s, %s\n" % (prepr(bpy.app.build_date), prepr(bpy.app.build_time)))
            output.write("platform: %s\n" % prepr(bpy.app.build_platform))
            output.write("binary path: %s\n" % prepr(bpy.app.binary_path))
            output.write("build cflags: %s\n" % prepr(bpy.app.build_cflags))
            output.write("build cxxflags: %s\n" % prepr(bpy.app.build_cxxflags))
            output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
            output.write("build system: %s\n" % prepr(bpy.app.build_system))

            # Python info.
            output.write(title("Python"))
            output.write("version: %s\n" % (sys.version.replace("\n", " ")))
            output.write("file system encoding: %s:%s\n" % (
                sys.getfilesystemencoding(),
                sys.getfilesystemencodeerrors(),
            ))
            output.write("paths:\n")
            for p in sys.path:
                output.write("\t%r\n" % p)

            output.write(title("Python (External Binary)"))
            output.write("binary path: %s\n" % prepr(bpy.app.binary_path_python))
            try:
                py_ver = prepr(subprocess.check_output([
                    bpy.app.binary_path_python,
                    "--version",
                ]).strip())
            except Exception as e:
                py_ver = str(e)
            output.write("version: %s\n" % py_ver)
            del py_ver

            output.write(title("Directories"))
            output.write("scripts:\n")
            for p in bpy.utils.script_paths():
                output.write("\t%r\n" % p)
            output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
            output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
            output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
            output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
            output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
            output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
            output.write("tempdir: %r\n" % (bpy.app.tempdir))

            output.write(title("FFmpeg"))
            ffmpeg = bpy.app.ffmpeg
            if ffmpeg.supported:
                for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
                    output.write(
                        "%s:%s%r\n" % (lib, " " * (10 - len(lib)),
                                       getattr(ffmpeg, lib + "_version_string")))
            else:
                output.write("Blender was built without FFmpeg support\n")

            if bpy.app.build_options.sdl:
                output.write(title("SDL"))
                output.write("Version: %s\n" % bpy.app.sdl.version_string)
                output.write("Loading method: ")
                if bpy.app.build_options.sdl_dynload:
                    output.write("dynamically loaded by Blender (WITH_SDL_DYNLOAD=ON)\n")
                else:
                    output.write("linked (WITH_SDL_DYNLOAD=OFF)\n")
                if not bpy.app.sdl.available:
                    output.write("WARNING: Blender could not load SDL library\n")

            output.write(title("Other Libraries"))
            ocio = bpy.app.ocio
            output.write("OpenColorIO: ")
            if ocio.supported:
                if ocio.version_string == "fallback":
                    output.write("Blender was built with OpenColorIO, " +
                                 "but it currently uses fallback color management.\n")
                else:
                    output.write("%s\n" % (ocio.version_string))
            else:
                output.write("Blender was built without OpenColorIO support\n")

            oiio = bpy.app.oiio
            output.write("OpenImageIO: ")
            if ocio.supported:
                output.write("%s\n" % (oiio.version_string))
            else:
                output.write("Blender was built without OpenImageIO support\n")

            output.write("OpenShadingLanguage: ")
            if bpy.app.build_options.cycles:
                if bpy.app.build_options.cycles_osl:
                    from _cycles import osl_version_string
                    output.write("%s\n" % (osl_version_string))
                else:
                    output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
            else:
                output.write("Blender was built without Cycles support\n")

            opensubdiv = bpy.app.opensubdiv
            output.write("OpenSubdiv: ")
            if opensubdiv.supported:
                output.write("%s\n" % opensubdiv.version_string)
            else:
                output.write("Blender was built without OpenSubdiv support\n")

            openvdb = bpy.app.openvdb
            output.write("OpenVDB: ")
            if openvdb.supported:
                output.write("%s\n" % openvdb.version_string)
            else:
                output.write("Blender was built without OpenVDB support\n")

            alembic = bpy.app.alembic
            output.write("Alembic: ")
            if alembic.supported:
                output.write("%s\n" % alembic.version_string)
            else:
                output.write("Blender was built without Alembic support\n")

            usd = bpy.app.usd
            output.write("USD: ")
            if usd.supported:
                output.write("%s\n" % usd.version_string)
            else:
                output.write("Blender was built without USD support\n")

            if not bpy.app.build_options.sdl:
                output.write("SDL: Blender was built without SDL support\n")

            if bpy.app.background:
                output.write("\nOpenGL: missing, background mode\n")
            else:
                output.write(title("OpenGL"))
                version = bgl.glGetString(bgl.GL_RENDERER)
                output.write("renderer:\t%r\n" % version)
                output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
                output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
                output.write("extensions:\n")

                limit = bgl.Buffer(bgl.GL_INT, 1)
                bgl.glGetIntegerv(bgl.GL_NUM_EXTENSIONS, limit)

                glext = []
                for i in range(limit[0]):
                    glext.append(bgl.glGetStringi(bgl.GL_EXTENSIONS, i))

                glext = sorted(glext)

                for l in glext:
                    output.write("\t%s\n" % l)

                output.write(title("Implementation Dependent OpenGL Limits"))
                bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_VERTICES, limit)
                output.write("Maximum DrawElements Vertices:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_INDICES, limit)
                output.write("Maximum DrawElements Indices:\t%d\n" % limit[0])

                output.write("\nGLSL:\n")
                bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
                output.write("Maximum Varying Floats:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
                output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
                output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
                output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
                output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
                output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
                output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])

            if bpy.app.build_options.cycles:
                import cycles
                output.write(title("Cycles"))
                output.write(cycles.engine.system_info())

            import addon_utils
            addon_utils.modules()
            output.write(title("Enabled add-ons"))
            for addon in bpy.context.preferences.addons.keys():
                addon_mod = addon_utils.addons_fake_modules.get(addon, None)
                if addon_mod is None:
                    output.write("%s (MISSING)\n" % (addon))
                else:
                    output.write("%s (version: %s, path: %s)\n" %
                                 (addon, addon_mod.bl_info.get('version', "UNKNOWN"), addon_mod.__file__))
        except Exception as e:
            output.write("ERROR: %s\n" % e)
Esempio n. 9
0
import ctypes

from .ui import Drawing
from .debug import dprint

from ..ext.bgl_ext import VoidBufValue

# note: not all supported by user system, but we don't need latest functionality
# https://github.com/mattdesl/lwjgl-basics/wiki/GLSL-Versions
# OpenGL  GLSL    OpenGL  GLSL
#  2.0    110      2.1    120
#  3.0    130      3.1    140
#  3.2    150      3.3    330
#  4.0    400      4.1    410
#  4.2    420      4.3    430
dprint('GLSL Version: ' + bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION))

DEBUG_PRINT = False

vbv_zero = VoidBufValue(0)
buf_zero = vbv_zero.buf  #bgl.Buffer(bgl.GL_BYTE, 1, [0])


class Shader():
    @staticmethod
    def shader_compile(name, shader):
        '''
        logging and error-checking not quite working :(
        '''

        bufLen = bgl.Buffer(bgl.GL_BYTE, 4)
Esempio n. 10
0
File: menu.py Progetto: z0u/cargo
 def dof_recommended(self):
     '''Depth of field filter causes issues on some platforms.'''
     vendor = bgl.glGetString(bgl.GL_VENDOR).lower()
     pform = platform.system().lower()
     return not any((v in vendor and p in pform) for (p, v) in DOF_BLACKLIST)
Esempio n. 11
0
def write_sysinfo(op):
    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % (len(header) * "=")
    firstlilies = "%s\n" % (len(header) * "=")
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write("\nBlender:\n")
    output.write(lilies)
    if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
        output.write("version %s, branch %r, commit date %r %r, hash %r, %r\n" %
            (bpy.app.version_string,
             bpy.app.build_branch,
             bpy.app.build_commit_date,
             bpy.app.build_commit_time,
             bpy.app.build_hash,
             bpy.app.build_type))
    else:
        output.write("version %s, revision %r. %r\n" %
            (bpy.app.version_string,
             bpy.app.build_change,
             bpy.app.build_type))

    output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time))
    output.write("platform: %r\n" % (bpy.app.build_platform))
    output.write("binary path: %r\n" % (bpy.app.binary_path))
    output.write("build cflags: %r\n" % (bpy.app.build_cflags))
    output.write("build cxxflags: %r\n" % (bpy.app.build_cxxflags))
    output.write("build linkflags: %r\n" % (bpy.app.build_linkflags))
    output.write("build system: %r\n" % (bpy.app.build_system))

    # python info
    output.write("\nPython:\n")
    output.write(lilies)
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % (p))

    output.write("\nDirectories:\n")
    output.write(lilies)
    output.write("scripts: %r\n" % (bpy.utils.script_paths()))
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write("\nFFmpeg:\n")
    output.write(lilies)
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write("%r:%r%r\n" % (lib, " " * (10 - len(lib)),
                         getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    output.write("\nOther Libraries:\n")
    output.write(lilies)
    ocio = bpy.app.ocio
    output.write("OpenColorIO: ")
    if ocio.supported:
        if ocio.version_string == "fallback":
            output.write("Blender was built with OpenColorIO, " +
                         "but it currently uses fallback color management.\n")
        else:
            output.write("%s\n" % (ocio.version_string))
    else:
        output.write("Blender was built without OpenColorIO support\n")

    oiio = bpy.app.oiio
    output.write("OpenImageIO: ")
    if ocio.supported:
        output.write("%s\n" % (oiio.version_string))
    else:
        output.write("Blender was built without OpenImageIO support\n")

    output.write("OpenShadingLanguage: ")
    if bpy.app.build_options.cycles:
        if bpy.app.build_options.cycles_osl:
            from _cycles import osl_version_string
            output.write("%s\n" % (osl_version_string))
        else:
            output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
    else:
        output.write("Blender was built without Cycles support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write("\nOpenGL\n")
        output.write(lilies)
        version = bgl.glGetString(bgl.GL_RENDERER)
        output.write("renderer:\t%r\n" % version)
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textWrap(glext, 70)
        for l in glext:
            output.write("\t\t%r\n" % (l))

        output.write("\nImplementation Dependent OpenGL Limits:\n")
        output.write(lilies)
        limit = bgl.Buffer(bgl.GL_INT, 1)
        bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_UNITS, limit)
        output.write("Maximum Fixed Function Texture Units:\t%d\n" % limit[0])

        output.write("\nGLSL:\n")
        if version[0] > '1':
            bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
            output.write("Maximum Varying Floats:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
            output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])

    if bpy.app.build_options.cycles:
        import cycles
        output.write("\nCycles\n")
        output.write(lilies)
        output.write(cycles.engine.system_info())

    output.current_line_index = 0

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
Esempio n. 12
0
from .globals import Globals

from ..ext.bgl_ext import VoidBufValue

# note: not all supported by user system, but we don't need full functionality
# https://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions
#     OpenGL  GLSL    OpenGL  GLSL
#      2.0    110      4.0    400
#      2.1    120      4.1    410
#      3.0    130      4.2    420
#      3.1    140      4.3    430
#      3.2    150      4.4    440
#      3.3    330      4.5    450
#                      4.6    460
print('(shaders) GLSL Version:',
      bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION))

DEBUG_PRINT = False

vbv_zero = VoidBufValue(0)
buf_zero = vbv_zero.buf  #bgl.Buffer(bgl.GL_BYTE, 1, [0])
Globals.buf_zero = buf_zero


class Shader():
    @staticmethod
    def shader_compile(name, shader, src):
        '''
        logging and error-checking not quite working :(
        '''
Esempio n. 13
0
from .decorators import blender_version_wrapper
from .utils import kwargs_splitter

from ..ext.bgl_ext import VoidBufValue

# note: not all supported by user system, but we don't need full functionality
# https://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions
#     OpenGL  GLSL    OpenGL  GLSL
#      2.0    110      4.0    400
#      2.1    120      4.1    410
#      3.0    130      4.2    420
#      3.1    140      4.3    430
#      3.2    150      4.4    440
#      3.3    330      4.5    450
#                      4.6    460
print('Addon Common: (shaders) GLSL Version:', bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION))

DEBUG_PRINT = False

vbv_zero = VoidBufValue(0)
buf_zero = vbv_zero.buf    #bgl.Buffer(bgl.GL_BYTE, 1, [0])
Globals.buf_zero = buf_zero

class Shader():
    @staticmethod
    def shader_compile(name, shader, src):
        '''
        logging and error-checking not quite working :(
        '''

        Globals.drawing.glCheckError(f'Pre shader compile')
Esempio n. 14
0
import ctypes

from .ui import Drawing
from .debug import dprint

from ..ext.bgl_ext import VoidBufValue

# note: not all supported by user system, but we don't need latest functionality
# https://github.com/mattdesl/lwjgl-basics/wiki/GLSL-Versions
# OpenGL  GLSL    OpenGL  GLSL
#  2.0    110      2.1    120
#  3.0    130      3.1    140
#  3.2    150      3.3    330
#  4.0    400      4.1    410
#  4.2    420      4.3    430
dprint('GLSL Version: ' + bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION))

DEBUG_PRINT = False

vbv_zero = VoidBufValue(0)
buf_zero = vbv_zero.buf    #bgl.Buffer(bgl.GL_BYTE, 1, [0])


class Shader():
    @staticmethod
    def shader_compile(name, shader):
        '''
        logging and error-checking not quite working :(
        '''

        bufLen = bgl.Buffer(bgl.GL_BYTE, 4)
Esempio n. 15
0
def write_sysinfo(op):
    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % (len(header) * "=")
    firstlilies = "%s\n" % (len(header) * "=")
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write("\nBlender:\n")
    output.write(lilies)
    if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
        output.write(
            "version %s, branch %r, commit date %r %r, hash %r, %r\n" %
            (bpy.app.version_string, bpy.app.build_branch,
             bpy.app.build_commit_date, bpy.app.build_commit_time,
             bpy.app.build_hash, bpy.app.build_type))
    else:
        output.write(
            "version %s, revision %r. %r\n" %
            (bpy.app.version_string, bpy.app.build_change, bpy.app.build_type))

    output.write("build date: %r, %r\n" %
                 (bpy.app.build_date, bpy.app.build_time))
    output.write("platform: %r\n" % (bpy.app.build_platform))
    output.write("binary path: %r\n" % (bpy.app.binary_path))
    output.write("build cflags: %r\n" % (bpy.app.build_cflags))
    output.write("build cxxflags: %r\n" % (bpy.app.build_cxxflags))
    output.write("build linkflags: %r\n" % (bpy.app.build_linkflags))
    output.write("build system: %r\n" % (bpy.app.build_system))

    # python info
    output.write("\nPython:\n")
    output.write(lilies)
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % (p))

    output.write("\nDirectories:\n")
    output.write(lilies)
    output.write("scripts: %r\n" % (bpy.utils.script_paths()))
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write("\nFFmpeg:\n")
    output.write(lilies)
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write(
                "%r:%r%r\n" %
                (lib, " " *
                 (10 - len(lib)), getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    output.write("\nOther Libraries:\n")
    output.write(lilies)
    ocio = bpy.app.ocio
    output.write("OpenColorIO: ")
    if ocio.supported:
        if ocio.version_string == "fallback":
            output.write("Blender was built with OpenColorIO, " +
                         "but it currently uses fallback color management.\n")
        else:
            output.write("%s\n" % (ocio.version_string))
    else:
        output.write("Blender was built without OpenColorIO support\n")

    oiio = bpy.app.oiio
    output.write("OpenImageIO: ")
    if ocio.supported:
        output.write("%s\n" % (oiio.version_string))
    else:
        output.write("Blender was built without OpenImageIO support\n")

    output.write("OpenShadingLanguage: ")
    if bpy.app.build_options.cycles:
        if bpy.app.build_options.cycles_osl:
            from _cycles import osl_version_string
            output.write("%s\n" % (osl_version_string))
        else:
            output.write(
                "Blender was built without OpenShadingLanguage support in Cycles\n"
            )
    else:
        output.write("Blender was built without Cycles support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write("\nOpenGL\n")
        output.write(lilies)
        output.write("renderer:\t%r\n" % (bgl.glGetString(bgl.GL_RENDERER)))
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textWrap(glext, 70)
        for l in glext:
            output.write("\t\t%r\n" % (l))

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
Esempio n. 16
0
def write_sysinfo(filepath):
    import sys

    import subprocess

    import bpy
    import bgl

    # pretty repr
    def prepr(v):
        r = repr(v)
        vt = type(v)
        if vt is bytes:
            r = r[2:-1]
        elif vt is list or vt is tuple:
            r = r[1:-1]
        return r

    with open(filepath, 'w', encoding="utf-8") as output:
        try:
            header = "= Blender %s System Information =\n" % bpy.app.version_string
            lilies = "%s\n\n" % ((len(header) - 1) * "=")
            output.write(lilies[:-1])
            output.write(header)
            output.write(lilies)

            def title(text):
                return "\n%s:\n%s" % (text, lilies)

            # build info
            output.write(title("Blender"))
            output.write(
                "version: %s, branch: %s, commit date: %s %s, hash: %s, type: %s\n" %
                (bpy.app.version_string,
                 prepr(bpy.app.build_branch),
                 prepr(bpy.app.build_commit_date),
                 prepr(bpy.app.build_commit_time),
                 prepr(bpy.app.build_hash),
                 prepr(bpy.app.build_type),
                 ))

            output.write("build date: %s, %s\n" % (prepr(bpy.app.build_date), prepr(bpy.app.build_time)))
            output.write("platform: %s\n" % prepr(bpy.app.build_platform))
            output.write("binary path: %s\n" % prepr(bpy.app.binary_path))
            output.write("build cflags: %s\n" % prepr(bpy.app.build_cflags))
            output.write("build cxxflags: %s\n" % prepr(bpy.app.build_cxxflags))
            output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
            output.write("build system: %s\n" % prepr(bpy.app.build_system))

            # python info
            output.write(title("Python"))
            output.write("version: %s\n" % (sys.version))
            output.write("paths:\n")
            for p in sys.path:
                output.write("\t%r\n" % p)

            output.write(title("Python (External Binary)"))
            output.write("binary path: %s\n" % prepr(bpy.app.binary_path_python))
            try:
                py_ver = prepr(subprocess.check_output([
                    bpy.app.binary_path_python,
                    "--version",
                ]).strip())
            except Exception as e:
                py_ver = str(e)
            output.write("version: %s\n" % py_ver)
            del py_ver

            output.write(title("Directories"))
            output.write("scripts:\n")
            for p in bpy.utils.script_paths():
                output.write("\t%r\n" % p)
            output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
            output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
            output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
            output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
            output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
            output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
            output.write("tempdir: %r\n" % (bpy.app.tempdir))

            output.write(title("FFmpeg"))
            ffmpeg = bpy.app.ffmpeg
            if ffmpeg.supported:
                for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
                    output.write(
                        "%s:%s%r\n" % (lib, " " * (10 - len(lib)),
                                       getattr(ffmpeg, lib + "_version_string")))
            else:
                output.write("Blender was built without FFmpeg support\n")

            if bpy.app.build_options.sdl:
                output.write(title("SDL"))
                output.write("Version: %s\n" % bpy.app.sdl.version_string)
                output.write("Loading method: ")
                if bpy.app.build_options.sdl_dynload:
                    output.write("dynamically loaded by Blender (WITH_SDL_DYNLOAD=ON)\n")
                else:
                    output.write("linked (WITH_SDL_DYNLOAD=OFF)\n")
                if not bpy.app.sdl.available:
                    output.write("WARNING: Blender could not load SDL library\n")

            output.write(title("Other Libraries"))
            ocio = bpy.app.ocio
            output.write("OpenColorIO: ")
            if ocio.supported:
                if ocio.version_string == "fallback":
                    output.write("Blender was built with OpenColorIO, " +
                                 "but it currently uses fallback color management.\n")
                else:
                    output.write("%s\n" % (ocio.version_string))
            else:
                output.write("Blender was built without OpenColorIO support\n")

            oiio = bpy.app.oiio
            output.write("OpenImageIO: ")
            if ocio.supported:
                output.write("%s\n" % (oiio.version_string))
            else:
                output.write("Blender was built without OpenImageIO support\n")

            output.write("OpenShadingLanguage: ")
            if bpy.app.build_options.cycles:
                if bpy.app.build_options.cycles_osl:
                    from _cycles import osl_version_string
                    output.write("%s\n" % (osl_version_string))
                else:
                    output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
            else:
                output.write("Blender was built without Cycles support\n")

            opensubdiv = bpy.app.opensubdiv
            output.write("OpenSubdiv: ")
            if opensubdiv.supported:
                output.write("%s\n" % opensubdiv.version_string)
            else:
                output.write("Blender was built without OpenSubdiv support\n")

            openvdb = bpy.app.openvdb
            output.write("OpenVDB: ")
            if openvdb.supported:
                output.write("%s\n" % openvdb.version_string)
            else:
                output.write("Blender was built without OpenVDB support\n")

            alembic = bpy.app.alembic
            output.write("Alembic: ")
            if alembic.supported:
                output.write("%s\n" % alembic.version_string)
            else:
                output.write("Blender was built without Alembic support\n")

            if not bpy.app.build_options.sdl:
                output.write("SDL: Blender was built without SDL support\n")

            if bpy.app.background:
                output.write("\nOpenGL: missing, background mode\n")
            else:
                output.write(title("OpenGL"))
                version = bgl.glGetString(bgl.GL_RENDERER)
                output.write("renderer:\t%r\n" % version)
                output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
                output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
                output.write("extensions:\n")

                limit = bgl.Buffer(bgl.GL_INT, 1)
                bgl.glGetIntegerv(bgl.GL_NUM_EXTENSIONS, limit)

                glext = []
                for i in range(limit[0]):
                    glext.append(bgl.glGetStringi(bgl.GL_EXTENSIONS, i))

                glext = sorted(glext)

                for l in glext:
                    output.write("\t%s\n" % l)

                output.write(title("Implementation Dependent OpenGL Limits"))
                bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_VERTICES, limit)
                output.write("Maximum DrawElements Vertices:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_ELEMENTS_INDICES, limit)
                output.write("Maximum DrawElements Indices:\t%d\n" % limit[0])

                output.write("\nGLSL:\n")
                bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
                output.write("Maximum Varying Floats:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
                output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
                output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
                output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
                output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
                output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
                bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
                output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])

            if bpy.app.build_options.cycles:
                import cycles
                output.write(title("Cycles"))
                output.write(cycles.engine.system_info())

            import addon_utils
            addon_utils.modules()
            output.write(title("Enabled add-ons"))
            for addon in bpy.context.preferences.addons.keys():
                addon_mod = addon_utils.addons_fake_modules.get(addon, None)
                if addon_mod is None:
                    output.write("%s (MISSING)\n" % (addon))
                else:
                    output.write("%s (version: %s, path: %s)\n" %
                                 (addon, addon_mod.bl_info.get('version', "UNKNOWN"), addon_mod.__file__))
        except Exception as e:
            output.write("ERROR: %s\n" % e)
Esempio n. 17
0
        git_ref_path = git_ref_path[len('refs/heads/'):]
        git_ref_fullpath = os.path.join('.git', 'logs', 'refs', 'heads', git_ref_path)
        if not os.path.exists(git_ref_fullpath): return
        log = open(git_ref_fullpath).read().splitlines()
        commit = log[-1].split()[1]
        print('git: %s %s' % (git_ref_path,commit))
        retopoflow_version_git = '%s %s' % (git_ref_path, commit)
    except Exception as e:
        print('An exception occurred while checking git info')
        print(e)
get_git_info()

platform_system,platform_node,platform_release,platform_version,platform_machine,platform_processor = platform.uname()

# https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glGetString.xml
gpu_vendor = bgl.glGetString(bgl.GL_VENDOR)
gpu_renderer = bgl.glGetString(bgl.GL_RENDERER)
gpu_version = bgl.glGetString(bgl.GL_VERSION)
gpu_shading = bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION)

retopoflow_issues_url = "https://github.com/CGCookie/retopoflow/issues"

# TODO: REPLACE WITH COOKIE-RELATED ACCOUNT!! :)
# NOTE: can add number to url to start the amount off
# ex: https://paypal.me/retopoflow/5
retopoflow_tip_url    = "https://paypal.me/gfxcoder/"



class Options:
    options_filename = 'RetopoFlow_options.json'    # the filename of the Shelve object
Esempio n. 18
0
def write_sysinfo(op):
    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = '= Blender {} System Information =\n'.format(bpy.app.version_string)
    lilies = '{}\n\n'.format(len(header) * '=')
    firstlilies = '{}\n'.format(len(header) * '=')
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write('\nBlender:\n')
    output.write(lilies)
    output.write('version {}, revision {}. {}\n'.format(bpy.app.version_string, bpy.app.build_revision, bpy.app.build_type))
    output.write('build date: {}, {}\n'.format(bpy.app.build_date, bpy.app.build_time))
    output.write('platform: {}\n'.format(bpy.app.build_platform))
    output.write('binary path: {}\n'.format(bpy.app.binary_path))
    output.write('build cflags: {}\n'.format(bpy.app.build_cflags))
    output.write('build cxxflags: {}\n'.format(bpy.app.build_cxxflags))
    output.write('build linkflags: {}\n'.format(bpy.app.build_linkflags))
    output.write('build system: {}\n'.format(bpy.app.build_system))

    # python info
    output.write('\nPython:\n')
    output.write(lilies)
    output.write('version: {}\n'.format(sys.version))
    output.write('paths:\n')
    for p in sys.path:
        output.write('\t{}\n'.format(p))

    output.write('\nDirectories:\n')
    output.write(lilies)
    output.write('scripts: {}\n'.format(bpy.utils.script_paths()))
    output.write('user scripts: {}\n'.format(bpy.utils.user_script_path()))
    output.write('datafiles: {}\n'.format(bpy.utils.user_resource('DATAFILES')))
    output.write('config: {}\n'.format(bpy.utils.user_resource('CONFIG')))
    output.write('scripts : {}\n'.format(bpy.utils.user_resource('SCRIPTS')))
    output.write('autosave: {}\n'.format(bpy.utils.user_resource('AUTOSAVE')))
    output.write('tempdir: {}\n'.format(bpy.app.tempdir))

    output.write('\nFFmpeg:\n')
    output.write(lilies)
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ['avcodec', 'avdevice', 'avformat', 'avutil', 'swscale']:
            output.write('{}:{}{}\n'.format(lib, " " * (10 - len(lib)),
                         getattr(ffmpeg, lib + '_version_string')))
    else:
        output.write('Blender was built without FFmpeg support\n')

    if bpy.app.background:
        output.write('\nOpenGL: missing, background mode\n')
    else:
        output.write('\nOpenGL\n')
        output.write(lilies)
        output.write('renderer:\t{}\n'.format(bgl.glGetString(bgl.GL_RENDERER)))
        output.write('vendor:\t\t{}\n'.format(bgl.glGetString(bgl.GL_VENDOR)))
        output.write('version:\t{}\n'.format(bgl.glGetString(bgl.GL_VERSION)))
        output.write('extensions:\n')

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textWrap(glext, 70)
        for l in glext:
            output.write('\t\t{}\n'.format(l))

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
Esempio n. 19
0
def init(cont):
    '''initializes the application'''
    try:
        logic.mouse.visible = True

        # gpu detection and ssao enabler
        vendor = bgl.glGetString(bgl.GL_VENDOR)
        renderer = bgl.glGetString(bgl.GL_RENDERER)
        version = bgl.glGetString(bgl.GL_VERSION)

        logging.debug("GL Vendor:\t" + str(vendor))
        logging.debug("GL Renderer:\t" + str(renderer))
        logging.debug("GL Version:\t" + str(version))

        fancyGPU = not "intel" in vendor.lower()

        if useAmbientOcclusion and fancyGPU:
            logging.debug("Using SSAO")
            cont.activate(cont.actuators['ssao'])
        else:
            logging.debug("Not using SSAO")

        # overlay scene enabler
        if useSceneOverlay:
            cont.activate(cont.actuators['scene2D'])
            logging.debug("Using 2D overlay")
        else:
            logging.debug("Not using 2D overlay")

        # more file paths
        if 'mac' in releaseOS:
            if useDebug:
                logic.binaryPlayerPath = logic.expandPath(
                    "//binMac/flipbook.app/Contents/MacOS/blenderplayer")
            else:
                logic.binaryPlayerPath = logic.expandPath(
                    "//../MacOS/blenderplayer")
            logic.binaryBlenderPath = logic.binaryPlayerPath[:-6]
        elif 'win' in releaseOS:
            logic.binaryPlayerPath = logic.expandPath(
                "//MolecularFlipbook.exe")
            logic.binaryBlenderPath = logic.expandPath("//blender.exe")

        # check paths:
        if os.path.exists(logic.binaryPlayerPath):
            logging.debug('binaryPlayer:\t' + str(logic.binaryPlayerPath))
        else:
            logging.warning(
                'binaryPlayerPath is not verified. Full functionality is improbable'
            )

        if os.path.exists(logic.binaryBlenderPath):
            logging.debug('binaryBlender:\t' + str(logic.binaryBlenderPath))
        else:
            logging.warning(
                'binaryBlenderPath is not verified. Full functionality is improbable'
            )

        # load config
        configPath = os.path.join(logic.tempFilePath, 'config')
        config.load(configPath)

        # initialize bgui
        logic.gui = gui.MyUI()

        # global aliases
        logic.scene = logic.getCurrentScene()  # blender scene alias
        logic.scene2D = None  # overlay 2d ui
        logic.viewCamObject = logic.scene.objects['camera3D']  # camera object
        logic.widgetObject = logic.scene.objects['widget']  # widget object
        logic.controllerObject = logic.scene.objects[
            'controller']  # controller empty
        logic.widgetList = ['rx', 'ry', 'rz', 'x', 'y', 'z', 'widget']
        logic.widgetRenderList = [
            'x.render', 'y.render', 'z.render', 'rx.render', 'ry.render',
            'rz.render', 'widget'
        ]
        logic.pivotObject = logic.scene.objects[
            'pivot']  # pivot object, used for multiobject transform
        logic.markerKey = logic.scene.objects[
            'markerKey']  # used to mark protein

        logic.mousePosDelta = [0, 0]  #
        logic.mouseUp = False
        logic.mouseDown = False
        logic.tap = False
        logic.idleTimer = 0.0  #
        logic.mouseExitHack = False

        # variables used by space 3d navigation
        logic.mousePosOld = [0, 0]
        logic.mousePosOffset = [0, 0]
        logic.viewLocTarget = [0.0, 0.0, 0.0]
        logic.viewZoomTarget = 10.0
        logic.viewZoomCurrent = 10.0
        logic.viewRotTarget = [-0.5, 0, 1]
        logic.viewRotCurrent = [0, 0, 0]

        # mouse stuff
        logic.mouseLock = 0  # 0 = No Lock; 1 = View Manipulation, 2 = Object Manipulation, 3 = UI Manipulation
        logic.multitouch = False
        logic.boxSelect = False
        logic.boxSelectCoord = [0, 0, 0, 0]

        # UI stuff
        logic.clickLInit = None
        logic.clickRInit = None
        logic.keyCounter = 0  # track  keyboard input delay

        logic.sleeping = False
        logic.watch = {
        }  # set this var to have the debugger automatically show the value
        logic.registeredFunctions = [
        ]  # list of functions to be run every frame
        logic.deferredFunctions = [
        ]  # list of functions to be run occasionally

        # var used for object manipulation
        logic.offsetPos = [0, 0, 0]  #
        logic.rotating = False
        logic.moving = False

        # session
        logic.filePath = None
        logic.videoPath = None
        logic.imagePath = None

        logic.projectName = 'Untitled'

        # hacks
        logic.objCounter = 1  # track how many obj bge has spawned
        logic.blobberSliderPriority = False  #hack

        # init widgets shader
        for w in logic.widgetRenderList:
            shader.initWidget(logic.scene.objects[w], 'manipulator')

        # init sky
        rgba = logic.mvb.bgColor[:]
        rgba.append(1.0)
        shader.initSky(logic.scene.objects['Sphere'], 'sky', color=rgba)

        # add the first slide on startup
        logic.timeline.slideAdd(silent=True)

        # start undo stack
        logic.undo = undo.init()

        # start pluggable system
        logic.pluggable = pluggable.init()

        logic.logger.new('Welcome to')
        logic.logger.new('Molecular Flipbook')

        # init updater
        if logic.config['lastUpdate']:
            elapsedTime = int(time.time() - logic.config['lastUpdate'])
            if elapsedTime > 86400 * updateInterval:
                logic.deferredFunctions.append(updater.check)
                config.set('lastUpdate', time.time())
        else:
            logic.deferredFunctions.append(updater.check)
            config.set('lastUpdate', time.time())

        # Done Init
        logging.debug('3D scene initialization done')

        # load file
        logging.debug(sys.argv)
        from . import fileInterface

        if len(sys.argv) > 1:
            try:
                path = sys.argv[1]
                if path.endswith('.flipbook'):
                    fileInterface.load(path=sys.argv[1])
            except Exception as E:
                logic.logger.new('Unable to load File', type='WARNING')
                logging.warning(str(E))

        # init tutorial system
        from . import tutorial
        logic.tutorial = tutorial.init()

        if logic.config['useTutorial'] and useTutorial and not logic.filePath:
            logic.tutorial.start()

        if useMultitouch:
            try:
                logging.debug('Using Multitouch')
                from . import multitouch
            except:
                logging.warning('Multitouch trackpad(s) not found')

        logic.pluggable.system.appStart.notify()

    except:
        logic.endGame()
        logging.exception('Initialization Error')
        print('Initialization Error: Check log for more information.')
        print('_' * 80)
Esempio n. 20
0
def write_sysinfo(op):
    import sys

    import textwrap
    import subprocess

    import bpy
    import bgl

    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    # pretty repr
    def prepr(v):
        r = repr(v)
        vt = type(v)
        if vt is bytes:
            r = r[2:-1]
        elif vt is list or vt is tuple:
            r = r[1:-1]
        return r


    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % ((len(header) - 1) * "=")
    output.write(lilies[:-1])
    output.write(header)
    output.write(lilies)

    def title(text):
        return "\n%s:\n%s" % (text, lilies)

    # build info
    output.write(title("Blender"))
    output.write("version: %s, branch: %s, commit date: %s %s, hash: %s, type: %s\n" %
        (bpy.app.version_string,
         prepr(bpy.app.build_branch),
         prepr(bpy.app.build_commit_date),
         prepr(bpy.app.build_commit_time),
         prepr(bpy.app.build_hash),
         prepr(bpy.app.build_type),
         ))

    output.write("build date: %s, %s\n" % (prepr(bpy.app.build_date), prepr(bpy.app.build_time)))
    output.write("platform: %s\n" % prepr(bpy.app.build_platform))
    output.write("binary path: %s\n" % prepr(bpy.app.binary_path))
    output.write("build cflags: %s\n" % prepr(bpy.app.build_cflags))
    output.write("build cxxflags: %s\n" % prepr(bpy.app.build_cxxflags))
    output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
    output.write("build system: %s\n" % prepr(bpy.app.build_system))

    # python info
    output.write(title("Python"))
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % p)

    output.write(title("Python (External Binary)"))
    output.write("binary path: %s\n" % prepr(bpy.app.binary_path_python))
    try:
        py_ver = prepr(subprocess.check_output([
                bpy.app.binary_path_python,
                "--version",
                ]).strip())
    except Exception as e:
        py_ver = str(e)
    output.write("version: %s\n" % py_ver)
    del py_ver

    output.write(title("Directories"))
    output.write("scripts:\n")
    for p in bpy.utils.script_paths():
        output.write("\t%r\n" % p)
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write(title("FFmpeg"))
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write("%s:%s%r\n" % (lib, " " * (10 - len(lib)),
                         getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    if bpy.app.build_options.sdl:
        output.write(title("SDL"))
        output.write("Version: %s\n" % bpy.app.sdl.version_string)
        output.write("Loading method: ")
        if bpy.app.build_options.sdl_dynload:
            output.write("dynamically loaded by Blender (WITH_SDL_DYNLOAD=ON)\n")
        else:
            output.write("linked (WITH_SDL_DYNLOAD=OFF)\n")
        if not bpy.app.sdl.available:
            output.write("WARNING: Blender could not load SDL library\n")

    output.write(title("Other Libraries"))
    ocio = bpy.app.ocio
    output.write("OpenColorIO: ")
    if ocio.supported:
        if ocio.version_string == "fallback":
            output.write("Blender was built with OpenColorIO, " +
                         "but it currently uses fallback color management.\n")
        else:
            output.write("%s\n" % (ocio.version_string))
    else:
        output.write("Blender was built without OpenColorIO support\n")

    oiio = bpy.app.oiio
    output.write("OpenImageIO: ")
    if ocio.supported:
        output.write("%s\n" % (oiio.version_string))
    else:
        output.write("Blender was built without OpenImageIO support\n")

    output.write("OpenShadingLanguage: ")
    if bpy.app.build_options.cycles:
        if bpy.app.build_options.cycles_osl:
            from _cycles import osl_version_string
            output.write("%s\n" % (osl_version_string))
        else:
            output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
    else:
        output.write("Blender was built without Cycles support\n")

    if not bpy.app.build_options.sdl:
        output.write("SDL: Blender was built without SDL support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write(title("OpenGL"))
        version = bgl.glGetString(bgl.GL_RENDERER)
        output.write("renderer:\t%r\n" % version)
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textwrap.wrap(glext, 70)
        for l in glext:
            output.write("\t%s\n" % l)

        output.write(title("Implementation Dependent OpenGL Limits"))
        limit = bgl.Buffer(bgl.GL_INT, 1)
        bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_UNITS, limit)
        output.write("Maximum Fixed Function Texture Units:\t%d\n" % limit[0])

        output.write("\nGLSL:\n")
        if version[0] > '1':
            bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
            output.write("Maximum Varying Floats:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
            output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])

    if bpy.app.build_options.cycles:
        import cycles
        output.write(title("Cycles"))
        output.write(cycles.engine.system_info())

    output.current_line_index = 0

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
Esempio n. 21
0
def write_sysinfo(op):
    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % (len(header) * "=")
    firstlilies = "%s\n" % (len(header) * "=")
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write("\nBlender:\n")
    output.write(lilies)
    output.write(
        "version %s, revision %r. %r\n" %
        (bpy.app.version_string, bpy.app.build_revision, bpy.app.build_type))
    output.write("build date: %r, %r\n" %
                 (bpy.app.build_date, bpy.app.build_time))
    output.write("platform: %r\n" % (bpy.app.build_platform))
    output.write("binary path: %r\n" % (bpy.app.binary_path))
    output.write("build cflags: %r\n" % (bpy.app.build_cflags))
    output.write("build cxxflags: %r\n" % (bpy.app.build_cxxflags))
    output.write("build linkflags: %r\n" % (bpy.app.build_linkflags))
    output.write("build system: %r\n" % (bpy.app.build_system))

    # python info
    output.write("\nPython:\n")
    output.write(lilies)
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % (p))

    output.write("\nDirectories:\n")
    output.write(lilies)
    output.write("scripts: %r\n" % (bpy.utils.script_paths()))
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write("\nFFmpeg:\n")
    output.write(lilies)
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write(
                "%r:%r%r\n" %
                (lib, " " *
                 (10 - len(lib)), getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write("\nOpenGL\n")
        output.write(lilies)
        output.write("renderer:\t%r\n" % (bgl.glGetString(bgl.GL_RENDERER)))
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textWrap(glext, 70)
        for l in glext:
            output.write("\t\t%r\n" % (l))

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
Esempio n. 22
0

get_git_info()

retopoflow_cgcookie_built = os.path.exists(
    os.path.join(os.path.dirname(__file__), '..', '.cgcookie'))

###########################################
# Get system info

build_platform = bpy.app.build_platform.decode('utf-8')
retopoflow_git_version = git_info()
platform_system, platform_node, platform_release, platform_version, platform_machine, platform_processor = platform.uname(
)
# https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glGetString.xml
gpu_vendor = bgl.glGetString(bgl.GL_VENDOR)
gpu_renderer = bgl.glGetString(bgl.GL_RENDERER)
gpu_version = bgl.glGetString(bgl.GL_VERSION)
gpu_shading = bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION)

print('RetopoFlow git: %s' % str(retopoflow_git_version))


class Options:
    path_root = None
    options_filename = 'RetopoFlow_options.json'  # the filename of the Shelve object
    # will be located at root of RF plug-in

    default_options = {                 # all the default settings for unset or reset
        'rf version':           None,   # if versions differ, flush stored options
        'version update':       False,
Esempio n. 23
0
def write_sysinfo(op):
    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % (len(header) * "=")
    firstlilies = "%s\n" % (len(header) * "=")
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write("\nBlender:\n")
    output.write(lilies)
    if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
        output.write("version %s, branch %r, commit date %r %r, hash %r, %r\n" %
            (bpy.app.version_string,
             bpy.app.build_branch,
             bpy.app.build_commit_date,
             bpy.app.build_commit_time,
             bpy.app.build_hash,
             bpy.app.build_type))
    else:
        output.write("version %s, revision %r. %r\n" %
            (bpy.app.version_string,
             bpy.app.build_change,
             bpy.app.build_type))

    output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time))
    output.write("platform: %r\n" % (bpy.app.build_platform))
    output.write("binary path: %r\n" % (bpy.app.binary_path))
    output.write("build cflags: %r\n" % (bpy.app.build_cflags))
    output.write("build cxxflags: %r\n" % (bpy.app.build_cxxflags))
    output.write("build linkflags: %r\n" % (bpy.app.build_linkflags))
    output.write("build system: %r\n" % (bpy.app.build_system))

    # python info
    output.write("\nPython:\n")
    output.write(lilies)
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % (p))

    output.write("\nDirectories:\n")
    output.write(lilies)
    output.write("scripts: %r\n" % (bpy.utils.script_paths()))
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write("\nFFmpeg:\n")
    output.write(lilies)
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write("%r:%r%r\n" % (lib, " " * (10 - len(lib)),
                         getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    output.write("\nOther Libraries:\n")
    output.write(lilies)
    ocio = bpy.app.ocio
    output.write("OpenColorIO: ")
    if ocio.supported:
        if ocio.version_string == "fallback":
            output.write("Blender was built with OpenColorIO, " +
                         "but it currently uses fallback color management.\n")
        else:
            output.write("%s\n" % (ocio.version_string))
    else:
        output.write("Blender was built without OpenColorIO support\n")

    oiio = bpy.app.oiio
    output.write("OpenImageIO: ")
    if ocio.supported:
        output.write("%s\n" % (oiio.version_string))
    else:
        output.write("Blender was built without OpenImageIO support\n")

    output.write("OpenShadingLanguage: ")
    if bpy.app.build_options.cycles:
        if bpy.app.build_options.cycles_osl:
            from _cycles import osl_version_string
            output.write("%s\n" % (osl_version_string))
        else:
            output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
    else:
        output.write("Blender was built without Cycles support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write("\nOpenGL\n")
        output.write(lilies)
        version = bgl.glGetString(bgl.GL_RENDERER);
        output.write("renderer:\t%r\n" % version)
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textWrap(glext, 70)
        for l in glext:
            output.write("\t\t%r\n" % (l))

        output.write("\nImplementation Dependent OpenGL Limits:\n")
        output.write(lilies)
        limit = bgl.Buffer(bgl.GL_INT, 1)
        bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_UNITS, limit)
        output.write("Maximum Fixed Function Texture Units:\t%d\n" % limit[0])

        output.write("\nGLSL:\n")
        if version[0] > '1':
            bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
            output.write("Maximum Varying Floats:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
            output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])

    output.current_line_index = 0

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
Esempio n. 24
0
from .profiler import profiler
from .decorators import blender_version_wrapper, add_cache



# note: not all supported by user system, but we don't need full functionality
# https://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions
#     OpenGL  GLSL    OpenGL  GLSL
#      2.0    110      4.0    400
#      2.1    120      4.1    410
#      3.0    130      4.2    420
#      3.1    140      4.3    430
#      3.2    150      4.4    440
#      3.3    330      4.5    450
#                      4.6    460
print('Addon Common: (bmesh_render) GLSL Version:', bgl.glGetString(bgl.GL_SHADING_LANGUAGE_VERSION))


@blender_version_wrapper('<', '2.80')
def glSetDefaultOptions():
    bgl.glDisable(bgl.GL_LIGHTING)
    bgl.glEnable(bgl.GL_MULTISAMPLE)
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glEnable(bgl.GL_DEPTH_TEST)
    bgl.glEnable(bgl.GL_POINT_SMOOTH)
    bgl.glEnable(bgl.GL_LINE_SMOOTH)
    bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST)
@blender_version_wrapper('>=', '2.80')
def glSetDefaultOptions():
    # bgl.glEnable(bgl.GL_MULTISAMPLE)
    bgl.glEnable(bgl.GL_BLEND)
Esempio n. 25
0
def init(cont):
	'''initializes the application'''
	try:
		logic.mouse.visible = True

		# gpu detection and ssao enabler
		vendor = bgl.glGetString(bgl.GL_VENDOR)
		renderer = bgl.glGetString(bgl.GL_RENDERER)
		version = bgl.glGetString(bgl.GL_VERSION)

		logging.debug("GL Vendor:\t" + str(vendor))
		logging.debug("GL Renderer:\t" + str(renderer))
		logging.debug("GL Version:\t" + str(version))

		fancyGPU = not "intel" in vendor.lower()

		if useAmbientOcclusion and fancyGPU:
			logging.debug("Using SSAO")
			cont.activate(cont.actuators['ssao'])
		else:
			logging.debug("Not using SSAO")


		# overlay scene enabler
		if useSceneOverlay:
			cont.activate(cont.actuators['scene2D'])
			logging.debug("Using 2D overlay")
		else:
			logging.debug("Not using 2D overlay")

		# more file paths
		if 'mac' in releaseOS:
			if useDebug:
				logic.binaryPlayerPath = logic.expandPath("//binMac/flipbook.app/Contents/MacOS/blenderplayer")
			else:
				logic.binaryPlayerPath = logic.expandPath("//../MacOS/blenderplayer")
			logic.binaryBlenderPath = logic.binaryPlayerPath[:-6]
		elif 'win' in releaseOS:
			logic.binaryPlayerPath = logic.expandPath("//MolecularFlipbook.exe")
			logic.binaryBlenderPath = logic.expandPath("//blender.exe")

		# check paths:
		if os.path.exists(logic.binaryPlayerPath):
			logging.debug('binaryPlayer:\t' + str(logic.binaryPlayerPath))
		else:
			logging.warning('binaryPlayerPath is not verified. Full functionality is improbable')

		if os.path.exists(logic.binaryBlenderPath):
			logging.debug('binaryBlender:\t' + str(logic.binaryBlenderPath))
		else:
			logging.warning('binaryBlenderPath is not verified. Full functionality is improbable')


		# load config
		configPath = os.path.join(logic.tempFilePath, 'config')
		config.load(configPath)

		# initialize bgui
		logic.gui = gui.MyUI()

		# global aliases
		logic.scene = logic.getCurrentScene()						# blender scene alias
		logic.scene2D = None										# overlay 2d ui
		logic.viewCamObject = logic.scene.objects['camera3D']		# camera object
		logic.widgetObject = logic.scene.objects['widget']			# widget object
		logic.controllerObject = logic.scene.objects['controller']	# controller empty
		logic.widgetList = ['rx','ry','rz','x','y','z', 'widget']
		logic.widgetRenderList = ['x.render', 'y.render', 'z.render', 'rx.render', 'ry.render', 'rz.render', 'widget']
		logic.pivotObject = logic.scene.objects['pivot']			# pivot object, used for multiobject transform
		logic.markerKey = logic.scene.objects['markerKey'] 			# used to mark protein

		logic.mousePosDelta = [0,0]									#
		logic.mouseUp = False
		logic.mouseDown = False
		logic.tap = False
		logic.idleTimer = 0.0										#
		logic.mouseExitHack = False

		# variables used by space 3d navigation
		logic.mousePosOld = [0,0]
		logic.mousePosOffset = [0,0]
		logic.viewLocTarget = [0.0,0.0,0.0]
		logic.viewZoomTarget = 10.0
		logic.viewZoomCurrent = 10.0
		logic.viewRotTarget = [-0.5,0,1]
		logic.viewRotCurrent = [0,0,0]

		# mouse stuff
		logic.mouseLock = 0											# 0 = No Lock; 1 = View Manipulation, 2 = Object Manipulation, 3 = UI Manipulation
		logic.multitouch = False
		logic.boxSelect = False
		logic.boxSelectCoord = [0,0,0,0]

		# UI stuff
		logic.clickLInit = None
		logic.clickRInit = None
		logic.keyCounter = 0 										# track  keyboard input delay

		logic.sleeping = False
		logic.watch = {} 											# set this var to have the debugger automatically show the value
		logic.registeredFunctions = []								# list of functions to be run every frame
		logic.deferredFunctions = [] 								# list of functions to be run occasionally

		# var used for object manipulation
		logic.offsetPos = [0,0,0]									#
		logic.rotating = False
		logic.moving = False

		# session
		logic.filePath = None
		logic.videoPath = None
		logic.imagePath = None

		logic.projectName = 'Untitled'
		
		# hacks
		logic.objCounter = 1 										# track how many obj bge has spawned
		logic.blobberSliderPriority = False 						#hack

		# init widgets shader
		for w in logic.widgetRenderList:
			shader.initWidget(logic.scene.objects[w], 'manipulator')

		# init sky
		rgba = logic.mvb.bgColor[:]
		rgba.append(1.0)
		shader.initSky(logic.scene.objects['Sphere'], 'sky', color = rgba)

		# add the first slide on startup
		logic.timeline.slideAdd(silent=True)

		# start undo stack
		logic.undo = undo.init()

		# start pluggable system
		logic.pluggable = pluggable.init()

		logic.logger.new('Welcome to')
		logic.logger.new('Molecular Flipbook')

		# init updater
		if logic.config['lastUpdate']:
			elapsedTime = int(time.time() - logic.config['lastUpdate'])
			if elapsedTime > 86400 * updateInterval:
				logic.deferredFunctions.append(updater.check)
				config.set('lastUpdate', time.time())
		else:
			logic.deferredFunctions.append(updater.check)
			config.set('lastUpdate', time.time())

		# Done Init
		logging.debug('3D scene initialization done')

		# load file
		logging.debug(sys.argv)
		from . import fileInterface
		
		if len(sys.argv) > 1:
			try:
				path = sys.argv[1]
				if path.endswith('.flipbook'):
					fileInterface.load(path=sys.argv[1])
			except Exception as E:
				logic.logger.new('Unable to load File', type='WARNING')
				logging.warning(str(E))

		# init tutorial system
		from . import tutorial
		logic.tutorial = tutorial.init()

		if logic.config['useTutorial'] and useTutorial and not logic.filePath:
			logic.tutorial.start()

		if useMultitouch:
			try:
				logging.debug('Using Multitouch')
				from . import multitouch
			except:
				logging.warning('Multitouch trackpad(s) not found')



		logic.pluggable.system.appStart.notify()

	except:
		logic.endGame()
		logging.exception('Initialization Error')
		print ('Initialization Error: Check log for more information.')
		print ('_'*80)
Esempio n. 26
0
def write_sysinfo(op):
    import textwrap

    output_filename = "system-info.txt"

    output = bpy.data.texts.get(output_filename)
    if output:
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    # pretty repr
    def prepr(v):
        r = repr(v)
        vt = type(v)
        if vt is bytes:
            r = r[2:-1]
        elif vt is list or vt is tuple:
            r = r[1:-1]
        return r


    header = "= Blender %s System Information =\n" % bpy.app.version_string
    lilies = "%s\n\n" % ((len(header) - 1) * "=")
    output.write(lilies[:-1])
    output.write(header)
    output.write(lilies)

    def title(text):
        return "\n%s:\n%s" % (text, lilies)

    # build info
    output.write(title("Blender"))
    output.write("version: %s, branch: %s, commit date: %s %s, hash: %s, type: %s\n" %
        (bpy.app.version_string,
         prepr(bpy.app.build_branch),
         prepr(bpy.app.build_commit_date),
         prepr(bpy.app.build_commit_time),
         prepr(bpy.app.build_hash),
         prepr(bpy.app.build_type),
         ))

    output.write("build date: %s, %s\n" % (prepr(bpy.app.build_date), prepr(bpy.app.build_time)))
    output.write("platform: %s\n" % prepr(bpy.app.build_platform))
    output.write("binary path: %s\n" % prepr(bpy.app.binary_path))
    output.write("build cflags: %s\n" % prepr(bpy.app.build_cflags))
    output.write("build cxxflags: %s\n" % prepr(bpy.app.build_cxxflags))
    output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
    output.write("build system: %s\n" % prepr(bpy.app.build_system))

    # python info
    output.write(title("Python"))
    output.write("version: %s\n" % (sys.version))
    output.write("paths:\n")
    for p in sys.path:
        output.write("\t%r\n" % p)

    output.write(title("Directories"))
    output.write("scripts:\n")
    for p in bpy.utils.script_paths():
        output.write("\t%r\n" % p)
    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
    output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
    output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
    output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
    output.write("autosave: %r\n" % (bpy.utils.user_resource('AUTOSAVE')))
    output.write("tempdir: %r\n" % (bpy.app.tempdir))

    output.write(title("FFmpeg"))
    ffmpeg = bpy.app.ffmpeg
    if ffmpeg.supported:
        for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"):
            output.write("%s:%s%r\n" % (lib, " " * (10 - len(lib)),
                         getattr(ffmpeg, lib + "_version_string")))
    else:
        output.write("Blender was built without FFmpeg support\n")

    if bpy.app.build_options.sdl:
        output.write(title("SDL"))
        output.write("Version: %s\n" % bpy.app.sdl.version_string)
        output.write("Loading method: ")
        if bpy.app.build_options.sdl_dynload:
            output.write("dynamically loaded by Blender (WITH_SDL_DYNLOAD=ON)\n")
        else:
            output.write("linked (WITH_SDL_DYNLOAD=OFF)\n")
        if not bpy.app.sdl.available:
            output.write("WARNING: Blender could not load SDL library\n")

    output.write(title("Other Libraries"))
    ocio = bpy.app.ocio
    output.write("OpenColorIO: ")
    if ocio.supported:
        if ocio.version_string == "fallback":
            output.write("Blender was built with OpenColorIO, " +
                         "but it currently uses fallback color management.\n")
        else:
            output.write("%s\n" % (ocio.version_string))
    else:
        output.write("Blender was built without OpenColorIO support\n")

    oiio = bpy.app.oiio
    output.write("OpenImageIO: ")
    if ocio.supported:
        output.write("%s\n" % (oiio.version_string))
    else:
        output.write("Blender was built without OpenImageIO support\n")

    output.write("OpenShadingLanguage: ")
    if bpy.app.build_options.cycles:
        if bpy.app.build_options.cycles_osl:
            from _cycles import osl_version_string
            output.write("%s\n" % (osl_version_string))
        else:
            output.write("Blender was built without OpenShadingLanguage support in Cycles\n")
    else:
        output.write("Blender was built without Cycles support\n")

    if not bpy.app.build_options.sdl:
        output.write("SDL: Blender was built without SDL support\n")

    if bpy.app.background:
        output.write("\nOpenGL: missing, background mode\n")
    else:
        output.write(title("OpenGL"))
        version = bgl.glGetString(bgl.GL_RENDERER)
        output.write("renderer:\t%r\n" % version)
        output.write("vendor:\t\t%r\n" % (bgl.glGetString(bgl.GL_VENDOR)))
        output.write("version:\t%r\n" % (bgl.glGetString(bgl.GL_VERSION)))
        output.write("extensions:\n")

        glext = bgl.glGetString(bgl.GL_EXTENSIONS)
        glext = textwrap.wrap(glext, 70)
        for l in glext:
            output.write("\t%s\n" % l)

        output.write(title("Implementation Dependent OpenGL Limits"))
        limit = bgl.Buffer(bgl.GL_INT, 1)
        bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_UNITS, limit)
        output.write("Maximum Fixed Function Texture Units:\t%d\n" % limit[0])

        output.write("\nGLSL:\n")
        if version[0] > '1':
            bgl.glGetIntegerv(bgl.GL_MAX_VARYING_FLOATS, limit)
            output.write("Maximum Varying Floats:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_ATTRIBS, limit)
            output.write("Maximum Vertex Attributes:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Vertex Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, limit)
            output.write("Maximum Fragment Uniform Components:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Vertex Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Fragment Image Units:\t%d\n" % limit[0])
            bgl.glGetIntegerv(bgl.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, limit)
            output.write("Maximum Pipeline Image Units:\t%d\n" % limit[0])

    if bpy.app.build_options.cycles:
        import cycles
        output.write(title("Cycles"))
        output.write(cycles.engine.system_info())

    output.current_line_index = 0

    op.report({'INFO'}, "System information generated in 'system-info.txt'")
def write_sysinfo(op):
    output_filename = "system-info.txt"
    warnings = 0
    notices = 0

    if output_filename in bpy.data.texts.keys():
        output = bpy.data.texts[output_filename]
        output.clear()
    else:
        output = bpy.data.texts.new(name=output_filename)

    header = '= Blender {} System Information =\n'.format(bpy.app.version_string)
    lilies = '{}\n\n'.format(len(header) * '=')
    firstlilies = '{}\n'.format(len(header) * '=')
    output.write(firstlilies)
    output.write(header)
    output.write(lilies)

    # build info
    output.write('\nBlender:\n')
    output.write(lilies)
    output.write('version {}, revision {}. {}\n'.format(bpy.app.version_string, bpy.app.build_revision, bpy.app.build_type))
    output.write('build date: {}, {}\n'.format(bpy.app.build_date, bpy.app.build_time))
    output.write('platform: {}\n'.format(bpy.app.build_platform))
    output.write('binary path: {}\n'.format(bpy.app.binary_path))
    output.write('build cflags: {}\n'.format(bpy.app.build_cflags))
    output.write('build cxxflags: {}\n'.format(bpy.app.build_cxxflags))
    output.write('build linkflags: {}\n'.format(bpy.app.build_linkflags))
    output.write('build system: {}\n'.format(bpy.app.build_system))

    # python info
    output.write('\nPython:\n')
    output.write(lilies)
    output.write('version: {}\n'.format(sys.version))
    output.write('paths:\n')
    for p in sys.path:
        output.write('\t{}\n'.format(p))

    output.write('\nDirectories:\n')
    output.write(lilies)
    output.write('scripts: {}\n'.format(bpy.utils.script_paths()))
    output.write('user scripts: {}\n'.format(bpy.utils.user_script_path()))
    output.write('datafiles: {}\n'.format(bpy.utils.user_resource('DATAFILES')))
    output.write('config: {}\n'.format(bpy.utils.user_resource('CONFIG')))
    output.write('scripts : {}\n'.format(bpy.utils.user_resource('SCRIPTS')))
    output.write('autosave: {}\n'.format(bpy.utils.user_resource('AUTOSAVE')))
    output.write('tempdir: {}\n'.format(bpy.app.tempdir))

    output.write('\nOpenGL\n')
    output.write(lilies)
    output.write('renderer:\t{}\n'.format(bgl.glGetString(bgl.GL_RENDERER)))
    output.write('vendor:\t\t{}\n'.format(bgl.glGetString(bgl.GL_VENDOR)))
    output.write('version:\t{}\n'.format(bgl.glGetString(bgl.GL_VERSION)))
    output.write('extensions:\n')

    glext = bgl.glGetString(bgl.GL_EXTENSIONS)
    glext = textWrap(glext, 70)
    for l in glext:
        output.write('\t\t{}\n'.format(l))

    op.report({'INFO'}, "System information generated in 'system-info.txt'")