本文整理汇总了Python中shader.Shader.supported方法的典型用法代码示例。如果您正苦于以下问题:Python Shader.supported方法的具体用法?Python Shader.supported怎么用?Python Shader.supported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shader.Shader
的用法示例。
在下文中一共展示了Shader.supported方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawMesh
# 需要导入模块: from shader import Shader [as 别名]
# 或者: from shader.Shader import supported [as 别名]
def drawMesh(obj):
if not obj.visibility:
return
glDepthFunc(GL_LEQUAL)
# Transform the current object
glPushMatrix()
transformObject(obj)
if obj.texture and obj.solid:
glEnable(GL_TEXTURE_2D)
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
glBindTexture(GL_TEXTURE_2D, obj.texture)
glTexCoordPointer(2, GL_FLOAT, 0, obj.UVs)
if obj.nTransparentPrimitives:
obj.sortFaces()
# Fill the array pointers with object mesh data
glVertexPointer(3, GL_FLOAT, 0, obj.verts)
glNormalPointer(GL_FLOAT, 0, obj.norms)
glColorPointer(4, GL_UNSIGNED_BYTE, 0, obj.color)
# Disable lighting if the object is shadeless
if obj.shadeless:
glDisable(GL_LIGHTING)
if obj.cull:
glEnable(GL_CULL_FACE)
glCullFace(GL_BACK if obj.cull > 0 else GL_FRONT)
# Enable the shader if the driver supports it and there is a shader assigned
if obj.shader and obj.solid and Shader.supported() and not obj.shadeless:
glUseProgram(obj.shader)
# Set custom attributes
if obj.shaderObj.requiresVertexTangent():
glVertexAttribPointer(obj.shaderObj.vertexTangentAttrId, 4, GL_FLOAT, GL_FALSE, 0, obj.tangents)
glEnableVertexAttribArray(obj.shaderObj.vertexTangentAttrId)
# TODO
# This should be optimized, since we only need to do it when it's changed
# Validation should also only be done when it is set
if obj.shaderParameters:
obj.shaderObj.setUniforms(obj.shaderParameters)
# draw the mesh
if not obj.solid:
glDisableClientState(GL_COLOR_ARRAY)
glColor3f(0.0, 0.0, 0.0)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
glEnableClientState(GL_COLOR_ARRAY)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
glEnable(GL_POLYGON_OFFSET_FILL)
glPolygonOffset(1.0, 1.0)
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
glDisable(GL_POLYGON_OFFSET_FILL)
elif obj.nTransparentPrimitives:
glDepthMask(GL_FALSE)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0.0)
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
glDisable(GL_ALPHA_TEST)
glDepthMask(GL_TRUE)
elif obj.depthless:
glDepthMask(GL_FALSE)
glDisable(GL_DEPTH_TEST)
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
glEnable(GL_DEPTH_TEST)
glDepthMask(GL_TRUE)
else:
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
if obj.solid and not obj.nTransparentPrimitives:
glDisableClientState(GL_COLOR_ARRAY)
for i, (start, count) in enumerate(obj.groups):
color = obj.gcolor(i)
if color is None or np.all(color[:3] == 255):
continue
glColor4ub(*color)
indices = obj.primitives[start:start+count,:]
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], indices.size, GL_UNSIGNED_INT, indices)
glEnableClientState(GL_COLOR_ARRAY)
# Disable the shader if the driver supports it and there is a shader assigned
if obj.shader and obj.solid and Shader.supported() and not obj.shadeless:
glUseProgram(0)
glActiveTexture(GL_TEXTURE0)
glDisable(GL_CULL_FACE)
# Enable lighting if the object was shadeless
if obj.shadeless:
glEnable(GL_LIGHTING)
if obj.texture and obj.solid:
glDisable(GL_TEXTURE_2D)
glDisableClientState(GL_TEXTURE_COORD_ARRAY)
#.........这里部分代码省略.........
示例2: drawMesh
# 需要导入模块: from shader import Shader [as 别名]
# 或者: from shader.Shader import supported [as 别名]
#.........这里部分代码省略.........
MatAmb = A(0.11, 0.11, 0.11, 1.0) # Material - Ambient Values
MatDif = A(1.0, 1.0, 1.0, 1.0) # Material - Diffuse Values
MatSpc = A(0.2, 0.2, 0.2, 1.0) # Material - Specular Values
MatShn = A(10.0,) # Material - Shininess
MatEms = A(0.0, 0.0, 0.0, 1.0) # Material - Emission Values
glMaterialfv(GL_FRONT, GL_AMBIENT, MatAmb) # Set Material Ambience
glMaterialfv(GL_FRONT, GL_DIFFUSE, MatDif) # Set Material Diffuse
glMaterialfv(GL_FRONT, GL_SPECULAR, MatSpc) # Set Material Specular
glMaterialfv(GL_FRONT, GL_SHININESS, MatShn) # Set Material Shininess
glMaterialfv(GL_FRONT, GL_EMISSION, MatEms) # Set Material Emission
if obj.useVertexColors:
# Vertex colors affect materials (lighting is enabled)
glEnable(GL_COLOR_MATERIAL)
# Vertex colors affect diffuse of material
glColorMaterial(GL_FRONT, GL_DIFFUSE)
else:
glDisable(GL_COLOR_MATERIAL)
# Enable the shader if the driver supports it and there is a shader assigned
if useShader:
glUseProgram(obj.shader)
# Set custom attributes
if obj.shaderObj.requiresVertexTangent():
glVertexAttribPointer(obj.shaderObj.vertexTangentAttrId, 4, GL_FLOAT, GL_FALSE, 0, obj.tangents)
glEnableVertexAttribArray(obj.shaderObj.vertexTangentAttrId)
# TODO
# This should be optimized, since we only need to do it when it's changed
# Validation should also only be done when it is set
obj.shaderObj.setUniforms(obj.shaderParameters)
elif Shader.supported():
glUseProgram(0)
# draw the mesh
if not obj.solid:
# Wireframe drawing
glEnable(GL_COLOR_MATERIAL)
glDisableClientState(GL_COLOR_ARRAY)
glColor3f(0.0, 0.0, 0.0)
glDisable(GL_LIGHTING)
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE) # Vertex colors affect ambient and diffuse of material
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
glEnableClientState(GL_COLOR_ARRAY)
glEnable(GL_LIGHTING)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
glEnable(GL_POLYGON_OFFSET_FILL)
glPolygonOffset(1.0, 1.0)
glDrawElements(g_primitiveMap[obj.vertsPerPrimitive-1], obj.primitives.size, GL_UNSIGNED_INT, obj.primitives)
glDisable(GL_POLYGON_OFFSET_FILL)
glDisable(GL_COLOR_MATERIAL)
elif obj.nTransparentPrimitives:
if have_multisample and obj.alphaToCoverage:
# Enable alpha-to-coverage (also called CSAA)
# using the multisample buffer for alpha to coverage disables its use for MSAA (anti-aliasing)
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
#glEnable(GL_SAMPLE_ALPHA_TO_ONE) # Enable this if transparent objects are too transparent
glDisable(GL_BLEND) # Disable alpha blending
else:
示例3: __init__
# 需要导入模块: from shader import Shader [as 别名]
# 或者: from shader.Shader import supported [as 别名]
def __init__(self, category):
gui3d.TaskView.__init__(self, category, 'General')
self.shaderGroup = []
shaderBox = self.addLeftWidget(gui.GroupBox('Shader'))
self.shaderNo = shaderBox.addWidget(gui.RadioButton(self.shaderGroup, "No shader", True))
self.shaderPhong = shaderBox.addWidget(gui.RadioButton(self.shaderGroup, "Phong shader"))
self.shaderToon = shaderBox.addWidget(gui.RadioButton(self.shaderGroup, "Toon shader"))
#self.shaderSkin = shaderBox.addWidget(gui.RadioButton(self.shaderGroup, "Skin shader"))
from shader import Shader
if not Shader.supported():
for radio in shaderBox.children:
radio.setEnabled(False)
sliderBox = self.addLeftWidget(gui.GroupBox('Slider behavior'))
self.realtimeUpdates = sliderBox.addWidget(gui.CheckBox("Update real-time",
gui3d.app.settings.get('realtimeUpdates', True)))
self.realtimeNormalUpdates = sliderBox.addWidget(gui.CheckBox("Update normals real-time",
gui3d.app.settings.get('realtimeNormalUpdates', True)))
self.cameraAutoZoom = sliderBox.addWidget(gui.CheckBox("Auto-zoom camera",
gui3d.app.settings.get('cameraAutoZoom', True)))
self.sliderImages = sliderBox.addWidget(gui.CheckBox("Slider images",
gui3d.app.settings.get('sliderImages', True)))
mouseBox = self.addLeftWidget(gui.SliderBox('Mouse behavior'))
self.normal = mouseBox.addWidget(gui.Slider(gui3d.app.settings.get('lowspeed', 1), 1, 10,
"Normal: %d"))
self.shift = mouseBox.addWidget(gui.Slider(gui3d.app.settings.get('highspeed', 5), 1, 10,
"Shift: %d"))
modes = []
unitBox = self.unitsBox = self.addLeftWidget(gui.GroupBox('Units'))
metric = unitBox.addWidget(gui.RadioButton(modes, 'Metric', gui3d.app.settings.get('units', 'metric') == 'metric'))
imperial = unitBox.addWidget(gui.RadioButton(modes, 'Imperial', gui3d.app.settings.get('units', 'metric') == 'imperial'))
preloadBox = self.addLeftWidget(gui.GroupBox('Preloading'))
self.preload = preloadBox.addWidget(gui.CheckBox("Preload macro targets",
gui3d.app.settings.get('preloadTargets', False)))
themes = []
themesBox = self.themesBox = self.addRightWidget(gui.GroupBox('Theme'))
self.themeNative = themesBox.addWidget(ThemeRadioButton(themes, "Native look", "default"))
self.themeMH = themesBox.addWidget(ThemeRadioButton(themes, "MakeHuman", "makehuman"))
# For debugging themes on multiple platforms
'''
platforms = []
platformsBox = self.platformsBox = self.addRightWidget(gui.GroupBox('Look and feel'))
for platform in gui3d.app.getLookAndFeelStyles():
platformsBox.addWidget(PlatformRadioButton(platforms, platform))
'''
# We might allow overriding the font from the style, but for now loaded fonts can be used from a style
'''
fonts = []
fontsBox = self.fontsBox = self.addRightWidget(gui.GroupBox('Font'))
fontsBox.addWidget(FontRadioButton(fonts, "Default"))
for font in gui3d.app.getCustomFonts():
fontsBox.addWidget(FontRadioButton(fonts, font))
'''
languages = []
languageBox = self.languageBox = self.addRightWidget(gui.GroupBox('Language'))
languageBox.addWidget(LanguageRadioButton(languages, 'english'))
languageFiles = [os.path.basename(filename).replace('.ini', '') for filename in os.listdir('data/languages') if filename.split(os.extsep)[-1] == "ini"]
for language in languageFiles:
languageBox.addWidget(LanguageRadioButton(languages, language))
@self.shaderNo.mhEvent
def onClicked(event):
human = gui3d.app.selectedHuman
human.mesh.setShader(None)
@self.shaderPhong.mhEvent
def onClicked(event):
self.setShader("data/shaders/glsl/phong")
@self.shaderToon.mhEvent
def onClicked(event):
self.setShader("data/shaders/glsl/toon")
#@self.shaderSkin.mhEvent
#def onClicked(event):
#self.setShader("data/shaders/glsl/skin")
#gui3d.app.selectedHuman.mesh.setShaderParameter("gradientMap", "data/textures/color_temperature.png")
#gui3d.app.selectedHuman.mesh.setShaderParameter("ambientOcclusionMap", "data/textures/female_young.tif")
@self.realtimeUpdates.mhEvent
def onClicked(event):
gui3d.app.settings['realtimeUpdates'] = self.realtimeUpdates.selected
@self.realtimeNormalUpdates.mhEvent
def onClicked(event):
gui3d.app.settings['realtimeNormalUpdates'] = self.realtimeNormalUpdates.selected
@self.cameraAutoZoom.mhEvent
def onClicked(event):
gui3d.app.settings['cameraAutoZoom'] = self.cameraAutoZoom.selected
#.........这里部分代码省略.........