def initializeGL(self): ''' Initialize GL ''' global mod if not hasGLExtension("GL_ARB_framebuffer_object"): print "GL_ARB_framebuffer_object not supported, switching to GL_GENERATE_MIPMAP" self.npot = 2 version = glGetString(GL_VERSION) if int(version[0]) == 1 and int(version[2]) < 4: #no opengl 1.4 support print "GL_GENERATE_MIPMAP not supported, not using mipmapping" self.npot = 1 if not hasGLExtension("GL_ARB_texture_non_power_of_two"): print "GL_ARB_texture_non_power_of_two not supported, switching to GL_ARB_texture_rectangle" self.texext = GL_TEXTURE_RECTANGLE_ARB self.npot = 1 if not hasGLExtension("GL_ARB_texture_rectangle"): print "GL_TEXTURE_RECTANGLE_ARB not supported, switching to GL_TEXTURE_2D" self.texext = GL_TEXTURE_2D self.npot = 0 glEnable(self.texext) glEnable(GL_BLEND) glDisable(GL_DEPTH_TEST) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glViewport(0, 0, self.width(), self.height()) glClearColor(0.0, 0.0, 0.0, 0.0) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST) initok = False if mod: ret = glmod.init(self.texext) if ret == -1: print "Something terrible went wrong in initializing glmod" mod = False elif ret == -2: print "using gl module without VBO support" else: initok = True print "using gl module with VBO support" if mod and initok: if glInitVertexBufferObjectARB() and bool(glBindBufferARB): self.vbos = True print "VBO support initialised succesfully" self.VBO = int(glGenBuffersARB(1)) glmod.initVBO(self.VBO, ADT.arrayByteCount(numpy.zeros((2, 2), 'f'))) else: print "VBO support initialisation failed, continuing without"
def initializeGL(self): ''' Initialize GL ''' global mod #stuff used as defaults for storing user settings. #Removed that feature since I'm lazy and didn't want to import too much from my other projects. self.fieldtemp = ["GL_COMPRESSED_RG_RGTC2", 4.0, "GL_LINEAR", "GL_LINEAR", "GL_LINEAR_MIPMAP_LINEAR", "On", "On", "Magic"] #mipmap support and NPOT texture support block if not hasGLExtension("GL_ARB_framebuffer_object"): print "GL_ARB_framebuffer_object not supported, switching to GL_GENERATE_MIPMAP" self.npot = 2 version = glGetString(GL_VERSION) if int(version[0]) == 1 and int(version[2]) < 4: #no opengl 1.4 support print "GL_GENERATE_MIPMAP not supported, not using mipmapping" self.npot = 1 if not hasGLExtension("GL_ARB_texture_non_power_of_two"): print "GL_ARB_texture_non_power_of_two not supported, switching to GL_ARB_texture_rectangle" self.texext = GL_TEXTURE_RECTANGLE_ARB self.npot = 1 if not hasGLExtension("GL_ARB_texture_rectangle"): print "GL_TEXTURE_RECTANGLE_ARB not supported, switching to GL_TEXTURE_2D" self.texext = GL_TEXTURE_2D self.npot = 0 #assorted settings block if hasGLExtension("GL_EXT_texture_compression_rgtc") and self.fieldtemp[0] != "None": self.compress = self.interpretString(self.fieldtemp[0]) # print "using " + self.fieldtemp[0] + " texture compression" if hasGLExtension("GL_EXT_texture_filter_anisotropic") and self.fieldtemp[1] > 1.0: self.anifilt = self.fieldtemp[1] print "using " + str(self.fieldtemp[1]) + "x anisotropic texture filtering. max: " + str(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)) self.minfilter = self.interpretString(self.fieldtemp[2]) self.magfilter = self.interpretString(self.fieldtemp[3]) self.mipminfilter = self.interpretString(self.fieldtemp[4]) if self.mipminfilter == "Off": self.mipminfilter = -1 if self.format().sampleBuffers() and self.fieldtemp[5] == "On": print "enabling " + str(self.format().samples()) + "x FSAA" glEnable(GL_MULTISAMPLE) else: print "FSAA not supported and/or disabled" glEnable(self.texext) glEnable(GL_BLEND) glDisable(GL_DEPTH_TEST) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glViewport(0, 0, self.width(), self.height()) glClearColor(0.0, 0.0, 0.0, 0.0) initok = False if mod: ret = glmod.init(self.texext) if ret == -1: print "Something terrible went wrong in initializing glmod" mod = False elif ret == -2: if self.fieldtemp[6] == "On": print "using gl module, VBO support requested but not available" else: print "using gl module, VBO support not requested" else: initok = True if self.fieldtemp[6] == "On": print "using gl module, VBO support requested and available" else: print "using gl module, VBO support not requested" if mod and initok and self.fieldtemp[6] == "On": if glInitVertexBufferObjectARB() and bool(glBindBufferARB): self.vbos = True print "VBO support initialised succesfully" self.VBO = int(glGenBuffersARB(1)) glmod.initVBO(self.VBO, ADT.arrayByteCount(numpy.zeros((2, 2), 'f'))) else: print "VBO support initialisation failed, continuing without"
def initializeGL(self): ''' Initialize GL ''' global mod #stuff used as defaults for storing user settings. #Removed that feature since I'm lazy and didn't want to import too much from my other projects. self.fieldtemp = [ "GL_COMPRESSED_RG_RGTC2", 4.0, "GL_LINEAR", "GL_LINEAR", "GL_LINEAR_MIPMAP_LINEAR", "On", "On", "Magic" ] #mipmap support and NPOT texture support block if not hasGLExtension("GL_ARB_framebuffer_object"): print "GL_ARB_framebuffer_object not supported, switching to GL_GENERATE_MIPMAP" self.npot = 2 version = glGetString(GL_VERSION) if int(version[0]) == 1 and int( version[2]) < 4: #no opengl 1.4 support print "GL_GENERATE_MIPMAP not supported, not using mipmapping" self.npot = 1 if not hasGLExtension("GL_ARB_texture_non_power_of_two"): print "GL_ARB_texture_non_power_of_two not supported, switching to GL_ARB_texture_rectangle" self.texext = GL_TEXTURE_RECTANGLE_ARB self.npot = 1 if not hasGLExtension("GL_ARB_texture_rectangle"): print "GL_TEXTURE_RECTANGLE_ARB not supported, switching to GL_TEXTURE_2D" self.texext = GL_TEXTURE_2D self.npot = 0 #assorted settings block if hasGLExtension("GL_EXT_texture_compression_rgtc" ) and self.fieldtemp[0] != "None": self.compress = self.interpretString(self.fieldtemp[0]) # print "using " + self.fieldtemp[0] + " texture compression" if hasGLExtension("GL_EXT_texture_filter_anisotropic" ) and self.fieldtemp[1] > 1.0: self.anifilt = self.fieldtemp[1] print "using " + str( self.fieldtemp[1] ) + "x anisotropic texture filtering. max: " + str( glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)) self.minfilter = self.interpretString(self.fieldtemp[2]) self.magfilter = self.interpretString(self.fieldtemp[3]) self.mipminfilter = self.interpretString(self.fieldtemp[4]) if self.mipminfilter == "Off": self.mipminfilter = -1 if self.format().sampleBuffers() and self.fieldtemp[5] == "On": print "enabling " + str(self.format().samples()) + "x FSAA" glEnable(GL_MULTISAMPLE) else: print "FSAA not supported and/or disabled" glEnable(self.texext) glEnable(GL_BLEND) glDisable(GL_DEPTH_TEST) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glViewport(0, 0, self.width(), self.height()) glClearColor(0.0, 0.0, 0.0, 0.0) initok = False if mod: ret = glmod.init(self.texext) if ret == -1: print "Something terrible went wrong in initializing glmod" mod = False elif ret == -2: if self.fieldtemp[6] == "On": print "using gl module, VBO support requested but not available" else: print "using gl module, VBO support not requested" else: initok = True if self.fieldtemp[6] == "On": print "using gl module, VBO support requested and available" else: print "using gl module, VBO support not requested" if mod and initok and self.fieldtemp[6] == "On": if glInitVertexBufferObjectARB() and bool(glBindBufferARB): self.vbos = True print "VBO support initialised succesfully" self.VBO = int(glGenBuffersARB(1)) glmod.initVBO(self.VBO, ADT.arrayByteCount(numpy.zeros((2, 2), 'f'))) else: print "VBO support initialisation failed, continuing without"