def main(): global window initLogger() Utils.init() # Create a windowed mode window and its OpenGL context window = glfw.create_window(640, 480, "Hello World", None, None) if not window: glfw.terminate() print("fail Window") return # Make the window's context current glfw.make_context_current(window) vertexPos, vertexColor, triangle = tmf.load("testData.tmf") #define input inputHandler.addEvent(KillProgram, "Esc") inputHandler.addEvent(Culling, "c") print vertexPos VAO, VertexSize, indexs = Utils.createVAO(vertexPos, vertexColor, triangle, 4) shaderProgram = ShaderM.compileShaderFromFile("shaders/basic.vert", "shaders/basic.frag") objectToRender = { "Indexs" : indexs, "VAO" : VAO, "VertexCount" : VertexSize, "ShaderProgram" : shaderProgram} mainLoop(objectToRender,window) glfw.terminate()
def main(): global window initLogger() Utils.init() window = Utils.createWindow(inputHandler.keyboardListner) # triangle position and color Utils.ToggleCulling(True) vertexPos, vertexColor, triangle = tmf.load("testData.tmf") glEnable(GL_DEPTH_TEST) #define input inputHandler.addEvent(KillProgram, "Esc") inputHandler.addEvent(Utils.ToggleCulling, "c") print vertexPos VAO,pos, VertexSize, indexs = Utils.createVAO(vertexPos, vertexColor, triangle, 4) shaderProgram = ShaderM.compileShaderFromFile("shaders/basic.vert", "shaders/basic.frag") objectToRender = { "Indexs" : indexs,"VertexBuffer" : pos, "VAO" : VAO, "VertexCount" : VertexSize, "ShaderProgram" : shaderProgram} mainLoop(objectToRender,window) glfw.terminate()
def __init__(self): ShowBase.__init__(self) self.base = ShowBase base.setBackgroundColor(0, 0, 0) self.model = None self.sm = ShaderManager.ShaderManager() self.shader = None self.quad = None self.quad2D = None self.accept('o', base.oobe) self.accept('1', self.hideQuad2D) self.accept('2', self.showQuad2D) self.accept('3', base.render2d.hide) self.accept('4', base.render2d.show) self.accept('5', base.render.hide) self.accept('6', base.render.show) self.accept('7', self.snapshot3D) self.accept('8', self.snapshot2D) self.accept('a', base.bufferViewer.toggleEnable) self.accept('0', self.loadShader) self.loadDemoModel() self.loadDemoGUI()
def __init__(self): self.display = DisplayOptions() OTPBase.OTPBase.__init__(self) base.enableMusic(self.display.settings.getBool('game', 'music', True)) base.enableSoundEffects( self.display.settings.getBool('game', 'sfx', True)) self.disableShowbaseMouse() self.addCullBins() base.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor self.toonChatSounds = self.config.GetBool('toon-chat-sounds', 1) self.textToSpeech = self.display.settings.getBool( 'game', 'textToSpeech', False) self.placeBeforeObjects = config.GetBool('place-before-objects', 1) self.endlessQuietZone = False self.wantDynamicShadows = 0 self.exitErrorCode = 0 camera.setPosHpr(0, 0, 0, 0, 0, 0) self.camLens.setMinFov(ToontownGlobals.DefaultCameraFov / (4.0 / 3.0)) self.camLens.setNearFar(ToontownGlobals.DefaultCameraNear, ToontownGlobals.DefaultCameraFar) self.cam2d.node().setCameraMask(BitMask32.bit(1)) self.musicManager.setVolume(0.65) self.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor) tpm = TextPropertiesManager.getGlobalPtr() candidateActive = TextProperties() candidateActive.setTextColor(0, 0, 1, 1) tpm.setProperties('candidate_active', candidateActive) candidateInactive = TextProperties() candidateInactive.setTextColor(0.3, 0.3, 0.7, 1) tpm.setProperties('candidate_inactive', candidateInactive) self.transitions.IrisModelName = 'phase_3/models/misc/iris' self.transitions.FadeModelName = 'phase_3/models/misc/fade' self.snapshotSfx = base.loader.loadSfx( 'phase_4/audio/sfx/Photo_shutter.ogg') self.flashTrack = None self.exitFunc = self.userExit if __builtins__.has_key('launcher') and launcher: launcher.setPandaErrorCode(11) globalClock.setMaxDt(0.2) if self.config.GetBool('want-particles', 1) == 1: self.notify.debug('Enabling particles') self.enableParticles() self.accept(ToontownGlobals.ScreenshotHotkey, self.takeScreenShot) if platform == 'darwin': self.acceptOnce(ToontownGlobals.QuitGameHotKeyOSX, self.exitOSX) self.accept(ToontownGlobals.QuitGameHotKeyRepeatOSX, self.exitOSX) self.acceptOnce(ToontownGlobals.HideGameHotKeyOSX, self.hideGame) self.accept(ToontownGlobals.HideGameHotKeyRepeatOSX, self.hideGame) self.acceptOnce(ToontownGlobals.MinimizeGameHotKeyOSX, self.minimizeGame) self.accept(ToontownGlobals.MinimizeGameHotKeyRepeatOSX, self.minimizeGame) self.accept('f3', self.toggleGui) self.accept('panda3d-render-error', self.panda3dRenderError) oldLoader = self.loader self.loader = ToontownLoader.ToontownLoader(self) __builtins__['loader'] = self.loader oldLoader.destroy() self.accept('PandaPaused', self.disableAllAudio) self.accept('PandaRestarted', self.enableAllAudio) self.friendMode = self.config.GetBool('switchboard-friends', 0) self.wantPets = self.config.GetBool('want-pets', 1) self.wantBingo = self.config.GetBool('want-fish-bingo', 1) self.wantKarts = self.config.GetBool('want-karts', 1) self.wantNewSpecies = self.config.GetBool('want-new-species', 0) self.inactivityTimeout = self.config.GetFloat( 'inactivity-timeout', ToontownGlobals.KeyboardTimeout) if self.inactivityTimeout: self.notify.debug('Enabling Panda timeout: %s' % self.inactivityTimeout) self.mouseWatcherNode.setInactivityTimeout(self.inactivityTimeout) self.mouseWatcherNode.setEnterPattern('mouse-enter-%r') self.mouseWatcherNode.setLeavePattern('mouse-leave-%r') self.mouseWatcherNode.setButtonDownPattern('button-down-%r') self.mouseWatcherNode.setButtonUpPattern('button-up-%r') self.randomMinigameAbort = self.config.GetBool('random-minigame-abort', 0) self.randomMinigameDisconnect = self.config.GetBool( 'random-minigame-disconnect', 0) self.randomMinigameNetworkPlugPull = self.config.GetBool( 'random-minigame-netplugpull', 0) self.autoPlayAgain = self.config.GetBool('auto-play-again', 0) self.skipMinigameReward = self.config.GetBool('skip-minigame-reward', 0) self.wantMinigameDifficulty = self.config.GetBool( 'want-minigame-difficulty', 0) self.minigameDifficulty = self.config.GetFloat('minigame-difficulty', -1.0) if self.minigameDifficulty == -1.0: del self.minigameDifficulty self.minigameSafezoneId = self.config.GetInt('minigame-safezone-id', -1) if self.minigameSafezoneId == -1: del self.minigameSafezoneId cogdoGameSafezoneId = self.config.GetInt('cogdo-game-safezone-id', -1) cogdoGameDifficulty = self.config.GetFloat('cogdo-game-difficulty', -1) if cogdoGameDifficulty != -1: self.cogdoGameDifficulty = cogdoGameDifficulty if cogdoGameSafezoneId != -1: self.cogdoGameSafezoneId = cogdoGameSafezoneId ToontownBattleGlobals.SkipMovie = self.config.GetBool( 'skip-battle-movies', 0) self.creditCardUpFront = self.config.GetInt('credit-card-up-front', -1) if self.creditCardUpFront == -1: del self.creditCardUpFront else: self.creditCardUpFront = self.creditCardUpFront != 0 self.housingEnabled = self.config.GetBool('want-housing', 1) self.cannonsEnabled = self.config.GetBool('estate-cannons', 0) self.fireworksEnabled = self.config.GetBool('estate-fireworks', 0) self.dayNightEnabled = self.config.GetBool('estate-day-night', 0) self.cloudPlatformsEnabled = self.config.GetBool('estate-clouds', 0) self.greySpacing = self.config.GetBool('allow-greyspacing', 0) self.goonsEnabled = self.config.GetBool('estate-goon', 0) self.restrictTrialers = self.config.GetBool('restrict-trialers', 1) self.roamingTrialers = self.config.GetBool('roaming-trialers', 1) self.slowQuietZone = self.config.GetBool('slow-quiet-zone', 0) self.slowQuietZoneDelay = self.config.GetFloat('slow-quiet-zone-delay', 5) self.killInterestResponse = self.config.GetBool( 'kill-interest-response', 0) tpMgr = TextPropertiesManager.getGlobalPtr() WLDisplay = TextProperties() WLDisplay.setSlant(0.3) WLEnter = TextProperties() WLEnter.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLDisplay', WLDisplay) tpMgr.setProperties('WLEnter', WLEnter) del tpMgr self.lastScreenShotTime = globalClock.getRealTime() self.accept('InputState-forward', self.__walking) self.canScreenShot = 1 self.glitchCount = 0 self.walking = 0 self.oldX = max(1, base.win.getXSize()) self.oldY = max(1, base.win.getYSize()) self.aspectRatio = float(self.oldX) / self.oldY self.localAvatarStyle = None self.shaderMgr = ShaderManager.ShaderManager() self.sosCheck = False return