mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 01:49:03 +08:00
Don't crash if the shader fails to compile
This commit is contained in:
parent
245a4435e1
commit
51378cae56
@ -1,14 +1,16 @@
|
|||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from UM.Qt.QtApplication import QtApplication
|
from UM.Qt.QtApplication import QtApplication
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.Math.Vector import Vector
|
from UM.Math.Vector import Vector
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
|
|
||||||
from UM.View.RenderPass import RenderPass
|
from UM.View.RenderPass import RenderPass
|
||||||
from UM.View.GL.OpenGL import OpenGL
|
from UM.View.GL.OpenGL import OpenGL
|
||||||
|
from UM.View.GL.ShaderProgram import InvalidShaderProgramError
|
||||||
from UM.View.RenderBatch import RenderBatch
|
from UM.View.RenderBatch import RenderBatch
|
||||||
|
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
@ -31,7 +33,11 @@ class PickingPass(RenderPass):
|
|||||||
|
|
||||||
def render(self) -> None:
|
def render(self) -> None:
|
||||||
if not self._shader:
|
if not self._shader:
|
||||||
|
try:
|
||||||
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "camera_distance.shader"))
|
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "camera_distance.shader"))
|
||||||
|
except InvalidShaderProgramError:
|
||||||
|
Logger.error("Unable to compile shader program: camera_distance.shader")
|
||||||
|
return
|
||||||
|
|
||||||
width, height = self.getSize()
|
width, height = self.getSize()
|
||||||
self._gl.glViewport(0, 0, width, height)
|
self._gl.glViewport(0, 0, width, height)
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from typing import Optional, TYPE_CHECKING, cast
|
from typing import Optional, TYPE_CHECKING, cast
|
||||||
|
|
||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
|
|
||||||
from UM.View.RenderPass import RenderPass
|
from UM.View.RenderPass import RenderPass
|
||||||
@ -63,6 +64,8 @@ class PreviewPass(RenderPass):
|
|||||||
self._shader.setUniformValue("u_shininess", 20.0)
|
self._shader.setUniformValue("u_shininess", 20.0)
|
||||||
self._shader.setUniformValue("u_renderError", 0.0) # We don't want any error markers!.
|
self._shader.setUniformValue("u_renderError", 0.0) # We don't want any error markers!.
|
||||||
self._shader.setUniformValue("u_faceId", -1) # Don't render any selected faces in the preview.
|
self._shader.setUniformValue("u_faceId", -1) # Don't render any selected faces in the preview.
|
||||||
|
else:
|
||||||
|
Logger.error("Unable to compile shader program: overhang.shader")
|
||||||
|
|
||||||
if not self._non_printing_shader:
|
if not self._non_printing_shader:
|
||||||
if self._non_printing_shader:
|
if self._non_printing_shader:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user