Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def initMuJoCo(filename, width2, height):
''' load model, init simulation and rendering '''
global window, sim, ctx
assert glfw.init(), 'Could not initialize GLFW'
glfw.window_hint(glfw.SAMPLES, 0)
glfw.window_hint(glfw.DOUBLEBUFFER, True)
glfw.window_hint(glfw.RESIZABLE, 0)
window = glfw.create_window(width2 // 4, height // 2, "mjvive.py", None, None)
assert window, "Could not create GLFW window"
glfw.make_context_current(window)
glfw.swap_interval(0)
# GLEW init required in C++, not in Python
sim = MjSim(load_model_from_xml(open(filename).read()))
sim.forward()
sim.model.vis.global_.offwidth = width2
sim.model.vis.global_.offheight = height
sim.model.vis.quality.offsamples = 8
ctx = MjRenderContext(sim)
ctx.scn.enabletransform = 1
ctx.scn.translate[1:3] = -0.5
ctx.scn.rotate[0:2] = math.cos(-0.25 * math.pi), math.sin(-0.25 * math.pi)
ctx.scn.scale = 1
ctx.scn.stereo = STEREO_SIDEBYSIDE
# Open Window and create its OpenGL context
window = glfw.create_window(1024, 768, "Tutorial 03", None, None) #(in the accompanying source code this variable will be global)
glfw.window_hint(glfw.SAMPLES, 4)
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if not window:
print("Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n",file=sys.stderr)
glfw.terminate()
return False
# Initialize GLEW
glfw.make_context_current(window)
glewExperimental = True
# GLEW is a framework for testing extension availability. Please see tutorial notes for
# more information including why can remove this code.
if glewInit() != GLEW_OK:
print("Failed to initialize GLEW\n",file=sys.stderr);
return False
return True
def main():
if not glfw.init():
return -1
if not glfw.init():
return -1
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 2)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 1)
window = glfw.create_window(800, 600, "Oculus Test", None, None)
if not window:
glfw.terminate()
glfw.make_context_current(window)
glfw.swap_interval(0)
if failure(initialize()):
return -1
if failure(create()):
shutdown()
return -1
hmdInfo = getHmdInfo()
for eye, fov in enumerate(hmdInfo.defaultEyeFov):
setEyeRenderFov(eye, fov)
texSizeLeft = calcEyeBufferSize(EYE_LEFT)
def start_slicing_stl(stl_filename, layer_thickness, slice_save_path):
glfw.init()
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if platform.system() == 'Darwin': # for Mac OS
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
window = glfw.create_window(SCR_WIDTH, SCR_HEIGHT, 'STL Slicer', None, None)
glfw.make_context_current(window)
glfw.set_framebuffer_size_callback(window, framebuffer_size_callback)
glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_NORMAL)
loadMesh(stl_filename)
glBindVertexArray(params.maskVAO)
slicer_folder = os.path.dirname(os.path.abspath(__file__))
sliceShader = OurShaderProgram(os.path.join(slicer_folder, 'shaders', 'slice.vert'),
os.path.join(slicer_folder, 'shaders', 'slice.frag'))
prepareSlice()
i, height = 0, 0.
while not glfw.window_should_close(window):
processInput(window)
if height >= params.total_thickness - EPSILON:
break
def main():
# initialize glfw
if not glfw.init():
return
window = glfw.create_window(800, 600, "My OpenGL window", None, None)
if not window:
glfw.terminate()
return
glfw.make_context_current(window)
# positions colors
quad = [ -0.5, -0.5, 0.0, 1.0, 0.0, 0.0,
0.5, -0.5, 0.0, 0.0, 1.0, 0.0,
0.5, 0.5, 0.0, 0.0, 0.0, 1.0,
-0.5, 0.5, 0.0, 1.0, 1.0, 1.0]
quad = numpy.array(quad, dtype = numpy.float32)
indices = [0, 1, 2,
2, 3, 0]
indices = numpy.array(indices, dtype= numpy.uint32)
vertex_shader = """
#version 330
in vec3 position;
# Open Window and create its OpenGL context
window = glfw.create_window(1024, 768, "Tutorial 07", None, None) #(in the accompanying source code this variable will be global)
glfw.window_hint(glfw.SAMPLES, 4)
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if not window:
print("Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n",file=sys.stderr)
glfw.terminate()
return False
# Initialize GLEW
glfw.make_context_current(window)
glewExperimental = True
# GLEW is a framework for testing extension availability. Please see tutorial notes for
# more information including why can remove this code.a
if glewInit() != GLEW_OK:
print("Failed to initialize GLEW\n",file=stderropen.sys)
return False
return True
def main():
# initialize glfw
if not glfw.init():
return
#creating the window
window = glfw.create_window(800, 600, "My OpenGL window", None, None)
if not window:
glfw.terminate()
return
glfw.make_context_current(window)
# positions colors texture coords
quad = [ -0.5, -0.5, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
0.5, -0.5, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0,
0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0,
-0.5, 0.5, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0]
quad = numpy.array(quad, dtype = numpy.float32)
indices = [0, 1, 2,
2, 3, 0]
indices = numpy.array(indices, dtype= numpy.uint32)
vertex_shader = """
#version 330
in layout(location = 0) vec3 position;
# Open Window and create its OpenGL context
window = glfw.create_window(1024, 768, "Tutorial 08", None, None) #(in the accompanying source code this variable will be global)
glfw.window_hint(glfw.SAMPLES, 4)
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
if not window:
print("Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n",file=sys.stderr)
glfw.terminate()
return False
# Initialize GLEW
glfw.make_context_current(window)
glewExperimental = True
# GLEW is a framework for testing extension availability. Please see tutorial notes for
# more information including why can remove this code.a
if glewInit() != GLEW_OK:
print("Failed to initialize GLEW\n",file=stderropen.sys);
return False
return True
def __init__(self, instance):
self.m = instance
self.width = 800
self.height = 600
glfw.window_hint(glfw.SAMPLES, 4)
self.window = glfw.create_window(self.width, self.height, "Tangram", None, None)
if not self.window:
glfw.terminate()
exit
glfw.make_context_current(self.window)
self.panning = False
self.last_x_down = 0
self.last_y_down = 0
self.last_time_moved = 0
self.last_x_velocity = 0
self.last_y_velocity = 0
glfw.set_mouse_button_callback(self.window, self.mouse_button_callback)
glfw.set_cursor_pos_callback(self.window, self.cursor_pos_callback)
glfw.set_key_callback(self.window, self.key_callback)
glfw.set_scroll_callback(self.window, self.scroll_callback)
glfw.set_window_size_callback(self.window,
lambda win, w, h: self.m.resize(w, h))
self.m.resize(self.width, self.height)