diff --git a/README.md b/README.md
index 061497dd6d..ceb23f7793 100644
--- a/README.md
+++ b/README.md
@@ -31,8 +31,8 @@ are included as part of the Windows 7.1 SDK.
You will also need to have the third-party dependency libraries available for
the build scripts to use. These are available from one of these two URLs,
depending on whether you are on a 32-bit or 64-bit system:
-https://www.panda3d.org/download/panda3d-1.9.1/panda3d-1.9.1-tools-win32.zip
-https://www.panda3d.org/download/panda3d-1.9.1/panda3d-1.9.1-tools-win64.zip
+https://www.panda3d.org/download/panda3d-1.9.2/panda3d-1.9.2-tools-win32.zip
+https://www.panda3d.org/download/panda3d-1.9.2/panda3d-1.9.2-tools-win64.zip
After acquiring these dependencies, you may simply build Panda3D from the
command prompt using the following command:
@@ -97,7 +97,7 @@ Mac OS X
--------
On Mac OS X, you will need to download a set of precompiled thirdparty packages in order to
-compile Panda3D, which can be acquired from [here](https://www.panda3d.org/download/panda3d-1.9.1/panda3d-1.9.1-tools-mac.tar.gz).
+compile Panda3D, which can be acquired from [here](https://www.panda3d.org/download/panda3d-1.9.2/panda3d-1.9.2-tools-mac.tar.gz).
After placing the thirdparty directory inside the panda3d source directory,
you may build Panda3D using a command like the following:
diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py
index cfff9860d7..29db4290bd 100644
--- a/direct/src/actor/Actor.py
+++ b/direct/src/actor/Actor.py
@@ -6,7 +6,7 @@ from panda3d.core import *
from panda3d.core import Loader as PandaLoader
from direct.showbase.DirectObject import DirectObject
from direct.directnotify import DirectNotifyGlobal
-import types
+
class Actor(DirectObject, NodePath):
"""
@@ -239,30 +239,30 @@ class Actor(DirectObject, NodePath):
# models{}{}, anims{}{} = multi-part actor w/ LOD
#
# make sure we have models
- if (models):
+ if models:
# do we have a dictionary of models?
- if (type(models)==type({})):
+ if type(models) == dict:
# if this is a dictionary of dictionaries
- if (type(models[models.keys()[0]]) == type({})):
+ if type(models[next(iter(models))]) == dict:
# then it must be a multipart actor w/LOD
self.setLODNode(node = lodNode)
# preserve numerical order for lod's
# this will make it easier to set ranges
- sortedKeys = models.keys()
+ sortedKeys = list(models.keys())
sortedKeys.sort()
for lodName in sortedKeys:
# make a node under the LOD switch
# for each lod (just because!)
self.addLOD(str(lodName))
# iterate over both dicts
- for modelName in models[lodName].keys():
+ for modelName in models[lodName]:
self.loadModel(models[lodName][modelName],
modelName, lodName, copy = copy,
okMissing = okMissing)
# then if there is a dictionary of dictionaries of anims
- elif (type(anims[anims.keys()[0]])==type({})):
+ elif type(anims[next(iter(anims))]) == dict:
# then this is a multipart actor w/o LOD
- for partName in models.keys():
+ for partName in models:
# pass in each part
self.loadModel(models[partName], partName,
copy = copy, okMissing = okMissing)
@@ -270,7 +270,7 @@ class Actor(DirectObject, NodePath):
# it is a single part actor w/LOD
self.setLODNode(node = lodNode)
# preserve order of LOD's
- sortedKeys = models.keys()
+ sortedKeys = list(models.keys())
sortedKeys.sort()
for lodName in sortedKeys:
self.addLOD(str(lodName))
@@ -283,28 +283,28 @@ class Actor(DirectObject, NodePath):
# load anims
# make sure the actor has animations
- if (anims):
- if (len(anims) >= 1):
+ if anims:
+ if len(anims) >= 1:
# if so, does it have a dictionary of dictionaries?
- if (type(anims[anims.keys()[0]])==type({})):
+ if type(anims[next(iter(anims))]) == dict:
# are the models a dict of dicts too?
- if (type(models)==type({})):
- if (type(models[models.keys()[0]]) == type({})):
+ if type(models) == dict:
+ if type(models[next(iter(models))]) == dict:
# then we have a multi-part w/ LOD
- sortedKeys = models.keys()
+ sortedKeys = list(models.keys())
sortedKeys.sort()
for lodName in sortedKeys:
# iterate over both dicts
- for partName in anims.keys():
+ for partName in anims:
self.loadAnims(
anims[partName], partName, lodName)
else:
# then it must be multi-part w/o LOD
- for partName in anims.keys():
+ for partName in anims:
self.loadAnims(anims[partName], partName)
- elif (type(models)==type({})):
+ elif type(models) == dict:
# then we have single-part w/ LOD
- sortedKeys = models.keys()
+ sortedKeys = list(models.keys())
sortedKeys.sort()
for lodName in sortedKeys:
self.loadAnims(anims, lodName=lodName)
@@ -431,11 +431,10 @@ class Actor(DirectObject, NodePath):
part.outputValue(lineStream)
value = lineStream.getLine()
- print ' ' * indentLevel, part.getName(), value
+ print(' '.join((' ' * indentLevel, part.getName(), value)))
- for i in range(part.getNumChildren()):
- self.__doListJoints(indentLevel + 2, part.getChild(i),
- isIncluded, subset)
+ for child in part.getChildren():
+ self.__doListJoints(indentLevel + 2, child, isIncluded, subset)
def getActorInfo(self):
@@ -449,14 +448,14 @@ class Actor(DirectObject, NodePath):
lodName = self.__sortedLODNames[0]
partInfo = []
- for partName in partDict.keys():
+ for partName in partDict:
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
partBundleDict = self.__partBundleDict.get(lodName)
partDef = partBundleDict.get(subpartDef.truePartName)
partBundle = partDef.getBundle()
animDict = partDict[partName]
animInfo = []
- for animName in animDict.keys():
+ for animName in animDict:
file = animDict[animName].filename
animControl = animDict[animName].animControl
animInfo.append([animName, file, animControl])
@@ -478,17 +477,17 @@ class Actor(DirectObject, NodePath):
Pretty print actor's details
"""
for lodName, lodInfo in self.getActorInfo():
- print 'LOD:', lodName
+ print('LOD: %s' % lodName)
for partName, bundle, animInfo in lodInfo:
- print ' Part:', partName
- print ' Bundle:', repr(bundle)
+ print(' Part: %s' % partName)
+ print(' Bundle: %r' % bundle)
for animName, file, animControl in animInfo:
- print ' Anim:', animName
- print ' File:', file
+ print(' Anim: %s' % animName)
+ print(' File: %s' % file)
if animControl == None:
- print ' (not loaded)'
+ print(' (not loaded)')
else:
- print (' NumFrames: %d PlayRate: %0.2f' %
+ print(' NumFrames: %d PlayRate: %0.2f' %
(animControl.getNumFrames(),
animControl.getPlayRate()))
@@ -568,7 +567,7 @@ class Actor(DirectObject, NodePath):
def __updateSortedLODNames(self):
# Cache the sorted LOD names so we don't have to grab them
# and sort them every time somebody asks for the list
- self.__sortedLODNames = self.__partBundleDict.keys()
+ self.__sortedLODNames = list(self.__partBundleDict.keys())
# Reverse sort the doing a string->int
def sortKey(x):
if not str(x).isdigit():
@@ -604,8 +603,8 @@ class Actor(DirectObject, NodePath):
"""
partNames = []
if self.__partBundleDict:
- partNames = self.__partBundleDict.values()[0].keys()
- return partNames + self.__subpartDict.keys()
+ partNames = list(next(iter(self.__partBundleDict.values())).keys())
+ return partNames + list(self.__subpartDict.keys())
def getGeomNode(self):
"""
@@ -646,33 +645,33 @@ class Actor(DirectObject, NodePath):
"""
# make sure we don't call this twice in a row
# and pollute the the switches dictionary
-## sortedKeys = self.switches.keys()
+## sortedKeys = list(self.switches.keys())
## sortedKeys.sort()
child = self.__LODNode.find(str(lodName))
index = self.__LODNode.node().findChild(child.node())
self.__LODNode.node().forceSwitch(index)
def printLOD(self):
-## sortedKeys = self.switches.keys()
+## sortedKeys = list(self.switches.keys())
## sortedKeys.sort()
sortedKeys = self.__sortedLODNames
for eachLod in sortedKeys:
- print "python switches for %s: in: %d, out %d" % (eachLod,
+ print("python switches for %s: in: %d, out %d" % (eachLod,
self.switches[eachLod][0],
- self.switches[eachLod][1])
+ self.switches[eachLod][1]))
switchNum = self.__LODNode.node().getNumSwitches()
for eachSwitch in range(0, switchNum):
- print "c++ switches for %d: in: %d, out: %d" % (eachSwitch,
+ print("c++ switches for %d: in: %d, out: %d" % (eachSwitch,
self.__LODNode.node().getIn(eachSwitch),
- self.__LODNode.node().getOut(eachSwitch))
+ self.__LODNode.node().getOut(eachSwitch)))
def resetLOD(self):
"""
Restore all switch distance info (usually after a useLOD call)"""
self.__LODNode.node().clearForceSwitch()
-## sortedKeys = self.switches.keys()
+## sortedKeys = list(self.switches.keys())
## sortedKeys.sort()
## for eachLod in sortedKeys:
## index = sortedKeys.index(eachLod)
@@ -699,7 +698,7 @@ class Actor(DirectObject, NodePath):
# save the switch distance info
self.switches[lodName] = [inDist, outDist]
# add the switch distance info
-## sortedKeys = self.switches.keys()
+## sortedKeys = list(self.switches.keys())
## sortedKeys.sort()
self.__LODNode.node().setSwitch(self.getLODIndex(lodName), inDist, outDist)
@@ -798,7 +797,7 @@ class Actor(DirectObject, NodePath):
lodName = lodNames[lod]
if partName == None:
partBundleDict = self.__partBundleDict[lodName]
- partNames = partBundleDict.keys()
+ partNames = list(partBundleDict.keys())
else:
partNames = [partName]
@@ -822,7 +821,7 @@ class Actor(DirectObject, NodePath):
If no part specified, return anim durations of first part.
NOTE: returns info only for an arbitrary LOD
"""
- lodName = self.__animControlDict.keys()[0]
+ lodName = next(iter(self.__animControlDict))
controls = self.getAnimControls(animName, partName)
if len(controls) == 0:
return None
@@ -834,7 +833,7 @@ class Actor(DirectObject, NodePath):
Return frame rate of given anim name and given part, unmodified
by any play rate in effect.
"""
- lodName = self.__animControlDict.keys()[0]
+ lodName = next(iter(self.__animControlDict))
controls = self.getAnimControls(animName, partName)
if len(controls) == 0:
return None
@@ -850,7 +849,7 @@ class Actor(DirectObject, NodePath):
"""
if self.__animControlDict:
# use the first lod
- lodName = self.__animControlDict.keys()[0]
+ lodName = next(iter(self.__animControlDict))
controls = self.getAnimControls(animName, partName)
if controls:
return controls[0].getPlayRate()
@@ -877,7 +876,7 @@ class Actor(DirectObject, NodePath):
If no part specified, return anim duration of first part.
NOTE: returns info for arbitrary LOD
"""
- lodName = self.__animControlDict.keys()[0]
+ lodName = next(iter(self.__animControlDict))
controls = self.getAnimControls(animName, partName)
if len(controls) == 0:
return None
@@ -890,7 +889,7 @@ class Actor(DirectObject, NodePath):
return ((toFrame+1)-fromFrame) / animControl.getFrameRate()
def getNumFrames(self, animName=None, partName=None):
- lodName = self.__animControlDict.keys()[0]
+ lodName = next(iter(self.__animControlDict))
controls = self.getAnimControls(animName, partName)
if len(controls) == 0:
return None
@@ -908,12 +907,12 @@ class Actor(DirectObject, NodePath):
specified return current anim of an arbitrary part in dictionary.
NOTE: only returns info for an arbitrary LOD
"""
- if len(self.__animControlDict.items()) == 0:
+ if len(self.__animControlDict) == 0:
return
- lodName, animControlDict = self.__animControlDict.items()[0]
+ lodName, animControlDict = next(iter(self.__animControlDict.items()))
if partName == None:
- partName, animDict = animControlDict.items()[0]
+ partName, animDict = next(iter(animControlDict.items()))
else:
animDict = animControlDict.get(partName)
if animDict == None:
@@ -936,9 +935,9 @@ class Actor(DirectObject, NodePath):
actor. If part not specified return current anim of first part
in dictionary. NOTE: only returns info for an arbitrary LOD
"""
- lodName, animControlDict = self.__animControlDict.items()[0]
+ lodName, animControlDict = next(iter(self.__animControlDict.items()))
if partName == None:
- partName, animDict = animControlDict.items()[0]
+ partName, animDict = next(iter(animControlDict.items()))
else:
animDict = animControlDict.get(partName)
if animDict == None:
@@ -1420,17 +1419,15 @@ class Actor(DirectObject, NodePath):
if mode > 0:
# Use the 'fixed' bin instead of reordering the scene
# graph.
- numFrontParts = frontParts.getNumPaths()
- for partNum in range(0, numFrontParts):
- frontParts[partNum].setBin('fixed', mode)
+ for part in frontParts:
+ part.setBin('fixed', mode)
return
if mode == -2:
# Turn off depth test/write on the frontParts.
- numFrontParts = frontParts.getNumPaths()
- for partNum in range(0, numFrontParts):
- frontParts[partNum].setDepthWrite(0)
- frontParts[partNum].setDepthTest(0)
+ for part in frontParts:
+ part.setDepthWrite(0)
+ part.setDepthTest(0)
# Find the back part.
backPart = root.find("**/" + backPartName)
@@ -1457,12 +1454,8 @@ class Actor(DirectObject, NodePath):
char = partData.partBundleNP
char.node().update()
geomNodes = char.findAllMatches("**/+GeomNode")
- numGeomNodes = geomNodes.getNumPaths()
- for nodeNum in xrange(numGeomNodes):
- thisGeomNode = geomNodes.getPath(nodeNum)
- numGeoms = thisGeomNode.node().getNumGeoms()
- for geomNum in xrange(numGeoms):
- thisGeom = thisGeomNode.node().getGeom(geomNum)
+ for thisGeomNode in geomNodes:
+ for thisGeom in thisGeomNode.node().getGeoms():
thisGeom.markBoundsStale()
thisGeomNode.node().markInternalBoundsStale()
else:
@@ -1473,12 +1466,8 @@ class Actor(DirectObject, NodePath):
char = partData.partBundleNP
char.node().update()
geomNodes = char.findAllMatches("**/+GeomNode")
- numGeomNodes = geomNodes.getNumPaths()
- for nodeNum in xrange(numGeomNodes):
- thisGeomNode = geomNodes.getPath(nodeNum)
- numGeoms = thisGeomNode.node().getNumGeoms()
- for geomNum in xrange(numGeoms):
- thisGeom = thisGeomNode.node().getGeom(geomNum)
+ for thisGeomNode in geomNodes:
+ for thisGeom in thisGeomNode.node().getGeoms():
thisGeom.markBoundsStale()
thisGeomNode.node().markInternalBoundsStale()
@@ -1494,19 +1483,14 @@ class Actor(DirectObject, NodePath):
# update all characters first
charNodes = part.findAllMatches("**/+Character")
- numCharNodes = charNodes.getNumPaths()
- for charNum in range(0, numCharNodes):
- (charNodes.getPath(charNum)).node().update()
+ for charNode in charNodes:
+ charNode.node().update()
# for each geomNode, iterate through all geoms and force update
# of bounding spheres by marking current bounds as stale
geomNodes = part.findAllMatches("**/+GeomNode")
- numGeomNodes = geomNodes.getNumPaths()
- for nodeNum in range(0, numGeomNodes):
- thisGeomNode = geomNodes.getPath(nodeNum)
- numGeoms = thisGeomNode.node().getNumGeoms()
- for geomNum in range(0, numGeoms):
- thisGeom = thisGeomNode.node().getGeom(geomNum)
+ for nodeNum, thisGeomNode in enumerate(geomNodes):
+ for geomNum, thisGeom in enumerate(thisGeomNode.node().getGeoms()):
thisGeom.markBoundsStale()
assert Actor.notify.debug("fixing bounds for node %s, geom %s" % \
(nodeNum, geomNum))
@@ -1517,20 +1501,18 @@ class Actor(DirectObject, NodePath):
Show the bounds of all actor geoms
"""
geomNodes = self.__geomNode.findAllMatches("**/+GeomNode")
- numGeomNodes = geomNodes.getNumPaths()
- for nodeNum in range(0, numGeomNodes):
- geomNodes.getPath(nodeNum).showBounds()
+ for node in geomNodes:
+ node.showBounds()
def hideAllBounds(self):
"""
Hide the bounds of all actor geoms
"""
geomNodes = self.__geomNode.findAllMatches("**/+GeomNode")
- numGeomNodes = geomNodes.getNumPaths()
- for nodeNum in range(0, numGeomNodes):
- geomNodes.getPath(nodeNum).hideBounds()
+ for node in geomNodes:
+ node.hideBounds()
# actions
@@ -1698,7 +1680,7 @@ class Actor(DirectObject, NodePath):
if self.mergeLODBundles:
lodName = 'common'
elif self.switches:
- lodName = str(self.switches.keys()[0])
+ lodName = str(next(iter(self.switches)))
else:
lodName = 'lodRoot'
@@ -1723,7 +1705,7 @@ class Actor(DirectObject, NodePath):
lodName = 'common'
elif not lodName:
if self.switches:
- lodName = str(self.switches.keys()[0])
+ lodName = str(next(iter(self.switches)))
else:
lodName = 'lodRoot'
@@ -1777,7 +1759,7 @@ class Actor(DirectObject, NodePath):
# If we have the __subpartsComplete flag, and no partName
# is specified, it really means to play the animation on
# all subparts, not on the overall Actor.
- partName = self.__subpartDict.keys()
+ partName = list(self.__subpartDict.keys())
controls = []
# build list of lodNames and corresponding animControlDicts
@@ -1805,7 +1787,7 @@ class Actor(DirectObject, NodePath):
else:
# Get exactly the named part or parts.
- if isinstance(partName, types.StringTypes):
+ if isinstance(partName, str):
partNameList = [partName]
else:
partNameList = partName
@@ -1835,7 +1817,7 @@ class Actor(DirectObject, NodePath):
controls.append(anim.animControl)
else:
# get the named animation(s) only.
- if isinstance(animName, types.StringTypes):
+ if isinstance(animName, str):
# A single animName
animNameList = [animName]
else:
@@ -2058,7 +2040,7 @@ class Actor(DirectObject, NodePath):
if otherPartName != partName and otherPartDef.truePartName == parent:
joints = self.getOverlappingJoints(partName, otherPartName)
if joints:
- raise StandardError, 'Overlapping joints: %s and %s' % (partName, otherPartName)
+ raise Exception('Overlapping joints: %s and %s' % (partName, otherPartName))
def setSubpartsComplete(self, flag):
@@ -2107,7 +2089,7 @@ class Actor(DirectObject, NodePath):
if lodName:
partNames = self.__partBundleDict[lodName].keys()
else:
- partNames = self.__partBundleDict.values()[0].keys()
+ partNames = next(iter(self.__partBundleDict.values())).keys()
for partName in partNames:
subJoints = set()
@@ -2133,9 +2115,9 @@ class Actor(DirectObject, NodePath):
lodNames = ['common']
elif lodName == 'all':
reload = False
- lodNames = self.switches.keys()
+ lodNames = list(self.switches.keys())
lodNames.sort()
- for i in range(0,len(lodNames)):
+ for i in range(0, len(lodNames)):
lodNames[i] = str(lodNames[i])
else:
lodNames = [lodName]
@@ -2256,20 +2238,20 @@ class Actor(DirectObject, NodePath):
assert Actor.notify.debug("in unloadAnims: %s, part: %s, lod: %s" %
(anims, partName, lodName))
- if lodName == None or self.mergeLODBundles:
+ if lodName is None or self.mergeLODBundles:
lodNames = self.__animControlDict.keys()
else:
lodNames = [lodName]
- if (partName == None):
+ if partName is None:
if len(lodNames) > 0:
- partNames = self.__animControlDict[lodNames[0]].keys()
+ partNames = self.__animControlDict[next(iter(lodNames))].keys()
else:
partNames = []
else:
partNames = [partName]
- if (anims==None):
+ if anims is None:
for lodName in lodNames:
for partName in partNames:
for animDef in self.__animControlDict[lodName][partName].values():
@@ -2400,7 +2382,7 @@ class Actor(DirectObject, NodePath):
Copy the part bundle dictionary from another actor as this
instance's own. NOTE: this method does not actually copy geometry
"""
- for lodName in other.__partBundleDict.keys():
+ for lodName in other.__partBundleDict:
# find the lod Asad
if lodName == 'lodRoot':
partLod = self
@@ -2445,11 +2427,11 @@ class Actor(DirectObject, NodePath):
assert(other.mergeLODBundles == self.mergeLODBundles)
- for lodName in other.__animControlDict.keys():
+ for lodName in other.__animControlDict:
self.__animControlDict[lodName] = {}
- for partName in other.__animControlDict[lodName].keys():
+ for partName in other.__animControlDict[lodName]:
self.__animControlDict[lodName][partName] = {}
- for animName in other.__animControlDict[lodName][partName].keys():
+ for animName in other.__animControlDict[lodName][partName]:
anim = other.__animControlDict[lodName][partName][animName]
anim = anim.makeCopy()
self.__animControlDict[lodName][partName][animName] = anim
@@ -2512,13 +2494,13 @@ class Actor(DirectObject, NodePath):
def printAnimBlends(self, animName=None, partName=None, lodName=None):
for lodName, animList in self.getAnimBlends(animName, partName, lodName):
- print 'LOD %s:' % (lodName)
+ print('LOD %s:' % (lodName))
for animName, blendList in animList:
list = []
for partName, effect in blendList:
list.append('%s:%.3f' % (partName, effect))
- print ' %s: %s' % (animName, ', '.join(list))
+ print(' %s: %s' % (animName, ', '.join(list)))
def osdAnimBlends(self, animName=None, partName=None, lodName=None):
if not onScreenDebug.enabled:
@@ -2565,5 +2547,5 @@ class Actor(DirectObject, NodePath):
def renamePartBundles(self, partName, newBundleName):
subpartDef = self.__subpartDict.get(partName, Actor.SubpartDef(partName))
for partBundleDict in self.__partBundleDict.values():
- partDef=partBundleDict.get(subpartDef.truePartName)
+ partDef = partBundleDict.get(subpartDef.truePartName)
partDef.getBundle().setName(newBundleName)
diff --git a/direct/src/actor/DistributedActor.py b/direct/src/actor/DistributedActor.py
index 2e991d2043..c46a8863c4 100644
--- a/direct/src/actor/DistributedActor.py
+++ b/direct/src/actor/DistributedActor.py
@@ -4,7 +4,7 @@ __all__ = ['DistributedActor']
from direct.distributed import DistributedNode
-import Actor
+from . import Actor
class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
def __init__(self, cr):
diff --git a/direct/src/cluster/ClusterClient.py b/direct/src/cluster/ClusterClient.py
index f238aca91d..873b03d4ea 100644
--- a/direct/src/cluster/ClusterClient.py
+++ b/direct/src/cluster/ClusterClient.py
@@ -1,8 +1,8 @@
"""ClusterClient: Master for mutli-piping or PC clusters. """
from panda3d.core import *
-from ClusterMsgs import *
-from ClusterConfig import *
+from .ClusterMsgs import *
+from .ClusterConfig import *
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import DirectObject
from direct.task import Task
@@ -44,10 +44,10 @@ class ClusterClient(DirectObject.DirectObject):
self.daemon.tellServer(serverConfig.serverName,
serverConfig.serverDaemonPort,
serverCommand)
- print 'Begin waitForServers'
+ print('Begin waitForServers')
if not self.daemon.waitForServers(len(configList)):
- print 'Cluster Client, no response from servers'
- print 'End waitForServers'
+ print('Cluster Client, no response from servers')
+ print('End waitForServers')
self.qcm=QueuedConnectionManager()
self.serverList = []
self.serverQueues = []
@@ -262,9 +262,8 @@ class ClusterClient(DirectObject.DirectObject):
def getNodePathFindCmd(self, nodePath):
- import string
pathString = repr(nodePath)
- index = string.find(pathString, '/')
+ index = pathString.find('/')
if index != -1:
rootName = pathString[:index]
searchString = pathString[index+1:]
@@ -273,9 +272,8 @@ class ClusterClient(DirectObject.DirectObject):
return rootName
def getNodePathName(self, nodePath):
- import string
pathString = repr(nodePath)
- index = string.find(pathString, '/')
+ index = pathString.find('/')
if index != -1:
name = pathString[index+1:]
return name
@@ -409,7 +407,7 @@ class ClusterClientSync(ClusterClient):
#I probably don't need this
self.waitForSwap = 0
self.ready = 0
- print "creating synced client"
+ print("creating synced client")
self.startSwapCoordinatorTask()
def startSwapCoordinatorTask(self):
diff --git a/direct/src/cluster/ClusterConfig.py b/direct/src/cluster/ClusterConfig.py
index 6cf71dcaab..73e4ebf2b6 100644
--- a/direct/src/cluster/ClusterConfig.py
+++ b/direct/src/cluster/ClusterConfig.py
@@ -1,5 +1,5 @@
-from ClusterClient import *
+from .ClusterClient import *
# A dictionary of information for various cluster configurations.
# Dictionary is keyed on cluster-config string
diff --git a/direct/src/cluster/ClusterServer.py b/direct/src/cluster/ClusterServer.py
index 4ec78b0841..511dc84cef 100644
--- a/direct/src/cluster/ClusterServer.py
+++ b/direct/src/cluster/ClusterServer.py
@@ -1,5 +1,5 @@
from panda3d.core import *
-from ClusterMsgs import *
+from .ClusterMsgs import *
from direct.distributed.MsgTypes import *
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import DirectObject
@@ -246,7 +246,7 @@ class ClusterServer(DirectObject.DirectObject):
if (type == CLUSTER_NONE):
pass
elif (type == CLUSTER_EXIT):
- print 'GOT EXIT'
+ print('GOT EXIT')
import sys
sys.exit()
elif (type == CLUSTER_CAM_OFFSET):
diff --git a/direct/src/controls/BattleWalker.py b/direct/src/controls/BattleWalker.py
index 8b6e634e25..a26beb4103 100755
--- a/direct/src/controls/BattleWalker.py
+++ b/direct/src/controls/BattleWalker.py
@@ -2,7 +2,7 @@
from direct.showbase.InputStateGlobal import inputState
from direct.task.Task import Task
from pandac.PandaModules import *
-import GravityWalker
+from . import GravityWalker
BattleStrafe = 0
@@ -166,7 +166,7 @@ class BattleWalker(GravityWalker.GravityWalker):
# Should fSlide be renamed slideButton?
self.slideSpeed=.15*(turnLeft and -self.avatarControlForwardSpeed or
turnRight and self.avatarControlForwardSpeed)
- print 'slideSpeed: ', self.slideSpeed
+ print('slideSpeed: %s' % self.slideSpeed)
self.rotationSpeed=0
self.speed=0
@@ -233,7 +233,7 @@ class BattleWalker(GravityWalker.GravityWalker):
if self.moving:
distance = dt * self.speed
slideDistance = dt * self.slideSpeed
- print 'slideDistance: ', slideDistance
+ print('slideDistance: %s' % slideDistance)
rotation = dt * self.rotationSpeed
# Take a step in the direction of our previous heading.
diff --git a/direct/src/controls/GhostWalker.py b/direct/src/controls/GhostWalker.py
index 8dd36f2450..4badbf7258 100755
--- a/direct/src/controls/GhostWalker.py
+++ b/direct/src/controls/GhostWalker.py
@@ -15,7 +15,7 @@ animations based on walker events.
"""
from direct.directnotify import DirectNotifyGlobal
-import NonPhysicsWalker
+from . import NonPhysicsWalker
class GhostWalker(NonPhysicsWalker.NonPhysicsWalker):
diff --git a/direct/src/controls/ObserverWalker.py b/direct/src/controls/ObserverWalker.py
index efc9c4b0f9..f93e0e3325 100755
--- a/direct/src/controls/ObserverWalker.py
+++ b/direct/src/controls/ObserverWalker.py
@@ -16,7 +16,7 @@ animations based on walker events.
from panda3d.core import *
from direct.directnotify import DirectNotifyGlobal
-import NonPhysicsWalker
+from . import NonPhysicsWalker
class ObserverWalker(NonPhysicsWalker.NonPhysicsWalker):
notify = DirectNotifyGlobal.directNotify.newCategory("ObserverWalker")
diff --git a/direct/src/controls/PhysicsWalker.py b/direct/src/controls/PhysicsWalker.py
index b0a0cdfcb8..fc6fe1ca70 100755
--- a/direct/src/controls/PhysicsWalker.py
+++ b/direct/src/controls/PhysicsWalker.py
@@ -324,7 +324,7 @@ class PhysicsWalker(DirectObject.DirectObject):
indicator.instanceTo(contactIndicatorNode)
self.physContactIndicator=contactIndicatorNode
else:
- print "failed load of physics indicator"
+ print("failed load of physics indicator")
def avatarPhysicsIndicator(self, task):
#assert self.debugPrint("avatarPhysicsIndicator()")
@@ -710,7 +710,7 @@ class PhysicsWalker(DirectObject.DirectObject):
def setPriorParentVector(self):
assert self.debugPrint("doDeltaPos()")
- print "self.__oldDt", self.__oldDt, "self.__oldPosDelta", self.__oldPosDelta
+ print("self.__oldDt %s self.__oldPosDelta %s" % (self.__oldDt, self.__oldPosDelta))
if __debug__:
onScreenDebug.add("__oldDt", "% 10.4f"%self.__oldDt)
onScreenDebug.add("self.__oldPosDelta",
diff --git a/direct/src/controls/TwoDWalker.py b/direct/src/controls/TwoDWalker.py
index d80f90bf4d..b99f6db11b 100644
--- a/direct/src/controls/TwoDWalker.py
+++ b/direct/src/controls/TwoDWalker.py
@@ -2,7 +2,7 @@
TwoDWalker.py is for controling the avatars in a 2D Scroller game environment.
"""
-from GravityWalker import *
+from .GravityWalker import *
from panda3d.core import ConfigVariableBool
diff --git a/direct/src/directbase/DirectStart.py b/direct/src/directbase/DirectStart.py
index 6264b09486..031dc85323 100644
--- a/direct/src/directbase/DirectStart.py
+++ b/direct/src/directbase/DirectStart.py
@@ -1,7 +1,9 @@
""" This is a deprecated module that creates a global instance of ShowBase. """
__all__ = []
-print('Using deprecated DirectStart interface.')
+
+if __debug__:
+ print('Using deprecated DirectStart interface.')
from direct.showbase import ShowBase
base = ShowBase.ShowBase()
diff --git a/direct/src/directbase/ThreeUpStart.py b/direct/src/directbase/ThreeUpStart.py
index 3d1784408f..b0a78fcef9 100644
--- a/direct/src/directbase/ThreeUpStart.py
+++ b/direct/src/directbase/ThreeUpStart.py
@@ -1,5 +1,5 @@
-print 'ThreeUpStart: Starting up environment.'
+print('ThreeUpStart: Starting up environment.')
from pandac.PandaModules import *
diff --git a/direct/src/directdevices/DirectFastrak.py b/direct/src/directdevices/DirectFastrak.py
index 4f046329a0..c6e30bd8fc 100644
--- a/direct/src/directdevices/DirectFastrak.py
+++ b/direct/src/directdevices/DirectFastrak.py
@@ -1,7 +1,7 @@
""" Class used to create and control radamec device """
from math import *
from direct.showbase.DirectObject import DirectObject
-from DirectDeviceManager import *
+from .DirectDeviceManager import *
from direct.directnotify import DirectNotifyGlobal
diff --git a/direct/src/directdevices/DirectJoybox.py b/direct/src/directdevices/DirectJoybox.py
index 7376154947..60c4c4211b 100644
--- a/direct/src/directdevices/DirectJoybox.py
+++ b/direct/src/directdevices/DirectJoybox.py
@@ -1,6 +1,6 @@
""" Class used to create and control joybox device """
from direct.showbase.DirectObject import DirectObject
-from DirectDeviceManager import *
+from .DirectDeviceManager import *
from direct.directtools.DirectUtil import *
from direct.gui import OnscreenText
from direct.task import Task
diff --git a/direct/src/directdevices/DirectRadamec.py b/direct/src/directdevices/DirectRadamec.py
index 65880be00f..2aa7b1933c 100644
--- a/direct/src/directdevices/DirectRadamec.py
+++ b/direct/src/directdevices/DirectRadamec.py
@@ -1,7 +1,7 @@
""" Class used to create and control radamec device """
from math import *
from direct.showbase.DirectObject import DirectObject
-from DirectDeviceManager import *
+from .DirectDeviceManager import *
from direct.directnotify import DirectNotifyGlobal
@@ -77,7 +77,7 @@ class DirectRadamec(DirectObject):
maxRange = self.maxRange[chan]
minRange = self.minRange[chan]
except IndexError:
- raise RuntimeError, "can't normalize this channel (chanel %d)" % chan
+ raise RuntimeError("can't normalize this channel (channel %d)" % chan)
range = maxRange - minRange
clampedVal = CLAMP(self.aList[chan], minRange, maxRange)
return ((maxVal - minVal) * (clampedVal - minRange) / range) + minVal
diff --git a/direct/src/directnotify/DirectNotify.py b/direct/src/directnotify/DirectNotify.py
index 96f79f57a3..14a712bd40 100644
--- a/direct/src/directnotify/DirectNotify.py
+++ b/direct/src/directnotify/DirectNotify.py
@@ -2,8 +2,8 @@
DirectNotify module: this module contains the DirectNotify class
"""
-import Notifier
-import Logger
+from . import Notifier
+from . import Logger
class DirectNotify:
"""
@@ -35,7 +35,7 @@ class DirectNotify:
"""
Return list of category dictionary keys
"""
- return (self.__categories.keys())
+ return list(self.__categories.keys())
def getCategory(self, categoryName):
"""getCategory(self, string)
@@ -97,7 +97,7 @@ class DirectNotify:
category.setInfo(1)
category.setDebug(1)
else:
- print ("DirectNotify: unknown notify level: " + str(level)
+ print("DirectNotify: unknown notify level: " + str(level)
+ " for category: " + str(categoryName))
diff --git a/direct/src/directnotify/DirectNotifyGlobal.py b/direct/src/directnotify/DirectNotifyGlobal.py
index 353b3d48f7..e25ddb11ad 100644
--- a/direct/src/directnotify/DirectNotifyGlobal.py
+++ b/direct/src/directnotify/DirectNotifyGlobal.py
@@ -2,7 +2,7 @@
__all__ = ['directNotify', 'giveNotify']
-import DirectNotify
+from . import DirectNotify
directNotify = DirectNotify.DirectNotify()
giveNotify = directNotify.giveNotify
diff --git a/direct/src/directnotify/LoggerGlobal.py b/direct/src/directnotify/LoggerGlobal.py
index 87a89e446d..610a009a8f 100644
--- a/direct/src/directnotify/LoggerGlobal.py
+++ b/direct/src/directnotify/LoggerGlobal.py
@@ -1,5 +1,5 @@
"""instantiate global Logger object"""
-import Logger
+from . import Logger
defaultLogger = Logger.Logger()
diff --git a/direct/src/directnotify/Notifier.py b/direct/src/directnotify/Notifier.py
index a49bbf0d03..35a916f8b3 100644
--- a/direct/src/directnotify/Notifier.py
+++ b/direct/src/directnotify/Notifier.py
@@ -2,7 +2,7 @@
Notifier module: contains methods for handling information output
for the programmer/user
"""
-from LoggerGlobal import defaultLogger
+from .LoggerGlobal import defaultLogger
from direct.showbase import PythonUtil
from panda3d.core import ConfigVariableBool, NotifyCategory, StreamWriter, Notify
import time
@@ -116,7 +116,7 @@ class Notifier:
return NSError
# error funcs
- def error(self, errorString, exception=StandardError):
+ def error(self, errorString, exception=Exception):
"""
Raise an exception with given string and optional type:
Exception: error
@@ -237,7 +237,7 @@ class Notifier:
if self.streamWriter:
self.streamWriter.write(string + '\n')
else:
- print >> sys.stderr, string
+ sys.stderr.write(string + '\n')
def debugStateCall(self, obj=None, fsmMemberName='fsm',
secondaryFsm='secondaryFSM'):
diff --git a/direct/src/directnotify/RotatingLog.py b/direct/src/directnotify/RotatingLog.py
index caf7bbd527..e663da67ac 100755
--- a/direct/src/directnotify/RotatingLog.py
+++ b/direct/src/directnotify/RotatingLog.py
@@ -91,7 +91,7 @@ class RotatingLog:
self.timeLimit=time.time()+self.timeInterval
else:
# We'll keep writing to the old file, if available.
- print "RotatingLog error: Unable to open new log file \"%s\"."%(path,)
+ print("RotatingLog error: Unable to open new log file \"%s\"." % (path,))
def write(self, data):
"""
@@ -115,8 +115,9 @@ class RotatingLog:
def isatty(self):
return self.file.isatty()
- def next(self):
- return self.file.next()
+ def __next__(self):
+ return next(self.file)
+ next = __next__
def read(self, size):
return self.file.read(size)
diff --git a/direct/src/directscripts/eggcacher.py b/direct/src/directscripts/eggcacher.py
index ea2f653876..ebef394890 100644
--- a/direct/src/directscripts/eggcacher.py
+++ b/direct/src/directscripts/eggcacher.py
@@ -19,8 +19,8 @@ class EggCacher:
self.pandaloader = Loader()
self.loaderopts = LoaderOptions(LoaderOptions.LF_no_ram_cache)
if (self.bamcache.getActive() == 0):
- print "The model cache is not currently active."
- print "You must set a model-cache-dir in your config file."
+ print("The model cache is not currently active.")
+ print("You must set a model-cache-dir in your config file.")
sys.exit(1)
self.parseArgs(args)
files = self.scanPaths(self.paths)
@@ -39,13 +39,13 @@ class EggCacher:
else:
break
if (len(args) < 1):
- print "Usage: eggcacher options file-or-directory"
+ print("Usage: eggcacher options file-or-directory")
sys.exit(1)
self.paths = args
def scanPath(self, eggs, path):
if (os.path.exists(path)==0):
- print "No such file or directory: "+path
+ print("No such file or directory: " + path)
return
if (os.path.isdir(path)):
for f in os.listdir(path):
@@ -78,7 +78,7 @@ class EggCacher:
percent = (progress * 100) / total
report = path
if (self.concise): report = os.path.basename(report)
- print "Preprocessing Models %2d%% %s" % (percent, report)
+ print("Preprocessing Models %2d%% %s" % (percent, report))
sys.stdout.flush()
if (cached) and (cached.hasData()==0):
self.pandaloader.loadSync(fn, self.loaderopts)
diff --git a/direct/src/directscripts/extract_docs.py b/direct/src/directscripts/extract_docs.py
index 8e291f95ae..b6ad69e946 100644
--- a/direct/src/directscripts/extract_docs.py
+++ b/direct/src/directscripts/extract_docs.py
@@ -5,6 +5,8 @@ You need to run this before invoking Doxyfile.python.
It requires a valid makepanda installation with interrogatedb .in
files in the lib/pandac/input directory. """
+from __future__ import print_function
+
__all__ = []
import os
@@ -156,61 +158,61 @@ def translated_type_name(type, scoped=True):
def processElement(handle, element):
if interrogate_element_has_comment(element):
- print >>handle, comment(interrogate_element_comment(element))
+ print(comment(interrogate_element_comment(element)), file=handle)
- print >>handle, translated_type_name(interrogate_element_type(element)),
- print >>handle, interrogate_element_name(element) + ';'
+ print(translated_type_name(interrogate_element_type(element)), end=' ', file=handle)
+ print(interrogate_element_name(element) + ';', file=handle)
def processFunction(handle, function, isConstructor = False):
- for i_wrapper in xrange(interrogate_function_number_of_python_wrappers(function)):
+ for i_wrapper in range(interrogate_function_number_of_python_wrappers(function)):
wrapper = interrogate_function_python_wrapper(function, i_wrapper)
if interrogate_wrapper_has_comment(wrapper):
- print >>handle, block_comment(interrogate_wrapper_comment(wrapper))
+ print(block_comment(interrogate_wrapper_comment(wrapper)), file=handle)
if not isConstructor:
if interrogate_function_is_method(function):
if not interrogate_wrapper_number_of_parameters(wrapper) > 0 or not interrogate_wrapper_parameter_is_this(wrapper, 0):
- print >>handle, "static",
+ print("static", end=' ', file=handle)
if interrogate_wrapper_has_return_value(wrapper):
- print >>handle, translated_type_name(interrogate_wrapper_return_type(wrapper)),
+ print(translated_type_name(interrogate_wrapper_return_type(wrapper)), end=' ', file=handle)
else:
pass#print >>handle, "void",
- print >>handle, translateFunctionName(interrogate_function_name(function)) + "(",
+ print(translateFunctionName(interrogate_function_name(function)) + "(", end=' ', file=handle)
else:
- print >>handle, "__init__(",
+ print("__init__(", end=' ', file=handle)
first = True
for i_param in range(interrogate_wrapper_number_of_parameters(wrapper)):
if not interrogate_wrapper_parameter_is_this(wrapper, i_param):
if not first:
- print >>handle, ",",
- print >>handle, translated_type_name(interrogate_wrapper_parameter_type(wrapper, i_param)),
+ print(",", end=' ', file=handle)
+ print(translated_type_name(interrogate_wrapper_parameter_type(wrapper, i_param)), end=' ', file=handle)
if interrogate_wrapper_parameter_has_name(wrapper, i_param):
- print >>handle, interrogate_wrapper_parameter_name(wrapper, i_param),
+ print(interrogate_wrapper_parameter_name(wrapper, i_param), end=' ', file=handle)
first = False
- print >>handle, ");"
+ print(");", file=handle)
def processType(handle, type):
typename = translated_type_name(type, scoped=False)
derivations = [ translated_type_name(interrogate_type_get_derivation(type, n)) for n in range(interrogate_type_number_of_derivations(type)) ]
if interrogate_type_has_comment(type):
- print >>handle, block_comment(interrogate_type_comment(type))
+ print(block_comment(interrogate_type_comment(type)), file=handle)
if interrogate_type_is_enum(type):
- print >>handle, "enum %s {" % typename
+ print("enum %s {" % typename, file=handle)
for i_value in range(interrogate_type_number_of_enum_values(type)):
docstring = comment(interrogate_type_enum_value_comment(type, i_value))
if docstring:
- print >>handle, docstring
- print >>handle, interrogate_type_enum_value_name(type, i_value), "=", interrogate_type_enum_value(type, i_value), ","
+ print(docstring, file=handle)
+ print(interrogate_type_enum_value_name(type, i_value), "=", interrogate_type_enum_value(type, i_value), ",", file=handle)
elif interrogate_type_is_typedef(type):
wrapped_type = translated_type_name(interrogate_type_wrapped_type(type))
- print >>handle, "typedef %s %s;" % (wrapped_type, typename)
+ print("typedef %s %s;" % (wrapped_type, typename), file=handle)
return
else:
if interrogate_type_is_struct(type):
@@ -220,39 +222,39 @@ def processType(handle, type):
elif interrogate_type_is_union(type):
classtype = "union"
else:
- print "I don't know what type %s is" % interrogate_type_true_name(type)
+ print("I don't know what type %s is" % interrogate_type_true_name(type))
return
if len(derivations) > 0:
- print >>handle, "%s %s : public %s {" % (classtype, typename, ", public ".join(derivations))
+ print("%s %s : public %s {" % (classtype, typename, ", public ".join(derivations)), file=handle)
else:
- print >>handle, "%s %s {" % (classtype, typename)
- print >>handle, "public:"
+ print("%s %s {" % (classtype, typename), file=handle)
+ print("public:", file=handle)
- for i_ntype in xrange(interrogate_type_number_of_nested_types(type)):
+ for i_ntype in range(interrogate_type_number_of_nested_types(type)):
processType(handle, interrogate_type_get_nested_type(type, i_ntype))
- for i_method in xrange(interrogate_type_number_of_constructors(type)):
+ for i_method in range(interrogate_type_number_of_constructors(type)):
processFunction(handle, interrogate_type_get_constructor(type, i_method), True)
- for i_method in xrange(interrogate_type_number_of_methods(type)):
+ for i_method in range(interrogate_type_number_of_methods(type)):
processFunction(handle, interrogate_type_get_method(type, i_method))
- for i_method in xrange(interrogate_type_number_of_make_seqs(type)):
- print >>handle, "list", translateFunctionName(interrogate_make_seq_seq_name(interrogate_type_get_make_seq(type, i_method))), "();"
+ for i_method in range(interrogate_type_number_of_make_seqs(type)):
+ print("list", translateFunctionName(interrogate_make_seq_seq_name(interrogate_type_get_make_seq(type, i_method))), "();", file=handle)
- for i_element in xrange(interrogate_type_number_of_elements(type)):
+ for i_element in range(interrogate_type_number_of_elements(type)):
processElement(handle, interrogate_type_get_element(type, i_element))
- print >>handle, "};"
+ print("};", file=handle)
def processModule(handle, package):
- print >>handle, "namespace %s {" % package
+ print("namespace %s {" % package, file=handle)
if package != "core":
- print >>handle, "using namespace core;"
+ print("using namespace core;", file=handle)
- for i_type in xrange(interrogate_number_of_global_types()):
+ for i_type in range(interrogate_number_of_global_types()):
type = interrogate_get_global_type(i_type)
if interrogate_type_has_module_name(type):
@@ -260,9 +262,9 @@ def processModule(handle, package):
if "panda3d." + package == module_name:
processType(handle, type)
else:
- print "Type %s has no module name" % typename
+ print("Type %s has no module name" % typename)
- for i_func in xrange(interrogate_number_of_global_functions()):
+ for i_func in range(interrogate_number_of_global_functions()):
func = interrogate_get_global_function(i_func)
if interrogate_function_has_module_name(func):
@@ -270,16 +272,16 @@ def processModule(handle, package):
if "panda3d." + package == module_name:
processFunction(handle, func)
else:
- print "Type %s has no module name" % typename
+ print("Type %s has no module name" % typename)
- print >>handle, "}"
+ print("}", file=handle)
if __name__ == "__main__":
handle = open("pandadoc.hpp", "w")
- print >>handle, comment("Panda3D modules that are implemented in C++.")
- print >>handle, "namespace panda3d {"
+ print(comment("Panda3D modules that are implemented in C++."), file=handle)
+ print("namespace panda3d {", file=handle)
# Determine the path to the interrogatedb files
interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "..", "..", "etc"))
@@ -295,5 +297,5 @@ if __name__ == "__main__":
processModule(handle, module_name)
- print >>handle, "}"
+ print("}", file=handle)
handle.close()
diff --git a/direct/src/directscripts/gendocs.py b/direct/src/directscripts/gendocs.py
index edf402382c..6bb83c9567 100644
--- a/direct/src/directscripts/gendocs.py
+++ b/direct/src/directscripts/gendocs.py
@@ -48,7 +48,7 @@
#
########################################################################
-import os, sys, parser, symbol, token, types, re
+import os, sys, parser, symbol, token, re
########################################################################
#
@@ -103,12 +103,12 @@ def writeFileLines(wfile, lines):
sys.exit("Cannot write "+wfile)
def findFiles(dirlist, ext, ign, list):
- if isinstance(dirlist, types.StringTypes):
+ if isinstance(dirlist, str):
dirlist = [dirlist]
for dir in dirlist:
for file in os.listdir(dir):
full = dir + "/" + file
- if (ign.has_key(full)==0) and (ign.has_key(file)==0):
+ if full not in ign and file not in ign:
if (os.path.isfile(full)):
if (file.endswith(ext)):
list.append(full)
@@ -145,7 +145,7 @@ def textToHTML(comment, sep, delsection=None):
sec = sec.replace(" "," ")
if (delsection != None) and (delsection.match(sec)):
included[sec] = 1
- if (included.has_key(sec)==0):
+ if sec not in included:
included[sec] = 1
total = total + sec + " \n"
return total
@@ -195,8 +195,8 @@ class InterrogateTokenizer:
neg = 1
self.pos += 1
if (self.data[self.pos].isdigit()==0):
- print "File position "+str(self.pos)
- print "Text: "+self.data[self.pos:self.pos+50]
+ print("File position " + str(self.pos))
+ print("Text: " + self.data[self.pos:self.pos+50])
sys.exit("Syntax error in interrogate file format 0")
value = 0
while (self.data[self.pos].isdigit()):
@@ -340,20 +340,20 @@ class InterrogateDatabase:
def printTree(tree, indent):
spacing = " "[:indent]
- if isinstance(tree, types.TupleType) and isinstance(tree[0], types.IntType):
- if symbol.sym_name.has_key(tree[0]):
+ if isinstance(tree, tuple) and isinstance(tree[0], int):
+ if tree[0] in symbol.sym_name:
for i in range(len(tree)):
if (i==0):
- print spacing + "(symbol." + symbol.sym_name[tree[0]] + ","
+ print(spacing + "(symbol." + symbol.sym_name[tree[0]] + ",")
else:
printTree(tree[i], indent+1)
- print spacing + "),"
- elif token.tok_name.has_key(tree[0]):
- print spacing + "(token." + token.tok_name[tree[0]] + ", '" + tree[1] + "'),"
+ print(spacing + "),")
+ elif tree[0] in token.tok_name:
+ print(spacing + "(token." + token.tok_name[tree[0]] + ", '" + tree[1] + "'),")
else:
- print spacing + str(tree)
+ print(spacing + str(tree))
else:
- print spacing + str(tree)
+ print(spacing + str(tree))
COMPOUND_STMT_PATTERN = (
@@ -447,7 +447,7 @@ class ParseTreeInfo:
self.function_info = {}
self.assign_info = {}
self.derivs = {}
- if isinstance(tree, types.StringType):
+ if isinstance(tree, str):
try:
tree = parser.suite(tree+"\n").totuple()
if (tree):
@@ -455,8 +455,8 @@ class ParseTreeInfo:
if found:
self.docstring = vars["docstring"]
except:
- print "CAUTION --- Parse failed: "+name
- if isinstance(tree, types.TupleType):
+ print("CAUTION --- Parse failed: " + name)
+ if isinstance(tree, tuple):
self.extract_info(tree)
def match(self, pattern, data, vars=None):
@@ -480,10 +480,10 @@ class ParseTreeInfo:
"""
if vars is None:
vars = {}
- if type(pattern) is types.ListType: # 'variables' are ['varname']
+ if type(pattern) is list: # 'variables' are ['varname']
vars[pattern[0]] = data
return 1, vars
- if type(pattern) is not types.TupleType:
+ if type(pattern) is not tuple:
return (pattern == data), vars
if len(data) != len(pattern):
return 0, vars
@@ -534,11 +534,11 @@ class ParseTreeInfo:
classinfo.derivs[vars["classname"]] = 1
def extract_tokens(self, str, tree):
- if (isinstance(tree, types.TupleType)):
- if (token.tok_name.has_key(tree[0])):
+ if (isinstance(tree, tuple)):
+ if tree[0] in token.tok_name:
str = str + tree[1]
if (tree[1]==","): str=str+" "
- elif (symbol.sym_name.has_key(tree[0])):
+ elif tree[0] in symbol.sym_name:
for sub in tree[1:]:
str = self.extract_tokens(str, sub)
return str
@@ -564,12 +564,12 @@ class CodeDatabase:
self.varExports = {}
self.globalfn = []
self.formattedprotos = {}
- print "Reading C++ source files"
+ print("Reading C++ source files")
for cxx in cxxlist:
tokzr = InterrogateTokenizer(cxx)
idb = InterrogateDatabase(tokzr)
for type in idb.types.values():
- if (type.flags & 8192) or (self.types.has_key(type.scopedname)==0):
+ if (type.flags & 8192) or type.scopedname not in self.types:
self.types[type.scopedname] = type
if (type.flags & 8192) and (type.atomictype == 0) and (type.scopedname.count(" ")==0) and (type.scopedname.count(":")==0):
self.goodtypes[type.scopedname] = type
@@ -583,7 +583,7 @@ class CodeDatabase:
self.funcExports.setdefault("pandac.PandaModules", []).append(func.pyname)
else:
self.funcs[type.scopedname+"."+func.pyname] = func
- print "Reading Python sources files"
+ print("Reading Python sources files")
for py in pylist:
pyinf = ParseTreeInfo(readFile(py), py, py)
mod = pathToModule(py)
@@ -602,7 +602,7 @@ class CodeDatabase:
self.varExports.setdefault(mod, []).append(var)
def getClassList(self):
- return self.goodtypes.keys()
+ return list(self.goodtypes.keys())
def getGlobalFunctionList(self):
return self.globalfn
@@ -625,7 +625,7 @@ class CodeDatabase:
parents.append(basetype.scopedname)
return parents
elif (isinstance(type, ParseTreeInfo)):
- return type.derivs.keys()
+ return list(type.derivs.keys())
else:
return []
@@ -706,7 +706,7 @@ class CodeDatabase:
def getFunctionPrototype(self, fn, urlprefix, urlsuffix):
func = self.funcs.get(fn)
if (isinstance(func, InterrogateFunction)):
- if self.formattedprotos.has_key(fn):
+ if fn in self.formattedprotos:
proto = self.formattedprotos[fn]
else:
proto = func.prototype
@@ -767,7 +767,7 @@ CLASS_RENAME_DICT = {
########################################################################
def makeCodeDatabase(indirlist, directdirlist):
- if isinstance(directdirlist, types.StringTypes):
+ if isinstance(directdirlist, str):
directdirlist = [directdirlist]
ignore = {}
ignore["__init__.py"] = 1
@@ -820,7 +820,7 @@ def generate(pversion, indirlist, directdirlist, docdir, header, footer, urlpref
classes = code.getClassList()[:]
classes.sort(None, str.lower)
xclasses = classes[:]
- print "Generating HTML pages"
+ print("Generating HTML pages")
for type in classes:
body = "
" + type + " \n"
comment = code.getClassComment(type)
@@ -864,7 +864,7 @@ def generate(pversion, indirlist, directdirlist, docdir, header, footer, urlpref
body = body + generateFunctionDocs(code, method, urlprefix, urlsuffix)
body = header + body + footer
writeFile(docdir + "/" + type + ".html", body)
- if (CLASS_RENAME_DICT.has_key(type)):
+ if type in CLASS_RENAME_DICT:
modtype = CLASS_RENAME_DICT[type]
writeFile(docdir + "/" + modtype + ".html", body)
xclasses.append(modtype)
@@ -892,20 +892,22 @@ def generate(pversion, indirlist, directdirlist, docdir, header, footer, urlpref
for method in code.getClassMethods(type)[:]:
name = code.getFunctionName(method)
prefix = name[0].upper()
- if (table.has_key(prefix)==0): table[prefix] = {}
- if (table[prefix].has_key(name)==0): table[prefix][name] = []
+ if prefix not in table:
+ table[prefix] = {}
+ if name not in table[prefix]:
+ table[prefix][name] = []
table[prefix][name].append(type)
index = "List of Methods - Panda " + pversion + " \n"
- prefixes = table.keys()
+ prefixes = list(table.keys())
prefixes.sort(None, str.lower)
for prefix in prefixes:
index = index + linkTo("#"+prefix, prefix) + " "
index = index + " "
for prefix in prefixes:
index = index + '' + "\n"
- names = table[prefix].keys()
+ names = list(table[prefix].keys())
names.sort(None, str.lower)
for name in names:
line = '' + name + ": \n"
@@ -966,18 +968,18 @@ def expandImports(indirlist, directdirlist, fixdirlist):
varExports = code.getVarExports(module)
if (len(typeExports)+len(funcExports)+len(varExports)==0):
result.append(line)
- print fixfile+" : "+module+" : no exports"
+ print(fixfile + " : " + module + " : no exports")
else:
- print fixfile+" : "+module+" : repairing"
+ print(fixfile + " : " + module + " : repairing")
for x in funcExports:
fn = code.getFunctionName(x)
- if (used.has_key(fn)):
+ if fn in used:
result.append("from "+module+" import "+fn)
for x in typeExports:
- if (used.has_key(x)):
+ if x in used:
result.append("from "+module+" import "+x)
for x in varExports:
- if (used.has_key(x)):
+ if x in used:
result.append("from "+module+" import "+x)
else:
result.append(line)
diff --git a/direct/src/directscripts/packpanda.py b/direct/src/directscripts/packpanda.py
index 1868b0f1cb..b8dec72610 100755
--- a/direct/src/directscripts/packpanda.py
+++ b/direct/src/directscripts/packpanda.py
@@ -13,7 +13,7 @@
#
##############################################################################
-import sys, os, getopt, string, shutil, py_compile, subprocess
+import sys, os, getopt, shutil, py_compile, subprocess
OPTIONLIST = [
("dir", 1, "Name of directory containing game"),
@@ -27,14 +27,14 @@ OPTIONLIST = [
]
def ParseFailure():
- print ""
- print "packpanda usage:"
- print ""
+ print("")
+ print("packpanda usage:")
+ print("")
for (opt, hasval, explanation) in OPTIONLIST:
if (hasval):
- print " --%-10s %s"%(opt+" x", explanation)
+ print(" --%-10s %s"%(opt+" x", explanation))
else:
- print " --%-10s %s"%(opt+" ", explanation)
+ print(" --%-10s %s"%(opt+" ", explanation))
sys.exit(1)
def ParseOptions(args):
@@ -75,7 +75,7 @@ for dir in sys.path:
PANDA=os.path.abspath(dir)
if (PANDA is None):
sys.exit("Cannot locate the panda root directory in the python path (cannot locate directory containing direct and pandac).")
-print "PANDA located at "+PANDA
+print("PANDA located at "+PANDA)
if (os.path.exists(os.path.join(PANDA,"..","makepanda","makepanda.py"))) and (sys.platform != "win32" or os.path.exists(os.path.join(PANDA,"..","thirdparty","win-nsis","makensis.exe"))):
PSOURCE=os.path.abspath(os.path.join(PANDA,".."))
@@ -95,7 +95,7 @@ else:
VER=OPTIONS["version"]
DIR=OPTIONS["dir"]
if (DIR==""):
- print "You must specify the --dir option."
+ print("You must specify the --dir option.")
ParseFailure()
DIR=os.path.abspath(DIR)
MYDIR=os.path.abspath(os.getcwd())
@@ -123,21 +123,21 @@ else: MAIN="main.py"
def PrintFileStatus(label, file):
if (os.path.exists(file)):
- print "%-15s: %s"%(label, file)
+ print("%-15s: %s"%(label, file))
else:
- print "%-15s: %s (MISSING)"%(label, file)
+ print("%-15s: %s (MISSING)"%(label, file))
PrintFileStatus("Dir", DIR)
-print "%-15s: %s"%("Name", NAME)
-print "%-15s: %s"%("Start Menu", SMDIRECTORY)
+print("%-15s: %s"%("Name", NAME))
+print("%-15s: %s"%("Start Menu", SMDIRECTORY))
PrintFileStatus("Main", os.path.join(DIR, MAIN))
if (sys.platform == "win32"):
PrintFileStatus("Icon", ICON)
PrintFileStatus("Bitmap", BITMAP)
PrintFileStatus("License", LICENSE)
-print "%-15s: %s"%("Output", OUTFILE)
+print("%-15s: %s"%("Output", OUTFILE))
if (sys.platform == "win32"):
- print "%-15s: %s"%("Install Dir", INSTALLDIR)
+ print("%-15s: %s"%("Install Dir", INSTALLDIR))
if (os.path.isdir(DIR)==0):
sys.exit("Difficulty reading "+DIR+". Cannot continue.")
@@ -181,8 +181,8 @@ if (sys.platform == "win32"):
else:
TMPGAME=os.path.join(TMPDIR,"usr","share","games",BASENAME,"game")
TMPETC=os.path.join(TMPDIR,"usr","share","games",BASENAME,"etc")
-print ""
-print "Copying the game to "+TMPDIR+"..."
+print("")
+print("Copying the game to "+TMPDIR+"...")
if (os.path.exists(TMPDIR)):
try: shutil.rmtree(TMPDIR)
except: sys.exit("Cannot delete "+TMPDIR)
@@ -247,7 +247,7 @@ def egg2bam(file,bam):
present = os.path.exists(bam)
if (present): bam = "packpanda-TMP.bam";
cmd = 'egg2bam -noabs -ps rel -pd . "'+file+'" -o "'+bam+'"'
- print "Executing: "+cmd
+ print("Executing: "+cmd)
if (sys.platform == "win32"):
res = os.spawnl(os.P_WAIT, EGG2BAM, cmd)
else:
@@ -257,7 +257,7 @@ def egg2bam(file,bam):
os.unlink(bam)
def py2pyc(file):
- print "Compiling python "+file
+ print("Compiling python "+file)
pyc = file[:-3]+'.pyc'
pyo = file[:-3]+'.pyo'
if (os.path.exists(pyc)): os.unlink(pyc)
@@ -284,24 +284,24 @@ def CompileFiles(file):
CompileFiles(os.path.join(file, x))
def DeleteFiles(file):
- base = string.lower(os.path.basename(file))
+ base = os.path.basename(file).lower()
if (os.path.isdir(file)):
for pattern in OPTIONS["rmdir"]:
- if (string.lower(pattern) == base):
- print "Deleting "+file
+ if pattern.lower() == base:
+ print("Deleting "+file)
shutil.rmtree(file)
return
for x in os.listdir(file):
DeleteFiles(os.path.join(file, x))
else:
for ext in OPTIONS["rmext"]:
- if (base[-(len(ext)+1):] == string.lower("."+ext)):
- print "Deleting "+file
+ if base[-(len(ext) + 1):] == ("." + ext).lower():
+ print("Deleting "+file)
os.unlink(file)
return
-print ""
-print "Compiling BAM and PYC files..."
+print("")
+print("Compiling BAM and PYC files...")
os.chdir(TMPGAME)
CompileFiles(".")
DeleteFiles(".")
@@ -371,9 +371,9 @@ if (sys.platform == "win32"):
CMD=CMD+'/DPPICON="'+PPICON+'" '
CMD=CMD+'"'+PSOURCE+'\\direct\\directscripts\\packpanda.nsi"'
- print ""
- print CMD
- print "packing..."
+ print("")
+ print(CMD)
+ print("packing...")
subprocess.call(CMD)
else:
os.chdir(MYDIR)
diff --git a/direct/src/directtools/DirectCameraControl.py b/direct/src/directtools/DirectCameraControl.py
index e3fbe6c8b7..2913260c57 100644
--- a/direct/src/directtools/DirectCameraControl.py
+++ b/direct/src/directtools/DirectCameraControl.py
@@ -1,8 +1,8 @@
from direct.showbase.DirectObject import DirectObject
-from DirectUtil import *
-from DirectGeometry import *
-from DirectGlobals import *
-from DirectSelection import SelectionRay
+from .DirectUtil import *
+from .DirectGeometry import *
+from .DirectGlobals import *
+from .DirectSelection import SelectionRay
from direct.interval.IntervalGlobal import Sequence, Func
from direct.directnotify import DirectNotifyGlobal
from direct.task import Task
@@ -233,13 +233,13 @@ class DirectCameraControl(DirectObject):
self.updateCoaMarkerSize()
def mouseFlyStartTopWin(self):
- print "Moving mouse 2 in new window"
+ print("Moving mouse 2 in new window")
#altIsDown = base.getAlt()
#if altIsDown:
# print "Alt is down"
def mouseFlyStopTopWin(self):
- print "Stopping mouse 2 in new window"
+ print("Stopping mouse 2 in new window")
def spawnXZTranslateOrHPanYZoom(self):
# Kill any existing tasks
diff --git a/direct/src/directtools/DirectGeometry.py b/direct/src/directtools/DirectGeometry.py
index 9c748e57b3..2c69a8d8d5 100644
--- a/direct/src/directtools/DirectGeometry.py
+++ b/direct/src/directtools/DirectGeometry.py
@@ -1,7 +1,7 @@
from panda3d.core import *
-from DirectGlobals import *
-from DirectUtil import *
+from .DirectGlobals import *
+from .DirectUtil import *
import math
class LineNodePath(NodePath):
@@ -28,10 +28,10 @@ class LineNodePath(NodePath):
ls.setColor(colorVec)
def moveTo(self, *_args):
- apply(self.lineSegs.moveTo, _args)
+ self.lineSegs.moveTo(*_args)
def drawTo(self, *_args):
- apply(self.lineSegs.drawTo, _args)
+ self.lineSegs.drawTo(*_args)
def create(self, frameAccurate = 0):
self.lineSegs.create(self.lineNode, frameAccurate)
@@ -47,13 +47,13 @@ class LineNodePath(NodePath):
self.lineSegs.setThickness(thickness)
def setColor(self, *_args):
- apply(self.lineSegs.setColor, _args)
+ self.lineSegs.setColor(*_args)
def setVertex(self, *_args):
- apply(self.lineSegs.setVertex, _args)
+ self.lineSegs.setVertex(*_args)
def setVertexColor(self, vertex, *_args):
- apply(self.lineSegs.setVertexColor, (vertex,) + _args)
+ self.lineSegs.setVertexColor(*(vertex,) + _args)
def getCurrentPosition(self):
return self.lineSegs.getCurrentPosition()
@@ -119,9 +119,9 @@ class LineNodePath(NodePath):
Given a list of lists of points, draw a separate line for each list
"""
for pointList in lineList:
- apply(self.moveTo, pointList[0])
+ self.moveTo(*pointList[0])
for point in pointList[1:]:
- apply(self.drawTo, point)
+ self.drawTo(*point)
##
## Given a point in space, and a direction, find the point of intersection
diff --git a/direct/src/directtools/DirectGlobals.py b/direct/src/directtools/DirectGlobals.py
index 372d16839f..9d10a3f691 100644
--- a/direct/src/directtools/DirectGlobals.py
+++ b/direct/src/directtools/DirectGlobals.py
@@ -51,12 +51,12 @@ LE_CAM_MASKS = {'persp':LE_PERSP_CAM_MASK,
'top':LE_TOP_CAM_MASK}
def LE_showInAllCam(nodePath):
- for camName in LE_CAM_MASKS.keys():
+ for camName in LE_CAM_MASKS:
nodePath.show(LE_CAM_MASKS[camName])
def LE_showInOneCam(nodePath, thisCamName):
LE_showInAllCam(nodePath)
- for camName in LE_CAM_MASKS.keys():
+ for camName in LE_CAM_MASKS:
if camName != thisCamName:
nodePath.hide(LE_CAM_MASKS[camName])
diff --git a/direct/src/directtools/DirectGrid.py b/direct/src/directtools/DirectGrid.py
index e7e67823a3..80d8280ec0 100644
--- a/direct/src/directtools/DirectGrid.py
+++ b/direct/src/directtools/DirectGrid.py
@@ -1,8 +1,8 @@
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
-from DirectUtil import *
-from DirectGeometry import *
+from .DirectUtil import *
+from .DirectGeometry import *
class DirectGrid(NodePath, DirectObject):
def __init__(self,gridSize=100.0,gridSpacing=5.0,planeColor=(0.5,0.5,0.5,0.5),parent = None):
diff --git a/direct/src/directtools/DirectLights.py b/direct/src/directtools/DirectLights.py
index 1797351032..f20f08aca7 100644
--- a/direct/src/directtools/DirectLights.py
+++ b/direct/src/directtools/DirectLights.py
@@ -78,7 +78,7 @@ class DirectLights(NodePath):
light.setColor(VBase4(1))
light.setLens(PerspectiveLens())
else:
- print 'Invalid light type'
+ print('Invalid light type')
return None
# Add the new light
directLight = DirectLight(light, self)
diff --git a/direct/src/directtools/DirectManipulation.py b/direct/src/directtools/DirectManipulation.py
index ad9a1c0e51..3ebc697400 100644
--- a/direct/src/directtools/DirectManipulation.py
+++ b/direct/src/directtools/DirectManipulation.py
@@ -1,10 +1,9 @@
from direct.showbase.DirectObject import DirectObject
-from DirectGlobals import *
-from DirectUtil import *
-from DirectGeometry import *
-from DirectSelection import SelectionRay
+from .DirectGlobals import *
+from .DirectUtil import *
+from .DirectGeometry import *
+from .DirectSelection import SelectionRay
from direct.task import Task
-import types
from copy import deepcopy
class DirectManipulationControl(DirectObject):
@@ -1207,7 +1206,7 @@ class ObjectHandles(NodePath, DirectObject):
self.reparentTo(hidden)
def enableHandles(self, handles):
- if type(handles) == types.ListType:
+ if type(handles) == list:
for handle in handles:
self.enableHandle(handle)
elif handles == 'x':
@@ -1256,7 +1255,7 @@ class ObjectHandles(NodePath, DirectObject):
self.zScaleGroup.reparentTo(self.zHandles)
def disableHandles(self, handles):
- if type(handles) == types.ListType:
+ if type(handles) == list:
for handle in handles:
self.disableHandle(handle)
elif handles == 'x':
diff --git a/direct/src/directtools/DirectSelection.py b/direct/src/directtools/DirectSelection.py
index 2b2373ce26..ef14fb429b 100644
--- a/direct/src/directtools/DirectSelection.py
+++ b/direct/src/directtools/DirectSelection.py
@@ -1,7 +1,7 @@
from direct.showbase.DirectObject import DirectObject
-from DirectGlobals import *
-from DirectUtil import *
-from DirectGeometry import *
+from .DirectGlobals import *
+from .DirectUtil import *
+from .DirectGeometry import *
COA_ORIGIN = 0
COA_CENTER = 1
@@ -68,7 +68,7 @@ class SelectedNodePaths(DirectObject):
""" Select the specified node path. Multiselect as required """
# Do nothing if nothing selected
if not nodePath:
- print 'Nothing selected!!'
+ print('Nothing selected!!')
return None
# Reset selected objects and highlight if multiSelect is false
@@ -160,7 +160,7 @@ class SelectedNodePaths(DirectObject):
return None
def getDeselectedAsList(self):
- return self.deselectedDict.values()[:]
+ return list(self.deselectedDict.values())
def getDeselectedDict(self, id):
"""
@@ -260,7 +260,7 @@ class SelectedNodePaths(DirectObject):
return self.getDeselectedDict(id)
def getNumSelected(self):
- return len(self.selectedDict.keys())
+ return len(self.selectedDict)
class DirectBoundingBox:
diff --git a/direct/src/directtools/DirectSession.py b/direct/src/directtools/DirectSession.py
index 2fb18b5806..96f8bdb610 100644
--- a/direct/src/directtools/DirectSession.py
+++ b/direct/src/directtools/DirectSession.py
@@ -1,27 +1,25 @@
import math
-import types
-import string
+import sys
from panda3d.core import *
-from DirectUtil import *
+from .DirectUtil import *
from direct.showbase.DirectObject import DirectObject
from direct.task import Task
-from DirectGlobals import DIRECT_NO_MOD
-from DirectCameraControl import DirectCameraControl
-from DirectManipulation import DirectManipulationControl
-from DirectSelection import SelectionRay, COA_ORIGIN, SelectedNodePaths
-from DirectGrid import DirectGrid
+from .DirectGlobals import DIRECT_NO_MOD
+from .DirectCameraControl import DirectCameraControl
+from .DirectManipulation import DirectManipulationControl
+from .DirectSelection import SelectionRay, COA_ORIGIN, SelectedNodePaths
+from .DirectGrid import DirectGrid
#from DirectGeometry import *
-from DirectLights import DirectLights
+from .DirectLights import DirectLights
from direct.cluster.ClusterClient import createClusterClient, DummyClusterClient
from direct.cluster.ClusterServer import ClusterServer
## from direct.tkpanels import Placer
## from direct.tkwidgets import Slider
## from direct.tkwidgets import SceneGraphExplorer
from direct.gui import OnscreenText
-from direct.showbase import Loader
from direct.interval.IntervalGlobal import *
class DirectSession(DirectObject):
@@ -115,7 +113,7 @@ class DirectSession(DirectObject):
if fastrak:
from direct.directdevices import DirectFastrak
# parse string into format device:N where N is the sensor name
- fastrak = string.split(fastrak)
+ fastrak = fastrak.split()
for i in range(len(fastrak))[1:]:
self.fastrak.append(DirectFastrak.DirectFastrak(fastrak[0] + ':' + fastrak[i]))
@@ -556,12 +554,12 @@ class DirectSession(DirectObject):
input = input[:-7]
# Deal with keyboard and mouse input
- if input in self.hotKeyMap.keys():
+ if input in self.hotKeyMap:
keyDesc = self.hotKeyMap[input]
messenger.send(keyDesc[1])
- elif input in self.speicalKeyMap.keys():
+ elif input in self.speicalKeyMap:
messenger.send(self.speicalKeyMap[input])
- elif input in self.directOnlyKeyMap.keys():
+ elif input in self.directOnlyKeyMap:
if self.fIgnoreDirectOnlyKeyMap:
return
keyDesc = self.directOnlyKeyMap[input]
@@ -808,7 +806,7 @@ class DirectSession(DirectObject):
def isNotCycle(self, nodePath, parent):
if nodePath == parent:
- print 'DIRECT.reparent: Invalid parent'
+ print('DIRECT.reparent: Invalid parent')
return 0
elif parent.hasParent():
return self.isNotCycle(nodePath, parent.getParent())
@@ -944,7 +942,10 @@ class DirectSession(DirectObject):
def getAndSetName(self, nodePath):
""" Prompt user for new node path name """
- from tkSimpleDialog import askstring
+ if sys.version_info >= (3, 0):
+ from tkinter.simpledialog import askstring
+ else:
+ from tkSimpleDialog import askstring
newName = askstring('Node Path: ' + nodePath.getName(),
'Enter new name:')
if newName:
diff --git a/direct/src/directtools/DirectUtil.py b/direct/src/directtools/DirectUtil.py
index 224b069b9d..9919f841b2 100644
--- a/direct/src/directtools/DirectUtil.py
+++ b/direct/src/directtools/DirectUtil.py
@@ -1,5 +1,5 @@
-from DirectGlobals import *
+from .DirectGlobals import *
# Routines to adjust values
def ROUND_TO(value, divisor):
diff --git a/direct/src/directutil/DeltaProfiler.py b/direct/src/directutil/DeltaProfiler.py
index 8e2612fd1c..2c51c699be 100755
--- a/direct/src/directutil/DeltaProfiler.py
+++ b/direct/src/directutil/DeltaProfiler.py
@@ -16,11 +16,11 @@ class DeltaProfiler:
def printDeltaTime(self, label):
if self.active:
deltaTime=time()-self.priorTime
- print "%s DeltaTime %-25s to %-25s: %3.5f"%(
+ print("%s DeltaTime %-25s to %-25s: %3.5f"%(
self.name,
self.priorLabel,
label,
- deltaTime)
+ deltaTime))
self.priorLabel=label
# The printing time is not included in the timing.
# This is intentional.
diff --git a/direct/src/directutil/DistributedLargeBlobSender.py b/direct/src/directutil/DistributedLargeBlobSender.py
index ae521369c2..39748a13a2 100755
--- a/direct/src/directutil/DistributedLargeBlobSender.py
+++ b/direct/src/directutil/DistributedLargeBlobSender.py
@@ -2,7 +2,7 @@
from direct.distributed import DistributedObject
from direct.directnotify import DirectNotifyGlobal
-import LargeBlobSenderConsts
+from . import LargeBlobSenderConsts
class DistributedLargeBlobSender(DistributedObject.DistributedObject):
"""DistributedLargeBlobSender: for sending large chunks of data through
diff --git a/direct/src/directutil/DistributedLargeBlobSenderAI.py b/direct/src/directutil/DistributedLargeBlobSenderAI.py
index b679a5f714..648599731d 100755
--- a/direct/src/directutil/DistributedLargeBlobSenderAI.py
+++ b/direct/src/directutil/DistributedLargeBlobSenderAI.py
@@ -2,7 +2,7 @@
from direct.distributed import DistributedObjectAI
from direct.directnotify import DirectNotifyGlobal
-import LargeBlobSenderConsts
+from . import LargeBlobSenderConsts
class DistributedLargeBlobSenderAI(DistributedObjectAI.DistributedObjectAI):
"""DistributedLargeBlobSenderAI: for sending large chunks of data through
diff --git a/direct/src/directutil/MemoryLeakHelpers.py b/direct/src/directutil/MemoryLeakHelpers.py
index 4607d05e16..950e7fd9b1 100755
--- a/direct/src/directutil/MemoryLeakHelpers.py
+++ b/direct/src/directutil/MemoryLeakHelpers.py
@@ -11,7 +11,7 @@
import gc
gc.set_debug(gc.DEBUG_LEAK)
gc.collect()
-print gc.garbage
+print(gc.garbage)
# Inside DistributedObjectAI, you can uncomment the __del__ function to
# see when your objects are being deleted (or not)
diff --git a/direct/src/directutil/Mopath.py b/direct/src/directutil/Mopath.py
index 07d7dd63b2..05e437d34d 100644
--- a/direct/src/directutil/Mopath.py
+++ b/direct/src/directutil/Mopath.py
@@ -29,7 +29,7 @@ class Mopath(DirectObject):
elif isinstance( objectToLoad, str ):
self.loadFile( objectToLoad )
elif objectToLoad is not None:
- print "Mopath: Unable to load object '%s', objectToLoad must be a file name string or a NodePath" % objectToLoad
+ print("Mopath: Unable to load object '%s', objectToLoad must be a file name string or a NodePath" % objectToLoad)
def getMaxT(self):
return self.maxT * self.timeScale
@@ -40,7 +40,7 @@ class Mopath(DirectObject):
self.loadNodePath(nodePath)
nodePath.removeNode()
else:
- print 'Mopath: no data in file: %s' % filename
+ print('Mopath: no data in file: %s' % filename)
def loadNodePath(self, nodePath, fReset = 1):
@@ -55,7 +55,7 @@ class Mopath(DirectObject):
elif (self.hprNurbsCurve != None):
self.maxT = self.hprNurbsCurve.getMaxT()
else:
- print 'Mopath: no valid curves in nodePath: %s' % nodePath
+ print('Mopath: no valid curves in nodePath: %s' % nodePath)
def reset(self):
@@ -77,7 +77,7 @@ class Mopath(DirectObject):
if (self.xyzNurbsCurve == None):
self.xyzNurbsCurve = node
else:
- print 'Mopath: got a PCT_NONE curve and an XYZ Curve in nodePath: %s' % nodePath
+ print('Mopath: got a PCT_NONE curve and an XYZ Curve in nodePath: %s' % nodePath)
elif (node.getCurveType() == PCTT):
self.tNurbsCurve.append(node)
else:
@@ -106,7 +106,7 @@ class Mopath(DirectObject):
def goTo(self, node, time):
if (self.xyzNurbsCurve == None) and (self.hprNurbsCurve == None):
- print 'Mopath: Mopath has no curves'
+ print('Mopath: Mopath has no curves')
return
time /= self.timeScale
self.playbackTime = self.calcTime(CLAMP(time, 0.0, self.maxT))
@@ -145,7 +145,7 @@ class Mopath(DirectObject):
def play(self, node, time = 0.0, loop = 0):
if (self.xyzNurbsCurve == None) and (self.hprNurbsCurve == None):
- print 'Mopath: Mopath has no curves'
+ print('Mopath: Mopath has no curves')
return
self.node = node
self.loop = loop
diff --git a/direct/src/directutil/Verify.py b/direct/src/directutil/Verify.py
index 8a1f41acb5..ce23b1daa9 100755
--- a/direct/src/directutil/Verify.py
+++ b/direct/src/directutil/Verify.py
@@ -52,11 +52,11 @@ def verify(assertion):
wish to have the assertion checked, even in release (-O) code.
"""
if not assertion:
- print "\n\nverify failed:"
+ print("\n\nverify failed:")
import sys
- print " File \"%s\", line %d"%(
+ print(" File \"%s\", line %d"%(
sys._getframe(1).f_code.co_filename,
- sys._getframe(1).f_lineno)
+ sys._getframe(1).f_lineno))
if wantVerifyPdb:
import pdb
pdb.set_trace()
diff --git a/direct/src/distributed/AsyncRequest.py b/direct/src/distributed/AsyncRequest.py
index dc3c6bf4d6..1d30259a6e 100755
--- a/direct/src/distributed/AsyncRequest.py
+++ b/direct/src/distributed/AsyncRequest.py
@@ -1,7 +1,7 @@
#from otp.ai.AIBaseGlobal import *
from direct.directnotify import DirectNotifyGlobal
from direct.showbase.DirectObject import DirectObject
-from ConnectionRepository import *
+from .ConnectionRepository import *
from panda3d.core import ConfigVariableDouble, ConfigVariableInt, ConfigVariableBool
ASYNC_REQUEST_DEFAULT_TIMEOUT_IN_SECONDS = 8.0
@@ -251,9 +251,9 @@ class AsyncRequest(DirectObject):
if __debug__:
if _breakOnTimeout:
if hasattr(self, "avatarId"):
- print "\n\nself.avatarId =", self.avatarId
- print "\nself.neededObjects =", self.neededObjects
- print "\ntimed out after %s seconds.\n\n"%(task.delayTime,)
+ print("\n\nself.avatarId =", self.avatarId)
+ print("\nself.neededObjects =", self.neededObjects)
+ print("\ntimed out after %s seconds.\n\n"%(task.delayTime,))
import pdb; pdb.set_trace()
self.delete()
return Task.done
diff --git a/direct/src/distributed/CRCache.py b/direct/src/distributed/CRCache.py
index 2c3d966778..b256c4f13e 100644
--- a/direct/src/distributed/CRCache.py
+++ b/direct/src/distributed/CRCache.py
@@ -1,7 +1,7 @@
"""CRCache module: contains the CRCache class"""
from direct.directnotify import DirectNotifyGlobal
-import DistributedObject
+from . import DistributedObject
class CRCache:
notify = DirectNotifyGlobal.directNotify.newCategory("CRCache")
diff --git a/direct/src/distributed/CRDataCache.py b/direct/src/distributed/CRDataCache.py
index afc86abaa1..85036544de 100755
--- a/direct/src/distributed/CRDataCache.py
+++ b/direct/src/distributed/CRDataCache.py
@@ -23,7 +23,7 @@ class CRDataCache:
# cache is full, throw out a random doId's data
if self._junkIndex >= len(self._doId2name2data):
self._junkIndex = 0
- junkDoId = self._doId2name2data.keys()[self._junkIndex]
+ junkDoId = list(self._doId2name2data.keys())[self._junkIndex]
self._junkIndex += 1
for name in self._doId2name2data[junkDoId]:
self._doId2name2data[junkDoId][name].flush()
@@ -96,7 +96,7 @@ if __debug__:
assert 'testCachedData2' in data
assert data['testCachedData'].foo == 34
assert data['testCachedData2'].bar == 45
- for cd in data.itervalues():
+ for cd in data.values():
cd.flush()
del data
dc._checkMemLeaks()
diff --git a/direct/src/distributed/ClientRepository.py b/direct/src/distributed/ClientRepository.py
index a22c5b404c..b3745c1355 100644
--- a/direct/src/distributed/ClientRepository.py
+++ b/direct/src/distributed/ClientRepository.py
@@ -1,12 +1,12 @@
"""ClientRepository module: contains the ClientRepository class"""
-from ClientRepositoryBase import ClientRepositoryBase
+from .ClientRepositoryBase import ClientRepositoryBase
from direct.directnotify import DirectNotifyGlobal
-from MsgTypesCMU import *
-from PyDatagram import PyDatagram
-from PyDatagramIterator import PyDatagramIterator
+from .MsgTypesCMU import *
+from .PyDatagram import PyDatagram
+from .PyDatagramIterator import PyDatagramIterator
from panda3d.core import UniqueIdAllocator
-import types
+
class ClientRepository(ClientRepositoryBase):
"""
@@ -305,7 +305,7 @@ class ClientRepository(ClientRepositoryBase):
def handleDatagram(self, di):
if self.notify.getDebug():
- print "ClientRepository received datagram:"
+ print("ClientRepository received datagram:")
di.getDatagram().dumpHex(ostream)
msgType = self.getMsgType()
diff --git a/direct/src/distributed/ClientRepositoryBase.py b/direct/src/distributed/ClientRepositoryBase.py
index 9f60eaac98..9836f0fd0b 100644
--- a/direct/src/distributed/ClientRepositoryBase.py
+++ b/direct/src/distributed/ClientRepositoryBase.py
@@ -1,18 +1,16 @@
from pandac.PandaModules import *
-from MsgTypes import *
+from .MsgTypes import *
from direct.task import Task
from direct.directnotify import DirectNotifyGlobal
-import CRCache
+from . import CRCache
from direct.distributed.CRDataCache import CRDataCache
from direct.distributed.ConnectionRepository import ConnectionRepository
from direct.showbase import PythonUtil
-import ParentMgr
-import RelatedObjectMgr
+from . import ParentMgr
+from . import RelatedObjectMgr
import time
-from ClockDelta import *
-from PyDatagram import PyDatagram
-from PyDatagramIterator import PyDatagramIterator
-import types
+from .ClockDelta import *
+
class ClientRepositoryBase(ConnectionRepository):
"""
@@ -190,7 +188,7 @@ class ClientRepositoryBase(ConnectionRepository):
for dg, di in updates:
# non-DC updates that need to be played back in-order are
# stored as (msgType, (dg, di))
- if type(di) is types.TupleType:
+ if type(di) is tuple:
msgType = dg
dg, di = di
self.replayDeferredGenerate(msgType, (dg, di))
@@ -264,7 +262,7 @@ class ClientRepositoryBase(ConnectionRepository):
distObj.setLocation(parentId, zoneId)
distObj.updateRequiredFields(dclass, di)
# updateRequiredFields calls announceGenerate
- print "New DO:%s, dclass:%s"%(doId, dclass.getName())
+ print("New DO:%s, dclass:%s"%(doId, dclass.getName()))
return distObj
def generateWithRequiredOtherFields(self, dclass, doId, di,
@@ -602,8 +600,8 @@ class ClientRepositoryBase(ConnectionRepository):
del self._delayDeletedDOs[key]
def printDelayDeletes(self):
- print 'DelayDeletes:'
- print '============='
- for obj in self._delayDeletedDOs.itervalues():
- print '%s\t%s (%s)\tdelayDeletes=%s' % (
- obj.doId, safeRepr(obj), itype(obj), obj.getDelayDeleteNames())
+ print('DelayDeletes:')
+ print('=============')
+ for obj in self._delayDeletedDOs.values():
+ print('%s\t%s (%s)\tdelayDeletes=%s' % (
+ obj.doId, safeRepr(obj), itype(obj), obj.getDelayDeleteNames()))
diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py
index 3ff327a5b4..deda5ab5c6 100644
--- a/direct/src/distributed/ConnectionRepository.py
+++ b/direct/src/distributed/ConnectionRepository.py
@@ -4,15 +4,12 @@ from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.distributed.DoInterestManager import DoInterestManager
from direct.distributed.DoCollectionManager import DoCollectionManager
from direct.showbase import GarbageReport
-from PyDatagram import PyDatagram
-from PyDatagramIterator import PyDatagramIterator
+from .PyDatagramIterator import PyDatagramIterator
import types
-import imp
import gc
-
class ConnectionRepository(
DoInterestManager, DoCollectionManager, CConnectionRepository):
"""
@@ -248,7 +245,7 @@ class ConnectionRepository(
self.dclassesByNumber = {}
self.hashVal = 0
- if isinstance(dcFileNames, types.StringTypes):
+ if isinstance(dcFileNames, str):
# If we were given a single string, make it a list.
dcFileNames = [dcFileNames]
@@ -418,7 +415,7 @@ class ConnectionRepository(
if hasattr(module, symbolName):
dcImports[symbolName] = getattr(module, symbolName)
else:
- raise StandardError, 'Symbol %s not defined in module %s.' % (symbolName, moduleName)
+ raise Exception('Symbol %s not defined in module %s.' % (symbolName, moduleName))
else:
# "import moduleName"
@@ -514,7 +511,7 @@ class ConnectionRepository(
if failureCallback:
failureCallback(0, '', *failureArgs)
else:
- print "uh oh, we aren't using one of the tri-state CM variables"
+ print("uh oh, we aren't using one of the tri-state CM variables")
failureCallback(0, '', *failureArgs)
def disconnect(self):
diff --git a/direct/src/distributed/DistributedCamera.py b/direct/src/distributed/DistributedCamera.py
index 7ea07d91bb..297a24bf98 100755
--- a/direct/src/distributed/DistributedCamera.py
+++ b/direct/src/distributed/DistributedCamera.py
@@ -148,8 +148,8 @@ class Fixture(NodePath, FSM):
# if added to the dc definition of the Fixture struct and
# saved out to the Camera file.
lodNodes = render.findAllMatches('**/+LODNode')
- for i in xrange(0,lodNodes.getNumPaths()):
- lodNodes[i].node().forceSwitch(lodNodes[i].node().getHighestSwitch())
+ for lodNode in lodNodes:
+ lodNode.node().forceSwitch(lodNode.node().getHighestSwitch())
def exitUsing(self):
@@ -183,13 +183,13 @@ class DistributedCamera(DistributedObject):
def __str__(self):
out = ''
- for fixture in self.fixtures.itervalues():
+ for fixture in self.fixtures.values():
out = '%s\n%s' % (out, fixture)
return out[1:]
def pack(self):
out = ''
- for fixture in self.fixtures.itervalues():
+ for fixture in self.fixtures.values():
out = '%s\n%s' % (out, fixture.pack())
return out[1:]
@@ -198,7 +198,7 @@ class DistributedCamera(DistributedObject):
self.parent = None
- for fixture in self.fixtures.itervalues():
+ for fixture in self.fixtures.values():
fixture.cleanup()
fixture.detachNode()
self.fixtures = {}
@@ -215,7 +215,7 @@ class DistributedCamera(DistributedObject):
else:
self.parent = self.cr.getDo(doId)
- for fix in self.fixtures.itervalues():
+ for fix in self.fixtures.values():
fix.reparentTo(self.parent)
def getCamParent(self):
diff --git a/direct/src/distributed/DistributedCartesianGrid.py b/direct/src/distributed/DistributedCartesianGrid.py
index 80d0bafc4e..8c156af9d1 100755
--- a/direct/src/distributed/DistributedCartesianGrid.py
+++ b/direct/src/distributed/DistributedCartesianGrid.py
@@ -15,7 +15,7 @@ if __debug__:
from direct.directtools.DirectGeometry import *
from direct.showbase.PythonUtil import randFloat
-from CartesianGridBase import CartesianGridBase
+from .CartesianGridBase import CartesianGridBase
# increase this number if you want to visualize the grid lines
# above water level
diff --git a/direct/src/distributed/DistributedCartesianGridAI.py b/direct/src/distributed/DistributedCartesianGridAI.py
index e9f3b53816..3b830b8028 100755
--- a/direct/src/distributed/DistributedCartesianGridAI.py
+++ b/direct/src/distributed/DistributedCartesianGridAI.py
@@ -2,8 +2,8 @@
from pandac.PandaModules import *
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.task import Task
-from DistributedNodeAI import DistributedNodeAI
-from CartesianGridBase import CartesianGridBase
+from .DistributedNodeAI import DistributedNodeAI
+from .CartesianGridBase import CartesianGridBase
class DistributedCartesianGridAI(DistributedNodeAI, CartesianGridBase):
notify = directNotify.newCategory("DistributedCartesianGridAI")
diff --git a/direct/src/distributed/DistributedNode.py b/direct/src/distributed/DistributedNode.py
index 590a58eeb4..1b0c3412dc 100644
--- a/direct/src/distributed/DistributedNode.py
+++ b/direct/src/distributed/DistributedNode.py
@@ -1,10 +1,9 @@
"""DistributedNode module: contains the DistributedNode class"""
from panda3d.core import NodePath
-from direct.task import Task
-import GridParent
-import DistributedObject
-import types
+from . import GridParent
+from . import DistributedObject
+
class DistributedNode(DistributedObject.DistributedObject, NodePath):
"""Distributed Node class:"""
@@ -77,7 +76,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
### setParent ###
def b_setParent(self, parentToken):
- if type(parentToken) == types.StringType:
+ if type(parentToken) == str:
self.setParentStr(parentToken)
else:
self.setParent(parentToken)
@@ -85,7 +84,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
self.d_setParent(parentToken)
def d_setParent(self, parentToken):
- if type(parentToken) == types.StringType:
+ if type(parentToken) == str:
self.sendUpdate("setParentStr", [parentToken])
else:
self.sendUpdate("setParent", [parentToken])
diff --git a/direct/src/distributed/DistributedNodeAI.py b/direct/src/distributed/DistributedNodeAI.py
index e48fb3e70b..3d30e8d707 100644
--- a/direct/src/distributed/DistributedNodeAI.py
+++ b/direct/src/distributed/DistributedNodeAI.py
@@ -1,7 +1,7 @@
from pandac.PandaModules import NodePath
-import DistributedObjectAI
-import GridParent
-import types
+from . import DistributedObjectAI
+from . import GridParent
+
class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI, NodePath):
def __init__(self, air, name=None):
@@ -47,7 +47,7 @@ class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI, NodePath):
### setParent ###
def b_setParent(self, parentToken):
- if type(parentToken) == types.StringType:
+ if type(parentToken) == str:
self.setParentStr(parentToken)
else:
self.setParent(parentToken)
diff --git a/direct/src/distributed/DistributedNodeUD.py b/direct/src/distributed/DistributedNodeUD.py
index 1924a03420..21d6a2dbbb 100755
--- a/direct/src/distributed/DistributedNodeUD.py
+++ b/direct/src/distributed/DistributedNodeUD.py
@@ -1,5 +1,5 @@
#from otp.ai.AIBaseGlobal import *
-from DistributedObjectUD import DistributedObjectUD
+from .DistributedObjectUD import DistributedObjectUD
class DistributedNodeUD(DistributedObjectUD):
def __init__(self, air, name=None):
@@ -13,7 +13,7 @@ class DistributedNodeUD(DistributedObjectUD):
name = self.__class__.__name__
def b_setParent(self, parentToken):
- if type(parentToken) == types.StringType:
+ if type(parentToken) == str:
self.setParentStr(parentToken)
else:
self.setParent(parentToken)
diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py
index cfd25fda23..0ed3e90a54 100644
--- a/direct/src/distributed/DistributedObject.py
+++ b/direct/src/distributed/DistributedObject.py
@@ -1,6 +1,7 @@
"""DistributedObject module: contains the DistributedObject class"""
-from pandac.PandaModules import *
+from panda3d.core import *
+from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.distributed.DistributedObjectBase import DistributedObjectBase
from direct.showbase.PythonUtil import StackTrace
@@ -80,14 +81,11 @@ class DistributedObject(DistributedObjectBase):
and conditionally show generated, disabled, neverDisable,
or cachable"
"""
- spaces=' '*(indent+2)
+ spaces = ' ' * (indent + 2)
try:
- print "%s%s:"%(
- ' '*indent, self.__class__.__name__)
- print "%sfrom DistributedObject doId:%s, parent:%s, zone:%s"%(
- spaces,
- self.doId, self.parentId, self.zoneId),
- flags=[]
+ print("%s%s:" % (' ' * indent, self.__class__.__name__))
+
+ flags = []
if self.activeState == ESGenerated:
flags.append("generated")
if self.activeState < ESGenerating:
@@ -96,10 +94,15 @@ class DistributedObject(DistributedObjectBase):
flags.append("neverDisable")
if self.cacheable:
flags.append("cacheable")
+
+ flagStr = ""
if len(flags):
- print "(%s)"%(" ".join(flags),),
- print
- except Exception, e: print "%serror printing status"%(spaces,), e
+ flagStr = " (%s)" % (" ".join(flags))
+
+ print("%sfrom DistributedObject doId:%s, parent:%s, zone:%s%s" % (
+ spaces, self.doId, self.parentId, self.zoneId, flagStr))
+ except Exception as e:
+ print("%serror printing status %s" % (spaces, e))
def getAutoInterests(self):
# returns the sub-zones under this object that are automatically
@@ -123,7 +126,7 @@ class DistributedObject(DistributedObjectBase):
p = DCPacker()
p.setUnpackData(field.getDefaultValue())
len = p.rawUnpackUint16()/4
- for i in xrange(len):
+ for i in range(len):
zone = int(p.rawUnpackUint32())
autoInterests.add(zone)
autoInterests.update(autoInterests)
@@ -247,7 +250,7 @@ class DistributedObject(DistributedObjectBase):
# we are going to crash, output the destroyDo stacktrace
self.notify.warning('self.cr is none in _deactivateDO %d' % self.doId)
if hasattr(self, 'destroyDoStackTrace'):
- print self.destroyDoStackTrace
+ print(self.destroyDoStackTrace)
self.__callbacks = {}
self.cr.closeAutoInterests(self)
self.setLocation(0,0)
@@ -260,7 +263,7 @@ class DistributedObject(DistributedObjectBase):
# check for leftover cached data that was not retrieved or flushed by this object
# this will catch typos in the data name in calls to get/setCachedData
if hasattr(self, '_cachedData'):
- for name, cachedData in self._cachedData.iteritems():
+ for name, cachedData in self._cachedData.items():
self.notify.warning('flushing unretrieved cached data: %s' % name)
cachedData.flush()
del self._cachedData
@@ -398,7 +401,7 @@ class DistributedObject(DistributedObjectBase):
def getCurrentContexts(self):
# Returns a list of the currently outstanding contexts created
# by getCallbackContext().
- return self.__callbacks.keys()
+ return list(self.__callbacks.keys())
def getCallback(self, context):
# Returns the callback that was passed in to the previous
diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py
index 18985e42e1..efe5cd02bf 100644
--- a/direct/src/distributed/DistributedObjectAI.py
+++ b/direct/src/distributed/DistributedObjectAI.py
@@ -3,7 +3,8 @@
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.distributed.DistributedObjectBase import DistributedObjectBase
from direct.showbase import PythonUtil
-from pandac.PandaModules import *
+from panda3d.core import *
+from panda3d.direct import *
#from PyDatagram import PyDatagram
#from PyDatagramIterator import PyDatagramIterator
@@ -56,25 +57,26 @@ class DistributedObjectAI(DistributedObjectBase):
def status(self, indent=0):
"""
print out doId(parentId, zoneId) className
- and conditionally show generated, disabled, neverDisable,
- or cachable
+ and conditionally show generated or deleted
"""
- spaces=' '*(indent+2)
+ spaces = ' ' * (indent + 2)
try:
- print "%s%s:"%(
- ' '*indent, self.__class__.__name__)
- print "%sfrom DistributedObject doId:%s, parent:%s, zone:%s"%(
- spaces,
- self.doId, self.parentId, self.zoneId),
- flags=[]
+ print("%s%s:" % (' ' * indent, self.__class__.__name__))
+
+ flags = []
if self.__generated:
flags.append("generated")
if self.air == None:
flags.append("deleted")
+
+ flagStr = ""
if len(flags):
- print "(%s)"%(" ".join(flags),),
- print
- except Exception, e: print "%serror printing status"%(spaces,), e
+ flagStr = " (%s)" % (" ".join(flags))
+
+ print("%sfrom DistributedObject doId:%s, parent:%s, zone:%s%s" % (
+ spaces, self.doId, self.parentId, self.zoneId, flagStr))
+ except Exception as e:
+ print("%serror printing status %s" % (spaces, e))
def getDeleteEvent(self):
# this is sent just before we get deleted
@@ -347,16 +349,16 @@ class DistributedObjectAI(DistributedObjectBase):
self.air.sendUpdate(self, fieldName, args)
def GetPuppetConnectionChannel(self, doId):
- return doId + (1L << 32)
+ return doId + (1 << 32)
def GetAccountConnectionChannel(self, doId):
- return doId + (3L << 32)
+ return doId + (3 << 32)
def GetAccountIDFromChannelCode(self, channel):
return channel >> 32
def GetAvatarIDFromChannelCode(self, channel):
- return channel & 0xffffffffL
+ return channel & 0xffffffff
def sendUpdateToAvatarId(self, avId, fieldName, args):
assert self.notify.debugStateCall(self)
diff --git a/direct/src/distributed/DistributedObjectBase.py b/direct/src/distributed/DistributedObjectBase.py
index 70a7c567ca..e105e4c891 100755
--- a/direct/src/distributed/DistributedObjectBase.py
+++ b/direct/src/distributed/DistributedObjectBase.py
@@ -22,14 +22,13 @@ class DistributedObjectBase(DirectObject):
"""
print out "doId(parentId, zoneId) className"
"""
- spaces=' '*(indent+2)
+ spaces = ' ' * (indent + 2)
try:
- print "%s%s:"%(
- ' '*indent, self.__class__.__name__)
- print "%sfrom DistributedObject doId:%s, parent:%s, zone:%s"%(
- spaces,
- self.doId, self.parentId, self.zoneId),
- except Exception, e: print "%serror printing status"%(spaces,), e
+ print("%s%s:" % (' ' * indent, self.__class__.__name__))
+ print("%sfrom DistributedObject doId:%s, parent:%s, zone:%s" % (
+ spaces, self.doId, self.parentId, self.zoneId))
+ except Exception as e:
+ print("%serror printing status %s" % (spaces, e))
def getLocation(self):
try:
diff --git a/direct/src/distributed/DistributedObjectGlobalAI.py b/direct/src/distributed/DistributedObjectGlobalAI.py
index 10b80be712..28ce8d2c7d 100755
--- a/direct/src/distributed/DistributedObjectGlobalAI.py
+++ b/direct/src/distributed/DistributedObjectGlobalAI.py
@@ -1,5 +1,5 @@
-from DistributedObjectAI import DistributedObjectAI
+from .DistributedObjectAI import DistributedObjectAI
from direct.directnotify.DirectNotifyGlobal import directNotify
diff --git a/direct/src/distributed/DistributedObjectGlobalUD.py b/direct/src/distributed/DistributedObjectGlobalUD.py
index 191c60c685..ce51d8421c 100755
--- a/direct/src/distributed/DistributedObjectGlobalUD.py
+++ b/direct/src/distributed/DistributedObjectGlobalUD.py
@@ -1,6 +1,6 @@
-from DistributedObjectUD import DistributedObjectUD
+from .DistributedObjectUD import DistributedObjectUD
from direct.directnotify.DirectNotifyGlobal import directNotify
import sys
diff --git a/direct/src/distributed/DistributedObjectOV.py b/direct/src/distributed/DistributedObjectOV.py
index ef3c12dd62..52ed2d13be 100755
--- a/direct/src/distributed/DistributedObjectOV.py
+++ b/direct/src/distributed/DistributedObjectOV.py
@@ -40,22 +40,24 @@ class DistributedObjectOV(DistributedObjectBase):
print out "doId(parentId, zoneId) className"
and conditionally show generated, disabled
"""
- spaces=' '*(indent+2)
+ spaces = ' ' * (indent + 2)
try:
- print "%s%s:"%(
- ' '*indent, self.__class__.__name__)
- print "%sfrom DistributedObjectOV doId:%s, parent:%s, zone:%s"%(
- spaces,
- self.doId, self.parentId, self.zoneId),
- flags=[]
+ print("%s%s:" % (' ' * indent, self.__class__.__name__))
+
+ flags = []
if self.activeState == ESGenerated:
flags.append("generated")
if self.activeState < ESGenerating:
flags.append("disabled")
+
+ flagStr = ""
if len(flags):
- print "(%s)"%(" ".join(flags),),
- print
- except Exception, e: print "%serror printing status"%(spaces,), e
+ flagStr = " (%s)" % (" ".join(flags))
+
+ print("%sfrom DistributedObjectOV doId:%s, parent:%s, zone:%s%s" % (
+ spaces, self.doId, self.parentId, self.zoneId, flagStr))
+ except Exception as e:
+ print("%serror printing status %s" % (spaces, e))
def getDelayDeleteCount(self):
diff --git a/direct/src/distributed/DistributedObjectUD.py b/direct/src/distributed/DistributedObjectUD.py
index 7642cd222b..4309ad7d80 100755
--- a/direct/src/distributed/DistributedObjectUD.py
+++ b/direct/src/distributed/DistributedObjectUD.py
@@ -54,24 +54,26 @@ class DistributedObjectUD(DistributedObjectBase):
def status(self, indent=0):
"""
print out doId(parentId, zoneId) className
- and conditionally show generated, disabled, neverDisable,
- or cachable
+ and conditionally show generated or deleted
"""
spaces = ' ' * (indent + 2)
try:
- print "%s%s:" % (' ' * indent, self.__class__.__name__)
- print ("%sfrom "
- "DistributedObject doId:%s, parent:%s, zone:%s" %
- (spaces, self.doId, self.parentId, self.zoneId)),
+ print("%s%s:" % (' ' * indent, self.__class__.__name__))
+
flags = []
if self.__generated:
flags.append("generated")
if self.air == None:
flags.append("deleted")
+
+ flagStr = ""
if len(flags):
- print "(%s)" % (" ".join(flags),),
- print
- except Exception, e: print "%serror printing status" % (spaces,), e
+ flagStr = " (%s)" % (" ".join(flags))
+
+ print("%sfrom DistributedObject doId:%s, parent:%s, zone:%s%s" % (
+ spaces, self.doId, self.parentId, self.zoneId, flagStr))
+ except Exception as e:
+ print("%serror printing status %s" % (spaces, e))
def getDeleteEvent(self):
# this is sent just before we get deleted
@@ -267,16 +269,16 @@ class DistributedObjectUD(DistributedObjectBase):
self.air.sendUpdate(self, fieldName, args)
def GetPuppetConnectionChannel(self, doId):
- return doId + (1L << 32)
+ return doId + (1 << 32)
def GetAccountConnectionChannel(self, doId):
- return doId + (3L << 32)
+ return doId + (3 << 32)
def GetAccountIDFromChannelCode(self, channel):
return channel >> 32
def GetAvatarIDFromChannelCode(self, channel):
- return channel & 0xffffffffL
+ return channel & 0xffffffff
def sendUpdateToAvatarId(self, avId, fieldName, args):
assert self.notify.debugStateCall(self)
diff --git a/direct/src/distributed/DistributedSmoothNode.py b/direct/src/distributed/DistributedSmoothNode.py
index 34ad0ae52b..cdc2dc034e 100644
--- a/direct/src/distributed/DistributedSmoothNode.py
+++ b/direct/src/distributed/DistributedSmoothNode.py
@@ -1,9 +1,9 @@
"""DistributedSmoothNode module: contains the DistributedSmoothNode class"""
from pandac.PandaModules import *
-from ClockDelta import *
-import DistributedNode
-import DistributedSmoothNodeBase
+from .ClockDelta import *
+from . import DistributedNode
+from . import DistributedSmoothNodeBase
from direct.task.Task import cont
# This number defines our tolerance for out-of-sync telemetry packets.
diff --git a/direct/src/distributed/DistributedSmoothNodeAI.py b/direct/src/distributed/DistributedSmoothNodeAI.py
index 968a7ccfa4..fe8ec19b1c 100755
--- a/direct/src/distributed/DistributedSmoothNodeAI.py
+++ b/direct/src/distributed/DistributedSmoothNodeAI.py
@@ -1,5 +1,5 @@
-import DistributedNodeAI
-import DistributedSmoothNodeBase
+from . import DistributedNodeAI
+from . import DistributedSmoothNodeBase
class DistributedSmoothNodeAI(DistributedNodeAI.DistributedNodeAI,
DistributedSmoothNodeBase.DistributedSmoothNodeBase):
diff --git a/direct/src/distributed/DistributedSmoothNodeBase.py b/direct/src/distributed/DistributedSmoothNodeBase.py
index faeda49115..8f7d1c31e4 100755
--- a/direct/src/distributed/DistributedSmoothNodeBase.py
+++ b/direct/src/distributed/DistributedSmoothNodeBase.py
@@ -1,6 +1,6 @@
"""DistributedSmoothNodeBase module: contains the DistributedSmoothNodeBase class"""
-from ClockDelta import *
+from .ClockDelta import *
from direct.task import Task
from direct.showbase.PythonUtil import randFloat, Enum
from panda3d.direct import CDistributedSmoothNodeBase
diff --git a/direct/src/distributed/DoCollectionManager.py b/direct/src/distributed/DoCollectionManager.py
index 691e84f75a..16bf345f4e 100755
--- a/direct/src/distributed/DoCollectionManager.py
+++ b/direct/src/distributed/DoCollectionManager.py
@@ -117,29 +117,29 @@ class DoCollectionManager:
return 1
def dosByDistance(self):
- objs = self.doId2do.values()
+ objs = list(self.doId2do.values())
objs.sort(cmp=self._compareDistance)
return objs
def doByDistance(self):
objs = self.dosByDistance()
for obj in objs:
- print '%s\t%s\t%s' % (obj.doId, self._getDistanceFromLA(obj),
- obj.dclass.getName())
+ print('%s\t%s\t%s' % (obj.doId, self._getDistanceFromLA(obj),
+ obj.dclass.getName()))
if __debug__:
def printObjects(self):
format="%10s %10s %10s %30s %20s"
title=format%("parentId", "zoneId", "doId", "dclass", "name")
- print title
- print '-'*len(title)
+ print(title)
+ print('-'*len(title))
for distObj in self.doId2do.values():
- print format%(
+ print(format%(
distObj.__dict__.get("parentId"),
distObj.__dict__.get("zoneId"),
distObj.__dict__.get("doId"),
distObj.dclass.getName(),
- distObj.__dict__.get("name"))
+ distObj.__dict__.get("name")))
def _printObjects(self, table):
class2count = {}
@@ -148,14 +148,14 @@ class DoCollectionManager:
class2count.setdefault(className, 0)
class2count[className] += 1
count2classes = invertDictLossless(class2count)
- counts = count2classes.keys()
+ counts = list(count2classes.keys())
counts.sort()
counts.reverse()
for count in counts:
count2classes[count].sort()
for name in count2classes[count]:
- print '%s %s' % (count, name)
- print ''
+ print('%s %s' % (count, name))
+ print('')
def _returnObjects(self, table):
class2count = {}
@@ -165,7 +165,7 @@ class DoCollectionManager:
class2count.setdefault(className, 0)
class2count[className] += 1
count2classes = invertDictLossless(class2count)
- counts = count2classes.keys()
+ counts = list(count2classes.keys())
counts.sort()
counts.reverse()
for count in counts:
@@ -189,12 +189,12 @@ class DoCollectionManager:
def printObjectCount(self):
# print object counts by distributed object type
- print '==== OBJECT COUNT ===='
+ print('==== OBJECT COUNT ====')
if self.hasOwnerView():
- print '== doId2do'
+ print('== doId2do')
self._printObjects(self.getDoTable(ownerView=False))
if self.hasOwnerView():
- print '== doId2ownerView'
+ print('== doId2ownerView')
self._printObjects(self.getDoTable(ownerView=True))
def getDoList(self, parentId, zoneId=None, classType=None):
diff --git a/direct/src/distributed/DoInterestManager.py b/direct/src/distributed/DoInterestManager.py
index ed72de562c..a81000a788 100755
--- a/direct/src/distributed/DoInterestManager.py
+++ b/direct/src/distributed/DoInterestManager.py
@@ -8,10 +8,10 @@ p.s. A great deal of this code is just code moved from ClientRepository.py.
"""
from pandac.PandaModules import *
-from MsgTypes import *
+from .MsgTypes import *
from direct.showbase.PythonUtil import *
from direct.showbase import DirectObject
-from PyDatagram import PyDatagram
+from .PyDatagram import PyDatagram
from direct.directnotify.DirectNotifyGlobal import directNotify
import types
from direct.showbase.PythonUtil import report
@@ -184,8 +184,8 @@ class DoInterestManager(DirectObject.DirectObject):
DoInterestManager._interests[handle] = InterestState(
description, InterestState.StateActive, contextId, event, parentId, zoneIdList, self._completeEventCount)
if self.__verbose():
- print 'CR::INTEREST.addInterest(handle=%s, parentId=%s, zoneIdList=%s, description=%s, event=%s)' % (
- handle, parentId, zoneIdList, description, event)
+ print('CR::INTEREST.addInterest(handle=%s, parentId=%s, zoneIdList=%s, description=%s, event=%s)' % (
+ handle, parentId, zoneIdList, description, event))
self._sendAddInterest(handle, contextId, parentId, zoneIdList, description)
if event:
messenger.send(self._getAddInterestEvent(), [event])
@@ -218,8 +218,8 @@ class DoInterestManager(DirectObject.DirectObject):
DoInterestManager._interests[handle] = InterestState(
description, InterestState.StateActive, 0, None, parentId, zoneIdList, self._completeEventCount, True)
if self.__verbose():
- print 'CR::INTEREST.addInterest(handle=%s, parentId=%s, zoneIdList=%s, description=%s)' % (
- handle, parentId, zoneIdList, description)
+ print('CR::INTEREST.addInterest(handle=%s, parentId=%s, zoneIdList=%s, description=%s)' % (
+ handle, parentId, zoneIdList, description))
assert self.printInterestsIfDebug()
return InterestHandle(handle)
@@ -266,8 +266,8 @@ class DoInterestManager(DirectObject.DirectObject):
if not event:
self._considerRemoveInterest(handle)
if self.__verbose():
- print 'CR::INTEREST.removeInterest(handle=%s, event=%s)' % (
- handle, event)
+ print('CR::INTEREST.removeInterest(handle=%s, event=%s)' % (
+ handle, event))
else:
DoInterestManager.notify.warning(
"removeInterest: handle not found: %s" % (handle))
@@ -302,7 +302,7 @@ class DoInterestManager(DirectObject.DirectObject):
intState.state = InterestState.StatePendingDel
self._considerRemoveInterest(handle)
if self.__verbose():
- print 'CR::INTEREST.removeAutoInterest(handle=%s)' % (handle)
+ print('CR::INTEREST.removeAutoInterest(handle=%s)' % (handle))
else:
DoInterestManager.notify.warning(
"removeInterest: handle not found: %s" % (handle))
@@ -357,8 +357,8 @@ class DoInterestManager(DirectObject.DirectObject):
DoInterestManager._interests[handle].addEvent(event)
if self.__verbose():
- print 'CR::INTEREST.alterInterest(handle=%s, parentId=%s, zoneIdList=%s, description=%s, event=%s)' % (
- handle, parentId, zoneIdList, description, event)
+ print('CR::INTEREST.alterInterest(handle=%s, parentId=%s, zoneIdList=%s, description=%s, event=%s)' % (
+ handle, parentId, zoneIdList, description, event))
self._sendAddInterest(handle, contextId, parentId, zoneIdList, description, action='modify')
exists = True
assert self.printInterestsIfDebug()
@@ -445,24 +445,24 @@ class DoInterestManager(DirectObject.DirectObject):
DoInterestManager._debug_maxDescriptionLen, len(description))
def printInterestHistory(self):
- print "***************** Interest History *************"
+ print("***************** Interest History *************")
format = '%9s %' + str(DoInterestManager._debug_maxDescriptionLen) + 's %6s %6s %9s %s'
- print format % (
+ print(format % (
"Action", "Description", "Handle", "Context", "ParentId",
- "ZoneIdList")
+ "ZoneIdList"))
for i in DoInterestManager._debug_interestHistory:
- print format % tuple(i)
- print "Note: interests with a Context of 0 do not get" \
- " done/finished notices."
+ print(format % tuple(i))
+ print("Note: interests with a Context of 0 do not get" \
+ " done/finished notices.")
def printInterestSets(self):
- print "******************* Interest Sets **************"
+ print("******************* Interest Sets **************")
format = '%6s %' + str(DoInterestManager._debug_maxDescriptionLen) + 's %11s %11s %8s %8s %8s'
- print format % (
+ print(format % (
"Handle", "Description",
"ParentId", "ZoneIdList",
"State", "Context",
- "Event")
+ "Event"))
for id, state in DoInterestManager._interests.items():
if len(state.events) == 0:
event = ''
@@ -470,11 +470,11 @@ class DoInterestManager(DirectObject.DirectObject):
event = state.events[0]
else:
event = state.events
- print format % (id, state.desc,
+ print(format % (id, state.desc,
state.parentId, state.zoneIdList,
state.state, state.context,
- event)
- print "************************************************"
+ event))
+ print("************************************************")
def printInterests(self):
self.printInterestHistory()
@@ -492,7 +492,7 @@ class DoInterestManager(DirectObject.DirectObject):
"""
assert DoInterestManager.notify.debugCall()
if __debug__:
- if isinstance(zoneIdList, types.ListType):
+ if isinstance(zoneIdList, list):
zoneIdList.sort()
if action is None:
action = 'add'
@@ -507,7 +507,7 @@ class DoInterestManager(DirectObject.DirectObject):
datagram.addUint16(handle)
datagram.addUint32(contextId)
datagram.addUint32(parentId)
- if isinstance(zoneIdList, types.ListType):
+ if isinstance(zoneIdList, list):
vzl = list(zoneIdList)
vzl.sort()
uniqueElements(vzl)
@@ -585,7 +585,7 @@ class DoInterestManager(DirectObject.DirectObject):
handle = di.getUint16()
contextId = di.getUint32()
if self.__verbose():
- print 'CR::INTEREST.interestDone(handle=%s)' % handle
+ print('CR::INTEREST.interestDone(handle=%s)' % handle)
DoInterestManager.notify.debug(
"handleInterestDoneMessage--> Received handle %s, context %s" % (
handle, contextId))
diff --git a/direct/src/distributed/GridChild.py b/direct/src/distributed/GridChild.py
index 78b35f8c67..462c4d841e 100755
--- a/direct/src/distributed/GridChild.py
+++ b/direct/src/distributed/GridChild.py
@@ -106,7 +106,7 @@ class GridChild:
self._gridInterests[gridDoId] = [None,zoneId]
def getGridInterestIds(self):
- return self._gridInterests.keys()
+ return list(self._gridInterests.keys())
def getGridInterestZoneId(self,gridDoId):
return self._gridInterests.get(gridDoId,[None,None])[1]
diff --git a/direct/src/distributed/NetMessenger.py b/direct/src/distributed/NetMessenger.py
index 0d24e2a1ff..03c666d2ea 100755
--- a/direct/src/distributed/NetMessenger.py
+++ b/direct/src/distributed/NetMessenger.py
@@ -1,10 +1,14 @@
-from cPickle import dumps, loads
-
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.PyDatagram import PyDatagram
from direct.showbase.Messenger import Messenger
+import sys
+if sys.version_info >= (3, 0):
+ from pickle import dumps, loads
+else:
+ from cPickle import dumps, loads
+
# Messages do not need to be in the MESSAGE_TYPES list.
# This is just an optimization. If the message is found
diff --git a/direct/src/distributed/OldClientRepository.py b/direct/src/distributed/OldClientRepository.py
index 2e996cc5df..daeb4af628 100644
--- a/direct/src/distributed/OldClientRepository.py
+++ b/direct/src/distributed/OldClientRepository.py
@@ -1,6 +1,6 @@
"""OldClientRepository module: contains the OldClientRepository class"""
-from ClientRepositoryBase import *
+from .ClientRepositoryBase import *
class OldClientRepository(ClientRepositoryBase):
"""
@@ -126,7 +126,7 @@ class OldClientRepository(ClientRepositoryBase):
def handleDatagram(self, di):
if self.notify.getDebug():
- print "ClientRepository received datagram:"
+ print("ClientRepository received datagram:")
di.getDatagram().dumpHex(ostream)
msgType = self.getMsgType()
diff --git a/direct/src/distributed/ParentMgr.py b/direct/src/distributed/ParentMgr.py
index 434c3cbd64..6e52b1097b 100644
--- a/direct/src/distributed/ParentMgr.py
+++ b/direct/src/distributed/ParentMgr.py
@@ -2,7 +2,7 @@
from direct.directnotify import DirectNotifyGlobal
from direct.showbase.PythonUtil import isDefaultValue
-import types
+
class ParentMgr:
# This is now used on the AI as well.
@@ -90,7 +90,7 @@ class ParentMgr:
if isDefaultValue(token):
self.notify.error('parent token (for %s) cannot be a default value (%s)' % (repr(parent), token))
- if type(token) is types.IntType:
+ if type(token) is int:
if token > 0xFFFFFFFF:
self.notify.error('parent token %s (for %s) is out of uint32 range' % (token, repr(parent)))
diff --git a/direct/src/distributed/ServerRepository.py b/direct/src/distributed/ServerRepository.py
index 613b88788f..11cec06ac3 100644
--- a/direct/src/distributed/ServerRepository.py
+++ b/direct/src/distributed/ServerRepository.py
@@ -5,9 +5,7 @@ from direct.distributed.MsgTypesCMU import *
from direct.task import Task
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.PyDatagram import PyDatagram
-from direct.distributed.PyDatagramIterator import PyDatagramIterator
-import time
-import types
+
class ServerRepository:
@@ -153,7 +151,7 @@ class ServerRepository:
for client in flush:
client.connection.flush()
- return task.again
+ return Task.again
def setTcpHeaderSize(self, headerSize):
"""Sets the header size of TCP packets. At the present, legal
@@ -192,7 +190,7 @@ class ServerRepository:
dcImports[symbolName] = getattr(module, symbolName)
else:
- raise StandardError, 'Symbol %s not defined in module %s.' % (symbolName, moduleName)
+ raise Exception('Symbol %s not defined in module %s.' % (symbolName, moduleName))
else:
# "import moduleName"
@@ -299,7 +297,7 @@ class ServerRepository:
retVal = self.qcl.getNewConnection(rendezvous, netAddress,
newConnection)
if not retVal:
- return task.cont
+ return Task.cont
# Crazy dereferencing
newConnection = newConnection.p()
@@ -321,13 +319,13 @@ class ServerRepository:
self.lastConnection = newConnection
self.sendDoIdRange(client)
- return task.cont
+ return Task.cont
def readerPollUntilEmpty(self, task):
""" continuously polls for new messages on the server """
while self.readerPollOnce():
pass
- return task.cont
+ return Task.cont
def readerPollOnce(self):
""" checks for available messages to the server """
@@ -691,7 +689,7 @@ class ServerRepository:
for client in self.clientsByConnection.values():
if not self.qcr.isConnectionOk(client.connection):
self.handleClientDisconnect(client)
- return task.cont
+ return Task.cont
def sendToZoneExcept(self, zoneId, datagram, exceptionList):
"""sends a message to everyone who has interest in the
diff --git a/direct/src/distributed/TimeManagerAI.py b/direct/src/distributed/TimeManagerAI.py
index a9aed1222e..c912394326 100644
--- a/direct/src/distributed/TimeManagerAI.py
+++ b/direct/src/distributed/TimeManagerAI.py
@@ -18,6 +18,6 @@ class TimeManagerAI(DistributedObjectAI.DistributedObjectAI):
"""
timestamp = globalClockDelta.getRealNetworkTime(bits=32)
requesterId = self.air.getAvatarIdFromSender()
- print "requestServerTime from %s" % (requesterId)
+ print("requestServerTime from %s" % (requesterId))
self.sendUpdateToAvatarId(requesterId, "serverTime",
[context, timestamp])
diff --git a/direct/src/doc/howto.adjust b/direct/src/doc/howto.adjust
index 5862e708a2..cf6925ad2f 100644
--- a/direct/src/doc/howto.adjust
+++ b/direct/src/doc/howto.adjust
@@ -52,7 +52,10 @@ of the slider to change settings. Click on:
You can pack multiple sliders into a single panel:
-from Tkinter import *
+if sys.version_info >= (3, 0):
+ from tkinter import *
+else:
+ from Tkinter import *
def func1(x):
print '1:', x
diff --git a/direct/src/extensions_native/CInterval_extensions.py b/direct/src/extensions_native/CInterval_extensions.py
index eb82fc50f3..9ed7ff48a0 100644
--- a/direct/src/extensions_native/CInterval_extensions.py
+++ b/direct/src/extensions_native/CInterval_extensions.py
@@ -63,14 +63,17 @@ def popupControls(self, tl = None):
import math
# Don't use a regular import, to prevent ModuleFinder from picking
# it up as a dependency when building a .p3d package.
- import importlib
+ import importlib, sys
EntryScale = importlib.import_module('direct.tkwidgets.EntryScale')
- Tkinter = importlib.import_module('Tkinter')
+ if sys.version_info >= (3, 0):
+ tkinter = importlib.import_module('tkinter')
+ else:
+ tkinter = importlib.import_module('Tkinter')
if tl == None:
- tl = Tkinter.Toplevel()
+ tl = tkinter.Toplevel()
tl.title('Interval Controls')
- outerFrame = Tkinter.Frame(tl)
+ outerFrame = tkinter.Frame(tl)
def entryScaleCommand(t, s=self):
s.setT(t)
s.pause()
@@ -79,8 +82,8 @@ def popupControls(self, tl = None):
min = 0, max = math.floor(self.getDuration() * 100) / 100,
command = entryScaleCommand)
es.set(self.getT(), fCommand = 0)
- es.pack(expand = 1, fill = Tkinter.X)
- bf = Tkinter.Frame(outerFrame)
+ es.pack(expand = 1, fill = tkinter.X)
+ bf = tkinter.Frame(outerFrame)
# Jump to start and end
def toStart(s=self, es=es):
s.setT(0.0)
@@ -88,23 +91,23 @@ def popupControls(self, tl = None):
def toEnd(s=self):
s.setT(s.getDuration())
s.pause()
- jumpToStart = Tkinter.Button(bf, text = '<<', command = toStart)
+ jumpToStart = tkinter.Button(bf, text = '<<', command = toStart)
# Stop/play buttons
def doPlay(s=self, es=es):
s.resume(es.get())
- stop = Tkinter.Button(bf, text = 'Stop',
+ stop = tkinter.Button(bf, text = 'Stop',
command = lambda s=self: s.pause())
- play = Tkinter.Button(
+ play = tkinter.Button(
bf, text = 'Play',
command = doPlay)
- jumpToEnd = Tkinter.Button(bf, text = '>>', command = toEnd)
- jumpToStart.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- play.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- stop.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- jumpToEnd.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- bf.pack(expand = 1, fill = Tkinter.X)
- outerFrame.pack(expand = 1, fill = Tkinter.X)
+ jumpToEnd = tkinter.Button(bf, text = '>>', command = toEnd)
+ jumpToStart.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ play.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ stop.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ jumpToEnd.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ bf.pack(expand = 1, fill = tkinter.X)
+ outerFrame.pack(expand = 1, fill = tkinter.X)
# Add function to update slider during setT calls
def update(t, es=es):
es.set(t, fCommand = 0)
diff --git a/direct/src/extensions_native/NodePath_extensions.py b/direct/src/extensions_native/NodePath_extensions.py
index 7383ae1e06..4c388becf7 100644
--- a/direct/src/extensions_native/NodePath_extensions.py
+++ b/direct/src/extensions_native/NodePath_extensions.py
@@ -690,7 +690,7 @@ def subdivideCollisions(self, numSolidsInLeaves):
# this CollisionNode doesn't need to be split
continue
solids = []
- for i in xrange(numSolids):
+ for i in range(numSolids):
solids.append(node.getSolid(i))
# recursively subdivide the solids into a spatial binary tree
solidTree = self.r_subdivideCollisions(solids, numSolidsInLeaves)
@@ -743,7 +743,7 @@ def r_subdivideCollisions(self, solids, numSolidsInLeaves):
midY += maxExtent
if extentZ < (maxExtent * .75) or extentZ > (maxExtent * 1.25):
midZ += maxExtent
- for i in xrange(len(solids)):
+ for i in range(len(solids)):
origin = origins[i]
x = origin.getX(); y = origin.getY(); z = origin.getZ()
if x < midX:
diff --git a/direct/src/extensions_native/extension_native_helpers.py b/direct/src/extensions_native/extension_native_helpers.py
index c6747e7272..e9648e7440 100644
--- a/direct/src/extensions_native/extension_native_helpers.py
+++ b/direct/src/extensions_native/extension_native_helpers.py
@@ -1,7 +1,6 @@
-### Tools
__all__ = ["Dtool_ObjectToDict", "Dtool_funcToMethod"]
-import imp, sys, os
+import sys
def Dtool_ObjectToDict(cls, name, obj):
cls.DtoolClassDict[name] = obj
@@ -11,8 +10,10 @@ def Dtool_funcToMethod(func, cls, method_name=None):
The new method is accessible to any instance immediately."""
if sys.version_info < (3, 0):
func.im_class = cls
- func.im_func = func
- func.im_self = None
+ func.im_func = func
+ func.im_self = None
+ func.__func__ = func
+ func.__self__ = None
if not method_name:
method_name = func.__name__
cls.DtoolClassDict[method_name] = func
diff --git a/direct/src/filter/CommonFilters.py b/direct/src/filter/CommonFilters.py
index c861561066..9cfe72d987 100644
--- a/direct/src/filter/CommonFilters.py
+++ b/direct/src/filter/CommonFilters.py
@@ -15,7 +15,7 @@ clunky approach. - Josh
"""
-from FilterManager import FilterManager
+from .FilterManager import FilterManager
from panda3d.core import LVecBase4, LPoint2
from panda3d.core import Filename
from panda3d.core import AuxBitplaneAttrib
diff --git a/direct/src/fsm/ClassicFSM.py b/direct/src/fsm/ClassicFSM.py
index a0d6045c5f..847cf290db 100644
--- a/direct/src/fsm/ClassicFSM.py
+++ b/direct/src/fsm/ClassicFSM.py
@@ -10,18 +10,15 @@ existing code. New code should use the FSM module instead.
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
-import types
import weakref
if __debug__:
- _debugFsms={}
+ _debugFsms = {}
def printDebugFsmList():
global _debugFsms
- keys=_debugFsms.keys()
- keys.sort()
- for k in keys:
- print k, _debugFsms[k]()
- __builtins__['debugFsmList']=printDebugFsmList
+ for k in sorted(_debugFsms.keys()):
+ print("%s %s" % (k, _debugFsms[k]()))
+ __builtins__['debugFsmList'] = printDebugFsmList
class ClassicFSM(DirectObject):
"""
@@ -123,7 +120,7 @@ class ClassicFSM(DirectObject):
self.__name = name
def getStates(self):
- return self.__states.values()
+ return list(self.__states.values())
def setStates(self, states):
"""setStates(self, State[])"""
@@ -251,7 +248,7 @@ class ClassicFSM(DirectObject):
(self.__name))
self.__currentState = self.__initialState
- if isinstance(aStateName, types.StringType):
+ if isinstance(aStateName, str):
aState = self.getStateNamed(aStateName)
else:
# Allow the caller to pass in a state in itself, not just
@@ -342,7 +339,7 @@ class ClassicFSM(DirectObject):
(self.__name))
self.__currentState = self.__initialState
- if isinstance(aStateName, types.StringType):
+ if isinstance(aStateName, str):
aState = self.getStateNamed(aStateName)
else:
# Allow the caller to pass in a state in itself, not just
diff --git a/direct/src/fsm/FSM.py b/direct/src/fsm/FSM.py
index 1c0465b74d..a62bede3f0 100644
--- a/direct/src/fsm/FSM.py
+++ b/direct/src/fsm/FSM.py
@@ -9,7 +9,7 @@ from direct.showbase.DirectObject import DirectObject
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import PythonUtil
from direct.stdpy.threading import RLock
-import types
+
class FSMException(Exception):
pass
@@ -190,7 +190,7 @@ class FSM(DirectObject):
def getCurrentFilter(self):
if not self.state:
error = "FSM cannot determine current filter while in transition (%s -> %s)." % (self.oldState, self.newState)
- raise AlreadyInTransition, error
+ raise AlreadyInTransition(error)
filter = getattr(self, "filter" + self.state, None)
if not filter:
@@ -238,7 +238,7 @@ class FSM(DirectObject):
self.fsmLock.acquire()
try:
- assert isinstance(request, types.StringTypes)
+ assert isinstance(request, str)
self.notify.debug("%s.forceTransition(%s, %s" % (
self.name, request, str(args)[1:]))
@@ -266,7 +266,7 @@ class FSM(DirectObject):
self.fsmLock.acquire()
try:
- assert isinstance(request, types.StringTypes)
+ assert isinstance(request, str)
self.notify.debug("%s.demand(%s, %s" % (
self.name, request, str(args)[1:]))
if not self.state:
@@ -276,7 +276,7 @@ class FSM(DirectObject):
return
if not self.request(request, *args):
- raise RequestDenied, "%s (from state: %s)" % (request, self.state)
+ raise RequestDenied("%s (from state: %s)" % (request, self.state))
finally:
self.fsmLock.release()
@@ -305,14 +305,14 @@ class FSM(DirectObject):
self.fsmLock.acquire()
try:
- assert isinstance(request, types.StringTypes)
+ assert isinstance(request, str)
self.notify.debug("%s.request(%s, %s" % (
self.name, request, str(args)[1:]))
filter = self.getCurrentFilter()
- result = filter(request, args)
+ result = list(filter(request, args))
if result:
- if isinstance(result, types.StringTypes):
+ if isinstance(result, str):
# If the return value is a string, it's just the name
# of the state. Wrap it in a tuple for consistency.
result = (result,) + args
@@ -381,7 +381,7 @@ class FSM(DirectObject):
# request) not listed in defaultTransitions and not
# handled by an earlier filter.
if request[0].isupper():
- raise RequestDenied, "%s (from state: %s)" % (request, self.state)
+ raise RequestDenied("%s (from state: %s)" % (request, self.state))
# In either case, we quietly ignore unhandled command
# (lowercase) requests.
diff --git a/direct/src/fsm/FourState.py b/direct/src/fsm/FourState.py
index 790439e901..df653825f9 100755
--- a/direct/src/fsm/FourState.py
+++ b/direct/src/fsm/FourState.py
@@ -6,8 +6,8 @@ __all__ = ['FourState']
from direct.directnotify import DirectNotifyGlobal
#import DistributedObject
-import ClassicFSM
-import State
+from . import ClassicFSM
+from . import State
class FourState:
@@ -122,7 +122,7 @@ class FourState:
}
self.stateIndex = 0
self.fsm = ClassicFSM.ClassicFSM('FourState',
- self.states.values(),
+ list(self.states.values()),
# Initial State
names[0],
# Final State
diff --git a/direct/src/fsm/FourStateAI.py b/direct/src/fsm/FourStateAI.py
index 814d8f057a..6f5ff8d966 100755
--- a/direct/src/fsm/FourStateAI.py
+++ b/direct/src/fsm/FourStateAI.py
@@ -6,8 +6,8 @@ __all__ = ['FourStateAI']
from direct.directnotify import DirectNotifyGlobal
#import DistributedObjectAI
-import ClassicFSM
-import State
+from . import ClassicFSM
+from . import State
from direct.task import Task
@@ -128,7 +128,7 @@ class FourStateAI:
[names[1]]),
}
self.fsm = ClassicFSM.ClassicFSM('FourState',
- self.states.values(),
+ list(self.states.values()),
# Initial State
names[0],
# Final State
diff --git a/direct/src/fsm/SampleFSM.py b/direct/src/fsm/SampleFSM.py
index b3b6fa88ed..9db513afa2 100644
--- a/direct/src/fsm/SampleFSM.py
+++ b/direct/src/fsm/SampleFSM.py
@@ -2,9 +2,8 @@
__all__ = ['ClassicStyle', 'NewStyle', 'ToonEyes']
-import FSM
+from . import FSM
from direct.task import Task
-import string
class ClassicStyle(FSM.FSM):
@@ -19,61 +18,61 @@ class ClassicStyle(FSM.FSM):
}
def enterRed(self):
- print "enterRed(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("enterRed(self, '%s', '%s')" % (self.oldState, self.newState))
def exitRed(self):
- print "exitRed(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("exitRed(self, '%s', '%s')" % (self.oldState, self.newState))
def enterYellow(self):
- print "enterYellow(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("enterYellow(self, '%s', '%s')" % (self.oldState, self.newState))
def exitYellow(self):
- print "exitYellow(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("exitYellow(self, '%s', '%s')" % (self.oldState, self.newState))
def enterGreen(self):
- print "enterGreen(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("enterGreen(self, '%s', '%s')" % (self.oldState, self.newState))
def exitGreen(self):
- print "exitGreen(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("exitGreen(self, '%s', '%s')" % (self.oldState, self.newState))
class NewStyle(FSM.FSM):
def enterRed(self):
- print "enterRed(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("enterRed(self, '%s', '%s')" % (self.oldState, self.newState))
def filterRed(self, request, args):
- print "filterRed(self, '%s', %s)" % (request, args)
+ print("filterRed(self, '%s', %s)" % (request, args))
if request == 'advance':
return 'Green'
return self.defaultFilter(request, args)
def exitRed(self):
- print "exitRed(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("exitRed(self, '%s', '%s')" % (self.oldState, self.newState))
def enterYellow(self):
- print "enterYellow(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("enterYellow(self, '%s', '%s')" % (self.oldState, self.newState))
def filterYellow(self, request, args):
- print "filterYellow(self, '%s', %s)" % (request, args)
+ print("filterYellow(self, '%s', %s)" % (request, args))
if request == 'advance':
return 'Red'
return self.defaultFilter(request, args)
def exitYellow(self):
- print "exitYellow(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("exitYellow(self, '%s', '%s')" % (self.oldState, self.newState))
def enterGreen(self):
- print "enterGreen(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("enterGreen(self, '%s', '%s')" % (self.oldState, self.newState))
def filterGreen(self, request, args):
- print "filterGreen(self, '%s', %s)" % (request, args)
+ print("filterGreen(self, '%s', %s)" % (request, args))
if request == 'advance':
return 'Yellow'
return self.defaultFilter(request, args)
def exitGreen(self):
- print "exitGreen(self, '%s', '%s')" % (self.oldState, self.newState)
+ print("exitGreen(self, '%s', '%s')" % (self.oldState, self.newState))
class ToonEyes(FSM.FSM):
@@ -88,14 +87,14 @@ class ToonEyes(FSM.FSM):
def defaultFilter(self, request, args):
# The default filter accepts any direct state request (these
# start with a capital letter).
- if request[0] in string.uppercase:
+ if request[0].isupper():
return request
# Unexpected command requests are quietly ignored.
return None
def enterOpen(self):
- print "swap in eyes open model"
+ print("swap in eyes open model")
def filterOpen(self, request, args):
if request == 'blink':
@@ -109,7 +108,7 @@ class ToonEyes(FSM.FSM):
return Task.done
def enterClosed(self):
- print "swap in eyes closed model"
+ print("swap in eyes closed model")
def filterClosed(self, request, args):
if request == 'unblink':
@@ -117,7 +116,7 @@ class ToonEyes(FSM.FSM):
return self.defaultFilter(request, args)
def enterSurprised(self):
- print "swap in eyes surprised model"
+ print("swap in eyes surprised model")
def enterOff(self):
taskMgr.remove(self.__unblinkName)
diff --git a/direct/src/fsm/State.py b/direct/src/fsm/State.py
index 3be6501002..3842b0844b 100644
--- a/direct/src/fsm/State.py
+++ b/direct/src/fsm/State.py
@@ -30,18 +30,18 @@ class State(DirectObject):
exitFunc = state.getExitFunc()
# print 'testing: ', state, enterFunc, exitFunc, oldFunction
if type(enterFunc) == types.MethodType:
- if (enterFunc.im_func == oldFunction):
+ if enterFunc.__func__ == oldFunction:
# print 'found: ', enterFunc, oldFunction
state.setEnterFunc(types.MethodType(newFunction,
- enterFunc.im_self,
- enterFunc.im_class))
+ enterFunc.__self__,
+ enterFunc.__self__.__class__))
count += 1
if type(exitFunc) == types.MethodType:
- if (exitFunc.im_func == oldFunction):
+ if exitFunc.__func__ == oldFunction:
# print 'found: ', exitFunc, oldFunction
state.setExitFunc(types.MethodType(newFunction,
- exitFunc.im_self,
- exitFunc.im_class))
+ exitFunc.__self__,
+ exitFunc.__self__.__class__))
count += 1
return count
@@ -199,7 +199,7 @@ class State(DirectObject):
self.__enterChildren(argList)
if (self.__enterFunc != None):
- apply(self.__enterFunc, argList)
+ self.__enterFunc(*argList)
def exit(self, argList=[]):
"""
@@ -210,7 +210,7 @@ class State(DirectObject):
# call exit function if it exists
if (self.__exitFunc != None):
- apply(self.__exitFunc, argList)
+ self.__exitFunc(*argList)
def __str__(self):
return "State: name = %s, enter = %s, exit = %s, trans = %s, children = %s" %\
diff --git a/direct/src/fsm/StateData.py b/direct/src/fsm/StateData.py
index 82ce729d93..9223d3c12c 100644
--- a/direct/src/fsm/StateData.py
+++ b/direct/src/fsm/StateData.py
@@ -5,7 +5,6 @@ __all__ = ['StateData']
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
-from direct.directnotify import DirectNotifyGlobal
class StateData(DirectObject):
"""
diff --git a/direct/src/fsm/StatePush.py b/direct/src/fsm/StatePush.py
index 0d30a8c3f8..fe0f496158 100755
--- a/direct/src/fsm/StatePush.py
+++ b/direct/src/fsm/StatePush.py
@@ -16,8 +16,8 @@ class PushesStateChanges:
def destroy(self):
if len(self._subscribers) != 0:
- raise '%s object still has subscribers in destroy(): %s' % (
- self.__class__.__name__, self._subscribers)
+ raise Exception('%s object still has subscribers in destroy(): %s' % (
+ self.__class__.__name__, self._subscribers))
del self._subscribers
del self._value
@@ -154,7 +154,7 @@ class ReceivesMultipleStateChanges:
self._source2key = {}
def destroy(self):
- keys = self._key2source.keys()
+ keys = list(self._key2source.keys())
for key in keys:
self._unsubscribe(key)
del self._key2source
@@ -202,15 +202,14 @@ class FunctionCall(ReceivesMultipleStateChanges, PushesStateChanges):
# the value of arguments that push state
self._bakedArgs = []
self._bakedKargs = {}
- for i in xrange(len(self._args)):
+ for i, arg in enumerate(self._args):
key = i
- arg = self._args[i]
if isinstance(arg, PushesStateChanges):
self._bakedArgs.append(arg.getState())
self._subscribeTo(arg, key)
else:
self._bakedArgs.append(self._args[i])
- for key, arg in self._kArgs.iteritems():
+ for key, arg in self._kArgs.items():
if isinstance(arg, PushesStateChanges):
self._bakedKargs[key] = arg.getState()
self._subscribeTo(arg, key)
diff --git a/direct/src/gui/DirectButton.py b/direct/src/gui/DirectButton.py
index f5dcee7413..87077d20a0 100644
--- a/direct/src/gui/DirectButton.py
+++ b/direct/src/gui/DirectButton.py
@@ -3,8 +3,8 @@
__all__ = ['DirectButton']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
class DirectButton(DirectFrame):
"""
@@ -100,7 +100,7 @@ class DirectButton(DirectFrame):
def commandFunc(self, event):
if self['command']:
# Pass any extra args to command
- apply(self['command'], self['extraArgs'])
+ self['command'](*self['extraArgs'])
def setClickSound(self):
clickSound = self['clickSound']
diff --git a/direct/src/gui/DirectCheckBox.py b/direct/src/gui/DirectCheckBox.py
index e0e2f8dc24..26b561edaf 100755
--- a/direct/src/gui/DirectCheckBox.py
+++ b/direct/src/gui/DirectCheckBox.py
@@ -55,5 +55,5 @@ class DirectCheckBox(DirectButton):
if self['command']:
# Pass any extra args to command
- apply(self['command'], [self['isChecked']] + self['extraArgs'])
+ self['command'](*[self['isChecked']] + self['extraArgs'])
diff --git a/direct/src/gui/DirectCheckButton.py b/direct/src/gui/DirectCheckButton.py
index 5212031600..3df28a0730 100644
--- a/direct/src/gui/DirectCheckButton.py
+++ b/direct/src/gui/DirectCheckButton.py
@@ -3,8 +3,8 @@
__all__ = ['DirectCheckButton']
from panda3d.core import *
-from DirectButton import *
-from DirectLabel import *
+from .DirectButton import *
+from .DirectLabel import *
class DirectCheckButton(DirectButton):
"""
@@ -169,7 +169,7 @@ class DirectCheckButton(DirectButton):
if self['command']:
# Pass any extra args to command
- apply(self['command'], [self['indicatorValue']] + self['extraArgs'])
+ self['command'](*[self['indicatorValue']] + self['extraArgs'])
def setIndicatorValue(self):
self.component('indicator').guiItem.setState(self['indicatorValue'])
diff --git a/direct/src/gui/DirectDialog.py b/direct/src/gui/DirectDialog.py
index b1d245b1b1..039092c511 100644
--- a/direct/src/gui/DirectDialog.py
+++ b/direct/src/gui/DirectDialog.py
@@ -3,9 +3,9 @@
__all__ = ['findDialog', 'cleanupDialog', 'DirectDialog', 'OkDialog', 'OkCancelDialog', 'YesNoDialog', 'YesNoCancelDialog', 'RetryCancelDialog']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
-from DirectButton import *
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
+from .DirectButton import *
import types
def findDialog(uniqueName):
@@ -186,8 +186,8 @@ class DirectDialog(DirectFrame):
bindList = zip(self.buttonList, self['buttonHotKeyList'],
self['buttonValueList'])
for button, hotKey, value in bindList:
- if ((type(hotKey) == types.ListType) or
- (type(hotKey) == types.TupleType)):
+ if ((type(hotKey) == list) or
+ (type(hotKey) == tuple)):
for key in hotKey:
button.bind('press-' + key + '-', self.buttonCommand,
extraArgs = [value])
@@ -274,12 +274,12 @@ class DirectDialog(DirectFrame):
scale = self['button_scale']
# Can either be a Vec3 or a tuple of 3 values
if (isinstance(scale, Vec3) or
- (type(scale) == types.ListType) or
- (type(scale) == types.TupleType)):
+ (type(scale) == list) or
+ (type(scale) == tuple)):
sx = scale[0]
sz = scale[2]
- elif ((type(scale) == types.IntType) or
- (type(scale) == types.FloatType)):
+ elif ((type(scale) == int) or
+ (type(scale) == float)):
sx = sz = scale
else:
sx = sz = 1
diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py
index ceddf741f7..45733b7c35 100644
--- a/direct/src/gui/DirectEntry.py
+++ b/direct/src/gui/DirectEntry.py
@@ -3,10 +3,10 @@
__all__ = ['DirectEntry']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
-from OnscreenText import OnscreenText
-import string,types
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
+from .OnscreenText import OnscreenText
+import sys
# import this to make sure it gets pulled into the publish
import encodings.utf_8
from direct.showbase.DirectObject import DirectObject
@@ -181,12 +181,12 @@ class DirectEntry(DirectFrame):
def commandFunc(self, event):
if self['command']:
# Pass any extra args to command
- apply(self['command'], [self.get()] + self['extraArgs'])
+ self['command'](*[self.get()] + self['extraArgs'])
def failedCommandFunc(self, event):
if self['failedCommand']:
# Pass any extra args
- apply(self['failedCommand'], [self.get()] + self['failedExtraArgs'])
+ self['failedCommand'](*[self.get()] + self['failedExtraArgs'])
def autoCapitalizeFunc(self):
if self['autoCapitalize']:
@@ -198,7 +198,7 @@ class DirectEntry(DirectFrame):
def focusInCommandFunc(self):
if self['focusInCommand']:
- apply(self['focusInCommand'], self['focusInExtraArgs'])
+ self['focusInCommand'](*self['focusInExtraArgs'])
if self['autoCapitalize']:
self.accept(self.guiItem.getTypeEvent(), self._handleTyping)
self.accept(self.guiItem.getEraseEvent(), self._handleErasing)
@@ -216,14 +216,13 @@ class DirectEntry(DirectFrame):
wordSoFar = ''
# track whether the previous character was part of a word or not
wasNonWordChar = True
- for i in xrange(len(name)):
- character = name[i]
+ for i, character in enumerate(name):
# test to see if we are between words
# - Count characters that can't be capitalized as a break between words
# This assumes that string.lower and string.upper will return different
# values for all unicode letters.
# - Don't count apostrophes as a break between words
- if ((string.lower(character) == string.upper(character)) and (character != "'")):
+ if character.lower() == character.upper() and character != "'":
# we are between words
wordSoFar = ''
wasNonWordChar = True
@@ -232,7 +231,7 @@ class DirectEntry(DirectFrame):
if wasNonWordChar:
# first letter of a word, capitalize it unconditionally;
capitalize = True
- elif (character == string.upper(character) and
+ elif (character == character.upper() and
len(self.autoCapitalizeAllowPrefixes) and
wordSoFar in self.autoCapitalizeAllowPrefixes):
# first letter after one of the prefixes, allow it to be capitalized
@@ -243,9 +242,9 @@ class DirectEntry(DirectFrame):
capitalize = True
if capitalize:
# allow this letter to remain capitalized
- character = string.upper(character)
+ character = character.upper()
else:
- character = string.lower(character)
+ character = character.lower()
wordSoFar += character
wasNonWordChar = False
capName += character
@@ -253,7 +252,7 @@ class DirectEntry(DirectFrame):
def focusOutCommandFunc(self):
if self['focusOutCommand']:
- apply(self['focusOutCommand'], self['focusOutExtraArgs'])
+ self['focusOutCommand'](*self['focusOutExtraArgs'])
if self['autoCapitalize']:
self.ignore(self.guiItem.getTypeEvent())
self.ignore(self.guiItem.getEraseEvent())
@@ -263,11 +262,16 @@ class DirectEntry(DirectFrame):
does not change the current cursor position. Also see
enterText(). """
- self.unicodeText = isinstance(text, types.UnicodeType)
- if self.unicodeText:
+ if sys.version_info >= (3, 0):
+ assert not isinstance(text, bytes)
+ self.unicodeText = True
self.guiItem.setWtext(text)
else:
- self.guiItem.setText(text)
+ self.unicodeText = isinstance(text, unicode)
+ if self.unicodeText:
+ self.guiItem.setWtext(text)
+ else:
+ self.guiItem.setText(text)
def get(self, plain = False):
""" Returns the text currently showing in the typable region.
diff --git a/direct/src/gui/DirectEntryScroll.py b/direct/src/gui/DirectEntryScroll.py
index 3fe1599b1b..0cd7c3ea21 100644
--- a/direct/src/gui/DirectEntryScroll.py
+++ b/direct/src/gui/DirectEntryScroll.py
@@ -1,10 +1,10 @@
__all__ = ['DirectEntryScroll']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectScrolledFrame import *
-from DirectFrame import *
-from DirectEntry import *
+from . import DirectGuiGlobals as DGG
+from .DirectScrolledFrame import *
+from .DirectFrame import *
+from .DirectEntry import *
class DirectEntryScroll(DirectFrame):
def __init__(self, entry, parent = None, **kw):
diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py
index 2f5ed61241..9c164038b9 100644
--- a/direct/src/gui/DirectFrame.py
+++ b/direct/src/gui/DirectFrame.py
@@ -3,11 +3,17 @@
__all__ = ['DirectFrame']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectGuiBase import *
-from OnscreenImage import OnscreenImage
-from OnscreenGeom import OnscreenGeom
-import types
+from . import DirectGuiGlobals as DGG
+from .DirectGuiBase import *
+from .OnscreenImage import OnscreenImage
+from .OnscreenGeom import OnscreenGeom
+import sys
+
+if sys.version_info >= (3, 0):
+ stringType = str
+else:
+ stringType = basestring
+
class DirectFrame(DirectGuiWidget):
DefDynGroups = ('text', 'geom', 'image')
@@ -54,7 +60,7 @@ class DirectFrame(DirectGuiWidget):
# Determine if user passed in single string or a sequence
if self['text'] == None:
textList = (None,) * self['numStates']
- elif isinstance(self['text'], types.StringTypes):
+ elif isinstance(self['text'], stringType):
# If just passing in a single string, make a tuple out of it
textList = (self['text'],) * self['numStates']
else:
@@ -80,7 +86,7 @@ class DirectFrame(DirectGuiWidget):
if text == None:
return
else:
- from OnscreenText import OnscreenText
+ from .OnscreenText import OnscreenText
self.createcomponent(
component, (), 'text',
OnscreenText,
@@ -97,7 +103,7 @@ class DirectFrame(DirectGuiWidget):
# Passed in None
geomList = (None,) * self['numStates']
elif isinstance(geom, NodePath) or \
- isinstance(geom, types.StringTypes):
+ isinstance(geom, stringType):
# Passed in a single node path, make a tuple out of it
geomList = (geom,) * self['numStates']
else:
@@ -139,14 +145,14 @@ class DirectFrame(DirectGuiWidget):
imageList = (None,) * self['numStates']
elif isinstance(arg, NodePath) or \
isinstance(arg, Texture) or \
- isinstance(arg, types.StringTypes):
+ isinstance(arg, stringType):
# Passed in a single node path, make a tuple out of it
imageList = (arg,) * self['numStates']
else:
# Otherwise, hope that the user has passed in a tuple/list
if ((len(arg) == 2) and
- isinstance(arg[0], types.StringTypes) and
- isinstance(arg[1], types.StringTypes)):
+ isinstance(arg[0], stringType) and
+ isinstance(arg[1], stringType)):
# Its a model/node pair of strings
imageList = (arg,) * self['numStates']
else:
diff --git a/direct/src/gui/DirectGui.py b/direct/src/gui/DirectGui.py
index 1d3c0636de..e0a59abb82 100644
--- a/direct/src/gui/DirectGui.py
+++ b/direct/src/gui/DirectGui.py
@@ -1,9 +1,9 @@
-"""Undocumented Module"""
+""" Imports all of the DirectGUI classes. """
-import DirectGuiGlobals as DGG
-from OnscreenText import *
-from OnscreenGeom import *
-from OnscreenImage import *
+from . import DirectGuiGlobals as DGG
+from .OnscreenText import *
+from .OnscreenGeom import *
+from .OnscreenImage import *
# MPG DirectStart should call this?
# Set up default font
@@ -12,17 +12,17 @@ from OnscreenImage import *
# PGItem.getTextNode().setFont(defaultFont)
# Direct Gui Classes
-from DirectFrame import *
-from DirectButton import *
-from DirectEntry import *
-from DirectEntryScroll import *
-from DirectLabel import *
-from DirectScrolledList import *
-from DirectDialog import *
-from DirectWaitBar import *
-from DirectSlider import *
-from DirectScrollBar import *
-from DirectScrolledFrame import *
-from DirectCheckButton import *
-from DirectOptionMenu import *
-from DirectRadioButton import *
+from .DirectFrame import *
+from .DirectButton import *
+from .DirectEntry import *
+from .DirectEntryScroll import *
+from .DirectLabel import *
+from .DirectScrolledList import *
+from .DirectDialog import *
+from .DirectWaitBar import *
+from .DirectSlider import *
+from .DirectScrollBar import *
+from .DirectScrolledFrame import *
+from .DirectCheckButton import *
+from .DirectOptionMenu import *
+from .DirectRadioButton import *
diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py
index 41322bcdff..833bf8ebcb 100644
--- a/direct/src/gui/DirectGuiBase.py
+++ b/direct/src/gui/DirectGuiBase.py
@@ -5,14 +5,19 @@ __all__ = ['DirectGuiBase', 'DirectGuiWidget']
from panda3d.core import *
from panda3d.direct import get_config_showbase
-import DirectGuiGlobals as DGG
-from OnscreenText import *
-from OnscreenGeom import *
-from OnscreenImage import *
+from . import DirectGuiGlobals as DGG
+from .OnscreenText import *
+from .OnscreenGeom import *
+from .OnscreenImage import *
from direct.directtools.DirectUtil import ROUND_TO
from direct.showbase import DirectObject
from direct.task import Task
-import types
+import sys
+
+if sys.version_info >= (3, 0):
+ stringType = str
+else:
+ stringType = basestring
guiObjectCollector = PStatCollector("Client::GuiObjects")
@@ -243,7 +248,7 @@ class DirectGuiBase(DirectObject.DirectObject):
# Now check if anything is left over
unusedOptions = []
keywords = self._constructorKeywords
- for name in keywords.keys():
+ for name in keywords:
used = keywords[name][1]
if not used:
# This keyword argument has not been used. If it
@@ -258,8 +263,8 @@ class DirectGuiBase(DirectObject.DirectObject):
text = 'Unknown option "'
else:
text = 'Unknown options "'
- raise KeyError, text + ', '.join(unusedOptions) + \
- '" for ' + myClass.__name__
+ raise KeyError(text + ', '.join(unusedOptions) + \
+ '" for ' + myClass.__name__)
# Can now call post init func
self.postInitialiseFunc()
@@ -350,8 +355,8 @@ class DirectGuiBase(DirectObject.DirectObject):
# This is one of the options of this gui item.
# Check it is an initialisation option.
if optionInfo[option][FUNCTION] is DGG.INITOPT:
- print 'Cannot configure initialisation option "' \
- + option + '" for ' + self.__class__.__name__
+ print('Cannot configure initialisation option "' \
+ + option + '" for ' + self.__class__.__name__)
break
#raise KeyError, \
# 'Cannot configure initialisation option "' \
@@ -399,8 +404,8 @@ class DirectGuiBase(DirectObject.DirectObject):
if len(componentConfigFuncs) == 0 and \
component not in self._dynamicGroups:
- raise KeyError, 'Unknown option "' + option + \
- '" for ' + self.__class__.__name__
+ raise KeyError('Unknown option "' + option + \
+ '" for ' + self.__class__.__name__)
# Add the configure method(s) (may be more than
# one if this is configuring a component group)
@@ -413,8 +418,8 @@ class DirectGuiBase(DirectObject.DirectObject):
indirectOptions[componentConfigFunc][componentOption] \
= value
else:
- raise KeyError, 'Unknown option "' + option + \
- '" for ' + self.__class__.__name__
+ raise KeyError('Unknown option "' + option + \
+ '" for ' + self.__class__.__name__)
# Call the configure methods for any components.
# Pass in the dictionary of keyword/values created above
@@ -468,8 +473,8 @@ class DirectGuiBase(DirectObject.DirectObject):
return componentCget(componentOption)
# Option not found
- raise KeyError, 'Unknown option "' + option + \
- '" for ' + self.__class__.__name__
+ raise KeyError('Unknown option "' + option + \
+ '" for ' + self.__class__.__name__)
# Allow index style refererences
__getitem__ = cget
@@ -481,8 +486,7 @@ class DirectGuiBase(DirectObject.DirectObject):
"""
# Check for invalid component name
if '_' in componentName:
- raise ValueError, \
- 'Component name "%s" must not contain "_"' % componentName
+ raise ValueError('Component name "%s" must not contain "_"' % componentName)
# Get construction keywords
if hasattr(self, '_constructorKeywords'):
@@ -507,7 +511,7 @@ class DirectGuiBase(DirectObject.DirectObject):
# with corresponding keys beginning with *component*.
alias = alias + '_'
aliasLen = len(alias)
- for option in keywords.keys():
+ for option in keywords.copy():
if len(option) > aliasLen and option[:aliasLen] == alias:
newkey = component + '_' + option[aliasLen:]
keywords[newkey] = keywords[option]
@@ -520,7 +524,7 @@ class DirectGuiBase(DirectObject.DirectObject):
# First, walk through the option list looking for arguments
# than refer to this component's group.
- for option in keywords.keys():
+ for option in keywords:
# Check if this keyword argument refers to the group
# of this component. If so, add this to the options
# to use when constructing the widget. Mark the
@@ -539,7 +543,7 @@ class DirectGuiBase(DirectObject.DirectObject):
# specific than the group arguments, above; we walk through
# the list afterwards so they will override.
- for option in keywords.keys():
+ for option in keywords.copy():
if len(option) > nameLen and option[:nameLen] == componentPrefix:
# The keyword argument refers to this component, so add
# this to the options to use when constructing the widget.
@@ -551,7 +555,7 @@ class DirectGuiBase(DirectObject.DirectObject):
if widgetClass is None:
return None
# Get arguments for widget constructor
- if len(widgetArgs) == 1 and type(widgetArgs[0]) == types.TupleType:
+ if len(widgetArgs) == 1 and type(widgetArgs[0]) == tuple:
# Arguments to the constructor can be specified as either
# multiple trailing arguments to createcomponent() or as a
# single tuple argument.
@@ -601,7 +605,7 @@ class DirectGuiBase(DirectObject.DirectObject):
def components(self):
# Return a list of all components.
- names = self.__componentInfo.keys()
+ names = list(self.__componentInfo.keys())
names.sort()
return names
@@ -632,8 +636,8 @@ class DirectGuiBase(DirectObject.DirectObject):
gEvent = event + self.guiId
if get_config_showbase().GetBool('debug-directgui-msgs', False):
from direct.showbase.PythonUtil import StackTrace
- print gEvent
- print StackTrace()
+ print(gEvent)
+ print(StackTrace())
self.accept(gEvent, command, extraArgs = extraArgs)
def unbind(self, event):
@@ -945,7 +949,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
# Convert None, and string arguments
if relief == None:
relief = PGFrameStyle.TNone
- elif isinstance(relief, types.StringTypes):
+ elif isinstance(relief, stringType):
# Convert string to frame style int
relief = DGG.FrameStyleDict[relief]
# Set style
@@ -970,8 +974,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
def setFrameColor(self):
# this might be a single color or a list of colors
colors = self['frameColor']
- if type(colors[0]) == types.IntType or \
- type(colors[0]) == types.FloatType:
+ if type(colors[0]) == int or \
+ type(colors[0]) == float:
colors = (colors,)
for i in range(self['numStates']):
if i >= len(colors):
@@ -986,14 +990,14 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
textures = self['frameTexture']
if textures == None or \
isinstance(textures, Texture) or \
- isinstance(textures, types.StringTypes):
+ isinstance(textures, stringType):
textures = (textures,) * self['numStates']
for i in range(self['numStates']):
if i >= len(textures):
texture = textures[-1]
else:
texture = textures[i]
- if isinstance(texture, types.StringTypes):
+ if isinstance(texture, stringType):
texture = loader.loadTexture(texture)
if texture:
self.frameStyle[i].setTexture(texture)
@@ -1058,9 +1062,9 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
def printConfig(self, indent = 0):
space = ' ' * indent
- print space + self.guiId, '-', self.__class__.__name__
- print space + 'Pos: %s' % tuple(self.getPos())
- print space + 'Scale: %s' % tuple(self.getScale())
+ print('%s%s - %s' % (space, self.guiId, self.__class__.__name__))
+ print('%sPos: %s' % (space, tuple(self.getPos())))
+ print('%sScale: %s' % (space, tuple(self.getScale())))
# Print out children info
for child in self.getChildren():
messenger.send(DGG.PRINT + child.getName(), [indent + 2])
diff --git a/direct/src/gui/DirectGuiTest.py b/direct/src/gui/DirectGuiTest.py
index 6172aef04d..c68c705b0e 100644
--- a/direct/src/gui/DirectGuiTest.py
+++ b/direct/src/gui/DirectGuiTest.py
@@ -5,8 +5,8 @@ __all__ = []
if __name__ == "__main__":
from direct.showbase.ShowBase import ShowBase
- import DirectGuiGlobals
- from DirectGui import *
+ from . import DirectGuiGlobals
+ from .DirectGui import *
#from whrandom import *
from random import *
@@ -18,7 +18,7 @@ if __name__ == "__main__":
# Here we specify the button's command
def dummyCmd(index):
- print 'Button %d POW!!!!' % index
+ print('Button %d POW!!!!' % index)
# Define some commands to bind to enter, exit and click events
def shrink(db):
@@ -94,7 +94,7 @@ if __name__ == "__main__":
# DIRECT ENTRY EXAMPLE
def printEntryText(text):
- print 'Text:', text
+ print('Text: %s' % (text))
# Here we create an entry, and specify everything up front
# CALL de1.get() and de1.set('new text') to get and set entry contents
@@ -110,7 +110,7 @@ if __name__ == "__main__":
# DIRECT DIALOG EXAMPLE
def printDialogValue(value):
- print 'Value:', value
+ print('Value: %s' % (value))
simpleDialog = YesNoDialog(text = 'Simple',
command = printDialogValue)
@@ -136,9 +136,9 @@ if __name__ == "__main__":
# NOTE: There are some utility functions which help you get size
# of a direct gui widget. These can be used to position and scale an
# image after you've created the entry. scale = (width/2, 1, height/2)
- print 'BOUNDS:', de1.getBounds()
- print 'WIDTH:', de1.getWidth()
- print 'HEIGHT:', de1.getHeight()
- print 'CENTER:', de1.getCenter()
+ print('BOUNDS: %s' % de1.getBounds())
+ print('WIDTH: %s' % de1.getWidth())
+ print('HEIGHT: %s' % de1.getHeight())
+ print('CENTER: %s' % (de1.getCenter(),))
base.run()
diff --git a/direct/src/gui/DirectLabel.py b/direct/src/gui/DirectLabel.py
index 6dd31c6096..5cb2932900 100644
--- a/direct/src/gui/DirectLabel.py
+++ b/direct/src/gui/DirectLabel.py
@@ -3,7 +3,7 @@
__all__ = ['DirectLabel']
from panda3d.core import *
-from DirectFrame import *
+from .DirectFrame import *
class DirectLabel(DirectFrame):
"""
diff --git a/direct/src/gui/DirectOptionMenu.py b/direct/src/gui/DirectOptionMenu.py
index 7dfc758fee..e2432a5512 100644
--- a/direct/src/gui/DirectOptionMenu.py
+++ b/direct/src/gui/DirectOptionMenu.py
@@ -2,13 +2,11 @@
__all__ = ['DirectOptionMenu']
-import types
-
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectButton import *
-from DirectLabel import *
-from DirectFrame import *
+from . import DirectGuiGlobals as DGG
+from .DirectButton import *
+from .DirectLabel import *
+from .DirectFrame import *
class DirectOptionMenu(DirectButton):
"""
@@ -252,7 +250,7 @@ class DirectOptionMenu(DirectButton):
def index(self, index):
intIndex = None
- if isinstance(index, types.IntType):
+ if isinstance(index, int):
intIndex = index
elif index in self['items']:
i = 0
@@ -272,7 +270,7 @@ class DirectOptionMenu(DirectButton):
self['text'] = item
if fCommand and self['command']:
# Pass any extra args to command
- apply(self['command'], [item] + self['extraArgs'])
+ self['command'](*[item] + self['extraArgs'])
def get(self):
""" Get currently selected item """
diff --git a/direct/src/gui/DirectRadioButton.py b/direct/src/gui/DirectRadioButton.py
index 2b0f0473e4..8044e81295 100755
--- a/direct/src/gui/DirectRadioButton.py
+++ b/direct/src/gui/DirectRadioButton.py
@@ -3,9 +3,9 @@
__all__ = ['DirectRadioButton']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectButton import *
-from DirectLabel import *
+from . import DirectGuiGlobals as DGG
+from .DirectButton import *
+from .DirectLabel import *
class DirectRadioButton(DirectButton):
"""
@@ -205,7 +205,7 @@ class DirectRadioButton(DirectButton):
if self['command']:
# Pass any extra args to command
- apply(self['command'], self['extraArgs'])
+ self['command'](*self['extraArgs'])
def setOthers(self, others):
self['others'] = others
diff --git a/direct/src/gui/DirectScrollBar.py b/direct/src/gui/DirectScrollBar.py
index a2a6f70ab2..8493547e0d 100644
--- a/direct/src/gui/DirectScrollBar.py
+++ b/direct/src/gui/DirectScrollBar.py
@@ -3,9 +3,9 @@
__all__ = ['DirectScrollBar']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
-from DirectButton import *
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
+from .DirectButton import *
"""
import DirectScrollBar
@@ -142,7 +142,7 @@ class DirectScrollBar(DirectFrame):
elif self['orientation'] == DGG.VERTICAL_INVERTED:
self.guiItem.setAxis(Vec3(0, 0, 1))
else:
- raise ValueError, 'Invalid value for orientation: %s' % (self['orientation'])
+ raise ValueError('Invalid value for orientation: %s' % (self['orientation']))
def setManageButtons(self):
self.guiItem.setManagePieces(self['manageButtons'])
@@ -164,5 +164,5 @@ class DirectScrollBar(DirectFrame):
self._optionInfo['value'][DGG._OPT_VALUE] = self.guiItem.getValue()
if self['command']:
- apply(self['command'], self['extraArgs'])
+ self['command'](*self['extraArgs'])
diff --git a/direct/src/gui/DirectScrolledFrame.py b/direct/src/gui/DirectScrolledFrame.py
index 325582ef52..6a7be7cabf 100644
--- a/direct/src/gui/DirectScrolledFrame.py
+++ b/direct/src/gui/DirectScrolledFrame.py
@@ -3,9 +3,9 @@
__all__ = ['DirectScrolledFrame']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
-from DirectScrollBar import *
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
+from .DirectScrollBar import *
"""
import DirectScrolledFrame
@@ -87,7 +87,7 @@ class DirectScrolledFrame(DirectFrame):
def commandFunc(self):
if self['command']:
- apply(self['command'], self['extraArgs'])
+ self['command'](*self['extraArgs'])
def destroy(self):
# Destroy children of the canvas
diff --git a/direct/src/gui/DirectScrolledList.py b/direct/src/gui/DirectScrolledList.py
index 3bd5c9fd07..58d981950b 100644
--- a/direct/src/gui/DirectScrolledList.py
+++ b/direct/src/gui/DirectScrolledList.py
@@ -3,12 +3,11 @@
__all__ = ['DirectScrolledListItem', 'DirectScrolledList']
from panda3d.core import *
-import DirectGuiGlobals as DGG
+from . import DirectGuiGlobals as DGG
from direct.directnotify import DirectNotifyGlobal
from direct.task.Task import Task
-from DirectFrame import *
-from DirectButton import *
-import types
+from .DirectFrame import *
+from .DirectButton import *
class DirectScrolledListItem(DirectButton):
@@ -39,7 +38,7 @@ class DirectScrolledListItem(DirectButton):
def select(self):
assert self.notify.debugStateCall(self)
- apply(self.nextCommand, self.nextCommandExtraArgs)
+ self.nextCommand(*self.nextCommandExtraArgs)
self.parent.selectListItem(self)
@@ -49,7 +48,7 @@ class DirectScrolledList(DirectFrame):
def __init__(self, parent = None, **kw):
assert self.notify.debugStateCall(self)
self.index = 0
- self.forceHeight = None
+ self.__forceHeight = None
""" If one were to want a scrolledList that makes and adds its items
as needed, simply pass in an items list of strings (type 'str')
@@ -115,12 +114,12 @@ class DirectScrolledList(DirectFrame):
def setForceHeight(self):
assert self.notify.debugStateCall(self)
- self.forceHeight = self["forceHeight"]
+ self.__forceHeight = self["forceHeight"]
def recordMaxHeight(self):
assert self.notify.debugStateCall(self)
- if self.forceHeight is not None:
- self.maxHeight = self.forceHeight
+ if self.__forceHeight is not None:
+ self.maxHeight = self.__forceHeight
else:
self.maxHeight = 0.0
for item in self["items"]:
@@ -130,24 +129,24 @@ class DirectScrolledList(DirectFrame):
def setScrollSpeed(self):
assert self.notify.debugStateCall(self)
# Items per second to move
- self.scrollSpeed = self["scrollSpeed"]
- if self.scrollSpeed <= 0:
- self.scrollSpeed = 1
+ self.__scrollSpeed = self["scrollSpeed"]
+ if self.__scrollSpeed <= 0:
+ self.__scrollSpeed = 1
def setNumItemsVisible(self):
assert self.notify.debugStateCall(self)
# Items per second to move
- self.numItemsVisible = self["numItemsVisible"]
+ self.__numItemsVisible = self["numItemsVisible"]
def destroy(self):
assert self.notify.debugStateCall(self)
taskMgr.remove(self.taskName("scroll"))
if hasattr(self, "currentSelected"):
del self.currentSelected
- if self.incButtonCallback:
- self.incButtonCallback = None
- if self.decButtonCallback:
- self.decButtonCallback = None
+ if self.__incButtonCallback:
+ self.__incButtonCallback = None
+ if self.__decButtonCallback:
+ self.__decButtonCallback = None
self.incButton.destroy()
self.decButton.destroy()
DirectFrame.destroy(self)
@@ -169,10 +168,10 @@ class DirectScrolledList(DirectFrame):
#for i in range(len(self["items"])):
# print "buttontext[", i,"]", self["items"][i]["text"]
- if(len(self["items"])==0):
+ if len(self["items"]) == 0:
return 0
- if(type(self["items"][0])!=types.InstanceType):
+ if type(self["items"][0]) == type(''):
self.notify.warning("getItemIndexForItemID: cant find itemID for non-class list items!")
return 0
@@ -251,7 +250,7 @@ class DirectScrolledList(DirectFrame):
if item.__class__.__name__ == 'str':
if self['itemMakeFunction']:
# If there is a function to create the item
- item = apply(self['itemMakeFunction'], (item, i, self['itemMakeExtraArgs']))
+ item = self['itemMakeFunction'](item, i, self['itemMakeExtraArgs'])
else:
item = DirectFrame(text = item,
text_align = self['itemsAlign'],
@@ -269,7 +268,7 @@ class DirectScrolledList(DirectFrame):
if self['command']:
# Pass any extra args to command
- apply(self['command'], self['extraArgs'])
+ self['command'](*self['extraArgs'])
return ret
def makeAllItems(self):
@@ -283,8 +282,7 @@ class DirectScrolledList(DirectFrame):
if item.__class__.__name__ == 'str':
if self['itemMakeFunction']:
# If there is a function to create the item
- item = apply(self['itemMakeFunction'],
- (item, i, self['itemMakeExtraArgs']))
+ item = self['itemMakeFunction'](item, i, self['itemMakeExtraArgs'])
else:
item = DirectFrame(text = item,
text_align = self['itemsAlign'],
@@ -310,7 +308,7 @@ class DirectScrolledList(DirectFrame):
def __incButtonDown(self, event):
assert self.notify.debugStateCall(self)
task = Task(self.__scrollByTask)
- task.setDelay(1.0 / self.scrollSpeed)
+ task.setDelay(1.0 / self.__scrollSpeed)
task.prevTime = 0.0
task.delta = 1
taskName = self.taskName("scroll")
@@ -318,13 +316,13 @@ class DirectScrolledList(DirectFrame):
taskMgr.add(task, taskName)
self.scrollBy(task.delta)
messenger.send('wakeup')
- if self.incButtonCallback:
- self.incButtonCallback()
+ if self.__incButtonCallback:
+ self.__incButtonCallback()
def __decButtonDown(self, event):
assert self.notify.debugStateCall(self)
task = Task(self.__scrollByTask)
- task.setDelay(1.0 / self.scrollSpeed)
+ task.setDelay(1.0 / self.__scrollSpeed)
task.prevTime = 0.0
task.delta = -1
taskName = self.taskName("scroll")
@@ -332,8 +330,8 @@ class DirectScrolledList(DirectFrame):
taskMgr.add(task, taskName)
self.scrollBy(task.delta)
messenger.send('wakeup')
- if self.decButtonCallback:
- self.decButtonCallback()
+ if self.__decButtonCallback:
+ self.__decButtonCallback()
def __buttonUp(self, event):
assert self.notify.debugStateCall(self)
@@ -346,7 +344,7 @@ class DirectScrolledList(DirectFrame):
Add this string and extraArg to the list
"""
assert self.notify.debugStateCall(self)
- if(type(item) == types.InstanceType):
+ if type(item) != type(''):
# cant add attribs to non-classes (like strings & ints)
item.itemID = self.nextItemID
self.nextItemID += 1
@@ -355,7 +353,7 @@ class DirectScrolledList(DirectFrame):
item.reparentTo(self.itemFrame)
if refresh:
self.refresh()
- if(type(item) == types.InstanceType):
+ if type(item) != type(''):
return item.itemID # to pass to scrollToItemID
def removeItem(self, item, refresh=1):
@@ -467,11 +465,11 @@ class DirectScrolledList(DirectFrame):
def setIncButtonCallback(self):
assert self.notify.debugStateCall(self)
- self.incButtonCallback = self["incButtonCallback"]
+ self.__incButtonCallback = self["incButtonCallback"]
def setDecButtonCallback(self):
assert self.notify.debugStateCall(self)
- self.decButtonCallback = self["decButtonCallback"]
+ self.__decButtonCallback = self["decButtonCallback"]
"""
diff --git a/direct/src/gui/DirectSlider.py b/direct/src/gui/DirectSlider.py
index 40737e6c9f..73f5410e49 100644
--- a/direct/src/gui/DirectSlider.py
+++ b/direct/src/gui/DirectSlider.py
@@ -3,9 +3,9 @@
__all__ = ['DirectSlider']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
-from DirectButton import *
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
+from .DirectButton import *
"""
import DirectSlider
@@ -111,7 +111,7 @@ class DirectSlider(DirectFrame):
elif self['orientation'] == DGG.VERTICAL:
self.guiItem.setAxis(Vec3(0, 0, 1))
else:
- raise ValueError, 'Invalid value for orientation: %s' % (self['orientation'])
+ raise ValueError('Invalid value for orientation: %s' % (self['orientation']))
def destroy(self):
if (hasattr(self, 'thumb')):
@@ -124,4 +124,4 @@ class DirectSlider(DirectFrame):
self._optionInfo['value'][DGG._OPT_VALUE] = self.guiItem.getValue()
if self['command']:
- apply(self['command'], self['extraArgs'])
+ self['command'](*self['extraArgs'])
diff --git a/direct/src/gui/DirectWaitBar.py b/direct/src/gui/DirectWaitBar.py
index ac4509987d..a8eb9a56cc 100644
--- a/direct/src/gui/DirectWaitBar.py
+++ b/direct/src/gui/DirectWaitBar.py
@@ -3,9 +3,14 @@
__all__ = ['DirectWaitBar']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from DirectFrame import *
-import types
+from . import DirectGuiGlobals as DGG
+from .DirectFrame import *
+import sys
+
+if sys.version_info >= (3, 0):
+ stringType = str
+else:
+ stringType = basestring
"""
import DirectWaitBar
@@ -93,7 +98,7 @@ class DirectWaitBar(DirectFrame):
"""Updates the bar texture, which you can set using bar['barTexture']."""
# this must be a single texture (or a string).
texture = self['barTexture']
- if isinstance(texture, types.StringTypes):
+ if isinstance(texture, stringType):
texture = loader.loadTexture(texture)
if texture:
self.barStyle.setTexture(texture)
diff --git a/direct/src/gui/OnscreenGeom.py b/direct/src/gui/OnscreenGeom.py
index faf020a2d1..e1a35a77d1 100644
--- a/direct/src/gui/OnscreenGeom.py
+++ b/direct/src/gui/OnscreenGeom.py
@@ -4,7 +4,12 @@ __all__ = ['OnscreenGeom']
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
-import types
+import sys
+
+if sys.version_info >= (3, 0):
+ stringType = str
+else:
+ stringType = basestring
class OnscreenGeom(DirectObject, NodePath):
def __init__(self, geom = None,
@@ -49,25 +54,25 @@ class OnscreenGeom(DirectObject, NodePath):
# Adjust pose
# Set pos
- if (isinstance(pos, types.TupleType) or
- isinstance(pos, types.ListType)):
- apply(self.setPos, pos)
+ if (isinstance(pos, tuple) or
+ isinstance(pos, list)):
+ self.setPos(*pos)
elif isinstance(pos, VBase3):
self.setPos(pos)
# Hpr
- if (isinstance(hpr, types.TupleType) or
- isinstance(hpr, types.ListType)):
- apply(self.setHpr, hpr)
+ if (isinstance(hpr, tuple) or
+ isinstance(hpr, list)):
+ self.setHpr(*hpr)
elif isinstance(hpr, VBase3):
self.setPos(hpr)
# Scale
- if (isinstance(scale, types.TupleType) or
- isinstance(scale, types.ListType)):
- apply(self.setScale, scale)
+ if (isinstance(scale, tuple) or
+ isinstance(scale, list)):
+ self.setScale(*scale)
elif isinstance(scale, VBase3):
self.setPos(scale)
- elif (isinstance(scale, types.FloatType) or
- isinstance(scale, types.IntType)):
+ elif (isinstance(scale, float) or
+ isinstance(scale, int)):
self.setScale(scale)
def setGeom(self, geom,
@@ -93,7 +98,7 @@ class OnscreenGeom(DirectObject, NodePath):
# Assign geometry
if isinstance(geom, NodePath):
self.assign(geom.copyTo(parent, sort))
- elif isinstance(geom, types.StringTypes):
+ elif isinstance(geom, stringType):
self.assign(loader.loadModel(geom))
self.reparentTo(parent, sort)
@@ -116,17 +121,17 @@ class OnscreenGeom(DirectObject, NodePath):
if (((setter == self.setPos) or
(setter == self.setHpr) or
(setter == self.setScale)) and
- (isinstance(value, types.TupleType) or
- isinstance(value, types.ListType))):
- apply(setter, value)
+ (isinstance(value, tuple) or
+ isinstance(value, list))):
+ setter(*value)
else:
setter(value)
except AttributeError:
- print 'OnscreenText.configure: invalid option:', option
+ print('OnscreenText.configure: invalid option: %s' % option)
# Allow index style references
def __setitem__(self, key, value):
- apply(self.configure, (), {key: value})
+ self.configure(*(), **{key: value})
def cget(self, option):
# Get current configuration setting.
diff --git a/direct/src/gui/OnscreenImage.py b/direct/src/gui/OnscreenImage.py
index 7f4579886d..026076fc69 100644
--- a/direct/src/gui/OnscreenImage.py
+++ b/direct/src/gui/OnscreenImage.py
@@ -4,7 +4,13 @@ __all__ = ['OnscreenImage']
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
-import types
+import sys
+
+if sys.version_info >= (3, 0):
+ stringType = str
+else:
+ stringType = basestring
+
class OnscreenImage(DirectObject, NodePath):
def __init__(self, image = None,
@@ -49,25 +55,25 @@ class OnscreenImage(DirectObject, NodePath):
# Adjust pose
# Set pos
- if (isinstance(pos, types.TupleType) or
- isinstance(pos, types.ListType)):
- apply(self.setPos, pos)
+ if (isinstance(pos, tuple) or
+ isinstance(pos, list)):
+ self.setPos(*pos)
elif isinstance(pos, VBase3):
self.setPos(pos)
# Hpr
- if (isinstance(hpr, types.TupleType) or
- isinstance(hpr, types.ListType)):
- apply(self.setHpr, hpr)
+ if (isinstance(hpr, tuple) or
+ isinstance(hpr, list)):
+ self.setHpr(*hpr)
elif isinstance(hpr, VBase3):
self.setHpr(hpr)
# Scale
- if (isinstance(scale, types.TupleType) or
- isinstance(scale, types.ListType)):
- apply(self.setScale, scale)
+ if (isinstance(scale, tuple) or
+ isinstance(scale, list)):
+ self.setScale(*scale)
elif isinstance(scale, VBase3):
self.setScale(scale)
- elif (isinstance(scale, types.FloatType) or
- isinstance(scale, types.IntType)):
+ elif (isinstance(scale, float) or
+ isinstance(scale, int)):
self.setScale(scale)
# Set color
@@ -95,7 +101,7 @@ class OnscreenImage(DirectObject, NodePath):
# Assign geometry
if isinstance(image, NodePath):
self.assign(image.copyTo(parent, sort))
- elif isinstance(image, types.StringTypes) or \
+ elif isinstance(image, stringType) or \
isinstance(image, Texture):
if isinstance(image, Texture):
# It's a Texture
@@ -115,9 +121,9 @@ class OnscreenImage(DirectObject, NodePath):
if node:
self.assign(node.copyTo(parent, sort))
else:
- print 'OnscreenImage: node %s not found' % image[1]
+ print('OnscreenImage: node %s not found' % image[1])
else:
- print 'OnscreenImage: model %s not found' % image[0]
+ print('OnscreenImage: model %s not found' % image[0])
if transform and not self.isEmpty():
self.setTransform(transform)
@@ -133,17 +139,17 @@ class OnscreenImage(DirectObject, NodePath):
if (((setter == self.setPos) or
(setter == self.setHpr) or
(setter == self.setScale)) and
- (isinstance(value, types.TupleType) or
- isinstance(value, types.ListType))):
- apply(setter, value)
+ (isinstance(value, tuple) or
+ isinstance(value, list))):
+ setter(*value)
else:
setter(value)
except AttributeError:
- print 'OnscreenImage.configure: invalid option:', option
+ print('OnscreenImage.configure: invalid option: %s' % option)
# Allow index style references
def __setitem__(self, key, value):
- apply(self.configure, (), {key: value})
+ self.configure(*(), **{key: value})
def cget(self, option):
# Get current configuration setting.
diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py
index 9fbea1a3a6..1af714c44a 100644
--- a/direct/src/gui/OnscreenText.py
+++ b/direct/src/gui/OnscreenText.py
@@ -3,9 +3,8 @@
__all__ = ['OnscreenText', 'Plain', 'ScreenTitle', 'ScreenPrompt', 'NameConfirm', 'BlackOnWhite']
from panda3d.core import *
-import DirectGuiGlobals as DGG
-from direct.showbase.DirectObject import DirectObject
-import types
+from . import DirectGuiGlobals as DGG
+import sys
## These are the styles of text we might commonly see. They set the
## overall appearance of the text according to one of a number of
@@ -17,7 +16,7 @@ ScreenPrompt = 3
NameConfirm = 4
BlackOnWhite = 5
-class OnscreenText(DirectObject, NodePath):
+class OnscreenText(NodePath):
def __init__(self, text = '',
style = Plain,
@@ -152,7 +151,7 @@ class OnscreenText(DirectObject, NodePath):
else:
raise ValueError
- if not isinstance(scale, types.TupleType):
+ if not isinstance(scale, tuple):
# If the scale is already a tuple, it's a 2-d (x, y) scale.
# Otherwise, it's a uniform scale--make it a tuple.
scale = (scale, scale)
@@ -263,15 +262,24 @@ class OnscreenText(DirectObject, NodePath):
self.textNode.clearText()
def setText(self, text):
- self.unicodeText = isinstance(text, types.UnicodeType)
+ if sys.version_info >= (3, 0):
+ assert not isinstance(text, bytes)
+ self.unicodeText = True
+ else:
+ self.unicodeText = isinstance(text, unicode)
+
if self.unicodeText:
self.textNode.setWtext(text)
else:
self.textNode.setText(text)
def appendText(self, text):
- if isinstance(text, types.UnicodeType):
- self.unicodeText = 1
+ if sys.version_info >= (3, 0):
+ assert not isinstance(text, bytes)
+ self.unicodeText = True
+ else:
+ self.unicodeText = isinstance(text, unicode)
+
if self.unicodeText:
self.textNode.appendWtext(text)
else:
@@ -322,7 +330,7 @@ class OnscreenText(DirectObject, NodePath):
"""
if sy == None:
- if isinstance(sx, types.TupleType):
+ if isinstance(sx, tuple):
self.__scale = sx
else:
self.__scale = (sx, sx)
@@ -413,7 +421,7 @@ class OnscreenText(DirectObject, NodePath):
def configure(self, option=None, **kw):
# These is for compatibility with DirectGui functions
if not self.mayChange:
- print 'OnscreenText.configure: mayChange == 0'
+ print('OnscreenText.configure: mayChange == 0')
return
for option, value in kw.items():
# Use option string to access setter function
@@ -424,11 +432,11 @@ class OnscreenText(DirectObject, NodePath):
else:
setter(value)
except AttributeError:
- print 'OnscreenText.configure: invalid option:', option
+ print('OnscreenText.configure: invalid option: %s' % option)
# Allow index style references
def __setitem__(self, key, value):
- apply(self.configure, (), {key: value})
+ self.configure(*(), **{key: value})
def cget(self, option):
# Get current configuration setting.
diff --git a/direct/src/interval/ActorInterval.py b/direct/src/interval/ActorInterval.py
index ae26c4cde4..5d8b557ae6 100644
--- a/direct/src/interval/ActorInterval.py
+++ b/direct/src/interval/ActorInterval.py
@@ -5,7 +5,7 @@ __all__ = ['ActorInterval', 'LerpAnimInterval']
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-import Interval
+from . import Interval
import math
class ActorInterval(Interval.Interval):
diff --git a/direct/src/interval/AnimControlInterval.py b/direct/src/interval/AnimControlInterval.py
index 57494b145b..4223e69f08 100755
--- a/direct/src/interval/AnimControlInterval.py
+++ b/direct/src/interval/AnimControlInterval.py
@@ -5,7 +5,7 @@ __all__ = ['AnimControlInterval']
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-import Interval
+from . import Interval
import math
class AnimControlInterval(Interval.Interval):
diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py
index 2dc2d7686a..8f84ca9df8 100644
--- a/direct/src/interval/FunctionInterval.py
+++ b/direct/src/interval/FunctionInterval.py
@@ -6,7 +6,7 @@ from panda3d.core import *
from panda3d.direct import *
from direct.showbase.MessengerGlobal import *
from direct.directnotify.DirectNotifyGlobal import directNotify
-import Interval
+from . import Interval
#############################################################
@@ -34,11 +34,11 @@ class FunctionInterval(Interval.Interval):
# print 'testing: ', ival.function, oldFunction
# Note: you can only replace methods currently
if type(ival.function) == types.MethodType:
- if (ival.function.im_func == oldFunction):
+ if ival.function.__func__ == oldFunction:
# print 'found: ', ival.function, oldFunction
ival.function = types.MethodType(newFunction,
- ival.function.im_self,
- ival.function.im_class)
+ ival.function.__self__,
+ ival.function.__self__.__class__)
count += 1
return count
diff --git a/direct/src/interval/IndirectInterval.py b/direct/src/interval/IndirectInterval.py
index 991265273e..a0adf30a82 100644
--- a/direct/src/interval/IndirectInterval.py
+++ b/direct/src/interval/IndirectInterval.py
@@ -5,8 +5,8 @@ __all__ = ['IndirectInterval']
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-import Interval
-import LerpBlendHelpers
+from . import Interval
+from . import LerpBlendHelpers
class IndirectInterval(Interval.Interval):
"""
diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py
index 75eb336694..21a79f016a 100644
--- a/direct/src/interval/Interval.py
+++ b/direct/src/interval/Interval.py
@@ -452,14 +452,17 @@ class Interval(DirectObject):
"""
# Don't use a regular import, to prevent ModuleFinder from picking
# it up as a dependency when building a .p3d package.
- import importlib
+ import importlib, sys
EntryScale = importlib.import_module('direct.tkwidgets.EntryScale')
- Tkinter = importlib.import_module('Tkinter')
+ if sys.version_info >= (3, 0):
+ tkinter = importlib.import_module('tkinter')
+ else:
+ tkinter = importlib.import_module('Tkinter')
if tl == None:
- tl = Tkinter.Toplevel()
+ tl = tkinter.Toplevel()
tl.title('Interval Controls')
- outerFrame = Tkinter.Frame(tl)
+ outerFrame = tkinter.Frame(tl)
def entryScaleCommand(t, s=self):
s.setT(t)
s.pause()
@@ -468,8 +471,8 @@ class Interval(DirectObject):
min = 0, max = math.floor(self.getDuration() * 100) / 100,
command = entryScaleCommand)
es.set(self.getT(), fCommand = 0)
- es.pack(expand = 1, fill = Tkinter.X)
- bf = Tkinter.Frame(outerFrame)
+ es.pack(expand = 1, fill = tkinter.X)
+ bf = tkinter.Frame(outerFrame)
# Jump to start and end
def toStart(s=self, es=es):
s.clearToInitial()
@@ -479,23 +482,23 @@ class Interval(DirectObject):
s.setT(s.getDuration())
es.set(s.getDuration(), fCommand = 0)
s.pause()
- jumpToStart = Tkinter.Button(bf, text = '<<', command = toStart)
+ jumpToStart = tkinter.Button(bf, text = '<<', command = toStart)
# Stop/play buttons
def doPlay(s=self, es=es):
s.resume(es.get())
- stop = Tkinter.Button(bf, text = 'Stop',
+ stop = tkinter.Button(bf, text = 'Stop',
command = lambda s=self: s.pause())
- play = Tkinter.Button(
+ play = tkinter.Button(
bf, text = 'Play',
command = doPlay)
- jumpToEnd = Tkinter.Button(bf, text = '>>', command = toEnd)
- jumpToStart.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- play.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- stop.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- jumpToEnd.pack(side = Tkinter.LEFT, expand = 1, fill = Tkinter.X)
- bf.pack(expand = 1, fill = Tkinter.X)
- outerFrame.pack(expand = 1, fill = Tkinter.X)
+ jumpToEnd = tkinter.Button(bf, text = '>>', command = toEnd)
+ jumpToStart.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ play.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ stop.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ jumpToEnd.pack(side = tkinter.LEFT, expand = 1, fill = tkinter.X)
+ bf.pack(expand = 1, fill = tkinter.X)
+ outerFrame.pack(expand = 1, fill = tkinter.X)
# Add function to update slider during setT calls
def update(t, es=es):
es.set(t, fCommand = 0)
diff --git a/direct/src/interval/IntervalGlobal.py b/direct/src/interval/IntervalGlobal.py
index d1589d268d..903f92d14f 100644
--- a/direct/src/interval/IntervalGlobal.py
+++ b/direct/src/interval/IntervalGlobal.py
@@ -4,23 +4,23 @@
# since the purpose of this module is to add up the contributions
# of a number of other modules.
-from Interval import *
-from ActorInterval import *
-from FunctionInterval import *
-from LerpInterval import *
-from IndirectInterval import *
-from MopathInterval import *
+from .Interval import *
+from .ActorInterval import *
+from .FunctionInterval import *
+from .LerpInterval import *
+from .IndirectInterval import *
+from .MopathInterval import *
try:
import panda3d.physics
##Some people may have the particle system compiled out
if hasattr( panda3d.physics, 'ParticleSystem' ):
- from ParticleInterval import *
+ from .ParticleInterval import *
if __debug__:
- from TestInterval import *
+ from .TestInterval import *
except ImportError:
pass
-from SoundInterval import *
-from ProjectileInterval import *
-from MetaInterval import *
-from IntervalManager import *
+from .SoundInterval import *
+from .ProjectileInterval import *
+from .MetaInterval import *
+from .IntervalManager import *
from panda3d.direct import WaitInterval
diff --git a/direct/src/interval/IntervalTest.py b/direct/src/interval/IntervalTest.py
index 4bbfc9db57..fce7e0f755 100644
--- a/direct/src/interval/IntervalTest.py
+++ b/direct/src/interval/IntervalTest.py
@@ -6,7 +6,7 @@ __all__ = []
if __name__ == "__main__":
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
- from IntervalGlobal import *
+ from .IntervalGlobal import *
from direct.actor.Actor import *
from direct.directutil import Mopath
@@ -72,7 +72,7 @@ if __name__ == "__main__":
waterEventTrack.setIntervalStartTime('water-is-done', eventTime)
def handleWaterDone():
- print 'water is done'
+ print('water is done')
# Interval can handle its own event
messenger.accept('water-is-done', waterDone, handleWaterDone)
@@ -92,7 +92,7 @@ if __name__ == "__main__":
i2 = FunctionInterval(lambda: base.transitions.fadeIn())
def caughtIt():
- print 'Caught here-is-an-event'
+ print('Caught here-is-an-event')
class DummyAcceptor(DirectObject):
pass
@@ -106,7 +106,7 @@ if __name__ == "__main__":
# Using a function
def printDone():
- print 'done'
+ print('done')
i6 = FunctionInterval(printDone)
@@ -139,25 +139,25 @@ if __name__ == "__main__":
def printStart():
global startTime
startTime = globalClock.getFrameTime()
- print 'Start'
+ print('Start')
def printPreviousStart():
global startTime
currTime = globalClock.getFrameTime()
- print 'PREVIOUS_END %0.2f' % (currTime - startTime)
+ print('PREVIOUS_END %0.2f' % (currTime - startTime))
def printPreviousEnd():
global startTime
currTime = globalClock.getFrameTime()
- print 'PREVIOUS_END %0.2f' % (currTime - startTime)
+ print('PREVIOUS_END %0.2f' % (currTime - startTime))
def printTrackStart():
global startTime
currTime = globalClock.getFrameTime()
- print 'TRACK_START %0.2f' % (currTime - startTime)
+ print('TRACK_START %0.2f' % (currTime - startTime))
def printArguments(a, b, c):
- print 'My args were %d, %d, %d' % (a, b, c)
+ print('My args were %d, %d, %d' % (a, b, c))
i1 = FunctionInterval(printStart)
# Just to take time
diff --git a/direct/src/interval/LerpInterval.py b/direct/src/interval/LerpInterval.py
index 06271fc061..24435ae084 100644
--- a/direct/src/interval/LerpInterval.py
+++ b/direct/src/interval/LerpInterval.py
@@ -15,8 +15,8 @@ __all__ = [
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-import Interval
-import LerpBlendHelpers
+from . import Interval
+from . import LerpBlendHelpers
#
# Most of the intervals defined in this module--the group up here at
@@ -774,17 +774,17 @@ class LerpFunctionNoStateInterval(Interval.Interval):
if (t >= self.duration):
# Set to end value
if (t > self.duration):
- print "after end"
+ print("after end")
#apply(self.function, [self.toData] + self.extraArgs)
elif self.duration == 0.0:
# Zero duration, just use endpoint
- apply(self.function, [self.toData] + self.extraArgs)
+ self.function(*[self.toData] + self.extraArgs)
else:
# In the middle of the lerp, compute appropriate blended value
bt = self.blendType(t/self.duration)
data = (self.fromData * (1 - bt)) + (self.toData * bt)
# Evaluate function
- apply(self.function, [data] + self.extraArgs)
+ self.function(*[data] + self.extraArgs)
# Print debug information
# assert self.notify.debug('updateFunc() - %s: t = %f' % (self.name, t))
@@ -841,16 +841,16 @@ class LerpFunctionInterval(Interval.Interval):
#print "doing priv step",t
if (t >= self.duration):
# Set to end value
- apply(self.function, [self.toData] + self.extraArgs)
+ self.function(*[self.toData] + self.extraArgs)
elif self.duration == 0.0:
# Zero duration, just use endpoint
- apply(self.function, [self.toData] + self.extraArgs)
+ self.function(*[self.toData] + self.extraArgs)
else:
# In the middle of the lerp, compute appropriate blended value
bt = self.blendType(t/self.duration)
data = (self.fromData * (1 - bt)) + (self.toData * bt)
# Evaluate function
- apply(self.function, [data] + self.extraArgs)
+ self.function(*[data] + self.extraArgs)
# Print debug information
# assert self.notify.debug('updateFunc() - %s: t = %f' % (self.name, t))
diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py
index 7ec7967662..d7b23afdeb 100644
--- a/direct/src/interval/MetaInterval.py
+++ b/direct/src/interval/MetaInterval.py
@@ -5,10 +5,9 @@ __all__ = ['MetaInterval', 'Sequence', 'Parallel', 'ParallelEndTogether', 'Track
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-from IntervalManager import ivalMgr
-import Interval
+from .IntervalManager import ivalMgr
+from . import Interval
from direct.task.Task import TaskManager
-import types
#if __debug__:
# import direct.showbase.PythonUtil as PythonUtil
@@ -32,7 +31,7 @@ class MetaInterval(CMetaInterval):
# "create interval", 1, 10)
name = None
- #if len(ivals) == 2 and isinstance(ivals[1], types.StringType):
+ #if len(ivals) == 2 and isinstance(ivals[1], str):
# # If the second parameter is a string, it's the name.
# name = ivals[1]
# ivals = ivals[0]
@@ -69,7 +68,7 @@ class MetaInterval(CMetaInterval):
del kw['duration']
if kw:
- self.notify.error("Unexpected keyword parameters: %s" % (kw.keys()))
+ self.notify.error("Unexpected keyword parameters: %s" % (list(kw.keys())))
# We must allow the old style: Track([ival0, ival1, ...]) as
# well as the new style: Track(ival0, ival1, ...)
@@ -80,8 +79,8 @@ class MetaInterval(CMetaInterval):
# bug, since it will go away when we eventually remove support
# for the old interface.
#if len(ivals) == 1 and \
- # (isinstance(ivals[0], types.TupleType) or \
- # isinstance(ivals[0], types.ListType)):
+ # (isinstance(ivals[0], tuple) or \
+ # isinstance(ivals[0], list)):
# self.ivals = ivals[0]
#else:
@@ -121,7 +120,7 @@ class MetaInterval(CMetaInterval):
def append(self, ival):
# Appends a single interval to the list so far.
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.ivals.append(ival)
self.__ivalsDirty = 1
@@ -141,7 +140,7 @@ class MetaInterval(CMetaInterval):
def insert(self, index, ival):
# Inserts the given interval into the middle of the list.
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.ivals.insert(index, ival)
self.__ivalsDirty = 1
@@ -150,7 +149,7 @@ class MetaInterval(CMetaInterval):
def pop(self, index = None):
# Returns element index (or the last element) and removes it
# from the list.
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.__ivalsDirty = 1
if index == None:
@@ -160,21 +159,21 @@ class MetaInterval(CMetaInterval):
def remove(self, ival):
# Removes the indicated interval from the list.
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.ivals.remove(ival)
self.__ivalsDirty = 1
def reverse(self):
# Reverses the order of the intervals.
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.ivals.reverse()
self.__ivalsDirty = 1
def sort(self, cmpfunc = None):
# Sorts the intervals. (?)
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.__ivalsDirty = 1
if cmpfunc == None:
@@ -189,38 +188,38 @@ class MetaInterval(CMetaInterval):
return self.ivals[index]
def __setitem__(self, index, value):
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.ivals[index] = value
self.__ivalsDirty = 1
assert self.validateComponent(value)
def __delitem__(self, index):
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
del self.ivals[index]
self.__ivalsDirty = 1
def __getslice__(self, i, j):
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
return self.__class__(self.ivals[i: j])
def __setslice__(self, i, j, s):
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
self.ivals[i: j] = s
self.__ivalsDirty = 1
assert self.validateComponents(s)
def __delslice__(self, i, j):
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
del self.ivals[i: j]
self.__ivalsDirty = 1
def __iadd__(self, other):
- if isinstance(self.ivals, types.TupleType):
+ if isinstance(self.ivals, tuple):
self.ivals = list(self.ivals)
if isinstance(other, MetaInterval):
assert self.__class__ == other.__class__
@@ -283,8 +282,8 @@ class MetaInterval(CMetaInterval):
# is TRACK_START.
self.pushLevel(name, relTime, relTo)
for tuple in list:
- if isinstance(tuple, types.TupleType) or \
- isinstance(tuple, types.ListType):
+ if isinstance(tuple, tuple) or \
+ isinstance(tuple, list):
relTime = tuple[0]
ival = tuple[1]
if len(tuple) >= 3:
@@ -497,10 +496,10 @@ class MetaInterval(CMetaInterval):
ival = None
except:
if ival != None:
- print "Exception occurred while processing %s of %s:" % (ival.getName(), self.getName())
+ print("Exception occurred while processing %s of %s:" % (ival.getName(), self.getName()))
else:
- print "Exception occurred while processing %s:" % (self.getName())
- print self
+ print("Exception occurred while processing %s:" % (self.getName()))
+ print(self)
raise
def privDoEvent(self, t, event):
@@ -601,8 +600,8 @@ class Track(MetaInterval):
# this is the same as asking that the component is itself an
# Interval.
- if not (isinstance(tuple, types.TupleType) or \
- isinstance(tuple, types.ListType)):
+ if not (isinstance(tuple, tuple) or \
+ isinstance(tuple, list)):
# It's not a tuple.
return 0
@@ -613,8 +612,8 @@ class Track(MetaInterval):
else:
relTo = TRACK_START
- if not (isinstance(relTime, types.FloatType) or \
- isinstance(relTime, types.IntType)):
+ if not (isinstance(relTime, float) or \
+ isinstance(relTime, int)):
# First parameter is not a number.
return 0
if not MetaInterval.validateComponent(self, ival):
diff --git a/direct/src/interval/MopathInterval.py b/direct/src/interval/MopathInterval.py
index 0764b1bc12..83ea995caa 100644
--- a/direct/src/interval/MopathInterval.py
+++ b/direct/src/interval/MopathInterval.py
@@ -2,7 +2,7 @@
__all__ = ['MopathInterval']
-import LerpInterval
+from . import LerpInterval
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
diff --git a/direct/src/interval/ParticleInterval.py b/direct/src/interval/ParticleInterval.py
index 3682904fce..c373af7542 100644
--- a/direct/src/interval/ParticleInterval.py
+++ b/direct/src/interval/ParticleInterval.py
@@ -9,7 +9,7 @@ Contains the ParticleInterval class
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import directNotify
-from Interval import Interval
+from .Interval import Interval
class ParticleInterval(Interval):
diff --git a/direct/src/interval/ProjectileInterval.py b/direct/src/interval/ProjectileInterval.py
index d87253a5ad..a1b5d70014 100755
--- a/direct/src/interval/ProjectileInterval.py
+++ b/direct/src/interval/ProjectileInterval.py
@@ -5,7 +5,7 @@ __all__ = ['ProjectileInterval']
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-from Interval import Interval
+from .Interval import Interval
from direct.showbase import PythonUtil
class ProjectileInterval(Interval):
@@ -221,7 +221,7 @@ class ProjectileInterval(Interval):
def testTrajectory(self):
try:
self.__calcTrajectory(*self.trajectoryArgs)
- except StandardError:
+ except Exception:
assert self.notify.error('invalid projectile parameters')
return False
return True
diff --git a/direct/src/interval/ProjectileIntervalTest.py b/direct/src/interval/ProjectileIntervalTest.py
index 7e0b080d5a..bd747be382 100755
--- a/direct/src/interval/ProjectileIntervalTest.py
+++ b/direct/src/interval/ProjectileIntervalTest.py
@@ -4,7 +4,7 @@ __all__ = ['doTest']
from panda3d.core import *
from panda3d.direct import *
-from IntervalGlobal import *
+from .IntervalGlobal import *
def doTest():
smiley = loader.loadModel('models/misc/smiley')
diff --git a/direct/src/interval/SoundInterval.py b/direct/src/interval/SoundInterval.py
index ca38af297a..5927d14703 100644
--- a/direct/src/interval/SoundInterval.py
+++ b/direct/src/interval/SoundInterval.py
@@ -5,7 +5,7 @@ __all__ = ['SoundInterval']
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import *
-import Interval
+from . import Interval
import random
class SoundInterval(Interval.Interval):
diff --git a/direct/src/interval/TestInterval.py b/direct/src/interval/TestInterval.py
index 444ad20aaf..82a04b604e 100755
--- a/direct/src/interval/TestInterval.py
+++ b/direct/src/interval/TestInterval.py
@@ -9,7 +9,7 @@ Contains the ParticleInterval class
from panda3d.core import *
from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import directNotify
-from Interval import Interval
+from .Interval import Interval
class TestInterval(Interval):
diff --git a/direct/src/leveleditor/ActionMgr.py b/direct/src/leveleditor/ActionMgr.py
index 041f6b4cf2..29d9ba3742 100755
--- a/direct/src/leveleditor/ActionMgr.py
+++ b/direct/src/leveleditor/ActionMgr.py
@@ -1,5 +1,5 @@
from pandac.PandaModules import *
-import ObjectGlobals as OG
+from . import ObjectGlobals as OG
class ActionMgr:
def __init__(self):
@@ -22,7 +22,7 @@ class ActionMgr:
def undo(self):
if len(self.undoList) < 1:
- print 'No more undo'
+ print('No more undo')
else:
action = self.undoList.pop()
self.redoList.append(action)
@@ -30,7 +30,7 @@ class ActionMgr:
def redo(self):
if len(self.redoList) < 1:
- print 'No more redo'
+ print('No more redo')
else:
action = self.redoList.pop()
self.undoList.append(action)
@@ -70,7 +70,7 @@ class ActionBase(Functor):
pass
def undo(self):
- print "undo method is not defined for this action"
+ print("undo method is not defined for this action")
class ActionAddNewObj(ActionBase):
""" Action class for adding new object """
@@ -88,16 +88,16 @@ class ActionAddNewObj(ActionBase):
def redo(self):
if self.uid is None:
- print "Can't redo this add"
+ print("Can't redo this add")
else:
self.result = self._do__call__(uid=self.uid)
return self.result
def undo(self):
if self.result is None:
- print "Can't undo this add"
+ print("Can't undo this add")
else:
- print "Undo: addNewObject"
+ print("Undo: addNewObject")
if self.uid:
obj = self.editor.objectMgr.findObjectById(self.uid)
else:
@@ -109,7 +109,7 @@ class ActionAddNewObj(ActionBase):
base.direct.removeNodePath(obj[OG.OBJ_NP])
self.result = None
else:
- print "Can't undo this add"
+ print("Can't undo this add")
class ActionDeleteObj(ActionBase):
""" Action class for deleting object """
@@ -150,11 +150,11 @@ class ActionDeleteObj(ActionBase):
saveObjStatus(np, False)
def undo(self):
- if len(self.hierarchy.keys()) == 0 or\
- len(self.objInfos.keys()) == 0:
- print "Can't undo this deletion"
+ if len(self.hierarchy) == 0 or\
+ len(self.objInfos) == 0:
+ print("Can't undo this deletion")
else:
- print "Undo: deleteObject"
+ print("Undo: deleteObject")
def restoreObject(uid, parentNP):
obj = self.objInfos[uid]
objDef = obj[OG.OBJ_DEF]
@@ -169,8 +169,8 @@ class ActionDeleteObj(ActionBase):
self.editor.objectMgr.updateObjectProperties(objNP, objProp)
objNP.setMat(self.objTransforms[uid])
- while (len(self.hierarchy.keys()) > 0):
- for uid in self.hierarchy.keys():
+ while len(self.hierarchy) > 0:
+ for uid in self.hierarchy:
if self.hierarchy[uid] is None:
parentNP = None
restoreObject(uid, parentNP)
@@ -230,11 +230,11 @@ class ActionDeleteObjById(ActionBase):
saveObjStatus(self.uid, True)
def undo(self):
- if len(self.hierarchy.keys()) == 0 or\
- len(self.objInfos.keys()) == 0:
- print "Can't undo this deletion"
+ if len(self.hierarchy) == 0 or\
+ len(self.objInfos) == 0:
+ print("Can't undo this deletion")
else:
- print "Undo: deleteObjectById"
+ print("Undo: deleteObjectById")
def restoreObject(uid, parentNP):
obj = self.objInfos[uid]
objDef = obj[OG.OBJ_DEF]
@@ -249,8 +249,8 @@ class ActionDeleteObjById(ActionBase):
self.editor.objectMgr.updateObjectProperties(objNP, objProp)
objNP.setMat(self.objTransforms[uid])
- while (len(self.hierarchy.keys()) > 0):
- for uid in self.hierarchy.keys():
+ while len(self.hierarchy) > 0:
+ for uid in self.hierarchy:
if self.hierarchy[uid] is None:
parentNP = None
restoreObject(uid, parentNP)
@@ -298,7 +298,7 @@ class ActionSelectObj(ActionBase):
self.selectedUIDs.append(uid)
def undo(self):
- print "Undo : selectObject"
+ print("Undo : selectObject")
base.direct.deselectAllCB()
for uid in self.selectedUIDs:
obj = self.editor.objectMgr.findObjectById(uid)
@@ -332,9 +332,9 @@ class ActionTransformObj(ActionBase):
def undo(self):
if self.origMat is None:
- print "Can't undo this transform"
+ print("Can't undo this transform")
else:
- print "Undo: transformObject"
+ print("Undo: transformObject")
obj = self.editor.objectMgr.findObjectById(self.uid)
if obj:
obj[OG.OBJ_NP].setMat(self.origMat)
@@ -360,7 +360,7 @@ class ActionDeselectAll(ActionBase):
self.selectedUIDs.append(uid)
def undo(self):
- print "Undo : deselectAll"
+ print("Undo : deselectAll")
base.direct.deselectAllCB()
for uid in self.selectedUIDs:
obj = self.editor.objectMgr.findObjectById(uid)
@@ -391,7 +391,7 @@ class ActionUpdateObjectProp(ActionBase):
return self.result
def undo(self):
- print "Undo : updateObjectProp"
+ print("Undo : updateObjectProp")
if self.oldVal:
self.obj[OG.OBJ_PROP][self.propName] = self.oldVal
if self.undoFunc:
diff --git a/direct/src/leveleditor/AnimControlUI.py b/direct/src/leveleditor/AnimControlUI.py
index 71cf4168cf..2137da5c35 100755
--- a/direct/src/leveleditor/AnimControlUI.py
+++ b/direct/src/leveleditor/AnimControlUI.py
@@ -3,11 +3,9 @@
"""
from direct.interval.IntervalGlobal import *
from direct.actor.Actor import *
-from panda3d.core import VBase3,VBase4
-import ObjectGlobals as OG
-import AnimGlobals as AG
+from . import ObjectGlobals as OG
-import os,wx, time
+import os, wx
from wx.lib.embeddedimage import PyEmbeddedImage
#----------------------------------------------------------------------
@@ -895,13 +893,13 @@ class AnimControlUI(wx.Dialog):
del self.keys[i]
break
- for j in self.editor.animMgr.keyFramesInfo.keys():
+ for j in list(self.editor.animMgr.keyFramesInfo.keys()):
for k in range(0,len(self.editor.animMgr.keyFramesInfo[j])):
if self.curFrame == self.editor.animMgr.keyFramesInfo[j][k][0]:
del self.editor.animMgr.keyFramesInfo[j][k]
break
- for l in self.editor.animMgr.keyFramesInfo.keys():
+ for l in list(self.editor.animMgr.keyFramesInfo.keys()):
if len(self.editor.animMgr.keyFramesInfo[l]) == 0:
del self.editor.animMgr.keyFramesInfo[l]
diff --git a/direct/src/leveleditor/AnimMgr.py b/direct/src/leveleditor/AnimMgr.py
index 6be3aa58f6..f57766f791 100755
--- a/direct/src/leveleditor/AnimMgr.py
+++ b/direct/src/leveleditor/AnimMgr.py
@@ -1,7 +1,7 @@
"""
Defines AnimMgr
"""
-from AnimMgrBase import *
+from .AnimMgrBase import *
class AnimMgr(AnimMgrBase):
""" Animation will create, manage, update animations in the scene """
diff --git a/direct/src/leveleditor/AnimMgrBase.py b/direct/src/leveleditor/AnimMgrBase.py
index ecc0a55ae3..09cf49f73c 100755
--- a/direct/src/leveleditor/AnimMgrBase.py
+++ b/direct/src/leveleditor/AnimMgrBase.py
@@ -2,12 +2,12 @@
Defines AnimMgrBase
"""
-import os, wx, math
+import os, math
from direct.interval.IntervalGlobal import *
-from panda3d.core import VBase3,VBase4
-import ObjectGlobals as OG
-import AnimGlobals as AG
+from panda3d.core import VBase3
+from . import ObjectGlobals as OG
+from . import AnimGlobals as AG
class AnimMgrBase:
""" AnimMgr will create, manage, update animations in the scene """
@@ -47,7 +47,7 @@ class AnimMgrBase:
def generateKeyFrames(self):
#generate keyFrame list
self.keyFrames = []
- for property in self.keyFramesInfo.keys():
+ for property in list(self.keyFramesInfo.keys()):
for frameInfo in self.keyFramesInfo[property]:
frame = frameInfo[AG.FRAME]
exist = False
@@ -80,7 +80,7 @@ class AnimMgrBase:
return
def removeAnimInfo(self, uid):
- for property in self.keyFramesInfo.keys():
+ for property in list(self.keyFramesInfo.keys()):
if property[AG.UID] == uid:
del self.keyFramesInfo[property]
self.generateKeyFrames()
@@ -141,7 +141,7 @@ class AnimMgrBase:
#generate key frame animation for normal property
self.editor.objectMgr.findNodes(render)
for node in self.editor.objectMgr.Nodes:
- for property in self.keyFramesInfo.keys():
+ for property in list(self.keyFramesInfo.keys()):
if property[AG.UID] == node[OG.OBJ_UID] and property[AG.PROP_NAME] != 'X' and property[AG.PROP_NAME] != 'Y' and property[AG.PROP_NAME] != 'Z':
mysequence = Sequence(name = node[OG.OBJ_UID])
keyFramesInfo = self.keyFramesInfo[property]
@@ -166,7 +166,7 @@ class AnimMgrBase:
#generate key frame animation for the property which is controled by animation curve
self.editor.objectMgr.findNodes(render)
for node in self.editor.objectMgr.Nodes:
- for property in self.keyFramesInfo.keys():
+ for property in list(self.keyFramesInfo.keys()):
if property[AG.UID] == node[OG.OBJ_UID]:
if property[AG.PROP_NAME] == 'X' or property[AG.PROP_NAME] == 'Y' or property[AG.PROP_NAME] == 'Z':
mysequence = Sequence(name = node[OG.OBJ_UID])
diff --git a/direct/src/leveleditor/CurveAnimUI.py b/direct/src/leveleditor/CurveAnimUI.py
index b779b2c615..ca99d1eca4 100755
--- a/direct/src/leveleditor/CurveAnimUI.py
+++ b/direct/src/leveleditor/CurveAnimUI.py
@@ -1,12 +1,12 @@
"""
This is the GUI for the Curve Animation
"""
-import os, wx, time
+import wx
from direct.interval.IntervalGlobal import *
from direct.actor.Actor import *
-from direct.showutil.Rope import Rope
-import ObjectGlobals as OG
+from . import ObjectGlobals as OG
+
class CurveAnimUI(wx.Dialog):
"""
@@ -129,8 +129,8 @@ class CurveAnimUI(wx.Dialog):
return
hasKey = False
- for key in self.editor.animMgr.curveAnimation.keys():
- if key == (self.nodePath[OG.OBJ_UID],self.curve[OG.OBJ_UID]):
+ for key in self.editor.animMgr.curveAnimation:
+ if key == (self.nodePath[OG.OBJ_UID], self.curve[OG.OBJ_UID]):
dlg = wx.MessageDialog(None, 'Already have the animation for this object attach to this curve.', 'NOTICE', wx.OK )
dlg.ShowModal()
dlg.Destroy()
diff --git a/direct/src/leveleditor/CurveEditor.py b/direct/src/leveleditor/CurveEditor.py
index bc1d907c22..b1acc04525 100755
--- a/direct/src/leveleditor/CurveEditor.py
+++ b/direct/src/leveleditor/CurveEditor.py
@@ -7,9 +7,9 @@ from direct.wxwidgets.WxPandaShell import *
from direct.showbase.DirectObject import *
from direct.directtools.DirectSelection import SelectionRay
from direct.showutil.Rope import Rope
-from ActionMgr import *
+from .ActionMgr import *
from direct.task import Task
-import ObjectGlobals as OG
+
class CurveEditor(DirectObject):
""" CurveEditor will create and edit the curve """
diff --git a/direct/src/leveleditor/FileMgr.py b/direct/src/leveleditor/FileMgr.py
index c1b39fda98..a0b00d1a04 100755
--- a/direct/src/leveleditor/FileMgr.py
+++ b/direct/src/leveleditor/FileMgr.py
@@ -1,11 +1,6 @@
import os
import imp
-from ObjectMgr import ObjectMgr
-from ObjectHandler import ObjectHandler
-from ObjectPalette import ObjectPalette
-from ProtoPalette import ProtoPalette
-import ObjectGlobals as OG
class FileMgr:
""" To handle data file """
@@ -40,7 +35,7 @@ class FileMgr:
self.editor.updateStatusReadout('Sucessfully saved to %s'%fileName)
self.editor.fNeedToSave = False
except IOError:
- print 'failed to save %s'%fileName
+ print('failed to save %s'%fileName)
if f:
f.close()
@@ -54,4 +49,4 @@ class FileMgr:
self.editor.updateStatusReadout('Sucessfully opened file %s'%fileName)
self.editor.fNeedToSave = False
except:
- print 'failed to load %s'%fileName
+ print('failed to load %s'%fileName)
diff --git a/direct/src/leveleditor/GraphEditorUI.py b/direct/src/leveleditor/GraphEditorUI.py
index 5e69cf6710..908fde08da 100755
--- a/direct/src/leveleditor/GraphEditorUI.py
+++ b/direct/src/leveleditor/GraphEditorUI.py
@@ -1,12 +1,11 @@
"""
Defines Graph Editor
"""
-import os,wx
+import wx
import math
-import cPickle as pickle
-from PaletteTreeCtrl import *
-import ObjectGlobals as OG
-import AnimGlobals as AG
+from .PaletteTreeCtrl import *
+from . import ObjectGlobals as OG
+from . import AnimGlobals as AG
from wx.lib.embeddedimage import PyEmbeddedImage
property = [
@@ -131,7 +130,7 @@ class GraphEditorWindow(wx.Window):
if self._mainDialog.editor.animMgr.keyFramesInfo != {}:
self.keyFramesInfo = self._mainDialog.editor.animMgr.keyFramesInfo
- for key in self.keyFramesInfo.keys():
+ for key in self.keyFramesInfo:
if key == (self.object[OG.OBJ_UID], 'X'):
for i in range(len(self.keyFramesInfo[key])):
item = self.keyFramesInfo[key][i]
diff --git a/direct/src/leveleditor/HotKeyUI.py b/direct/src/leveleditor/HotKeyUI.py
index 8c8b442824..8cde68b0eb 100755
--- a/direct/src/leveleditor/HotKeyUI.py
+++ b/direct/src/leveleditor/HotKeyUI.py
@@ -89,8 +89,8 @@ class EditHotKeyDialog(wx.Dialog):
newKeyStr = specialKey
if newKeyStr != self.currKey:
- if newKeyStr in base.direct.hotKeyMap.keys():
- print 'a hotkey is to be overridden with', newKeyStr
+ if newKeyStr in list(base.direct.hotKeyMap.keys()):
+ print('a hotkey is to be overridden with %s' % newKeyStr)
oldKeyDesc = base.direct.hotKeyMap[newKeyStr]
msg = 'The hotkey is already assigned to %s\n'%oldKeyDesc[0] +\
'Do you want to override this?'
@@ -116,7 +116,7 @@ class HotKeyPanel(ScrolledPanel):
def updateUI(self):
vbox = wx.BoxSizer(wx.VERTICAL)
- keys = base.direct.hotKeyMap.keys()
+ keys = list(base.direct.hotKeyMap.keys())
keys.sort()
for key in keys:
keyDesc = base.direct.hotKeyMap[key]
diff --git a/direct/src/leveleditor/LayerEditorUI.py b/direct/src/leveleditor/LayerEditorUI.py
index 442d85d576..d77f8779bb 100644
--- a/direct/src/leveleditor/LayerEditorUI.py
+++ b/direct/src/leveleditor/LayerEditorUI.py
@@ -2,11 +2,9 @@
Defines Layer UI
"""
import wx
-import sys
-import cPickle as pickle
from pandac.PandaModules import *
-import ObjectGlobals as OG
+from . import ObjectGlobals as OG
class LayerEditorUI(wx.Panel):
def __init__(self, parent, editor):
@@ -160,7 +158,7 @@ class LayerEditorUI(wx.Panel):
self.llist.SetItemState(index, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED)
def removeObjData(self, objUID):
- layersDataDictKeys = self.layersDataDict.keys()
+ layersDataDictKeys = list(self.layersDataDict.keys())
for i in range(len(layersDataDictKeys)):
layersData = self.layersDataDict[layersDataDictKeys[i]]
for j in range(len(layersData)):
@@ -247,7 +245,7 @@ class LayerEditorUI(wx.Panel):
self.saveData.append(" ui.layerEditorUI.reset()")
for index in range(self.llist.GetItemCount()):
self.saveData.append(" ui.layerEditorUI.addLayerEntry('%s', %s )"%(self.llist.GetItemText(index), self.llist.GetItemData(index)))
- layersDataDictKeys = self.layersDataDict.keys()
+ layersDataDictKeys = list(self.layersDataDict.keys())
for i in range(len(layersDataDictKeys)):
layerData = self.layersDataDict[layersDataDictKeys[i]]
for j in range(len(layerData)):
diff --git a/direct/src/leveleditor/LevelEditor.py b/direct/src/leveleditor/LevelEditor.py
index 43fd87f473..c1322c455d 100644
--- a/direct/src/leveleditor/LevelEditor.py
+++ b/direct/src/leveleditor/LevelEditor.py
@@ -5,13 +5,13 @@ LevelEditor, ObjectHandler, ObjectPalette should be rewritten
to be game specific.
"""
-from LevelEditorUI import *
-from LevelEditorBase import *
-from ObjectMgr import *
-from AnimMgr import *
-from ObjectHandler import *
-from ObjectPalette import *
-from ProtoPalette import *
+from .LevelEditorUI import *
+from .LevelEditorBase import *
+from .ObjectMgr import *
+from .AnimMgr import *
+from .ObjectHandler import *
+from .ObjectPalette import *
+from .ProtoPalette import *
class LevelEditor(LevelEditorBase):
""" Class for Panda3D LevelEditor """
diff --git a/direct/src/leveleditor/LevelEditorBase.py b/direct/src/leveleditor/LevelEditorBase.py
index 68bcea9ec8..ad351a7e39 100755
--- a/direct/src/leveleditor/LevelEditorBase.py
+++ b/direct/src/leveleditor/LevelEditorBase.py
@@ -9,10 +9,10 @@ from direct.showbase.DirectObject import *
from direct.directtools.DirectUtil import *
from direct.gui.DirectGui import *
-from CurveEditor import *
-from FileMgr import *
-from ActionMgr import *
-from MayaConverter import *
+from .CurveEditor import *
+from .FileMgr import *
+from .ActionMgr import *
+from .MayaConverter import *
class LevelEditorBase(DirectObject):
""" Base Class for Panda3D LevelEditor """
diff --git a/direct/src/leveleditor/LevelEditorStart.py b/direct/src/leveleditor/LevelEditorStart.py
index e9bccd920a..4ec577106c 100644
--- a/direct/src/leveleditor/LevelEditorStart.py
+++ b/direct/src/leveleditor/LevelEditorStart.py
@@ -1,4 +1,4 @@
-import LevelEditor
+from . import LevelEditor
if __name__ == '__main__':
base.le = LevelEditor.LevelEditor()
diff --git a/direct/src/leveleditor/LevelEditorUI.py b/direct/src/leveleditor/LevelEditorUI.py
index 574c957239..9fec2d28d8 100755
--- a/direct/src/leveleditor/LevelEditorUI.py
+++ b/direct/src/leveleditor/LevelEditorUI.py
@@ -1,4 +1,4 @@
-from LevelEditorUIBase import *
+from .LevelEditorUIBase import *
class LevelEditorUI(LevelEditorUIBase):
""" Class for Panda3D LevelEditor """
diff --git a/direct/src/leveleditor/LevelEditorUIBase.py b/direct/src/leveleditor/LevelEditorUIBase.py
index 7b46e3eb02..f457f838d6 100755
--- a/direct/src/leveleditor/LevelEditorUIBase.py
+++ b/direct/src/leveleditor/LevelEditorUIBase.py
@@ -7,16 +7,16 @@ from direct.wxwidgets.WxPandaShell import *
from direct.directtools.DirectSelection import SelectionRay
#from ViewPort import *
-from ObjectPaletteUI import *
-from ObjectPropertyUI import *
-from SceneGraphUI import *
-from LayerEditorUI import *
-from HotKeyUI import *
-from ProtoPaletteUI import *
-from ActionMgr import *
-from AnimControlUI import *
-from CurveAnimUI import *
-from GraphEditorUI import *
+from .ObjectPaletteUI import *
+from .ObjectPropertyUI import *
+from .SceneGraphUI import *
+from .LayerEditorUI import *
+from .HotKeyUI import *
+from .ProtoPaletteUI import *
+from .ActionMgr import *
+from .AnimControlUI import *
+from .CurveAnimUI import *
+from .GraphEditorUI import *
class PandaTextDropTarget(wx.TextDropTarget):
def __init__(self, editor, view):
@@ -32,7 +32,7 @@ class PandaTextDropTarget(wx.TextDropTarget):
action = ActionAddNewObj(self.editor, text, parent=parentNPRef[0])
self.editor.actionMgr.push(action)
newobj = action()
- print newobj
+ print(newobj)
if newobj is None:
return
@@ -584,12 +584,12 @@ class LevelEditorUIBase(WxPandaShell):
def replaceObject(self, evt, all=False):
currObj = self.editor.objectMgr.findObjectByNodePath(base.direct.selected.last)
if currObj is None:
- print 'No valid object is selected for replacement'
+ print('No valid object is selected for replacement')
return
targetType = self.editor.ui.objectPaletteUI.getSelected()
if targetType is None:
- print 'No valid target type is selected for replacement'
+ print('No valid target type is selected for replacement')
return
if all:
diff --git a/direct/src/leveleditor/LevelLoader.py b/direct/src/leveleditor/LevelLoader.py
index 77824aaa37..79f4a6644c 100755
--- a/direct/src/leveleditor/LevelLoader.py
+++ b/direct/src/leveleditor/LevelLoader.py
@@ -16,8 +16,8 @@ from direct.leveleditor.LevelLoaderBase import LevelLoaderBase
from direct.leveleditor.ObjectMgr import ObjectMgr
from direct.leveleditor.ProtoPalette import ProtoPalette
from direct.leveleditor import ObjectGlobals as OG
-from ObjectHandler import ObjectHandler
-from ObjectPalette import ObjectPalette
+from .ObjectHandler import ObjectHandler
+from .ObjectPalette import ObjectPalette
class LevelLoader(LevelLoaderBase):
def __init__(self):
diff --git a/direct/src/leveleditor/LevelLoaderBase.py b/direct/src/leveleditor/LevelLoaderBase.py
index c5b9c6b907..1e3489e96b 100755
--- a/direct/src/leveleditor/LevelLoaderBase.py
+++ b/direct/src/leveleditor/LevelLoaderBase.py
@@ -33,5 +33,5 @@ class LevelLoaderBase:
module = imp.load_module(fileName, file, pathname, description)
return True
except:
- print 'failed to load %s'%fileName
+ print('failed to load %s'%fileName)
return None
diff --git a/direct/src/leveleditor/MayaConverter.py b/direct/src/leveleditor/MayaConverter.py
index cf13b1259d..6c1feb4db1 100755
--- a/direct/src/leveleditor/MayaConverter.py
+++ b/direct/src/leveleditor/MayaConverter.py
@@ -1,6 +1,6 @@
from direct.wxwidgets.WxAppShell import *
-import os, re, shutil
-import ObjectGlobals as OG
+import os
+from . import ObjectGlobals as OG
CLOSE_STDIN = ""
@@ -30,7 +30,7 @@ class Process:
#some platforms (like Windows) will send some small number
#of bytes per .write() call (sometimes 2 in the case of
#Windows).
- self.b.extend([input[i:i+512] for i in xrange(0, len(input), 512)])
+ self.b.extend([input[i:i+512] for i in range(0, len(input), 512)])
input = self.b.pop(0)
self.process._stdin_.write(input)
if hasattr(self.process._stdin_, "LastWrite"):
diff --git a/direct/src/leveleditor/ObjectHandler.py b/direct/src/leveleditor/ObjectHandler.py
index e51bf2b8fb..b93fc82ddb 100755
--- a/direct/src/leveleditor/ObjectHandler.py
+++ b/direct/src/leveleditor/ObjectHandler.py
@@ -7,7 +7,7 @@ to be game specific.
from direct.actor import Actor
-import ObjectGlobals as OG
+from . import ObjectGlobals as OG
class ObjectHandler:
""" ObjectHandler will create and update objects """
diff --git a/direct/src/leveleditor/ObjectMgr.py b/direct/src/leveleditor/ObjectMgr.py
index d3219dde70..d80f8d4439 100755
--- a/direct/src/leveleditor/ObjectMgr.py
+++ b/direct/src/leveleditor/ObjectMgr.py
@@ -1,7 +1,7 @@
"""
Defines ObjectMgr
"""
-from ObjectMgrBase import *
+from .ObjectMgrBase import *
class ObjectMgr(ObjectMgrBase):
""" ObjectMgr will create, manage, update objects in the scene """
diff --git a/direct/src/leveleditor/ObjectMgrBase.py b/direct/src/leveleditor/ObjectMgrBase.py
index bb16f47e4d..3a65d6a998 100755
--- a/direct/src/leveleditor/ObjectMgrBase.py
+++ b/direct/src/leveleditor/ObjectMgrBase.py
@@ -2,14 +2,13 @@
Defines ObjectMgrBase
"""
-import os, time, wx, types, copy
+import os, time, copy
from direct.task import Task
from direct.actor.Actor import Actor
from pandac.PandaModules import *
-from ActionMgr import *
-import ObjectGlobals as OG
-from ObjectPaletteBase import ObjectGen
+from .ActionMgr import *
+from . import ObjectGlobals as OG
# python wrapper around a panda.NodePath object
class PythonNodePath(NodePath):
@@ -41,14 +40,14 @@ class ObjectMgrBase:
def reset(self):
base.direct.deselectAllCB()
- for id in self.objects.keys():
+ for id in list(self.objects.keys()):
try:
self.objects[id][OG.OBJ_NP].removeNode()
except:
pass
del self.objects[id]
- for np in self.npIndex.keys():
+ for np in list(self.npIndex.keys()):
del self.npIndex[np]
self.objects = {}
@@ -179,13 +178,13 @@ class ObjectMgrBase:
funcName = objDef.createFunction[OG.FUNC_NAME]
funcArgs = copy.deepcopy(objDef.createFunction[OG.FUNC_ARGS])
- for pair in funcArgs.items():
+ for pair in list(funcArgs.items()):
if pair[1] == OG.ARG_NAME:
funcArgs[pair[0]] = nameStr
elif pair[1] == OG.ARG_PARENT:
funcArgs[pair[0]] = parent
- if type(funcName) == types.StringType:
+ if type(funcName) == str:
if funcName.startswith('.'):
# when it's using default objectHandler
if self.editor:
@@ -512,7 +511,7 @@ class ObjectMgrBase:
else:
newobjModel = loader.loadModel(model, okMissing=True)
if newobjModel is None:
- print "Can't load model %s"%model
+ print("Can't load model %s"%model)
return
self.flatten(newobjModel, model, objDef, uid)
newobj = PythonNodePath(newobjModel)
@@ -683,7 +682,7 @@ class ObjectMgrBase:
kwargs[key] = funcArgs[key]
undoKwargs[key] = funcArgs[key]
- if type(funcName) == types.StringType:
+ if type(funcName) == str:
if funcName.startswith('.'):
if self.editor:
func = Functor(getattr(self.editor, "objectHandler%s"%funcName), **kwargs)
diff --git a/direct/src/leveleditor/ObjectPalette.py b/direct/src/leveleditor/ObjectPalette.py
index 4b08ad1360..ff254cbb9c 100755
--- a/direct/src/leveleditor/ObjectPalette.py
+++ b/direct/src/leveleditor/ObjectPalette.py
@@ -14,7 +14,7 @@ Then you need implement ObjectPalette class inheriting ObjectPaletteBase,
and in the populate function you can define ObjectPalette tree structure.
"""
-from ObjectPaletteBase import *
+from .ObjectPaletteBase import *
class ObjectProp(ObjectBase):
def __init__(self, *args, **kw):
diff --git a/direct/src/leveleditor/ObjectPaletteBase.py b/direct/src/leveleditor/ObjectPaletteBase.py
index 1946926c89..5bbfe38e50 100755
--- a/direct/src/leveleditor/ObjectPaletteBase.py
+++ b/direct/src/leveleditor/ObjectPaletteBase.py
@@ -1,5 +1,5 @@
import copy
-import ObjectGlobals as OG
+from . import ObjectGlobals as OG
class ObjectGen:
""" Base class for obj definitions """
@@ -82,7 +82,7 @@ class ObjectPaletteBase:
def deleteStruct(self, name, deleteItems):
try:
item = self.data.pop(name)
- for key in self.dataStruct.keys():
+ for key in list(self.dataStruct.keys()):
if self.dataStruct[key] == name:
node = self.deleteStruct(key, deleteItems)
if node is not None:
@@ -98,7 +98,7 @@ class ObjectPaletteBase:
node = self.deleteStruct(name, deleteItems)
if node is not None:
deleteItems[name] = node
- for key in deleteItems.keys():
+ for key in list(deleteItems.keys()):
item = self.dataStruct.pop(key)
except:
return
@@ -126,7 +126,7 @@ class ObjectPaletteBase:
if newName == "":
return False
try:
- for key in self.dataStruct.keys():
+ for key in list(self.dataStruct.keys()):
if self.dataStruct[key] == oldName:
self.dataStruct[key] = newName
diff --git a/direct/src/leveleditor/ObjectPaletteUI.py b/direct/src/leveleditor/ObjectPaletteUI.py
index 4c9fa92d3d..bf84e3d492 100755
--- a/direct/src/leveleditor/ObjectPaletteUI.py
+++ b/direct/src/leveleditor/ObjectPaletteUI.py
@@ -2,8 +2,8 @@
Defines ObjectPalette tree UI
"""
import wx
-import cPickle as pickle
-from PaletteTreeCtrl import *
+from .PaletteTreeCtrl import *
+
class ObjectPaletteUI(wx.Panel):
def __init__(self, parent, editor):
diff --git a/direct/src/leveleditor/ObjectPropertyUI.py b/direct/src/leveleditor/ObjectPropertyUI.py
index 0be0910523..08adb8b784 100755
--- a/direct/src/leveleditor/ObjectPropertyUI.py
+++ b/direct/src/leveleditor/ObjectPropertyUI.py
@@ -10,8 +10,8 @@ from wx.lib.scrolledpanel import ScrolledPanel
from wx.lib.agw.cubecolourdialog import *
from direct.wxwidgets.WxSlider import *
from pandac.PandaModules import *
-import ObjectGlobals as OG
-import AnimGlobals as AG
+from . import ObjectGlobals as OG
+from . import AnimGlobals as AG
#----------------------------------------------------------------------
Key = PyEmbeddedImage(
@@ -495,14 +495,14 @@ class ObjectPropertyUI(ScrolledPanel):
sizer = wx.BoxSizer(wx.VERTICAL)
propNames = objDef.orderedProperties[:]
- for key in objDef.properties.keys():
+ for key in list(objDef.properties.keys()):
if key not in propNames:
propNames.append(key)
for key in propNames:
# handling properties mask
propMask = BitMask32()
- for modeKey in objDef.propertiesMask.keys():
+ for modeKey in list(objDef.propertiesMask.keys()):
if key in objDef.propertiesMask[modeKey]:
propMask |= modeKey
diff --git a/direct/src/leveleditor/PaletteTreeCtrl.py b/direct/src/leveleditor/PaletteTreeCtrl.py
index f774f0dac5..c4a5d46fce 100644
--- a/direct/src/leveleditor/PaletteTreeCtrl.py
+++ b/direct/src/leveleditor/PaletteTreeCtrl.py
@@ -2,8 +2,8 @@
Defines Palette tree control
"""
import wx
-import cPickle as pickle
-from ObjectPaletteBase import *
+from .ObjectPaletteBase import *
+
class PaletteTreeCtrl(wx.TreeCtrl):
def __init__(self, parent, treeStyle, rootName):
@@ -155,7 +155,7 @@ class PaletteTreeCtrl(wx.TreeCtrl):
if item != self.GetRootItem(): # prevent dragging root item
text = self.GetItemText(item)
- print "Starting drag'n'drop with %s..." % repr(text)
+ print("Starting drag'n'drop with %s..." % repr(text))
tdo = wx.TextDataObject(text)
tds = wx.DropSource(self)
diff --git a/direct/src/leveleditor/ProtoObjs.py b/direct/src/leveleditor/ProtoObjs.py
index a1bc137a3e..a8e2c7bd34 100755
--- a/direct/src/leveleditor/ProtoObjs.py
+++ b/direct/src/leveleditor/ProtoObjs.py
@@ -3,7 +3,7 @@ Palette for Prototyping
"""
import os
import imp
-import types
+
class ProtoObjs:
def __init__(self, name):
@@ -19,7 +19,7 @@ class ProtoObjs:
module = imp.load_module(moduleName, file, pathname, description)
self.data = module.protoData
except:
- print "%s doesn't exist"%(self.name)
+ print("%s doesn't exist"%(self.name))
return
def saveProtoData(self, f):
diff --git a/direct/src/leveleditor/ProtoObjsUI.py b/direct/src/leveleditor/ProtoObjsUI.py
index 67fb60f4b9..63222e3a2d 100755
--- a/direct/src/leveleditor/ProtoObjsUI.py
+++ b/direct/src/leveleditor/ProtoObjsUI.py
@@ -3,10 +3,9 @@ Defines ProtoObjs List UI
"""
import wx
import os
-import cPickle as pickl
from pandac.PandaModules import *
-from ProtoObjs import *
+from .ProtoObjs import *
class ProtoDropTarget(wx.PyDropTarget):
"""Implements drop target functionality to receive files, bitmaps and text"""
@@ -73,7 +72,7 @@ class ProtoObjsUI(wx.Panel):
self.SetDropTarget(ProtoDropTarget(self))
def populate(self):
- for key in self.protoObjs.data.keys():
+ for key in list(self.protoObjs.data.keys()):
self.add(self.protoObjs.data[key])
# All subclasses should implement this method
diff --git a/direct/src/leveleditor/ProtoPalette.py b/direct/src/leveleditor/ProtoPalette.py
index b796e712fa..0f8aacee3b 100755
--- a/direct/src/leveleditor/ProtoPalette.py
+++ b/direct/src/leveleditor/ProtoPalette.py
@@ -2,7 +2,7 @@
Palette for Prototyping
"""
-from ProtoPaletteBase import *
+from .ProtoPaletteBase import *
class ProtoPalette(ProtoPaletteBase):
def __init__(self):
diff --git a/direct/src/leveleditor/ProtoPaletteBase.py b/direct/src/leveleditor/ProtoPaletteBase.py
index 3c0c5bdd1c..9d9aa3775f 100755
--- a/direct/src/leveleditor/ProtoPaletteBase.py
+++ b/direct/src/leveleditor/ProtoPaletteBase.py
@@ -1,11 +1,9 @@
"""
Palette for Prototyping
"""
-import os
import imp
-import types
-from ObjectPaletteBase import *
+from .ObjectPaletteBase import *
class ProtoPaletteBase(ObjectPaletteBase):
def __init__(self):
@@ -14,9 +12,9 @@ class ProtoPaletteBase(ObjectPaletteBase):
assert self.dirname
def addItems(self):
- if type(protoData) == types.DictType:
- for key in protoData.keys():
- if type(protoData[key]) == types.DictType:
+ if type(protoData) == dict:
+ for key in list(protoData.keys()):
+ if type(protoData[key]) == dict:
self.add(key, parent)
self.addItems(protoData[key], key)
else:
@@ -30,7 +28,7 @@ class ProtoPaletteBase(ObjectPaletteBase):
self.data = module.protoData
self.dataStruct = module.protoDataStruct
except:
- print "protoPaletteData doesn't exist"
+ print("protoPaletteData doesn't exist")
return
#self.addItems()
@@ -39,14 +37,14 @@ class ProtoPaletteBase(ObjectPaletteBase):
if not f:
return
- for key in self.dataStruct.keys():
+ for key in list(self.dataStruct.keys()):
f.write("\t'%s':'%s',\n"%(key, self.dataStruct[key]))
def saveProtoData(self, f):
if not f:
return
- for key in self.data.keys():
+ for key in list(self.data.keys()):
if isinstance(self.data[key], ObjectBase):
f.write("\t'%s':ObjectBase(name='%s', model='%s', anims=%s, actor=%s),\n"%(key, self.data[key].name, self.data[key].model, self.data[key].anims, self.data[key].actor))
else:
diff --git a/direct/src/leveleditor/ProtoPaletteUI.py b/direct/src/leveleditor/ProtoPaletteUI.py
index 7c19e85754..d9f047b55f 100755
--- a/direct/src/leveleditor/ProtoPaletteUI.py
+++ b/direct/src/leveleditor/ProtoPaletteUI.py
@@ -3,9 +3,8 @@ Defines ProtoPalette tree UI
"""
import wx
import os
-import cPickle as pickl
from pandac.PandaModules import *
-from PaletteTreeCtrl import *
+from .PaletteTreeCtrl import *
class UniversalDropTarget(wx.PyDropTarget):
"""Implements drop target functionality to receive files, bitmaps and text"""
@@ -89,7 +88,7 @@ class ProtoPaletteUI(wx.Panel):
self.SetDropTarget(UniversalDropTarget(self.editor))
def populate(self):
- dataStructKeys = self.palette.dataStruct.keys()[:]
+ dataStructKeys = list(self.palette.dataStruct.keys())
self.tree.addTreeNodes(self.tree.GetRootItem(), self.palette.rootName, self.palette.dataStruct, dataStructKeys)
def OnBeginLabelEdit(self, event):
@@ -199,7 +198,7 @@ class ProtoPaletteUI(wx.Panel):
if self.opSort == self.opSortAlpha:
return cmp(data1, data2)
else:
- items = self.palette.data.keys()[:]
+ items = list(self.palette.data.keys())
index1 = items.index(data1)
index2 = items.index(data2)
return cmp(index1, index2)
diff --git a/direct/src/leveleditor/SceneGraphUI.py b/direct/src/leveleditor/SceneGraphUI.py
index 0a6ca41b69..f3c99e617b 100755
--- a/direct/src/leveleditor/SceneGraphUI.py
+++ b/direct/src/leveleditor/SceneGraphUI.py
@@ -1,7 +1,7 @@
"""
Defines Scene Graph tree UI
"""
-from SceneGraphUIBase import *
+from .SceneGraphUIBase import *
class SceneGraphUI(SceneGraphUIBase):
def __init__(self, parent, editor):
diff --git a/direct/src/leveleditor/SceneGraphUIBase.py b/direct/src/leveleditor/SceneGraphUIBase.py
index b8c4bc9b7e..c98cf8505c 100755
--- a/direct/src/leveleditor/SceneGraphUIBase.py
+++ b/direct/src/leveleditor/SceneGraphUIBase.py
@@ -2,20 +2,19 @@
Defines Scene Graph tree UI Base
"""
import wx
-import cPickle as pickle
from pandac.PandaModules import *
-from ActionMgr import *
+from .ActionMgr import *
-import ObjectGlobals as OG
+from . import ObjectGlobals as OG
class SceneGraphUIDropTarget(wx.TextDropTarget):
def __init__(self, editor):
- print "in SceneGraphUIDropTarget::init..."
+ print("in SceneGraphUIDropTarget::init...")
wx.TextDropTarget.__init__(self)
self.editor = editor
def OnDropText(self, x, y, text):
- print "in SceneGraphUIDropTarget::OnDropText..."
+ print("in SceneGraphUIDropTarget::OnDropText...")
self.editor.ui.sceneGraphUI.changeHierarchy(text, x, y)
class SceneGraphUIBase(wx.Panel):
@@ -299,7 +298,7 @@ class SceneGraphUIBase(wx.Panel):
if item != self.tree.GetRootItem(): # prevent dragging root item
text = self.tree.GetItemText(item)
- print "Starting SceneGraphUI drag'n'drop with %s..." % repr(text)
+ print("Starting SceneGraphUI drag'n'drop with %s..." % repr(text))
tdo = wx.TextDataObject(text)
tds = wx.DropSource(self.tree)
diff --git a/direct/src/motiontrail/MotionTrail.py b/direct/src/motiontrail/MotionTrail.py
index f678b34c7e..db891548ac 100644
--- a/direct/src/motiontrail/MotionTrail.py
+++ b/direct/src/motiontrail/MotionTrail.py
@@ -11,14 +11,14 @@ def remove_task ( ):
if (MotionTrail.task_added):
total_motion_trails = len (MotionTrail.motion_trail_list)
- if (total_motion_trails > 0):
- print "warning:", total_motion_trails, "motion trails still exist when motion trail task is removed"
+ if total_motion_trails > 0:
+ print("warning: %d motion trails still exist when motion trail task is removed" % (total_motion_trails))
MotionTrail.motion_trail_list = [ ]
taskMgr.remove (MotionTrail.motion_trail_task_name)
- print "MotionTrail task removed"
+ print("MotionTrail task removed")
MotionTrail.task_added = False
return
@@ -149,10 +149,10 @@ class MotionTrail(NodePath, DirectObject):
def print_matrix (self, matrix):
separator = ' '
- print matrix.getCell (0, 0), separator, matrix.getCell (0, 1), separator, matrix.getCell (0, 2), separator, matrix.getCell (0, 3)
- print matrix.getCell (1, 0), separator, matrix.getCell (1, 1), separator, matrix.getCell (1, 2), separator, matrix.getCell (1, 3)
- print matrix.getCell (2, 0), separator, matrix.getCell (2, 1), separator, matrix.getCell (2, 2), separator, matrix.getCell (2, 3)
- print matrix.getCell (3, 0), separator, matrix.getCell (3, 1), separator, matrix.getCell (3, 2), separator, matrix.getCell (3, 3)
+ print(matrix.getCell (0, 0), separator, matrix.getCell (0, 1), separator, matrix.getCell (0, 2), separator, matrix.getCell (0, 3))
+ print(matrix.getCell (1, 0), separator, matrix.getCell (1, 1), separator, matrix.getCell (1, 2), separator, matrix.getCell (1, 3))
+ print(matrix.getCell (2, 0), separator, matrix.getCell (2, 1), separator, matrix.getCell (2, 2), separator, matrix.getCell (2, 3))
+ print(matrix.getCell (3, 0), separator, matrix.getCell (3, 1), separator, matrix.getCell (3, 2), separator, matrix.getCell (3, 3))
def motion_trail_task (self, task):
@@ -379,8 +379,8 @@ class MotionTrail(NodePath, DirectObject):
elapsed_time = current_time - self.fade_start_time
if (elapsed_time < 0.0):
+ print("elapsed_time < 0: %f" % (elapsed_time))
elapsed_time = 0.0
- print "elapsed_time < 0", elapsed_time
if (elapsed_time < self.fade_time):
color_scale = (1.0 - (elapsed_time / self.fade_time)) * color_scale
diff --git a/direct/src/p3d/AppRunner.py b/direct/src/p3d/AppRunner.py
index 9c6c15631a..4a59e20de6 100644
--- a/direct/src/p3d/AppRunner.py
+++ b/direct/src/p3d/AppRunner.py
@@ -13,7 +13,11 @@ __all__ = ["AppRunner", "dummyAppRunner", "ArgumentError"]
import sys
import os
-import __builtin__ as builtins
+
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
from direct.showbase import VFSImporter
from direct.showbase.DirectObject import DirectObject
@@ -798,7 +802,7 @@ class AppRunner(DirectObject):
if not host.hasContentsFile:
# This is weird. How did we launch without having
# this file at all?
- raise OSError, message
+ raise OSError(message)
# Just make it a warning and continue.
self.notify.warning(message)
@@ -819,20 +823,20 @@ class AppRunner(DirectObject):
return self.addPackageInfo(name, platform, version, hostUrl, hostDir = hostDir, recurse = True)
message = "Couldn't find %s %s on %s" % (name, version, hostUrl)
- raise OSError, message
+ raise OSError(message)
package.checkStatus()
if not package.downloadDescFile(self.http):
message = "Couldn't get desc file for %s" % (name)
- raise OSError, message
+ raise OSError(message)
if not package.downloadPackage(self.http):
message = "Couldn't download %s" % (name)
- raise OSError, message
+ raise OSError(message)
if not package.installPackage(self):
message = "Couldn't install %s" % (name)
- raise OSError, message
+ raise OSError(message)
if package.guiApp:
self.guiApp = True
@@ -877,17 +881,17 @@ class AppRunner(DirectObject):
vfs = VirtualFileSystem.getGlobalPtr()
if not vfs.exists(fname):
- raise ArgumentError, "No such file: %s" % (p3dFilename)
+ raise ArgumentError("No such file: %s" % (p3dFilename))
fname.makeAbsolute()
fname.setBinary()
mf = Multifile()
if p3dOffset == 0:
if not mf.openRead(fname):
- raise ArgumentError, "Not a Panda3D application: %s" % (p3dFilename)
+ raise ArgumentError("Not a Panda3D application: %s" % (p3dFilename))
else:
if not mf.openRead(fname, p3dOffset):
- raise ArgumentError, "Not a Panda3D application: %s at offset: %s" % (p3dFilename, p3dOffset)
+ raise ArgumentError("Not a Panda3D application: %s at offset: %s" % (p3dFilename, p3dOffset))
# Now load the p3dInfo file.
self.p3dInfo = None
@@ -925,7 +929,7 @@ class AppRunner(DirectObject):
# The interactiveConsole flag can only be set true if the
# application has allow_python_dev set.
if not self.allowPythonDev and interactiveConsole:
- raise StandardError, "Impossible, interactive_console set without allow_python_dev."
+ raise Exception("Impossible, interactive_console set without allow_python_dev.")
self.interactiveConsole = interactiveConsole
if self.allowPythonDev:
diff --git a/direct/src/p3d/DeploymentTools.py b/direct/src/p3d/DeploymentTools.py
index 8d03fd94bc..9c390fbf07 100644
--- a/direct/src/p3d/DeploymentTools.py
+++ b/direct/src/p3d/DeploymentTools.py
@@ -5,8 +5,7 @@ to build for as many platforms as possible. """
__all__ = ["Standalone", "Installer"]
import os, sys, subprocess, tarfile, shutil, time, zipfile, socket, getpass, struct
-import gzip
-from io import BytesIO, TextIOWrapper
+import gzip, plistlib
from direct.directnotify.DirectNotifyGlobal import *
from direct.showbase.AppRunnerGlobal import appRunner
from panda3d.core import PandaSystem, HTTPClient, Filename, VirtualFileSystem, Multifile
@@ -22,6 +21,13 @@ try:
except ImportError:
pwd = None
+if sys.version_info >= (3, 0):
+ xrange = range
+ from io import BytesIO, TextIOWrapper
+else:
+ from io import BytesIO
+ from StringIO import StringIO
+
# Make sure this matches with the magic in p3dEmbedMain.cxx.
P3DEMBED_MAGIC = 0xFF3D3D00
@@ -758,20 +764,20 @@ class Installer:
desktopFile.setText()
desktopFile.makeDir()
desktop = open(desktopFile.toOsSpecific(), 'w')
- print >>desktop, "[Desktop Entry]"
- print >>desktop, "Name=%s" % self.fullname
- print >>desktop, "Exec=%s" % self.shortname.lower()
+ desktop.write("[Desktop Entry]\n")
+ desktop.write("Name=%s\n" % self.fullname)
+ desktop.write("Exec=%s\n" % self.shortname.lower())
if iconFile is not None:
- print >>desktop, "Icon=%s" % iconFile.getBasename()
+ desktop.write("Icon=%s\n" % iconFile.getBasename())
# Set the "Terminal" option based on whether or not a console env is requested
cEnv = self.standalone.tokens.get("console_environment", "")
if cEnv == "" or int(cEnv) == 0:
- print >>desktop, "Terminal=false"
+ desktop.write("Terminal=false\n")
else:
- print >>desktop, "Terminal=true"
+ desktop.write("Terminal=true\n")
- print >>desktop, "Type=Application"
+ desktop.write("Type=Application\n")
desktop.close()
if self.includeRequires or self.extracts:
@@ -805,17 +811,24 @@ class Installer:
# Create a control file in memory.
controlfile = BytesIO()
- cout = TextIOWrapper(controlfile, encoding='utf-8', newline='')
- cout.write(u"Package: %s\n" % self.shortname.lower())
- cout.write(u"Version: %s\n" % self.version)
- cout.write(u"Maintainer: %s <%s>\n" % (self.authorname, self.authoremail))
- cout.write(u"Section: games\n")
- cout.write(u"Priority: optional\n")
- cout.write(u"Architecture: %s\n" % arch)
- cout.write(u"Installed-Size: %d\n" % -(-totsize // 1024))
- cout.write(u"Description: %s\n" % self.fullname)
- cout.write(u"Depends: libc6, libgcc1, libstdc++6, libx11-6\n")
+ if sys.version_info >= (3, 0):
+ cout = TextIOWrapper(controlfile, encoding='utf-8', newline='')
+ else:
+ cout = StringIO()
+
+ cout.write("Package: %s\n" % self.shortname.lower())
+ cout.write("Version: %s\n" % self.version)
+ cout.write("Maintainer: %s <%s>\n" % (self.authorname, self.authoremail))
+ cout.write("Section: games\n")
+ cout.write("Priority: optional\n")
+ cout.write("Architecture: %s\n" % arch)
+ cout.write("Installed-Size: %d\n" % -(-totsize // 1024))
+ cout.write("Description: %s\n" % self.fullname)
+ cout.write("Depends: libc6, libgcc1, libstdc++6, libx11-6\n")
cout.flush()
+ if sys.version_info < (3, 0):
+ controlfile.write(cout.getvalue().encode('utf-8'))
+
controlinfo = TarInfoRoot("control")
controlinfo.mtime = modtime
controlinfo.size = controlfile.tell()
@@ -890,19 +903,26 @@ class Installer:
# Create a pkginfo file in memory.
pkginfo = BytesIO()
- pout = TextIOWrapper(pkginfo, encoding='utf-8', newline='')
- pout.write(u"# Generated using pdeploy\n")
- pout.write(u"# %s\n" % time.ctime(modtime))
- pout.write(u"pkgname = %s\n" % self.shortname.lower())
- pout.write(u"pkgver = %s\n" % pkgver)
- pout.write(u"pkgdesc = %s\n" % self.fullname)
- pout.write(u"builddate = %s\n" % modtime)
- pout.write(u"packager = %s <%s>\n" % (self.authorname, self.authoremail))
- pout.write(u"size = %d\n" % totsize)
- pout.write(u"arch = %s\n" % arch)
+ if sys.version_info >= (3, 0):
+ pout = TextIOWrapper(pkginfo, encoding='utf-8', newline='')
+ else:
+ pout = StringIO()
+
+ pout.write("# Generated using pdeploy\n")
+ pout.write("# %s\n" % time.ctime(modtime))
+ pout.write("pkgname = %s\n" % self.shortname.lower())
+ pout.write("pkgver = %s\n" % pkgver)
+ pout.write("pkgdesc = %s\n" % self.fullname)
+ pout.write("builddate = %s\n" % modtime)
+ pout.write("packager = %s <%s>\n" % (self.authorname, self.authoremail))
+ pout.write("size = %d\n" % totsize)
+ pout.write("arch = %s\n" % arch)
if self.licensename != "":
- pout.write(u"license = %s\n" % self.licensename)
+ pout.write("license = %s\n" % self.licensename)
pout.flush()
+ if sys.version_info < (3, 0):
+ pkginfo.write(pout.getvalue().encode('utf-8'))
+
pkginfoinfo = TarInfoRoot(".PKGINFO")
pkginfoinfo.mtime = modtime
pkginfoinfo.size = pkginfo.tell()
@@ -942,45 +962,25 @@ class Installer:
Installer.notify.info("Generating %s.icns..." % self.shortname)
hasIcon = self.icon.makeICNS(Filename(hostDir, "%s.icns" % self.shortname))
- # Create the application plist file.
- # Although it might make more sense to use Python's plistlib module here,
- # it is not available on non-OSX systems before Python 2.6.
- plist = open(Filename(output, "Contents/Info.plist").toOsSpecific(), "w")
- print >>plist, ''
- print >>plist, ''
- print >>plist, ''
- print >>plist, ''
- print >>plist, '\tCFBundleDevelopmentRegion '
- print >>plist, '\tEnglish '
- print >>plist, '\tCFBundleDisplayName '
- print >>plist, '\t%s ' % self.fullname
- print >>plist, '\tCFBundleExecutable '
- print >>plist, '\t%s ' % exefile.getBasename()
+ # Create the application plist file using Python's plistlib module.
+ plist = {
+ 'CFBundleDevelopmentRegion': 'English',
+ 'CFBundleDisplayName': self.fullname,
+ 'CFBundleExecutable': exefile.getBasename(),
+ 'CFBundleIdentifier': '%s.%s' % (self.author, self.shortname),
+ 'CFBundleInfoDictionaryVersion': '6.0',
+ 'CFBundleName': self.shortname,
+ 'CFBundlePackageType': 'APPL',
+ 'CFBundleShortVersionString': self.version,
+ 'CFBundleVersion': self.version,
+ 'LSHasLocalizedDisplayName': False,
+ 'NSAppleScriptEnabled': False,
+ 'NSPrincipalClass': 'NSApplication',
+ }
if hasIcon:
- print >>plist, '\tCFBundleIconFile '
- print >>plist, '\t%s.icns ' % self.shortname
- print >>plist, '\tCFBundleIdentifier '
- print >>plist, '\t%s.%s ' % (self.authorid, self.shortname)
- print >>plist, '\tCFBundleInfoDictionaryVersion '
- print >>plist, '\t6.0 '
- print >>plist, '\tCFBundleName '
- print >>plist, '\t%s ' % self.shortname
- print >>plist, '\tCFBundlePackageType '
- print >>plist, '\tAPPL '
- print >>plist, '\tCFBundleShortVersionString '
- print >>plist, '\t%s ' % self.version
- print >>plist, '\tCFBundleVersion '
- print >>plist, '\t%s ' % self.version
- print >>plist, '\tLSHasLocalizedDisplayName '
- print >>plist, '\t '
- print >>plist, '\tNSAppleScriptEnabled '
- print >>plist, '\t '
- print >>plist, '\tNSPrincipalClass '
- print >>plist, '\tNSApplication '
- print >>plist, ' '
- print >>plist, ' '
- plist.close()
+ plist['CFBundleIconFile'] = self.shortname + '.icns'
+ plistlib.writePlist(plist, Filename(output, "Contents/Info.plist").toOsSpecific())
return output
def buildPKG(self, output, platform):
@@ -1221,73 +1221,73 @@ class Installer:
nsi = open(nsifile.toOsSpecific(), "w")
# Some global info
- print >>nsi, 'Name "%s"' % self.fullname
- print >>nsi, 'OutFile "%s"' % output.toOsSpecific()
+ nsi.write('Name "%s"\n' % self.fullname)
+ nsi.write('OutFile "%s"\n' % output.toOsSpecific())
if platform == 'win_amd64':
- print >>nsi, 'InstallDir "$PROGRAMFILES64\\%s"' % self.fullname
+ nsi.write('InstallDir "$PROGRAMFILES64\\%s"\n' % self.fullname)
else:
- print >>nsi, 'InstallDir "$PROGRAMFILES\\%s"' % self.fullname
- print >>nsi, 'SetCompress auto'
- print >>nsi, 'SetCompressor lzma'
- print >>nsi, 'ShowInstDetails nevershow'
- print >>nsi, 'ShowUninstDetails nevershow'
- print >>nsi, 'InstType "Typical"'
+ nsi.write('InstallDir "$PROGRAMFILES\\%s"\n' % self.fullname)
+ nsi.write('SetCompress auto\n')
+ nsi.write('SetCompressor lzma\n')
+ nsi.write('ShowInstDetails nevershow\n')
+ nsi.write('ShowUninstDetails nevershow\n')
+ nsi.write('InstType "Typical"\n')
# Tell Vista that we require admin rights
- print >>nsi, 'RequestExecutionLevel admin'
- print >>nsi
+ nsi.write('RequestExecutionLevel admin\n')
+ nsi.write('\n')
if self.offerRun:
- print >>nsi, 'Function launch'
- print >>nsi, ' ExecShell "open" "$INSTDIR\\%s.exe"' % self.shortname
- print >>nsi, 'FunctionEnd'
- print >>nsi
+ nsi.write('Function launch\n')
+ nsi.write(' ExecShell "open" "$INSTDIR\\%s.exe"\n' % self.shortname)
+ nsi.write('FunctionEnd\n')
+ nsi.write('\n')
if self.offerDesktopShortcut:
- print >>nsi, 'Function desktopshortcut'
+ nsi.write('Function desktopshortcut\n')
if icofile is None:
- print >>nsi, ' CreateShortcut "$DESKTOP\\%s.lnk" "$INSTDIR\\%s.exe"' % (self.fullname, self.shortname)
+ nsi.write(' CreateShortcut "$DESKTOP\\%s.lnk" "$INSTDIR\\%s.exe"\n' % (self.fullname, self.shortname))
else:
- print >>nsi, ' CreateShortcut "$DESKTOP\\%s.lnk" "$INSTDIR\\%s.exe" "" "$INSTDIR\\%s.ico"' % (self.fullname, self.shortname, self.shortname)
- print >>nsi, 'FunctionEnd'
- print >>nsi
+ nsi.write(' CreateShortcut "$DESKTOP\\%s.lnk" "$INSTDIR\\%s.exe" "" "$INSTDIR\\%s.ico"\n' % (self.fullname, self.shortname, self.shortname))
+ nsi.write('FunctionEnd\n')
+ nsi.write('\n')
- print >>nsi, '!include "MUI2.nsh"'
- print >>nsi, '!define MUI_ABORTWARNING'
+ nsi.write('!include "MUI2.nsh"\n')
+ nsi.write('!define MUI_ABORTWARNING\n')
if self.offerRun:
- print >>nsi, '!define MUI_FINISHPAGE_RUN'
- print >>nsi, '!define MUI_FINISHPAGE_RUN_NOTCHECKED'
- print >>nsi, '!define MUI_FINISHPAGE_RUN_FUNCTION launch'
- print >>nsi, '!define MUI_FINISHPAGE_RUN_TEXT "Run %s"' % self.fullname
+ nsi.write('!define MUI_FINISHPAGE_RUN\n')
+ nsi.write('!define MUI_FINISHPAGE_RUN_NOTCHECKED\n')
+ nsi.write('!define MUI_FINISHPAGE_RUN_FUNCTION launch\n')
+ nsi.write('!define MUI_FINISHPAGE_RUN_TEXT "Run %s"\n' % self.fullname)
if self.offerDesktopShortcut:
- print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME ""'
- print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED'
- print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"'
- print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME_FUNCTION desktopshortcut'
- print >>nsi
- print >>nsi, 'Var StartMenuFolder'
- print >>nsi, '!insertmacro MUI_PAGE_WELCOME'
+ nsi.write('!define MUI_FINISHPAGE_SHOWREADME ""\n')
+ nsi.write('!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED\n')
+ nsi.write('!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"\n')
+ nsi.write('!define MUI_FINISHPAGE_SHOWREADME_FUNCTION desktopshortcut\n')
+ nsi.write('\n')
+ nsi.write('Var StartMenuFolder\n')
+ nsi.write('!insertmacro MUI_PAGE_WELCOME\n')
if not self.licensefile.empty():
abs = Filename(self.licensefile)
abs.makeAbsolute()
- print >>nsi, '!insertmacro MUI_PAGE_LICENSE "%s"' % abs.toOsSpecific()
- print >>nsi, '!insertmacro MUI_PAGE_DIRECTORY'
- print >>nsi, '!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder'
- print >>nsi, '!insertmacro MUI_PAGE_INSTFILES'
- print >>nsi, '!insertmacro MUI_PAGE_FINISH'
- print >>nsi, '!insertmacro MUI_UNPAGE_WELCOME'
- print >>nsi, '!insertmacro MUI_UNPAGE_CONFIRM'
- print >>nsi, '!insertmacro MUI_UNPAGE_INSTFILES'
- print >>nsi, '!insertmacro MUI_UNPAGE_FINISH'
- print >>nsi, '!insertmacro MUI_LANGUAGE "English"'
+ nsi.write('!insertmacro MUI_PAGE_LICENSE "%s"\n' % abs.toOsSpecific())
+ nsi.write('!insertmacro MUI_PAGE_DIRECTORY\n')
+ nsi.write('!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder\n')
+ nsi.write('!insertmacro MUI_PAGE_INSTFILES\n')
+ nsi.write('!insertmacro MUI_PAGE_FINISH\n')
+ nsi.write('!insertmacro MUI_UNPAGE_WELCOME\n')
+ nsi.write('!insertmacro MUI_UNPAGE_CONFIRM\n')
+ nsi.write('!insertmacro MUI_UNPAGE_INSTFILES\n')
+ nsi.write('!insertmacro MUI_UNPAGE_FINISH\n')
+ nsi.write('!insertmacro MUI_LANGUAGE "English"\n')
# This section defines the installer.
- print >>nsi, 'Section "" SecCore'
- print >>nsi, ' SetOutPath "$INSTDIR"'
- print >>nsi, ' File "%s"' % exefile.toOsSpecific()
+ nsi.write('Section "" SecCore\n')
+ nsi.write(' SetOutPath "$INSTDIR"\n')
+ nsi.write(' File "%s"\n' % exefile.toOsSpecific())
if icofile is not None:
- print >>nsi, ' File "%s"' % icofile.toOsSpecific()
+ nsi.write(' File "%s"\n' % icofile.toOsSpecific())
for f in extrafiles:
- print >>nsi, ' File "%s"' % f.toOsSpecific()
+ nsi.write(' File "%s"\n' % f.toOsSpecific())
curdir = ""
for root, dirs, files in self.os_walk(hostDir.toOsSpecific()):
for name in files:
@@ -1297,39 +1297,39 @@ class Installer:
file.makeRelativeTo(hostDir)
outdir = file.getDirname().replace('/', '\\')
if curdir != outdir:
- print >>nsi, ' SetOutPath "$INSTDIR\\%s"' % outdir
+ nsi.write(' SetOutPath "$INSTDIR\\%s"\n' % outdir)
curdir = outdir
- print >>nsi, ' File "%s"' % (basefile.toOsSpecific())
- print >>nsi, ' SetOutPath "$INSTDIR"'
- print >>nsi, ' WriteUninstaller "$INSTDIR\\Uninstall.exe"'
- print >>nsi, ' ; Start menu items'
- print >>nsi, ' !insertmacro MUI_STARTMENU_WRITE_BEGIN Application'
- print >>nsi, ' CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"'
+ nsi.write(' File "%s"\n' % (basefile.toOsSpecific()))
+ nsi.write(' SetOutPath "$INSTDIR"\n')
+ nsi.write(' WriteUninstaller "$INSTDIR\\Uninstall.exe"\n')
+ nsi.write(' ; Start menu items\n')
+ nsi.write(' !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n')
+ nsi.write(' CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"\n')
if icofile is None:
- print >>nsi, ' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe"' % (self.fullname, self.shortname)
+ nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe"\n' % (self.fullname, self.shortname))
else:
- print >>nsi, ' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe" "" "$INSTDIR\\%s.ico"' % (self.fullname, self.shortname, self.shortname)
- print >>nsi, ' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"'
- print >>nsi, ' !insertmacro MUI_STARTMENU_WRITE_END'
- print >>nsi, 'SectionEnd'
+ nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe" "" "$INSTDIR\\%s.ico"\n' % (self.fullname, self.shortname, self.shortname))
+ nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"\n')
+ nsi.write(' !insertmacro MUI_STARTMENU_WRITE_END\n')
+ nsi.write('SectionEnd\n')
# This section defines the uninstaller.
- print >>nsi, 'Section Uninstall'
- print >>nsi, ' Delete "$INSTDIR\\%s.exe"' % self.shortname
+ nsi.write('Section Uninstall\n')
+ nsi.write(' Delete "$INSTDIR\\%s.exe"\n' % self.shortname)
if icofile is not None:
- print >>nsi, ' Delete "$INSTDIR\\%s.ico"' % self.shortname
+ nsi.write(' Delete "$INSTDIR\\%s.ico"\n' % self.shortname)
for f in extrafiles:
- print >>nsi, ' Delete "%s"' % f.getBasename()
- print >>nsi, ' Delete "$INSTDIR\\Uninstall.exe"'
- print >>nsi, ' RMDir /r "$INSTDIR"'
- print >>nsi, ' ; Desktop icon'
- print >>nsi, ' Delete "$DESKTOP\\%s.lnk"' % self.fullname
- print >>nsi, ' ; Start menu items'
- print >>nsi, ' !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder'
- print >>nsi, ' Delete "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk"' % self.fullname
- print >>nsi, ' Delete "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk"'
- print >>nsi, ' RMDir "$SMPROGRAMS\\$StartMenuFolder"'
- print >>nsi, 'SectionEnd'
+ nsi.write(' Delete "%s"\n' % f.getBasename())
+ nsi.write(' Delete "$INSTDIR\\Uninstall.exe"\n')
+ nsi.write(' RMDir /r "$INSTDIR"\n')
+ nsi.write(' ; Desktop icon\n')
+ nsi.write(' Delete "$DESKTOP\\%s.lnk"\n' % self.fullname)
+ nsi.write(' ; Start menu items\n')
+ nsi.write(' !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder\n')
+ nsi.write(' Delete "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk"\n' % self.fullname)
+ nsi.write(' Delete "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk"\n')
+ nsi.write(' RMDir "$SMPROGRAMS\\$StartMenuFolder"\n')
+ nsi.write('SectionEnd\n')
nsi.close()
cmd = [makensis]
@@ -1339,7 +1339,7 @@ class Installer:
else:
cmd.append("-" + o)
cmd.append(nsifile.toOsSpecific())
- print cmd
+ print(cmd)
try:
retcode = subprocess.call(cmd, shell = False)
if retcode != 0:
diff --git a/direct/src/p3d/HostInfo.py b/direct/src/p3d/HostInfo.py
index d97a39ea8e..4e5efdcd3e 100644
--- a/direct/src/p3d/HostInfo.py
+++ b/direct/src/p3d/HostInfo.py
@@ -244,10 +244,10 @@ class HostInfo:
# if we get here there may be some bigger problem. Just
# give the generic "big problem" message.
launcher.setPandaErrorCode(6)
- except NameError,e:
+ except NameError as e:
# no launcher
pass
- except AttributeError, e:
+ except AttributeError as e:
self.notify.warning("%s" % (str(e),))
pass
return False
@@ -653,8 +653,8 @@ class HostInfo:
packages = packages[:]
- for key, platforms in self.packages.items():
- for platform, package in platforms.items():
+ for key, platforms in list(self.packages.items()):
+ for platform, package in list(platforms.items()):
if package in packages:
self.__deletePackageFiles(package)
del platforms[platform]
diff --git a/direct/src/p3d/JavaScript.py b/direct/src/p3d/JavaScript.py
index 3b6d295032..b59deb1aa2 100644
--- a/direct/src/p3d/JavaScript.py
+++ b/direct/src/p3d/JavaScript.py
@@ -4,8 +4,6 @@ code that runs in a browser via the web plugin. """
__all__ = ["UndefinedObject", "Undefined", "ConcreteStruct", "BrowserObject", "MethodWrapper"]
-import types
-
class UndefinedObject:
""" This is a special object that is returned by the browser to
represent an "undefined" or "void" value, typically the value for
@@ -13,9 +11,11 @@ class UndefinedObject:
attributes, similar to None, but it is a slightly different
concept in JavaScript. """
- def __nonzero__(self):
+ def __bool__(self):
return False
+ __nonzero__ = __bool__ # Python 2
+
def __str__(self):
return "Undefined"
@@ -40,7 +40,7 @@ class ConcreteStruct:
returns all properties of the object. You can override this
to restrict the set of properties that are uploaded. """
- return self.__dict__.items()
+ return list(self.__dict__.items())
class BrowserObject:
""" This class provides the Python wrapper around some object that
@@ -83,16 +83,18 @@ class BrowserObject:
def __str__(self):
return self.toString()
- def __nonzero__(self):
+ def __bool__(self):
return True
+ __nonzero__ = __bool__ # Python 2
+
def __call__(self, *args, **kw):
needsResponse = True
if 'needsResponse' in kw:
needsResponse = kw['needsResponse']
del kw['needsResponse']
if kw:
- raise ArgumentError, 'Keyword arguments not supported'
+ raise ArgumentError('Keyword arguments not supported')
try:
parentObj, attribName = self.__childObject
@@ -105,7 +107,7 @@ class BrowserObject:
# problems.
needsResponse = False
- if parentObj is self.__runner.dom and attribName == 'eval' and len(args) == 1 and isinstance(args[0], types.StringTypes):
+ if parentObj is self.__runner.dom and attribName == 'eval' and len(args) == 1 and isinstance(args[0], str):
# As another special hack, we make dom.eval() a
# special case, and map it directly into an eval()
# call. If the string begins with 'void ', we further
@@ -203,7 +205,7 @@ class BrowserObject:
# for numeric keys so we can properly support Python's
# iterators, but we return KeyError for string keys to
# emulate mapping objects.
- if isinstance(key, types.StringTypes):
+ if isinstance(key, str):
raise KeyError(key)
else:
raise IndexError(key)
@@ -215,7 +217,7 @@ class BrowserObject:
propertyName = str(key),
value = value)
if not result:
- if isinstance(key, types.StringTypes):
+ if isinstance(key, str):
raise KeyError(key)
else:
raise IndexError(key)
@@ -224,7 +226,7 @@ class BrowserObject:
result = self.__runner.scriptRequest('del_property', self,
propertyName = str(key))
if not result:
- if isinstance(key, types.StringTypes):
+ if isinstance(key, str):
raise KeyError(key)
else:
raise IndexError(key)
@@ -242,16 +244,18 @@ class MethodWrapper:
parentObj, attribName = self.__childObject
return "%s.%s" % (parentObj, attribName)
- def __nonzero__(self):
+ def __bool__(self):
return True
+ __nonzero__ = __bool__ # Python 2
+
def __call__(self, *args, **kw):
needsResponse = True
if 'needsResponse' in kw:
needsResponse = kw['needsResponse']
del kw['needsResponse']
if kw:
- raise ArgumentError, 'Keyword arguments not supported'
+ raise ArgumentError('Keyword arguments not supported')
try:
parentObj, attribName = self.__childObject
@@ -263,7 +267,7 @@ class MethodWrapper:
# problems.
needsResponse = False
- if parentObj is self.__runner.dom and attribName == 'eval' and len(args) == 1 and isinstance(args[0], types.StringTypes):
+ if parentObj is self.__runner.dom and attribName == 'eval' and len(args) == 1 and isinstance(args[0], str):
# As another special hack, we make dom.eval() a
# special case, and map it directly into an eval()
# call. If the string begins with 'void ', we further
diff --git a/direct/src/p3d/PackageInstaller.py b/direct/src/p3d/PackageInstaller.py
index 33527ef94e..cec1e07b11 100644
--- a/direct/src/p3d/PackageInstaller.py
+++ b/direct/src/p3d/PackageInstaller.py
@@ -239,7 +239,7 @@ class PackageInstaller(DirectObject):
downloaded. Call donePackages() to finish the list. """
if self.state != self.S_initial:
- raise ValueError, 'addPackage called after donePackages'
+ raise ValueError('addPackage called after donePackages')
host = self.appRunner.getHostWithAlt(hostUrl)
pp = self.PendingPackage(packageName, version, host)
diff --git a/direct/src/p3d/PackageMerger.py b/direct/src/p3d/PackageMerger.py
index a00a3f7d35..a22d8f5f2d 100644
--- a/direct/src/p3d/PackageMerger.py
+++ b/direct/src/p3d/PackageMerger.py
@@ -7,7 +7,7 @@ from panda3d.core import *
import shutil
import os
-class PackageMergerError(StandardError):
+class PackageMergerError(Exception):
pass
class PackageMerger:
@@ -102,12 +102,12 @@ class PackageMerger:
doc = TiXmlDocument(packageDescFullpath.toOsSpecific())
if not doc.LoadFile():
message = "Could not read XML file: %s" % (self.descFile.filename)
- raise OSError, message
+ raise OSError(message)
xpackage = doc.FirstChildElement('package')
if not xpackage:
message = "No package definition: %s" % (self.descFile.filename)
- raise OSError, message
+ raise OSError(message)
xcompressed = xpackage.FirstChildElement('compressed_archive')
if xcompressed:
@@ -207,7 +207,7 @@ class PackageMerger:
xcontents.SetAttribute('max_age', str(self.maxAge))
self.contentsSeq.storeXml(xcontents)
- contents = self.contents.items()
+ contents = list(self.contents.items())
contents.sort()
for key, pe in contents:
xpackage = pe.makeXml()
@@ -286,7 +286,7 @@ class PackageMerger:
if not self.__readContentsFile(sourceDir, packageNames):
message = "Couldn't read %s" % (sourceDir)
- raise PackageMergerError, message
+ raise PackageMergerError(message)
def close(self):
""" Finalizes the results of all of the previous calls to
diff --git a/direct/src/p3d/Packager.py b/direct/src/p3d/Packager.py
index f7d6855a90..b46cda30b7 100644
--- a/direct/src/p3d/Packager.py
+++ b/direct/src/p3d/Packager.py
@@ -11,8 +11,6 @@ from panda3d.core import *
import sys
import os
import glob
-import string
-import types
import struct
import subprocess
import copy
@@ -26,7 +24,7 @@ from direct.directnotify.DirectNotifyGlobal import *
vfs = VirtualFileSystem.getGlobalPtr()
-class PackagerError(StandardError):
+class PackagerError(Exception):
pass
class OutsideOfPackageError(PackagerError):
@@ -390,7 +388,7 @@ class Packager:
if not self.p3dApplication and not self.packager.allowPackages:
message = 'Cannot generate packages without an installDir; use -i'
- raise PackagerError, message
+ raise PackagerError(message)
if self.ignoredDirFiles:
exts = sorted(self.ignoredDirFiles.keys())
@@ -429,11 +427,11 @@ class Packager:
if self.version != PandaSystem.getPackageVersionString():
message = 'mismatched Panda3D version: requested %s, but Panda3D is built as %s' % (self.version, PandaSystem.getPackageVersionString())
- raise PackagerError, message
+ raise PackagerError(message)
if self.host != PandaSystem.getPackageHostUrl():
message = 'mismatched Panda3D host: requested %s, but Panda3D is built as %s' % (self.host, PandaSystem.getPackageHostUrl())
- raise PackagerError, message
+ raise PackagerError(message)
if self.p3dApplication:
# Default compression level for an app.
@@ -554,7 +552,7 @@ class Packager:
# Add the main module, if any.
if not self.mainModule and self.p3dApplication:
message = 'No main_module specified for application %s' % (self.packageName)
- raise PackagerError, message
+ raise PackagerError(message)
if self.mainModule:
moduleName, newName = self.mainModule
if newName not in self.freezer.modules:
@@ -574,7 +572,7 @@ class Packager:
# But first, make sure that all required modules are present.
missing = []
- moduleDict = dict(self.freezer.getModuleDefs()).keys()
+ moduleDict = dict(self.freezer.getModuleDefs())
for module in self.requiredModules:
if module not in moduleDict:
missing.append(module)
@@ -790,7 +788,7 @@ class Packager:
if not self.packager.allowPackages:
message = 'Cannot generate packages without an installDir; use -i'
- raise PackagerError, message
+ raise PackagerError(message)
installPath = Filename(self.packager.installDir, packageDir)
# Remove any files already in the installPath.
@@ -811,7 +809,7 @@ class Packager:
return
if len(files) != 1:
- raise PackagerError, 'Multiple files in "solo" package %s' % (self.packageName)
+ raise PackagerError('Multiple files in "solo" package %s' % (self.packageName))
Filename(installPath, '').makeDir()
@@ -1228,7 +1226,7 @@ class Packager:
filenames = []
for line in lines:
- if line[0] not in string.whitespace:
+ if not line[0].isspace():
continue
line = line.strip()
s = line.find(' (compatibility')
@@ -1535,7 +1533,7 @@ class Packager:
compressedPath = Filename(self.packager.installDir, newCompressedFilename)
if not compressFile(self.packageFullpath, compressedPath, 6):
message = 'Unable to write %s' % (compressedPath)
- raise PackagerError, message
+ raise PackagerError(message)
def readDescFile(self):
""" Reads the existing package.xml file before rewriting
@@ -1659,9 +1657,9 @@ class Packager:
xconfig = TiXmlElement('config')
for variable, value in self.configs.items():
- if isinstance(value, types.UnicodeType):
+ if sys.version_info < (3, 0) and isinstance(value, unicode):
xconfig.SetAttribute(variable, value.encode('utf-8'))
- elif isinstance(value, types.BooleanType):
+ elif isinstance(value, bool):
# True or False must be encoded as 1 or 0.
xconfig.SetAttribute(variable, str(int(value)))
else:
@@ -1838,7 +1836,7 @@ class Packager:
if parentName not in self.freezer.modules:
message = 'Cannot add Python file %s; not in package' % (file.newName)
if file.required or file.explicit:
- raise StandardError, message
+ raise Exception(message)
else:
self.notify.warning(message)
return
@@ -1852,7 +1850,7 @@ class Packager:
# Precompile egg files to bam's.
np = self.packager.loader.loadModel(file.filename)
if not np:
- raise StandardError, 'Could not read egg file %s' % (file.filename)
+ raise Exception('Could not read egg file %s' % (file.filename))
bamName = Filename(file.newName)
bamName.setExtension('bam')
@@ -1862,14 +1860,14 @@ class Packager:
# Load the bam file so we can massage its textures.
bamFile = BamFile()
if not bamFile.openRead(file.filename):
- raise StandardError, 'Could not read bam file %s' % (file.filename)
+ raise Exception('Could not read bam file %s' % (file.filename))
if not bamFile.resolve():
- raise StandardError, 'Could not resolve bam file %s' % (file.filename)
+ raise Exception('Could not resolve bam file %s' % (file.filename))
node = bamFile.readNode()
if not node:
- raise StandardError, 'Not a model file: %s' % (file.filename)
+ raise Exception('Not a model file: %s' % (file.filename))
self.addNode(node, file.filename, file.newName)
@@ -2190,7 +2188,7 @@ class Packager:
if package not in self.requires:
self.requires.append(package)
- for lowerName in package.targetFilenames.keys():
+ for lowerName in package.targetFilenames:
ext = Filename(lowerName).getExtension()
if ext not in self.packager.nonuniqueExtensions:
self.skipFilenames[lowerName] = True
@@ -2703,7 +2701,7 @@ class Packager:
self.allowPackages = False
if not PandaSystem.getPackageVersionString() or not PandaSystem.getPackageHostUrl():
- raise PackagerError, 'This script must be run using a version of Panda3D that has been built\nfor distribution. Try using ppackage.p3d or packp3d.p3d instead.\nIf you are running this script for development purposes, you may also\nset the Config variable panda-package-host-url to the URL you expect\nto download these contents from (for instance, a file:// URL).'
+ raise PackagerError('This script must be run using a version of Panda3D that has been built\nfor distribution. Try using ppackage.p3d or packp3d.p3d instead.\nIf you are running this script for development purposes, you may also\nset the Config variable panda-package-host-url to the URL you expect\nto download these contents from (for instance, a file:// URL).')
self.readContentsFile()
@@ -2726,7 +2724,7 @@ class Packager:
packageNames.append(package.packageName)
if packageNames:
- from PatchMaker import PatchMaker
+ from .PatchMaker import PatchMaker
pm = PatchMaker(self.installDir)
pm.buildPatches(packageNames = packageNames)
@@ -2759,7 +2757,7 @@ class Packager:
# By convention, the existence of a method of this class named
# do_foo(self) is sufficient to define a pdef method call
# foo().
- for methodName in self.__class__.__dict__.keys():
+ for methodName in list(self.__class__.__dict__.keys()):
if methodName.startswith('do_'):
name = methodName[3:]
c = func_closure(name)
@@ -2804,7 +2802,7 @@ class Packager:
self.notify.info("No files added to %s" % (name))
for (lineno, stype, sname, args, kw) in statements:
if stype == 'class':
- raise PackagerError, 'Nested classes not allowed'
+ raise PackagerError('Nested classes not allowed')
self.__evalFunc(sname, args, kw)
package = self.endPackage()
if package is not None:
@@ -2812,7 +2810,7 @@ class Packager:
elif packageNames is not None:
# If the name is explicitly specified, this means
# we should abort if the package faild to construct.
- raise PackagerError, 'Failed to construct %s' % name
+ raise PackagerError('Failed to construct %s' % name)
else:
self.__evalFunc(name, args, kw)
except PackagerError:
@@ -2838,7 +2836,7 @@ class Packager:
func(*args, **kw)
except OutsideOfPackageError:
message = '%s encountered outside of package definition' % (name)
- raise OutsideOfPackageError, message
+ raise OutsideOfPackageError(message)
def __expandTabs(self, line, tabWidth = 8):
""" Expands tab characters in the line to 8 spaces. """
@@ -2883,10 +2881,10 @@ class Packager:
value = value.strip()
if parameter not in argList:
message = 'Unknown parameter %s' % (parameter)
- raise PackagerError, message
+ raise PackagerError(message)
if parameter in args:
message = 'Duplicate parameter %s' % (parameter)
- raise PackagerError, message
+ raise PackagerError(message)
args[parameter] = value
@@ -2900,7 +2898,7 @@ class Packager:
to file() etc., and close the package with endPackage(). """
if self.currentPackage:
- raise PackagerError, 'unclosed endPackage %s' % (self.currentPackage.packageName)
+ raise PackagerError('unclosed endPackage %s' % (self.currentPackage.packageName))
package = self.Package(packageName, self)
self.currentPackage = package
@@ -2910,7 +2908,7 @@ class Packager:
if not package.p3dApplication and not self.allowPackages:
message = 'Cannot generate packages without an installDir; use -i'
- raise PackagerError, message
+ raise PackagerError(message)
def endPackage(self):
@@ -2919,7 +2917,7 @@ class Packager:
or None if the package failed to close (e.g. missing files). """
if not self.currentPackage:
- raise PackagerError, 'unmatched endPackage'
+ raise PackagerError('unmatched endPackage')
package = self.currentPackage
package.signParams += self.signParams[:]
@@ -3147,14 +3145,14 @@ class Packager:
while p < len(version):
# Scan to the first digit.
w = ''
- while p < len(version) and version[p] not in string.digits:
+ while p < len(version) and not version[p].isdigit():
w += version[p]
p += 1
words.append(w)
# Scan to the end of the string of digits.
w = ''
- while p < len(version) and version[p] in string.digits:
+ while p < len(version) and version[p].isdigit():
w += version[p]
p += 1
if w:
@@ -3233,7 +3231,7 @@ class Packager:
if not self.currentPackage:
raise OutsideOfPackageError
- for keyword, value in kw.items():
+ for keyword, value in list(kw.items()):
self.currentPackage.configs[keyword] = value
def do_require(self, *args, **kw):
@@ -3310,7 +3308,7 @@ class Packager:
raise OutsideOfPackageError
if (newName or filename) and len(moduleNames) != 1:
- raise PackagerError, 'Cannot specify newName with multiple modules'
+ raise PackagerError('Cannot specify newName with multiple modules')
if required:
self.currentPackage.requiredModules += moduleNames
@@ -3469,7 +3467,7 @@ class Packager:
package.mainModule = None
if not package.mainModule and compileToExe:
message = "No main_module specified for exe %s" % (filename)
- raise PackagerError, message
+ raise PackagerError(message)
if package.mainModule:
moduleName, newName = package.mainModule
@@ -3641,12 +3639,12 @@ class Packager:
if newName:
if len(files) != 1:
message = 'Cannot install multiple files on target filename %s' % (newName)
- raise PackagerError, message
+ raise PackagerError(message)
if text:
if len(files) != 1:
message = 'Cannot install text to multiple files'
- raise PackagerError, message
+ raise PackagerError(message)
if not newName:
newName = str(filenames[0])
@@ -3917,17 +3915,10 @@ class metaclass_def(type):
return type.__new__(self, name, bases, dict)
-class class_p3d:
- __metaclass__ = metaclass_def
- pass
-
-class class_package:
- __metaclass__ = metaclass_def
- pass
-
-class class_solo:
- __metaclass__ = metaclass_def
- pass
+# Define these dynamically to stay compatible with Python 2 and 3.
+class_p3d = metaclass_def(str('class_p3d'), (), {})
+class_package = metaclass_def(str('class_package'), (), {})
+class_solo = metaclass_def(str('class_solo'), (), {})
class func_closure:
diff --git a/direct/src/p3d/PatchMaker.py b/direct/src/p3d/PatchMaker.py
index 7055f5eb3e..b48ad80f24 100644
--- a/direct/src/p3d/PatchMaker.py
+++ b/direct/src/p3d/PatchMaker.py
@@ -180,7 +180,7 @@ class PatchMaker:
result = Filename.temporary('', 'patch_')
p = Patchfile()
if not p.apply(patchFilename, origFile, result):
- print "Internal patching failed: %s" % (patchFilename)
+ print("Internal patching failed: %s" % (patchFilename))
return None
return result
@@ -345,7 +345,7 @@ class PatchMaker:
packageDescFullpath = Filename(self.patchMaker.installDir, self.packageDesc)
self.doc = TiXmlDocument(packageDescFullpath.toOsSpecific())
if not self.doc.LoadFile():
- print "Couldn't read %s" % (packageDescFullpath)
+ print("Couldn't read %s" % (packageDescFullpath))
return False
xpackage = self.doc.FirstChildElement('package')
@@ -537,7 +537,7 @@ class PatchMaker:
packageSeq.storeXml(xpackage, 'seq')
doc.SaveFile()
else:
- print "Couldn't read %s" % (importDescFullpath)
+ print("Couldn't read %s" % (importDescFullpath))
if self.contentsDocPackage:
# Now that we've rewritten the xml file, we have to
@@ -633,7 +633,7 @@ class PatchMaker:
doc = TiXmlDocument(contentsFilename.toOsSpecific())
if not doc.LoadFile():
# Couldn't read file.
- print "couldn't read %s" % (contentsFilename)
+ print("couldn't read %s" % (contentsFilename))
return False
xcontents = doc.FirstChildElement('contents')
@@ -740,7 +740,7 @@ class PatchMaker:
remainingNames.remove(package.packageName)
if remainingNames:
- print "Unknown packages: %s" % (remainingNames,)
+ print("Unknown packages: %s" % (remainingNames,))
def processAllPackages(self):
""" Walks through the list of packages, and builds missing
@@ -765,7 +765,7 @@ class PatchMaker:
filename = Filename(package.currentFile.filename + '.%s.patch' % (package.patchVersion))
assert filename not in self.patchFilenames
if not self.buildPatch(topPv, currentPv, package, filename):
- raise StandardError, "Couldn't build patch."
+ raise Exception("Couldn't build patch.")
def buildPatch(self, v1, v2, package, patchFilename):
""" Builds a patch from PackageVersion v1 to PackageVersion
@@ -780,7 +780,7 @@ class PatchMaker:
compressedPathname = Filename(pathname + '.pz')
compressedPathname.unlink()
if not compressFile(pathname, compressedPathname, 9):
- raise StandardError, "Couldn't compress patch."
+ raise Exception("Couldn't compress patch.")
pathname.unlink()
patchfile = self.Patchfile(package)
@@ -803,7 +803,7 @@ class PatchMaker:
# No original version to patch from.
return False
- print "Building patch from %s to %s" % (printOrigName, printNewName)
+ print("Building patch from %s to %s" % (printOrigName, printNewName))
patchFilename.unlink()
p = Patchfile() # The C++ class
if p.build(origFilename, newFilename, patchFilename):
diff --git a/direct/src/p3d/SeqValue.py b/direct/src/p3d/SeqValue.py
index c146944dfa..68b655bce3 100644
--- a/direct/src/p3d/SeqValue.py
+++ b/direct/src/p3d/SeqValue.py
@@ -1,7 +1,5 @@
__all__ = ["SeqValue"]
-import types
-
class SeqValue:
""" This represents a sequence value read from a contents.xml
@@ -21,22 +19,22 @@ class SeqValue:
def set(self, value):
""" Sets the seq from the indicated value of unspecified
type. """
- if isinstance(value, types.TupleType):
+ if isinstance(value, tuple):
self.setFromTuple(value)
- elif isinstance(value, types.StringTypes):
+ elif isinstance(value, str):
self.setFromString(value)
else:
- raise TypeError, 'Invalid sequence type: %s' % (value,)
+ raise TypeError('Invalid sequence type: %s' % (value,))
def setFromTuple(self, value):
""" Sets the seq from the indicated tuple of integers. """
- assert isinstance(value, types.TupleType)
+ assert isinstance(value, tuple)
self.value = value
def setFromString(self, value):
""" Sets the seq from the indicated string of dot-separated
integers. Raises ValueError on error. """
- assert isinstance(value, types.StringTypes)
+ assert isinstance(value, str)
self.value = ()
if value:
diff --git a/direct/src/p3d/packp3d.py b/direct/src/p3d/packp3d.py
index e1cebf2137..dee4fa2656 100755
--- a/direct/src/p3d/packp3d.py
+++ b/direct/src/p3d/packp3d.py
@@ -100,14 +100,13 @@ import sys
import os
import getopt
import glob
-import direct
from direct.p3d import Packager
from panda3d.core import *
# Temp hack for debugging.
#from direct.p3d.AppRunner import dummyAppRunner; dummyAppRunner()
-class ArgumentError(StandardError):
+class ArgumentError(Exception):
pass
def makePackedApp(args):
@@ -159,21 +158,21 @@ def makePackedApp(args):
elif option == '-D':
allowPythonDev = True
elif option == '-h':
- print usageText % (
+ print(usageText % (
PandaSystem.getPackageVersionString(),
PandaSystem.getPackageHostUrl(),
os.path.split(sys.argv[0])[1],
- '%s.%s' % (sys.version_info[0], sys.version_info[1]))
+ '%s.%s' % (sys.version_info[0], sys.version_info[1])))
sys.exit(0)
if not appFilename:
- raise ArgumentError, "No target app specified. Use:\n %s -o app.p3d\nUse -h to get more usage information." % (os.path.split(sys.argv[0])[1])
+ raise ArgumentError("No target app specified. Use:\n %s -o app.p3d\nUse -h to get more usage information." % (os.path.split(sys.argv[0])[1]))
if args:
- raise ArgumentError, "Extra arguments on command line."
+ raise ArgumentError("Extra arguments on command line.")
if appFilename.getExtension() != 'p3d':
- raise ArgumentError, 'Application filename must end in ".p3d".'
+ raise ArgumentError('Application filename must end in ".p3d".')
appDir = Filename(appFilename.getDirname())
if not appDir:
@@ -188,9 +187,9 @@ def makePackedApp(args):
if not main.exists():
main = glob.glob(os.path.join(root.toOsSpecific(), '*.py'))
if len(main) == 0:
- raise ArgumentError, 'No Python files in root directory.'
+ raise ArgumentError('No Python files in root directory.')
elif len(main) > 1:
- raise ArgumentError, 'Multiple Python files in root directory; specify the main application with -m "main".'
+ raise ArgumentError('Multiple Python files in root directory; specify the main application with -m "main".')
main = Filename.fromOsSpecific(os.path.split(main[0])[1])
main.makeAbsolute(root)
@@ -228,13 +227,13 @@ def makePackedApp(args):
except Packager.PackagerError:
# Just print the error message and exit gracefully.
inst = sys.exc_info()[1]
- print inst.args[0]
+ print(inst.args[0])
sys.exit(1)
try:
makePackedApp(sys.argv[1:])
-except ArgumentError, e:
- print e.args[0]
+except ArgumentError as e:
+ print(e.args[0])
sys.exit(1)
# An explicit call to exit() is required to exit the program, when
diff --git a/direct/src/p3d/panda3d.pdef b/direct/src/p3d/panda3d.pdef
index 8317d0442b..59e53cb39b 100644
--- a/direct/src/p3d/panda3d.pdef
+++ b/direct/src/p3d/panda3d.pdef
@@ -1,3 +1,4 @@
+import sys
from panda3d.core import Filename, PandaSystem, getModelPath
# This file defines a number of standard "packages" that correspond to
@@ -96,12 +97,16 @@ class panda3d(package):
excludeModule('wx',
'direct.showbase.WxGlobal')
- excludeModule('Tkinter', 'Pmw',
+ excludeModule('Tkinter', 'tkinter', 'Pmw', 'tkinter.simpledialog',
'direct.showbase.TkGlobal',
'direct.tkpanels', 'direct.tkwidgets',
'tkCommonDialog', 'tkMessageBox', 'tkSimpleDialog')
- excludeModule('MySQLdb', '_mysql')
+ excludeModule('MySQLdb', 'MySQLdb.connections', 'MySQLdb.constants',
+ 'MySQLdb.converters', '_mysql')
+
+ # Some code in distributed conditionally imports these.
+ excludeModule('otp.ai', 'otp.ai.AIZoneData')
# Most of the core Panda3D DLL's will be included implicitly due to
# being referenced by the above Python code. Here we name a few more
@@ -140,60 +145,82 @@ class morepy(package):
config(display_name = "Python standard library")
require('panda3d')
- module('string', 're', 'struct', 'difflib', 'StringIO',
- 'cStringIO', 'StringIO', 'textwrap', 'codecs',
- 'unicodedata', 'stringprep', 'fpformat', 'datetime',
+ module('string', 're', 'struct', 'difflib',
+ 'textwrap', 'codecs', 'unicodedata', 'stringprep', 'datetime',
'calendar', 'collections', 'heapq', 'bisect', 'array',
- 'sets', 'sched', 'mutex', 'queue', 'weakref', 'UserDict',
- 'UserList', 'UserString', 'types', 'new', 'copy', 'pprint',
- 'repr', 'numbers', 'math', 'cmath', 'decimal', 'fractions',
+ 'sched', 'queue', 'weakref', 'types', 'copy', 'pprint',
+ 'numbers', 'math', 'cmath', 'decimal', 'fractions',
'random', 'itertools', 'functools', 'operator', 'os.path',
- 'fileinput', 'stat', 'statvfs', 'filecmp', 'tempfile',
- 'glob', 'fnmatch', 'linecache', 'shutil', 'dircache',
- 'macpath', 'pickle', 'cPickle', 'copy_reg', 'shelve',
- 'marshal', 'anydbm', 'whichdb', 'dbm', 'gdbm', 'dbhash',
- 'bsddb', 'dumbdbm', 'zlib', 'gzip', 'bz2', 'zipfile',
- 'tarfile', 'csv', 'ConfigParser', 'robotparser', 'netrc',
- 'xdrlib', 'plistlib', 'hashlib', 'hmac', 'md5', 'sha', 'os',
+ 'fileinput', 'filecmp', 'tempfile', 'glob', 'fnmatch', 'linecache',
+ 'shutil', 'macpath', 'pickle', 'shelve', 'marshal', 'zlib',
+ 'gzip', 'bz2', 'zipfile', 'tarfile', 'csv', 'netrc',
+ 'xdrlib', 'plistlib', 'hashlib', 'hmac', 'os',
'time', 'optparse', 'getopt', 'logging', 'logging.*')
module('getpass', 'curses', 'curses.textpad', 'curses.wrapper',
'curses.ascii', 'curses.panel', 'platform', 'errno',
- 'ctypes', 'select', 'threading', 'thread',
- 'dummy_threading', 'dummy_thread', 'multiprocessing',
- 'mmap', 'readline', 'rlcompleter', 'subprocess', 'socket',
- 'ssl', 'signal', 'popen2', 'asyncore', 'asynchat', 'email',
- 'json', 'mailcap', 'mailbox', 'mhlib', 'mimetools',
- 'mimetypes', 'MimeWriter', 'mimify', 'multifile', 'rfc822',
- 'base64', 'binhex', 'binascii', 'quopri', 'uu',
- 'HTMLParser', 'sgmllib', 'htmllib', 'htmlentitydefs',
- 'xml.parsers.expat', 'xml.dom', 'xml.dom.minidom',
+ 'ctypes', 'select', 'threading', 'dummy_threading', 'dummy_thread',
+ 'multiprocessing', 'mmap', 'readline', 'rlcompleter', 'subprocess',
+ 'socket', 'ssl', 'signal', 'asyncore', 'asynchat', 'email', 'json',
+ 'mailcap', 'mailbox', 'mimetypes', 'base64', 'binhex', 'binascii',
+ 'quopri', 'uu', 'xml.parsers.expat', 'xml.dom', 'xml.dom.minidom',
'xml.dom.pulldom', 'xml.sax', 'xml.sax.handler',
'xml.sax.saxutils', 'xml.sax.xmlreader',
'xml.etree.ElementTree', 'webbrowser', 'cgi', 'cgitb')
- module('wsgiref', 'urllib', 'urllib2', 'httplib', 'ftplib',
- 'poplib', 'imaplib', 'nntplib', 'smtplib', 'smtpd',
- 'telnetlib', 'uuid', 'urlparse', 'SocketServer',
- 'BaseHTTPServer', 'SimpleHTTPServer', 'CGIHTTPServer',
- 'cookielib', 'Cookie', 'xmlrpclib', 'SimpleXMLRPCServer',
- 'DocXMLRPCServer', 'audioop', 'imageop', 'aifc', 'sunau',
+ module('wsgiref', 'ftplib', 'poplib', 'imaplib', 'nntplib', 'smtplib',
+ 'smtpd', 'telnetlib', 'uuid', 'audioop', 'aifc', 'sunau',
'wave', 'chunk', 'colorsys', 'imghdr', 'sndhdr',
'ossaudiodev', 'gettext', 'locale', 'cmd', 'shlex',
'pydoc', 'doctest', 'unittest', 'test',
- 'test.test_support', 'bdb', 'pdb', 'hotshot', 'timeit',
- 'trace', 'sys', '__builtin__')
- module('future_builtins', 'warnings', 'contextlib', 'abc',
+ 'bdb', 'pdb', 'timeit', 'trace', 'sys')
+ module('warnings', 'contextlib', 'abc',
'atexit', 'traceback', '__future__', 'gc', 'inspect',
- 'site', 'user', 'fpectl', 'code', 'codeop', 'rexec',
- 'Bastion', 'imp', 'imputil', 'zipimport', 'pkgutil',
+ 'site', 'fpectl', 'code', 'codeop', 'zipimport', 'pkgutil',
'modulefinder', 'runpy', 'parser', 'symtable', 'symbol',
'token', 'keyword', 'tokenize', 'tabnanny', 'pyclbr',
'py_compile', 'compileall', 'dis', 'pickletools',
- 'distutils', 'formatter', 'msilib', 'msvcrt', '_winreg',
- 'winsound', 'posix', 'pwd', 'spwd', 'grp', 'crypt', 'dl',
- 'termios', 'tty', 'pty', 'fcntl', 'pipes', 'posixfile',
- 'resource', 'nis', 'syslog', 'commands', 'ic', 'MacOS',
- 'macostools', 'findertools', 'EasyDialogs', 'FrameWork',
- 'autoGIL', 'ColorPicker', 'ast')
+ 'distutils', 'msilib', 'msvcrt', 'winsound', 'posix', 'pwd', 'spwd',
+ 'grp', 'crypt', 'termios', 'tty', 'pty', 'fcntl', 'pipes',
+ 'resource', 'nis', 'syslog', 'ast')
+
+ # Handle module name differences between Python 2 and Python 3 (see PEP3108)
+ if sys.version_info[0] < 3:
+ # Deprecated modules that were removed in Python 3
+ module('posixfile', 'rfc822', 'mimetools','MimeWriter', 'mimify',
+ 'multifile', 'sets', 'md5', 'sha', 'imp', 'formatter')
+ # Mac-specific modules that were removed
+ module('autoGIL', 'ColorPicker', 'EasyDialogs', 'findertools',
+ 'FrameWork', 'ic', 'MacOS', 'macostools')
+ # Removed because they were hardly used
+ module('imputil', 'mutex', 'user', 'new')
+ # Removed because they were obsolete
+ module('Bastion', 'rexec', 'commands', 'dircache', 'dl', 'fpformat',
+ 'htmllib', 'imageop', 'mhlib', 'popen2', 'sgmllib', 'stat',
+ 'statvfs', 'thread', 'UserDict', 'UserList', 'UserString',
+ 'future_builtins', 'hotshot', 'bsddb')
+ # Renamed to fix PEP8 violations
+ module('_winreg', 'ConfigParser', 'copy_reg', 'SocketServer')
+ # C and Python implementations of the same interface were merged
+ module('cPickle', 'cStringIO', 'StringIO')
+ # Renamed because of poorly chosen names
+ module('repr', 'test.test_support', '__builtins__')
+ # Modules that got grouped under packages
+ module('anydbm', 'whichdb', 'dbm', 'dumbdbm', 'gdbm', 'dbhash')
+ module('HTMLParser', 'htmlentitydefs')
+ module('BaseHTTPServer', 'SimpleHTTPServer', 'cookielib', 'Cookie',
+ 'CGIHTTPServer', 'httplib')
+ module('urllib', 'urllib2', 'urlparse', 'robotparser')
+ module('xmlrpclib', 'SimpleXMLRPCServer', 'DocXMLRPCServer')
+ else:
+ # Renamed to fix PEP8 violations
+ module('winreg', 'configparser', 'copyreg', 'socketserver')
+ # Renamed because of poorly chosen names
+ module('reprlib', 'test.support', 'builtins')
+ # Modules that got grouped under packages
+ module('dbm')
+ module('html')
+ module('http')
+ module('urllib')
+ module('xmlrpc')
# To add the multitude of standard Python string encodings.
module('encodings', 'encodings.*')
@@ -291,6 +318,39 @@ class egg(package):
plugin-path $EGG_ROOT
load-file-type egg pandaegg
load-file-type p3ptloader
+
+# These are excerpted from the default Confauto.prc file.
+egg-object-type-portal portal { 1 }
+egg-object-type-polylight polylight { 1 }
+egg-object-type-seq24 { 1 } fps { 24 }
+egg-object-type-seq12 { 1 } fps { 12 }
+egg-object-type-indexed indexed { 1 }
+egg-object-type-seq10 { 1 } fps { 10 }
+egg-object-type-seq8 { 1 } fps { 8 }
+egg-object-type-seq6 { 1 } fps { 6 }
+egg-object-type-seq4 { 1 } fps { 4 }
+egg-object-type-seq2 { 1 } fps { 2 }
+
+egg-object-type-binary alpha { binary }
+egg-object-type-dual alpha { dual }
+egg-object-type-glass alpha { blend_no_occlude }
+
+egg-object-type-model { 1 }
+egg-object-type-dcs { 1 }
+egg-object-type-notouch { no_touch }
+
+egg-object-type-barrier { Polyset descend }
+egg-object-type-sphere { Sphere descend }
+egg-object-type-invsphere { InvSphere descend }
+egg-object-type-tube { Tube descend }
+egg-object-type-trigger { Polyset descend intangible }
+egg-object-type-trigger-sphere { Sphere descend intangible }
+egg-object-type-floor { Polyset descend level }
+egg-object-type-dupefloor { Polyset keep descend level }
+egg-object-type-bubble { Sphere keep descend }
+egg-object-type-ghost collide-mask { 0 }
+egg-object-type-glow blend { add }
+egg-object-type-direct-widget collide-mask { 0x80000000 } { Polyset descend }
""")
class ode(package):
diff --git a/direct/src/p3d/pdeploy.py b/direct/src/p3d/pdeploy.py
index 0b0a77f834..f98d10b65d 100644
--- a/direct/src/p3d/pdeploy.py
+++ b/direct/src/p3d/pdeploy.py
@@ -151,8 +151,8 @@ from panda3d.core import Filename, PandaSystem
def usage(code, msg = ''):
if not msg:
- print >> sys.stderr, usageText % {'prog' : os.path.split(sys.argv[0])[1]}
- print >> sys.stderr, msg
+ sys.stderr.write(usageText % {'prog' : os.path.split(sys.argv[0])[1]})
+ sys.stderr.write(msg + '\n')
sys.exit(code)
shortname = ""
@@ -173,7 +173,7 @@ omitDefaultCheckboxes = False
try:
opts, args = getopt.getopt(sys.argv[1:], 'n:N:v:o:t:P:csOl:L:a:A:e:i:h')
-except getopt.error, msg:
+except getopt.error as msg:
usage(1, msg or 'Invalid option')
for opt, arg in opts:
@@ -213,7 +213,7 @@ for opt, arg in opts:
usage(0)
else:
msg = 'illegal option: ' + flag
- print msg
+ print(msg)
sys.exit(1, msg)
if not args or len(args) != 2:
@@ -223,32 +223,32 @@ if not args or len(args) != 2:
appFilename = Filename.fromOsSpecific(args[0])
if appFilename.getExtension().lower() != 'p3d':
- print 'Application filename must end in ".p3d".'
+ print('Application filename must end in ".p3d".')
sys.exit(1)
deploy_mode = args[1].lower()
if not appFilename.exists():
- print 'Application filename does not exist!'
+ print('Application filename does not exist!')
sys.exit(1)
if shortname == '':
shortname = appFilename.getBasenameWoExtension()
if shortname.lower() != shortname or ' ' in shortname:
- print '\nProvided short name should be lowercase, and may not contain spaces!\n'
+ print('\nProvided short name should be lowercase, and may not contain spaces!\n')
if version == '' and deploy_mode == 'installer':
- print '\nA version number is required in "installer" mode.\n'
+ print('\nA version number is required in "installer" mode.\n')
sys.exit(1)
if not outputDir:
- print '\nYou must name the output directory with the -o parameter.\n'
+ print('\nYou must name the output directory with the -o parameter.\n')
sys.exit(1)
if not outputDir.exists():
- print '\nThe specified output directory does not exist!\n'
+ print('\nThe specified output directory does not exist!\n')
sys.exit(1)
elif not outputDir.isDirectory():
- print '\nThe specified output directory is a file!\n'
+ print('\nThe specified output directory is a file!\n')
sys.exit(1)
if deploy_mode == 'standalone':
@@ -287,8 +287,8 @@ elif deploy_mode == 'installer':
if authoremail:
i.authoremail = authoremail
if not authorname or not authoremail or not authorid:
- print "Using author \"%s\" <%s> with ID %s" % \
- (i.authorname, i.authoremail, i.authorid)
+ print("Using author \"%s\" <%s> with ID %s" % \
+ (i.authorname, i.authoremail, i.authorid))
# Add the supplied icon images
if len(iconFiles) > 0:
@@ -296,7 +296,7 @@ elif deploy_mode == 'installer':
i.icon = Icon()
for iconFile in iconFiles:
if not i.icon.addImage(iconFile):
- print '\nFailed to add icon image "%s"!\n' % iconFile
+ print('\nFailed to add icon image "%s"!\n' % iconFile)
failed = True
if failed:
sys.exit(1)
@@ -323,32 +323,32 @@ elif deploy_mode == 'html':
if "data" not in tokens:
tokens["data"] = appFilename.getBasename()
- print "Creating %s.html..." % shortname
+ print("Creating %s.html..." % shortname)
html = open(Filename(outputDir, shortname + ".html").toOsSpecific(), "w")
- print >>html, ""
- print >>html, ""
- print >>html, " "
- print >>html, " %s " % fullname
- print >>html, " "
+ html.write("\n")
+ html.write("\n")
+ html.write(" \n")
+ html.write(" %s \n" % fullname)
+ html.write(" \n")
if authorname:
- print >>html, " " % authorname.replace('"', '\\"')
- print >>html, " "
- print >>html, " "
- print >>html, " \n" % authorname.replace('"', '\\"'))
+ html.write(" \n")
+ html.write(" \n")
+ html.write(" >html, "%s=\"%s\"" % (key, value.replace('"', '\\"')),
+ html.write(" %s=\"%s\"" % (key, value.replace('"', '\\"')))
if "width" not in tokens:
- print >>html, "width=\"%s\"" % w,
+ html.write(" width=\"%s\"" % w)
if "height" not in tokens:
- print >>html, "height=\"%s\"" % h,
- print >>html, "type=\"application/x-panda3d\">"
- print >>html, " " % (w, h)
+ html.write(" height=\"%s\"" % h)
+ html.write(" type=\"application/x-panda3d\">")
+ html.write(" \n" % (w, h))
for key, value in tokens.items():
- print >>html, " " % (key, value.replace('"', '\\"'))
- print >>html, " "
- print >>html, " "
- print >>html, " "
- print >>html, ""
+ html.write(" \n" % (key, value.replace('"', '\\"')))
+ html.write(" \n")
+ html.write(" \n")
+ html.write(" \n")
+ html.write("\n")
html.close()
else:
usage(1, 'Invalid deployment mode!')
diff --git a/direct/src/p3d/pmerge.py b/direct/src/p3d/pmerge.py
index 2b290eb044..99492df35b 100755
--- a/direct/src/p3d/pmerge.py
+++ b/direct/src/p3d/pmerge.py
@@ -40,6 +40,7 @@ Options:
-h
Display this help
+
"""
import sys
@@ -47,16 +48,16 @@ import getopt
import os
from direct.p3d import PackageMerger
-from panda3d.core import *
+from panda3d.core import Filename
def usage(code, msg = ''):
- print >> sys.stderr, usageText % {'prog' : os.path.split(sys.argv[0])[1]}
- print >> sys.stderr, msg
+ sys.stderr.write(usageText % {'prog' : os.path.split(sys.argv[0])[1]})
+ sys.stderr.write(msg + '\n')
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], 'i:p:h')
-except getopt.error, msg:
+except getopt.error as msg:
usage(1, msg)
installDir = None
@@ -70,7 +71,7 @@ for opt, arg in opts:
elif opt == '-h':
usage(0)
else:
- print 'illegal option: ' + arg
+ print('illegal option: ' + arg)
sys.exit(1)
if not packageNames:
@@ -96,7 +97,7 @@ try:
except PackageMerger.PackageMergerError:
# Just print the error message and exit gracefully.
inst = sys.exc_info()[1]
- print inst.args[0]
+ print(inst.args[0])
sys.exit(1)
diff --git a/direct/src/p3d/ppatcher.py b/direct/src/p3d/ppatcher.py
index 440e22cb61..69e9689622 100755
--- a/direct/src/p3d/ppatcher.py
+++ b/direct/src/p3d/ppatcher.py
@@ -53,6 +53,7 @@ Options:
-h
Display this help
+
"""
import sys
@@ -60,16 +61,16 @@ import getopt
import os
from direct.p3d.PatchMaker import PatchMaker
-from panda3d.core import *
+from panda3d.core import Filename
def usage(code, msg = ''):
- print >> sys.stderr, usageText % {'prog' : os.path.split(sys.argv[0])[1]}
- print >> sys.stderr, msg
+ sys.stderr.write(usageText % {'prog' : os.path.split(sys.argv[0])[1]})
+ sys.stderr.write(msg + '\n')
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], 'i:h')
-except getopt.error, msg:
+except getopt.error as msg:
usage(1, msg)
installDir = None
@@ -80,7 +81,7 @@ for opt, arg in opts:
elif opt == '-h':
usage(0)
else:
- print 'illegal option: ' + arg
+ print('illegal option: ' + arg)
sys.exit(1)
packageNames = args
diff --git a/direct/src/p3d/runp3d.py b/direct/src/p3d/runp3d.py
index e561e73a0f..2ab457bc3c 100644
--- a/direct/src/p3d/runp3d.py
+++ b/direct/src/p3d/runp3d.py
@@ -26,7 +26,7 @@ See pack3d.p3d for an application that generates these p3d files.
import sys
import getopt
-from AppRunner import AppRunner, ArgumentError
+from .AppRunner import AppRunner, ArgumentError
from direct.task.TaskManagerGlobal import taskMgr
from panda3d.core import Filename
@@ -42,11 +42,11 @@ def parseSysArgs():
for option, value in opts:
if option == '-h':
- print __doc__
+ print(__doc__)
sys.exit(1)
if not args or not args[0]:
- raise ArgumentError, "No Panda app specified. Use:\nrunp3d.py app.p3d"
+ raise ArgumentError("No Panda app specified. Use:\nrunp3d.py app.p3d")
arg0 = args[0]
p3dFilename = Filename.fromOsSpecific(arg0)
@@ -62,8 +62,8 @@ def runPackedApp(pathname):
try:
runner.setP3DFilename(pathname, tokens = [], argv = [],
instanceId = 0, interactiveConsole = False)
- except ArgumentError, e:
- print e.args[0]
+ except ArgumentError as e:
+ print(e.args[0])
sys.exit(1)
if __name__ == '__main__':
@@ -73,7 +73,7 @@ if __name__ == '__main__':
argv = parseSysArgs()
runner.setP3DFilename(argv[0], tokens = [], argv = argv,
instanceId = 0, interactiveConsole = False)
- except ArgumentError, e:
- print e.args[0]
+ except ArgumentError as e:
+ print(e.args[0])
sys.exit(1)
taskMgr.run()
diff --git a/direct/src/p3d/thirdparty.pdef b/direct/src/p3d/thirdparty.pdef
index bc72b39eb7..bc001e427d 100644
--- a/direct/src/p3d/thirdparty.pdef
+++ b/direct/src/p3d/thirdparty.pdef
@@ -32,16 +32,28 @@ class tk(package):
#config(gui_app = True)
require('panda3d')
- module('Tkinter', '_tkinter', required = True)
- module('Tkconstants', 'Tkdnd', 'Tix', 'ScrolledText', 'turtle',
- 'tkColorChooser', 'tkCommonDialog', 'tkFileDialog',
- 'tkFont', 'tkMessageBox', 'tkSimpleDialog')
+ if sys.version_info >= (3, 0):
+ module('tkinter', '_tkinter', required = True)
+ module('tkinter.colorchooser', 'tkinter.commondialog',
+ 'tkinter.constants', 'tkinter.dialog', 'tkinter.dnd',
+ 'tkinter.filedialog', 'tkinter.font', 'tkinter.messagebox',
+ 'tkinter.scrolledtext', 'tkinter.simpledialog', 'tkinter.tix',
+ 'tkinter.ttk')
+ else:
+ module('Tkinter', '_tkinter', required = True)
+ module('Tkconstants', 'Tkdnd', 'Tix', 'ScrolledText', 'turtle',
+ 'tkColorChooser', 'tkCommonDialog', 'tkFileDialog',
+ 'tkFont', 'tkMessageBox', 'tkSimpleDialog')
+
module('direct.showbase.TkGlobal',
'direct.tkpanels',
'direct.tkwidgets')
try:
- from Tkinter import Tcl
+ if sys.version_info >= (3, 0):
+ from tkinter import Tcl
+ else:
+ from Tkinter import Tcl
tcl = Tcl()
dir = Filename.fromOsSpecific(tcl.eval("info library"))
ver = tcl.eval("info tclversion")
diff --git a/direct/src/particles/GlobalForceGroup.py b/direct/src/particles/GlobalForceGroup.py
index c371b74acf..c3ba10b98c 100644
--- a/direct/src/particles/GlobalForceGroup.py
+++ b/direct/src/particles/GlobalForceGroup.py
@@ -1,4 +1,4 @@
-import ForceGroup
+from . import ForceGroup
class GlobalForceGroup(ForceGroup.ForceGroup):
diff --git a/direct/src/particles/ParticleEffect.py b/direct/src/particles/ParticleEffect.py
index c645aea962..c58b7b4d46 100644
--- a/direct/src/particles/ParticleEffect.py
+++ b/direct/src/particles/ParticleEffect.py
@@ -98,7 +98,7 @@ class ParticleEffect(NodePath):
self.addForce(forceGroup[i])
def addForce(self, force):
- for p in self.particlesDict.values():
+ for p in list(self.particlesDict.values()):
p.addForce(force)
def removeForceGroup(self, forceGroup):
@@ -111,11 +111,11 @@ class ParticleEffect(NodePath):
self.forceGroupDict.pop(forceGroup.getName(), None)
def removeForce(self, force):
- for p in self.particlesDict.values():
+ for p in list(self.particlesDict.values()):
p.removeForce(force)
def removeAllForces(self):
- for fg in self.forceGroupDict.values():
+ for fg in list(self.forceGroupDict.values()):
self.removeForceGroup(fg)
def addParticles(self, particles):
@@ -123,7 +123,7 @@ class ParticleEffect(NodePath):
self.particlesDict[particles.getName()] = particles
# Associate all forces in all force groups with the particles
- for fg in self.forceGroupDict.values():
+ for fg in list(self.forceGroupDict.values()):
for i in range(len(fg)):
particles.addForce(fg[i])
@@ -135,16 +135,16 @@ class ParticleEffect(NodePath):
self.particlesDict.pop(particles.getName(), None)
# Remove all forces from the particles
- for fg in self.forceGroupDict.values():
+ for fg in list(self.forceGroupDict.values()):
for f in fg:
particles.removeForce(f)
def removeAllParticles(self):
- for p in self.particlesDict.values():
+ for p in list(self.particlesDict.values()):
self.removeParticles(p)
def getParticlesList(self):
- return self.particlesDict.values()
+ return list(self.particlesDict.values())
def getParticlesNamed(self, name):
return self.particlesDict.get(name, None)
@@ -153,7 +153,7 @@ class ParticleEffect(NodePath):
return self.particlesDict
def getForceGroupList(self):
- return self.forceGroupDict.values()
+ return list(self.forceGroupDict.values())
def getForceGroupNamed(self, name):
return self.forceGroupDict.get(name, None)
@@ -182,7 +182,7 @@ class ParticleEffect(NodePath):
# Save all the particles to file
num = 0
- for p in self.particlesDict.values():
+ for p in list(self.particlesDict.values()):
target = 'p%d' % num
num = num + 1
f.write(target + ' = Particles.Particles(\'%s\')\n' % p.getName())
@@ -191,7 +191,7 @@ class ParticleEffect(NodePath):
# Save all the forces to file
num = 0
- for fg in self.forceGroupDict.values():
+ for fg in list(self.forceGroupDict.values()):
target = 'f%d' % num
num = num + 1
f.write(target + ' = ForceGroup.ForceGroup(\'%s\')\n' % \
@@ -204,7 +204,7 @@ class ParticleEffect(NodePath):
def loadConfig(self, filename):
data = vfs.readFile(filename, 1)
- data = data.replace('\r', '')
+ data = data.replace(b'\r', b'')
try:
exec(data)
except:
diff --git a/direct/src/particles/ParticleTest.py b/direct/src/particles/ParticleTest.py
index 7399417b52..780ea4edc5 100644
--- a/direct/src/particles/ParticleTest.py
+++ b/direct/src/particles/ParticleTest.py
@@ -4,10 +4,10 @@ if __name__ == "__main__":
from panda3d.physics import LinearVectorForce
from panda3d.core import Vec3
- import ParticleEffect
+ from . import ParticleEffect
from direct.tkpanels import ParticlePanel
- import Particles
- import ForceGroup
+ from . import Particles
+ from . import ForceGroup
# Showbase
base.enableParticles()
diff --git a/direct/src/particles/Particles.py b/direct/src/particles/Particles.py
index ee82ffc81b..6ed19af896 100644
--- a/direct/src/particles/Particles.py
+++ b/direct/src/particles/Particles.py
@@ -23,7 +23,7 @@ from panda3d.physics import SphereSurfaceEmitter
from panda3d.physics import SphereVolumeEmitter
from panda3d.physics import TangentRingEmitter
-import SpriteParticleRendererExt
+from . import SpriteParticleRendererExt
from direct.directnotify.DirectNotifyGlobal import directNotify
import sys
@@ -108,7 +108,7 @@ class Particles(ParticleSystem):
elif (type == "OrientedParticleFactory"):
self.factory = OrientedParticleFactory()
else:
- print "unknown factory type: %s" % type
+ print("unknown factory type: %s" % type)
return None
self.factory.setLifespanBase(0.5)
ParticleSystem.setFactory(self, self.factory)
@@ -139,7 +139,7 @@ class Particles(ParticleSystem):
self.renderer = SpriteParticleRendererExt.SpriteParticleRendererExt()
# self.renderer.setTextureFromFile()
else:
- print "unknown renderer type: %s" % type
+ print("unknown renderer type: %s" % type)
return None
ParticleSystem.setRenderer(self, self.renderer)
@@ -171,7 +171,7 @@ class Particles(ParticleSystem):
elif (type == "TangentRingEmitter"):
self.emitter = TangentRingEmitter()
else:
- print "unknown emitter type: %s" % type
+ print("unknown emitter type: %s" % type)
return None
ParticleSystem.setEmitter(self, self.emitter)
@@ -568,9 +568,9 @@ class Particles(ParticleSystem):
self.factory.getLifespanBase()+self.factory.getLifespanSpread()]
birthRateRange = [self.getBirthRate()] * 3
- print 'Litter Ranges: ',litterRange
- print 'LifeSpan Ranges: ',lifespanRange
- print 'BirthRate Ranges: ',birthRateRange
+ print('Litter Ranges: %s' % litterRange)
+ print('LifeSpan Ranges: %s' % lifespanRange)
+ print('BirthRate Ranges: %s' % birthRateRange)
return dict(zip(('min','median','max'),[l*s/b for l,s,b in zip(litterRange,lifespanRange,birthRateRange)]))
diff --git a/direct/src/particles/SpriteParticleRendererExt.py b/direct/src/particles/SpriteParticleRendererExt.py
index 5a929b2dbc..f73b61e350 100644
--- a/direct/src/particles/SpriteParticleRendererExt.py
+++ b/direct/src/particles/SpriteParticleRendererExt.py
@@ -37,7 +37,7 @@ class SpriteParticleRendererExt(SpriteParticleRenderer):
self.setSourceTextureName(fileName)
return True
else:
- print "Couldn't find rendererSpriteTexture file: %s" % fileName
+ print("Couldn't find rendererSpriteTexture file: %s" % fileName)
return False
def addTextureFromFile(self, fileName = None):
@@ -52,7 +52,7 @@ class SpriteParticleRendererExt(SpriteParticleRenderer):
self.addTexture(t, t.getYSize())
return True
else:
- print "Couldn't find rendererSpriteTexture file: %s" % fileName
+ print("Couldn't find rendererSpriteTexture file: %s" % fileName)
return False
def getSourceFileName(self):
@@ -86,12 +86,12 @@ class SpriteParticleRendererExt(SpriteParticleRenderer):
# Load model and get texture
m = loader.loadModel(modelName)
if (m == None):
- print "SpriteParticleRendererExt: Couldn't find model: %s!" % modelName
+ print("SpriteParticleRendererExt: Couldn't find model: %s!" % modelName)
return False
np = m.find(nodeName)
if np.isEmpty():
- print "SpriteParticleRendererExt: Couldn't find node: %s!" % nodeName
+ print("SpriteParticleRendererExt: Couldn't find node: %s!" % nodeName)
m.removeNode()
return False
@@ -113,12 +113,12 @@ class SpriteParticleRendererExt(SpriteParticleRenderer):
# Load model and get texture
m = loader.loadModel(modelName)
if (m == None):
- print "SpriteParticleRendererExt: Couldn't find model: %s!" % modelName
+ print("SpriteParticleRendererExt: Couldn't find model: %s!" % modelName)
return False
np = m.find(nodeName)
if np.isEmpty():
- print "SpriteParticleRendererExt: Couldn't find node: %s!" % nodeName
+ print("SpriteParticleRendererExt: Couldn't find node: %s!" % nodeName)
m.removeNode()
return False
diff --git a/direct/src/plugin_installer/make_installer.py b/direct/src/plugin_installer/make_installer.py
index 0d0f12b0dc..9410f4fb90 100755
--- a/direct/src/plugin_installer/make_installer.py
+++ b/direct/src/plugin_installer/make_installer.py
@@ -298,7 +298,7 @@ def getDllVersion(filename):
tempfile = 'tversion.txt'
tempdata = open(tempfile, 'w+')
cmd = 'cscript //nologo "%s" "%s"' % (versionInfo, filename)
- print cmd
+ print(cmd)
result = subprocess.call(cmd, stdout = tempdata)
if result:
sys.exit(result)
@@ -326,18 +326,18 @@ def makeCabFile(ocx, pluginDependencies):
infFile = 'temp.inf'
inf = open(infFile, 'w')
- print >> inf, '[Add.Code]\n%s=%s\n%s=%s' % (infFile, infFile, ocx, ocx)
+ info.write('[Add.Code]\n%s=%s\n%s=%s\n' % (infFile, infFile, ocx, ocx))
dependencies = pluginDependencies[ocx]
for filename in dependencies:
- print >> inf, '%s=%s' % (filename, filename)
- print >> inf, '\n[%s]\nfile=thiscab' % (infFile)
- print >> inf, '\n[%s]\nfile=thiscab\nclsid={924B4927-D3BA-41EA-9F7E-8A89194AB3AC}\nRegisterServer=yes\nFileVersion=%s' % (ocx, getDllVersion(ocxFullpath))
+ inf.write('%s=%s\n' % (filename, filename))
+ inf.write('\n[%s]\nfile=thiscab\n' % (infFile))
+ inf.write('\n[%s]\nfile=thiscab\nclsid={924B4927-D3BA-41EA-9F7E-8A89194AB3AC}\nRegisterServer=yes\nFileVersion=%s\n' % (ocx, getDllVersion(ocxFullpath)))
fullpaths = []
for filename in dependencies:
fullpath = findExecutable(filename)
fullpaths.append(fullpath)
- print >> inf, '\n[%s]\nfile=thiscab\nDestDir=11\nRegisterServer=yes\nFileVersion=%s' % (filename, getDllVersion(fullpath))
+ inf.write('\n[%s]\nfile=thiscab\nDestDir=11\nRegisterServer=yes\nFileVersion=%s\n' % (filename, getDllVersion(fullpath)))
inf.close()
# Now process the inf file with cabarc.
@@ -350,20 +350,20 @@ def makeCabFile(ocx, pluginDependencies):
for fullpath in fullpaths:
cmd += ' "%s"' % (fullpath)
cmd += ' "%s" %s' % (ocxFullpath, infFile)
- print cmd
+ print(cmd)
result = subprocess.call(cmd)
if result:
sys.exit(result)
if not os.path.exists(cabFilename):
- print "Couldn't generate %s" % (cabFilename)
+ print("Couldn't generate %s" % (cabFilename))
sys.exit(1)
- print "Successfully generated %s" % (cabFilename)
+ print("Successfully generated %s" % (cabFilename))
if options.spc and options.pvk:
# Now we have to sign the cab file.
cmd = '"%s" -spc "%s" -k "%s" "%s"' % (signcode, options.spc, options.pvk, cabFilename)
- print cmd
+ print(cmd)
result = subprocess.call(cmd)
if result:
sys.exit(result)
@@ -502,8 +502,8 @@ def makeInstaller():
CMD += ' -i "%s"' % (infoFilename)
CMD += ' -d "%s"' % (descriptionFilename)
- print ""
- print CMD
+ print("")
+ print(CMD)
# Don't check the exit status of packagemaker; it's not always
# reliable.
@@ -518,7 +518,7 @@ def makeInstaller():
shutil.rmtree(tmpresdir)
if not os.path.exists(pkgname):
- print "Unable to create %s." % (pkgname)
+ print("Unable to create %s." % (pkgname))
sys.exit(1)
# Pack the .pkg into a .dmg
@@ -530,8 +530,8 @@ def makeInstaller():
tmpdmg = tempfile.mktemp('', 'p3d-setup') + ".dmg"
CMD = 'hdiutil create "%s" -srcfolder "%s"' % (tmpdmg, tmproot)
- print ""
- print CMD
+ print("")
+ print(CMD)
result = subprocess.call(CMD, shell = True)
if result:
sys.exit(result)
@@ -541,8 +541,8 @@ def makeInstaller():
if os.path.exists("p3d-setup.dmg"):
os.remove("p3d-setup.dmg")
CMD = 'hdiutil convert "%s" -format UDBZ -o "p3d-setup.dmg"' % tmpdmg
- print ""
- print CMD
+ print("")
+ print(CMD)
result = subprocess.call(CMD, shell = True)
if result:
sys.exit(result)
@@ -569,13 +569,12 @@ def makeInstaller():
if options.regview:
CMD += '/DREGVIEW=%s ' % (options.regview)
- dependencies = dependentFiles.items()
- for i in range(len(dependencies)):
- CMD += '/DDEP%s="%s" ' % (i, dependencies[i][0])
- CMD += '/DDEP%sP="%s" ' % (i, dependencies[i][1])
- dependencies = pluginDependencies[npapi]
- for i in range(len(dependencies)):
- CMD += '/DNPAPI_DEP%s="%s" ' % (i, dependencies[i])
+ for i, dep in enumerate(dependentFiles.items()):
+ CMD += '/DDEP%s="%s" ' % (i, dep[0])
+ CMD += '/DDEP%sP="%s" ' % (i, dep[1])
+
+ for i, dep in enumerate(pluginDependencies[npapi]):
+ CMD += '/DNPAPI_DEP%s="%s" ' % (i, dep)
if options.start:
CMD += '/DADD_START_MENU '
@@ -588,9 +587,9 @@ def makeInstaller():
CMD += '"' + this_dir + '\\p3d_installer.nsi"'
- print ""
- print CMD
- print "packing..."
+ print("")
+ print(CMD)
+ print("packing...")
result = subprocess.call(CMD)
if result:
sys.exit(result)
diff --git a/direct/src/plugin_installer/make_xpi.py b/direct/src/plugin_installer/make_xpi.py
index 185a6cdfd4..7cd02fd908 100755
--- a/direct/src/plugin_installer/make_xpi.py
+++ b/direct/src/plugin_installer/make_xpi.py
@@ -123,10 +123,10 @@ def makeXpiFile():
version files. """
if not options.host_url:
- print "Cannot generate xpi file without --host-url."
+ print("Cannot generate xpi file without --host-url.")
sys.exit(1)
- print "Generating xpi file"
+ print("Generating xpi file")
root = options.plugin_root
if os.path.isdir(os.path.join(root, 'plugin')):
root = os.path.join(root, 'plugin')
diff --git a/direct/src/plugin_npapi/make_osx_bundle.py b/direct/src/plugin_npapi/make_osx_bundle.py
index 8d83b35310..ce7a102b06 100755
--- a/direct/src/plugin_npapi/make_osx_bundle.py
+++ b/direct/src/plugin_npapi/make_osx_bundle.py
@@ -15,11 +15,11 @@ import glob
import shutil
import direct
-from pandac.PandaModules import Filename, DSearchPath
+from panda3d.core import Filename, DSearchPath
def usage(code, msg = ''):
- print >> sys.stderr, __doc__
- print >> sys.stderr, msg
+ sys.stderr.write(__doc__)
+ sys.stderr.write(msg + '\n')
sys.exit(code)
def makeBundle(startDir):
@@ -33,7 +33,7 @@ def makeBundle(startDir):
path.appendPath(os.environ['DYLD_LIBRARY_PATH'])
nppanda3d = path.findFile('nppanda3d')
if not nppanda3d:
- raise StandardError, "Couldn't find nppanda3d on path."
+ raise Exception("Couldn't find nppanda3d on path.")
# Generate the bundle directory structure
rootFilename = Filename(fstartDir, 'bundle')
@@ -54,7 +54,7 @@ def makeBundle(startDir):
resourceFilename.toOsSpecific(), Filename(fstartDir, "nppanda3d.r").toOsSpecific()))
if not resourceFilename.exists():
- raise IOError, 'Unable to run Rez'
+ raise IOError('Unable to run Rez')
# Copy in Info.plist and the compiled executable.
shutil.copyfile(Filename(fstartDir, "nppanda3d.plist").toOsSpecific(), plistFilename.toOsSpecific())
@@ -62,7 +62,7 @@ def makeBundle(startDir):
# All done!
bundleFilename.touch()
- print bundleFilename.toOsSpecific()
+ print(bundleFilename.toOsSpecific())
def buildDmg(startDir):
fstartDir = Filename.fromOsSpecific(startDir)
@@ -79,7 +79,7 @@ def buildDmg(startDir):
if __name__ == '__main__':
try:
opts, args = getopt.getopt(sys.argv[1:], 'h')
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
for opt, arg in opts:
diff --git a/direct/src/plugin_standalone/make_osx_bundle.py b/direct/src/plugin_standalone/make_osx_bundle.py
index 20807f6974..c88ce5ecf7 100755
--- a/direct/src/plugin_standalone/make_osx_bundle.py
+++ b/direct/src/plugin_standalone/make_osx_bundle.py
@@ -15,11 +15,11 @@ import glob
import shutil
import direct
-from pandac.PandaModules import Filename, DSearchPath, getModelPath, ExecutionEnvironment
+from panda3d.core import Filename, DSearchPath, getModelPath, ExecutionEnvironment
def usage(code, msg = ''):
- print >> sys.stderr, __doc__
- print >> sys.stderr, msg
+ sys.stderr.write(__doc__)
+ sys.stderr.write(msg + '\n')
sys.exit(code)
def makeBundle(startDir):
@@ -32,7 +32,7 @@ def makeBundle(startDir):
path.appendPath(os.defpath)
panda3d_mac = path.findFile('panda3d_mac')
if not panda3d_mac:
- raise StandardError, "Couldn't find panda3d_mac on path."
+ raise Exception("Couldn't find panda3d_mac on path.")
# Construct a search path to look for the images.
search = DSearchPath()
@@ -53,7 +53,7 @@ def makeBundle(startDir):
# Now find the icon file on the above search path.
icons = search.findFile('panda3d.icns')
if not icons:
- raise StandardError, "Couldn't find panda3d.icns on model-path."
+ raise Exception("Couldn't find panda3d.icns on model-path.")
# Generate the bundle directory structure
rootFilename = Filename(fstartDir)
@@ -71,18 +71,18 @@ def makeBundle(startDir):
# Copy in Info.plist, the icon file, and the compiled executable.
shutil.copyfile(Filename(fstartDir, "panda3d_mac.plist").toOsSpecific(), plistFilename.toOsSpecific())
shutil.copyfile(icons.toOsSpecific(), iconFilename.toOsSpecific())
- print panda3d_mac, exeFilename
+ print('%s %s' % (panda3d_mac, exeFilename))
shutil.copyfile(panda3d_mac.toOsSpecific(), exeFilename.toOsSpecific())
os.chmod(exeFilename.toOsSpecific(), 0o755)
# All done!
bundleFilename.touch()
- print bundleFilename.toOsSpecific()
+ print(bundleFilename.toOsSpecific())
if __name__ == '__main__':
try:
opts, args = getopt.getopt(sys.argv[1:], 'h')
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
for opt, arg in opts:
diff --git a/direct/src/showbase/Audio3DManager.py b/direct/src/showbase/Audio3DManager.py
index 270a7e56c4..e9cdb59eb8 100644
--- a/direct/src/showbase/Audio3DManager.py
+++ b/direct/src/showbase/Audio3DManager.py
@@ -123,7 +123,7 @@ class Audio3DManager:
Default: VBase3(0, 0, 0)
"""
if not isinstance(velocity, VBase3):
- raise TypeError, "Invalid argument 1, expected "
+ raise TypeError("Invalid argument 1, expected ")
self.vel_dict[sound]=velocity
def setSoundVelocityAuto(self, sound):
@@ -144,7 +144,7 @@ class Audio3DManager:
if (vel!=None):
return vel
else:
- for known_object in self.sound_dict.keys():
+ for known_object in list(self.sound_dict.keys()):
if self.sound_dict[known_object].count(sound):
return known_object.getPosDelta(self.root)/globalClock.getDt()
return VBase3(0, 0, 0)
@@ -156,7 +156,7 @@ class Audio3DManager:
Default: VBase3(0, 0, 0)
"""
if not isinstance(velocity, VBase3):
- raise TypeError, "Invalid argument 0, expected "
+ raise TypeError("Invalid argument 0, expected ")
self.listener_vel=velocity
def setListenerVelocityAuto(self):
@@ -185,7 +185,7 @@ class Audio3DManager:
"""
# sound is an AudioSound
# object is any Panda object with coordinates
- for known_object in self.sound_dict.keys():
+ for known_object in list(self.sound_dict.keys()):
if self.sound_dict[known_object].count(sound):
# This sound is already attached to something
#return 0
@@ -207,7 +207,7 @@ class Audio3DManager:
"""
sound will no longer have it's 3D position updated
"""
- for known_object in self.sound_dict.keys():
+ for known_object in list(self.sound_dict.keys()):
if self.sound_dict[known_object].count(sound):
self.sound_dict[known_object].remove(sound)
if len(self.sound_dict[known_object]) == 0:
@@ -258,7 +258,7 @@ class Audio3DManager:
if self.audio_manager.getActive()==0:
return Task.cont
- for known_object in self.sound_dict.keys():
+ for known_object in list(self.sound_dict.keys()):
tracked_sound = 0
while tracked_sound < len(self.sound_dict[known_object]):
sound = self.sound_dict[known_object][tracked_sound]
@@ -285,7 +285,7 @@ class Audio3DManager:
"""
taskMgr.remove("Audio3DManager-updateTask")
self.detachListener()
- for object in self.sound_dict.keys():
+ for object in list(self.sound_dict.keys()):
for sound in self.sound_dict[object]:
self.detachSound(sound)
diff --git a/direct/src/showbase/BulletinBoard.py b/direct/src/showbase/BulletinBoard.py
index 52265a1334..c46eb0ff0e 100755
--- a/direct/src/showbase/BulletinBoard.py
+++ b/direct/src/showbase/BulletinBoard.py
@@ -53,7 +53,7 @@ class BulletinBoard:
def __repr__(self):
str = 'Bulletin Board Contents\n'
str += '======================='
- keys = self._dict.keys()
+ keys = list(self._dict.keys())
keys.sort()
for postName in keys:
str += '\n%s: %s' % (postName, self._dict[postName])
diff --git a/direct/src/showbase/BulletinBoardGlobal.py b/direct/src/showbase/BulletinBoardGlobal.py
index 7bbf494574..dd750d9a22 100755
--- a/direct/src/showbase/BulletinBoardGlobal.py
+++ b/direct/src/showbase/BulletinBoardGlobal.py
@@ -2,6 +2,6 @@
__all__ = ['bulletinBoard']
-import BulletinBoard
+from . import BulletinBoard
bulletinBoard = BulletinBoard.BulletinBoard()
diff --git a/direct/src/showbase/ContainerLeakDetector.py b/direct/src/showbase/ContainerLeakDetector.py
index 580656d65e..abfe5cf99e 100755
--- a/direct/src/showbase/ContainerLeakDetector.py
+++ b/direct/src/showbase/ContainerLeakDetector.py
@@ -2,7 +2,29 @@ from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.PythonUtil import makeFlywheelGen
from direct.showbase.PythonUtil import itype, serialNum, safeRepr, fastRepr
from direct.showbase.Job import Job
-import types, weakref, random, __builtin__
+import types, weakref, random, sys
+
+if sys.version_info >= (3, 0):
+ import builtins as __builtin__
+
+ intTypes = (int,)
+ deadEndTypes = (bool, types.BuiltinFunctionType,
+ types.BuiltinMethodType, complex,
+ float, int,
+ type(None), type(NotImplemented),
+ type, types.CodeType, types.FunctionType,
+ bytes, str, tuple)
+else:
+ import __builtin__
+
+ intTypes = (int, long)
+ deadEndTypes = (types.BooleanType, types.BuiltinFunctionType,
+ types.BuiltinMethodType, types.ComplexType,
+ types.FloatType, types.IntType, types.LongType,
+ types.NoneType, types.NotImplementedType,
+ types.TypeType, types.CodeType, types.FunctionType,
+ types.StringType, types.UnicodeType, types.TupleType)
+
def _createContainerLeak():
def leakContainer(task=None):
@@ -17,7 +39,7 @@ def _createContainerLeak():
base.leakContainer[(LeakKey(),)] = {}
# test the non-weakref object reference handling
if random.random() < .01:
- key = random.choice(base.leakContainer.keys())
+ key = random.choice(list(base.leakContainer.keys()))
ContainerLeakDetector.notify.debug(
'removing reference to leakContainer key %s so it will be garbage-collected' % safeRepr(key))
del base.leakContainer[key]
@@ -82,7 +104,7 @@ class Indirection:
# store a weakref to the key
self.dictKey = weakref.ref(dictKey)
self._isWeakRef = True
- except TypeError, e:
+ except TypeError as e:
ContainerLeakDetector.notify.debug('could not weakref dict key %s' % keyRepr)
self.dictKey = dictKey
self._isWeakRef = False
@@ -163,7 +185,7 @@ class ObjectRef:
# make sure we're not storing a reference to the actual object,
# that could cause a memory leak
- assert type(objId) in (types.IntType, types.LongType)
+ assert type(objId) in intTypes
# prevent cycles (i.e. base.loader.base.loader)
assert not self.goesThrough(objId=objId)
@@ -184,7 +206,7 @@ class ObjectRef:
def goesThroughGen(self, obj=None, objId=None):
if obj is None:
- assert type(objId) in (types.IntType, types.LongType)
+ assert type(objId) in intTypes
else:
objId = id(obj)
o = None
@@ -238,11 +260,11 @@ class ObjectRef:
evalStr = '%s.%s' % (bis, evalStr)
try:
container = eval(evalStr)
- except NameError, ne:
+ except NameError as ne:
return None
- except AttributeError, ae:
+ except AttributeError as ae:
return None
- except KeyError, ke:
+ except KeyError as ke:
return None
return container
@@ -290,7 +312,7 @@ class ObjectRef:
indirections = self._indirections
for indirection in indirections:
indirection.acquire()
- for i in xrange(len(indirections)):
+ for i in range(len(indirections)):
yield None
if i > 0:
prevIndirection = indirections[i-1]
@@ -394,19 +416,14 @@ class FindContainers(Job):
return 1
def _isDeadEnd(self, obj, objName=None):
- if type(obj) in (types.BooleanType, types.BuiltinFunctionType,
- types.BuiltinMethodType, types.ComplexType,
- types.FloatType, types.IntType, types.LongType,
- types.NoneType, types.NotImplementedType,
- types.TypeType, types.CodeType, types.FunctionType,
- types.StringType, types.UnicodeType,
- types.TupleType):
+ if type(obj) in deadEndTypes:
return True
+
# if it's an internal object, ignore it
if id(obj) in ContainerLeakDetector.PrivateIds:
return True
# prevent crashes in objects that define __cmp__ and don't handle strings
- if type(objName) == types.StringType and objName in ('im_self', 'im_class'):
+ if type(objName) == str and objName in ('im_self', 'im_class'):
return True
try:
className = obj.__class__.__name__
@@ -440,7 +457,7 @@ class FindContainers(Job):
objId = id(obj)
if objId in self._id2discoveredStartRef:
existingRef = self._id2discoveredStartRef[objId]
- if type(existingRef) not in (types.IntType, types.LongType):
+ if type(existingRef) not in intTypes:
if (existingRef.getNumIndirections() >=
ref.getNumIndirections()):
# the ref that we already have is more concise than the new ref
@@ -471,7 +488,7 @@ class FindContainers(Job):
if curObjRef is None:
# choose an object to start a traversal from
try:
- startRefWorkingList = workingListSelector.next()
+ startRefWorkingList = next(workingListSelector)
except StopIteration:
# do relative # of traversals on each set based on how many refs it contains
baseLen = len(self._baseStartRefWorkingList.source)
@@ -488,7 +505,7 @@ class FindContainers(Job):
while True:
yield None
try:
- curObjRef = startRefWorkingList.refGen.next()
+ curObjRef = next(startRefWorkingList.refGen)
break
except StopIteration:
# we've run out of refs, grab a new set
@@ -498,7 +515,7 @@ class FindContainers(Job):
# make a generator that yields containers a # of times that is
# proportional to their length
for fw in makeFlywheelGen(
- startRefWorkingList.source.values(),
+ list(startRefWorkingList.source.values()),
countFunc=lambda x: self.getStartObjAffinity(x),
scale=.05):
yield None
@@ -509,7 +526,7 @@ class FindContainers(Job):
continue
# do we need to go look up the object in _id2ref? sometimes we do that
# to avoid storing multiple redundant refs to a single item
- if type(curObjRef) in (types.IntType, types.LongType):
+ if type(curObjRef) in intTypes:
startId = curObjRef
curObjRef = None
try:
@@ -560,10 +577,10 @@ class FindContainers(Job):
curObjRef = objRef
continue
- if type(curObj) is types.DictType:
+ if type(curObj) is dict:
key = None
attr = None
- keys = curObj.keys()
+ keys = list(curObj.keys())
# we will continue traversing the object graph via one key of the dict,
# choose it at random without taking a big chunk of CPU time
numKeysLeft = len(keys) + 1
@@ -572,7 +589,7 @@ class FindContainers(Job):
numKeysLeft -= 1
try:
attr = curObj[key]
- except KeyError, e:
+ except KeyError as e:
# this is OK because we are yielding during the iteration
self.notify.debug('could not index into %s with key %s' % (
parentObjRef, safeRepr(key)))
@@ -617,7 +634,7 @@ class FindContainers(Job):
while 1:
yield None
try:
- attr = itr.next()
+ attr = next(itr)
except:
# some custom classes don't do well when iterated
attr = None
@@ -651,13 +668,13 @@ class FindContainers(Job):
if curObjRef is None and random.randrange(numAttrsLeft) == 0:
curObjRef = objRef
del attr
- except StopIteration, e:
+ except StopIteration as e:
pass
del itr
continue
- except Exception, e:
- print 'FindContainers job caught exception: %s' % e
+ except Exception as e:
+ print('FindContainers job caught exception: %s' % e)
if __dev__:
raise
yield Job.Done
@@ -693,7 +710,7 @@ class CheckContainers(Job):
for result in self._leakDetector.getContainerByIdGen(objId):
yield None
container = result
- except Exception, e:
+ except Exception as e:
# this container no longer exists
if self.notify.getDebug():
for contName in self._leakDetector.getContainerNameByIdGen(objId):
@@ -714,7 +731,7 @@ class CheckContainers(Job):
continue
try:
cLen = len(container)
- except Exception, e:
+ except Exception as e:
# this container no longer exists
if self.notify.getDebug():
for contName in self._leakDetector.getContainerNameByIdGen(objId):
@@ -800,8 +817,8 @@ class CheckContainers(Job):
if config.GetBool('pdb-on-leak-detect', 0):
import pdb;pdb.set_trace()
pass
- except Exception, e:
- print 'CheckContainers job caught exception: %s' % e
+ except Exception as e:
+ print('CheckContainers job caught exception: %s' % e)
if __dev__:
raise
yield Job.Done
@@ -855,9 +872,9 @@ class FPTObjsOfType(Job):
except:
pass
else:
- print 'GPTC(' + self._otn + '):' + self.getJobName() + ': ' + ptc
- except Exception, e:
- print 'FPTObjsOfType job caught exception: %s' % e
+ print('GPTC(' + self._otn + '):' + self.getJobName() + ': ' + ptc)
+ except Exception as e:
+ print('FPTObjsOfType job caught exception: %s' % e)
if __dev__:
raise
yield Job.Done
@@ -909,9 +926,9 @@ class FPTObjsNamed(Job):
except:
pass
else:
- print 'GPTCN(' + self._on + '):' + self.getJobName() + ': ' + ptc
- except Exception, e:
- print 'FPTObjsNamed job caught exception: %s' % e
+ print('GPTCN(' + self._on + '):' + self.getJobName() + ': ' + ptc)
+ except Exception as e:
+ print('FPTObjsNamed job caught exception: %s' % e)
if __dev__:
raise
yield Job.Done
@@ -950,7 +967,7 @@ class PruneObjectRefs(Job):
# reference is invalid, remove it
self._leakDetector.removeContainerById(id)
_id2baseStartRef = self._leakDetector._findContainersJob._id2baseStartRef
- ids = _id2baseStartRef.keys()
+ ids = list(_id2baseStartRef.keys())
for id in ids:
yield None
try:
@@ -960,7 +977,7 @@ class PruneObjectRefs(Job):
# reference is invalid, remove it
del _id2baseStartRef[id]
_id2discoveredStartRef = self._leakDetector._findContainersJob._id2discoveredStartRef
- ids = _id2discoveredStartRef.keys()
+ ids = list(_id2discoveredStartRef.keys())
for id in ids:
yield None
try:
@@ -969,8 +986,8 @@ class PruneObjectRefs(Job):
except:
# reference is invalid, remove it
del _id2discoveredStartRef[id]
- except Exception, e:
- print 'PruneObjectRefs job caught exception: %s' % e
+ except Exception as e:
+ print('PruneObjectRefs job caught exception: %s' % e)
if __dev__:
raise
yield Job.Done
@@ -1058,7 +1075,7 @@ class ContainerLeakDetector(Job):
return 'pruneLeakingContainerRefs-%s' % self._serialNum
def getContainerIds(self):
- return self._id2ref.keys()
+ return list(self._id2ref.keys())
def getContainerByIdGen(self, id, **kwArgs):
# return a generator to look up a container
diff --git a/direct/src/showbase/ContainerReport.py b/direct/src/showbase/ContainerReport.py
index fd80977f92..753e72e84c 100755
--- a/direct/src/showbase/ContainerReport.py
+++ b/direct/src/showbase/ContainerReport.py
@@ -95,18 +95,18 @@ class ContainerReport(Job):
self._id2pathStr[id(child)] = str(self._id2pathStr[id(parentObj)])
continue
- if type(parentObj) is types.DictType:
+ if type(parentObj) is dict:
key = None
attr = None
- keys = parentObj.keys()
+ keys = list(parentObj.keys())
try:
keys.sort()
- except TypeError, e:
+ except TypeError as e:
self.notify.warning('non-sortable dict keys: %s: %s' % (self._id2pathStr[id(parentObj)], repr(e)))
for key in keys:
try:
attr = parentObj[key]
- except KeyError, e:
+ except KeyError as e:
self.notify.warning('could not index into %s with key %s' % (self._id2pathStr[id(parentObj)],
key))
if id(attr) not in self._visitedIds:
@@ -134,7 +134,7 @@ class ContainerReport(Job):
index = 0
while 1:
try:
- attr = itr.next()
+ attr = next(itr)
except:
# some custom classes don't do well when iterated
attr = None
@@ -146,7 +146,7 @@ class ContainerReport(Job):
self._id2pathStr[id(attr)] = self._id2pathStr[id(parentObj)] + '[%s]' % index
index += 1
del attr
- except StopIteration, e:
+ except StopIteration as e:
pass
del itr
continue
@@ -213,11 +213,11 @@ class ContainerReport(Job):
if type not in self._type2id2len:
return
len2ids = invertDictLossless(self._type2id2len[type])
- lengths = len2ids.keys()
+ lengths = list(len2ids.keys())
lengths.sort()
lengths.reverse()
- print '====='
- print '===== %s' % type
+ print('=====')
+ print('===== %s' % type)
count = 0
stop = False
for l in lengths:
@@ -232,13 +232,13 @@ class ContainerReport(Job):
yield None
pathStrList.sort()
for pathstr in pathStrList:
- print '%s: %s' % (l, pathstr)
+ print('%s: %s' % (l, pathstr))
if limit is not None and count >= limit:
return
def _output(self, **kArgs):
- print "===== ContainerReport: \'%s\' =====" % (self._name,)
- initialTypes = (types.DictType, types.ListType, types.TupleType)
+ print("===== ContainerReport: \'%s\' =====" % (self._name,))
+ initialTypes = (dict, list, tuple)
for type in initialTypes:
for i in self._outputType(type, **kArgs):
yield None
diff --git a/direct/src/showbase/CountedResource.py b/direct/src/showbase/CountedResource.py
index 1a89c663ff..62a25d28b2 100755
--- a/direct/src/showbase/CountedResource.py
+++ b/direct/src/showbase/CountedResource.py
@@ -97,13 +97,13 @@ if __debug__ and __name__ == '__main__':
# Now acquire the resource this class is
# managing.
- print '-- Acquire Mouse'
+ print('-- Acquire Mouse')
@classmethod
def release(cls):
# First, release the resource this class is
# managing.
- print '-- Release Mouse'
+ print('-- Release Mouse')
# The call to the super-class's release() is
# not necessary at the moment, but may be in
@@ -128,11 +128,11 @@ if __debug__ and __name__ == '__main__':
@classmethod
def acquire(cls):
super(CursorResource, cls).acquire()
- print '-- Acquire Cursor'
+ print('-- Acquire Cursor')
@classmethod
def release(cls):
- print '-- Release Cursor'
+ print('-- Release Cursor')
super(CursorResource, cls).release()
@@ -159,70 +159,70 @@ if __debug__ and __name__ == '__main__':
@classmethod
def acquire(cls):
super(InvalidResource, cls).acquire()
- print '-- Acquire Invalid'
+ print('-- Acquire Invalid')
@classmethod
def release(cls):
- print '-- Release Invalid'
+ print('-- Release Invalid')
super(InvalidResource, cls).release()
- print '\nAllocate Mouse'
+ print('\nAllocate Mouse')
m = MouseResource()
- print 'Free up Mouse'
+ print('Free up Mouse')
del m
- print '\nAllocate Cursor'
+ print('\nAllocate Cursor')
c = CursorResource()
- print 'Free up Cursor'
+ print('Free up Cursor')
del c
- print '\nAllocate Mouse then Cursor'
+ print('\nAllocate Mouse then Cursor')
m = MouseResource()
c = CursorResource()
- print 'Free up Cursor'
+ print('Free up Cursor')
del c
- print 'Free up Mouse'
+ print('Free up Mouse')
del m
- print '\nAllocate Mouse then Cursor'
+ print('\nAllocate Mouse then Cursor')
m = MouseResource()
c = CursorResource()
- print 'Free up Mouse'
+ print('Free up Mouse')
del m
- print 'Free up Cursor'
+ print('Free up Cursor')
del c
- print '\nAllocate Cursor then Mouse'
+ print('\nAllocate Cursor then Mouse')
c = CursorResource()
m = MouseResource()
- print 'Free up Mouse'
+ print('Free up Mouse')
del m
- print 'Free up Cursor'
+ print('Free up Cursor')
del c
- print '\nAllocate Cursor then Mouse'
+ print('\nAllocate Cursor then Mouse')
c = CursorResource()
m = MouseResource()
- print 'Free up Cursor'
+ print('Free up Cursor')
del c
# example of an invalid subclass
try:
- print '\nAllocate Invalid'
+ print('\nAllocate Invalid')
i = InvalidResource()
- print 'Free up Invalid'
- except AssertionError,e:
- print e
- print
+ print('Free up Invalid')
+ except AssertionError as e:
+ print(e)
+ print('')
- print 'Free up Mouse'
+ print('Free up Mouse')
del m
def demoFunc():
- print '\nAllocate Cursor within function'
+ print('\nAllocate Cursor within function')
c = CursorResource()
- print 'Cursor will be freed on function exit'
+ print('Cursor will be freed on function exit')
demoFunc()
diff --git a/direct/src/showbase/DirectObject.py b/direct/src/showbase/DirectObject.py
index f881d65b5a..22d846bc3e 100644
--- a/direct/src/showbase/DirectObject.py
+++ b/direct/src/showbase/DirectObject.py
@@ -4,7 +4,7 @@ __all__ = ['DirectObject']
from direct.directnotify.DirectNotifyGlobal import directNotify
-from MessengerGlobal import messenger
+from .MessengerGlobal import messenger
class DirectObject:
"""
@@ -60,7 +60,7 @@ class DirectObject:
if type(taskOrName) == type(''):
# we must use a copy, since task.remove will modify self._taskList
if hasattr(self, '_taskList'):
- taskListValues = self._taskList.values()
+ taskListValues = list(self._taskList.values())
for task in taskListValues:
if task.name == taskOrName:
task.remove()
@@ -69,7 +69,7 @@ class DirectObject:
def removeAllTasks(self):
if hasattr(self,'_taskList'):
- for task in self._taskList.values():
+ for task in list(self._taskList.values()):
task.remove()
def _addTask(self, task):
diff --git a/direct/src/showbase/DistancePhasedNode.py b/direct/src/showbase/DistancePhasedNode.py
index b94e31d028..dae96991af 100755
--- a/direct/src/showbase/DistancePhasedNode.py
+++ b/direct/src/showbase/DistancePhasedNode.py
@@ -1,7 +1,7 @@
from direct.showbase.DirectObject import DirectObject
from direct.directnotify.DirectNotifyGlobal import directNotify
from panda3d.core import *
-from PhasedObject import PhasedObject
+from .PhasedObject import PhasedObject
class DistancePhasedNode(PhasedObject, DirectObject, NodePath):
"""
@@ -84,7 +84,7 @@ class DistancePhasedNode(PhasedObject, DirectObject, NodePath):
fromCollideNode = None):
NodePath.__init__(self, name)
self.phaseParamMap = phaseParamMap
- self.phaseParamList = sorted(phaseParamMap.items(),
+ self.phaseParamList = sorted(list(phaseParamMap.items()),
key = lambda x: x[1],
reverse = True)
PhasedObject.__init__(self,
@@ -269,7 +269,7 @@ class BufferedDistancePhasedNode(DistancePhasedNode):
def __init__(self, name, bufferParamMap = {}, autoCleanup = True,
enterPrefix = 'enter', exitPrefix = 'exit', phaseCollideMask = BitMask32.allOn(), fromCollideNode = None):
self.bufferParamMap = bufferParamMap
- self.bufferParamList = sorted(bufferParamMap.items(),
+ self.bufferParamList = sorted(list(bufferParamMap.items()),
key = lambda x: x[1],
reverse = True)
diff --git a/direct/src/showbase/EventManager.py b/direct/src/showbase/EventManager.py
index 2d57b9e49b..35616f6002 100644
--- a/direct/src/showbase/EventManager.py
+++ b/direct/src/showbase/EventManager.py
@@ -3,7 +3,7 @@
__all__ = ['EventManager']
-from MessengerGlobal import *
+from .MessengerGlobal import *
from direct.directnotify.DirectNotifyGlobal import *
from direct.task.TaskManagerGlobal import taskMgr
from panda3d.core import PStatCollector, EventQueue, EventHandler
diff --git a/direct/src/showbase/EventManagerGlobal.py b/direct/src/showbase/EventManagerGlobal.py
index 175008ccdb..9e7000ed51 100644
--- a/direct/src/showbase/EventManagerGlobal.py
+++ b/direct/src/showbase/EventManagerGlobal.py
@@ -2,6 +2,6 @@
__all__ = ['eventMgr']
-import EventManager
+from . import EventManager
eventMgr = EventManager.EventManager()
diff --git a/direct/src/showbase/ExceptionVarDump.py b/direct/src/showbase/ExceptionVarDump.py
index f07161d1f7..82060a7d24 100755
--- a/direct/src/showbase/ExceptionVarDump.py
+++ b/direct/src/showbase/ExceptionVarDump.py
@@ -3,7 +3,6 @@ __all__ = ["install"]
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.PythonUtil import fastRepr
import sys
-import types
import traceback
notify = directNotify.newCategory("ExceptionVarDump")
@@ -22,7 +21,7 @@ def _varDump__init__(self, *args, **kArgs):
while True:
try:
frame = sys._getframe(f)
- except ValueError, e:
+ except ValueError as e:
break
else:
f += 1
@@ -111,7 +110,7 @@ def _excepthookDumpVars(eType, eValue, tb):
if name in codeNames:
name2obj[name] = obj
# show them in alphabetical order
- names = name2obj.keys()
+ names = list(name2obj.keys())
names.sort()
# push them in reverse order so they'll be popped in the correct order
names.reverse()
@@ -125,7 +124,7 @@ def _excepthookDumpVars(eType, eValue, tb):
name, obj, traversedIds = stateStack.pop()
#notify.info('%s, %s, %s' % (name, fastRepr(obj), traversedIds))
r = fastRepr(obj, maxLen=10)
- if type(r) is types.StringType:
+ if type(r) is str:
r = r.replace('\n', '\\n')
s += '\n %s = %s' % (name, r)
# if we've already traversed through this object, don't traverse through it again
@@ -145,7 +144,7 @@ def _excepthookDumpVars(eType, eValue, tb):
attrName2obj[attrName] = attr
if len(attrName2obj):
# show them in alphabetical order
- attrNames = attrName2obj.keys()
+ attrNames = list(attrName2obj.keys())
attrNames.sort()
# push them in reverse order so they'll be popped in the correct order
attrNames.reverse()
diff --git a/direct/src/showbase/Factory.py b/direct/src/showbase/Factory.py
index fcf9301976..bff33dd931 100755
--- a/direct/src/showbase/Factory.py
+++ b/direct/src/showbase/Factory.py
@@ -25,7 +25,7 @@ class Factory:
(type, self._type2ctor[type], ctor))
self._type2ctor[type] = ctor
def _registerTypes(self, type2ctor):
- for type, ctor in type2ctor.items():
+ for type, ctor in list(type2ctor.items()):
self._registerType(type, ctor)
def nullCtor(self, *args, **kwArgs):
diff --git a/direct/src/showbase/FindCtaPaths.py b/direct/src/showbase/FindCtaPaths.py
index 74d63b9617..a530778715 100755
--- a/direct/src/showbase/FindCtaPaths.py
+++ b/direct/src/showbase/FindCtaPaths.py
@@ -51,7 +51,7 @@ def getPaths():
# these will all be siblings, so we filter out duplicate
# parent directories.
- print 'Appending to sys.path based on $CTPROJS:'
+ print('Appending to sys.path based on $CTPROJS:')
# First, get the list of packages, then reverse the list to
# put it in ctattach order. (The reversal may not matter too
@@ -69,14 +69,14 @@ def getPaths():
for package in packages:
tree = os.getenv(package)
if not tree:
- print " CTPROJS contains %s, but $%s is not defined." % (package, package)
+ print(" CTPROJS contains %s, but $%s is not defined." % (package, package))
sys.exit(1)
tree = deCygwinify(tree)
parent, base = os.path.split(tree)
if base != package.lower():
- print " Warning: $%s refers to a directory named %s (instead of %s)" % (package, base, package.lower())
+ print(" Warning: $%s refers to a directory named %s (instead of %s)" % (package, base, package.lower()))
if parent not in parents:
parents.append(parent)
@@ -94,7 +94,7 @@ def getPaths():
# Now the result goes onto sys.path.
for parent in parents:
- print " %s" % (parent)
+ print(" %s" % (parent))
if parent not in sys.path:
sys.path.append(parent)
diff --git a/direct/src/showbase/Finder.py b/direct/src/showbase/Finder.py
index b3b2031633..f7c619da91 100644
--- a/direct/src/showbase/Finder.py
+++ b/direct/src/showbase/Finder.py
@@ -31,8 +31,7 @@ def findClass(className):
def rebindClass(filename):
file = open(filename, 'r')
lines = file.readlines()
- for i in xrange(len(lines)):
- line = lines[i]
+ for line in lines:
if (line[0:6] == 'class '):
# Chop off the "class " syntax and strip extra whitespace
classHeader = line[6:].strip()
@@ -46,12 +45,12 @@ def rebindClass(filename):
if colonLoc > 0:
className = classHeader[:colonLoc]
else:
- print 'error: className not found'
+ print('error: className not found')
# Remove that temp file
file.close()
os.remove(filename)
return
- print 'Rebinding class name: ' + className
+ print('Rebinding class name: ' + className)
break
# Try to find the original class with this class name
@@ -68,7 +67,7 @@ def rebindClass(filename):
realClass, realNameSpace = res
# Now execute that class def in this namespace
- execfile(filename, realNameSpace)
+ exec(compile(open(filename).read(), filename, 'exec'), realNameSpace)
# That execfile should have created a new class obj in that namespace
tmpClass = realNameSpace[className]
@@ -157,7 +156,7 @@ def replaceMessengerFunc(replaceFuncList):
for oldFunc, funcName, newFunc in replaceFuncList:
res = messenger.replaceMethod(oldFunc, newFunc)
if res:
- print ('replaced %s messenger function(s): %s' % (res, funcName))
+ print('replaced %s messenger function(s): %s' % (res, funcName))
def replaceTaskMgrFunc(replaceFuncList):
try:
@@ -166,7 +165,7 @@ def replaceTaskMgrFunc(replaceFuncList):
return
for oldFunc, funcName, newFunc in replaceFuncList:
if taskMgr.replaceMethod(oldFunc, newFunc):
- print ('replaced taskMgr function: %s' % funcName)
+ print('replaced taskMgr function: %s' % funcName)
def replaceStateFunc(replaceFuncList):
if not sys.modules.get('base.direct.fsm.State'):
@@ -175,7 +174,7 @@ def replaceStateFunc(replaceFuncList):
for oldFunc, funcName, newFunc in replaceFuncList:
res = State.replaceMethod(oldFunc, newFunc)
if res:
- print ('replaced %s FSM transition function(s): %s' % (res, funcName))
+ print('replaced %s FSM transition function(s): %s' % (res, funcName))
def replaceCRFunc(replaceFuncList):
try:
@@ -188,7 +187,7 @@ def replaceCRFunc(replaceFuncList):
return
for oldFunc, funcName, newFunc in replaceFuncList:
if base.cr.replaceMethod(oldFunc, newFunc):
- print ('replaced DistributedObject function: %s' % funcName)
+ print('replaced DistributedObject function: %s' % funcName)
def replaceAIRFunc(replaceFuncList):
try:
@@ -197,7 +196,7 @@ def replaceAIRFunc(replaceFuncList):
return
for oldFunc, funcName, newFunc in replaceFuncList:
if simbase.air.replaceMethod(oldFunc, newFunc):
- print ('replaced DistributedObject function: %s' % funcName)
+ print('replaced DistributedObject function: %s' % funcName)
def replaceIvalFunc(replaceFuncList):
# Make sure we have imported IntervalManager and thus created
@@ -208,4 +207,4 @@ def replaceIvalFunc(replaceFuncList):
for oldFunc, funcName, newFunc in replaceFuncList:
res = FunctionInterval.replaceMethod(oldFunc, newFunc)
if res:
- print ('replaced %s interval function(s): %s' % (res, funcName))
+ print('replaced %s interval function(s): %s' % (res, funcName))
diff --git a/direct/src/showbase/GarbageReport.py b/direct/src/showbase/GarbageReport.py
index 72c46b4a0e..db91df0c47 100755
--- a/direct/src/showbase/GarbageReport.py
+++ b/direct/src/showbase/GarbageReport.py
@@ -8,9 +8,13 @@ from direct.showbase.PythonUtil import AlphabetCounter
from direct.showbase.Job import Job
import gc
import types
+import sys
GarbageCycleCountAnnounceEvent = 'announceGarbageCycleDesc2num'
+if sys.version_info >= (3, 0):
+ xrange = range
+
class FakeObject:
pass
@@ -173,7 +177,7 @@ class GarbageReport(Job):
if hasattr(self.garbage[i], '_garbageInfo') and callable(self.garbage[i]._garbageInfo):
try:
info = self.garbage[i]._garbageInfo()
- except Exception, e:
+ except Exception as e:
info = str(e)
self._id2garbageInfo[id(self.garbage[i])] = info
yield None
@@ -211,7 +215,7 @@ class GarbageReport(Job):
startIndex = 0
# + 1 to include a reference back to the first object
endIndex = numObjs + 1
- if type(objs[-1]) is types.InstanceType and type(objs[0]) is types.DictType:
+ if type(objs[-1]) is types.InstanceType and type(objs[0]) is dict:
startIndex -= 1
endIndex -= 1
@@ -227,7 +231,7 @@ class GarbageReport(Job):
# skip past the instance dict and get the member obj
numToSkip += 1
member = objs[index+2]
- for key, value in obj.__dict__.iteritems():
+ for key, value in obj.__dict__.items():
if value is member:
break
yield None
@@ -235,11 +239,11 @@ class GarbageReport(Job):
key = ''
cycleBySyntax += '%s' % key
objAlreadyRepresented = True
- elif type(obj) is types.DictType:
+ elif type(obj) is dict:
cycleBySyntax += '{'
# get object referred to by dict
val = objs[index+1]
- for key, value in obj.iteritems():
+ for key, value in obj.items():
if value is val:
break
yield None
@@ -247,10 +251,10 @@ class GarbageReport(Job):
key = ''
cycleBySyntax += '%s}' % fastRepr(key)
objAlreadyRepresented = True
- elif type(obj) in (types.TupleType, types.ListType):
+ elif type(obj) in (tuple, list):
brackets = {
- types.TupleType: '()',
- types.ListType: '[]',
+ tuple: '()',
+ list: '[]',
}[type(obj)]
# get object being referenced by container
nextObj = objs[index+1]
@@ -508,16 +512,16 @@ class GarbageReport(Job):
candidateCycle, curId, numDelInstances, resumeIndex = stateStack.pop()
if self.notify.getDebug():
if self._args.delOnly:
- print 'restart: %s root=%s cur=%s numDelInstances=%s resume=%s' % (
- candidateCycle, rootId, curId, numDelInstances, resumeIndex)
+ print('restart: %s root=%s cur=%s numDelInstances=%s resume=%s' % (
+ candidateCycle, rootId, curId, numDelInstances, resumeIndex))
else:
- print 'restart: %s root=%s cur=%s resume=%s' % (
- candidateCycle, rootId, curId, resumeIndex)
+ print('restart: %s root=%s cur=%s resume=%s' % (
+ candidateCycle, rootId, curId, resumeIndex))
for index in xrange(resumeIndex, len(self.referentsByNumber[curId])):
yield None
refId = self.referentsByNumber[curId][index]
if self.notify.getDebug():
- print ' : %s -> %s' % (curId, refId)
+ print(' : %s -> %s' % (curId, refId))
if refId == rootId:
# we found a cycle! mark it down and move on to the next refId
normCandidateCycle = self._getNormalizedCycle(candidateCycle)
@@ -527,7 +531,7 @@ class GarbageReport(Job):
# cleaned up by Python
if (not self._args.delOnly) or numDelInstances >= 1:
if self.notify.getDebug():
- print ' FOUND: ', normCandidateCycle + [normCandidateCycle[0],]
+ print(' FOUND: ', normCandidateCycle + [normCandidateCycle[0],])
cycles.append(normCandidateCycle + [normCandidateCycle[0],])
uniqueCycleSets.add(normCandidateCycleTuple)
elif refId in candidateCycle:
@@ -562,9 +566,9 @@ def checkForGarbageLeaks():
numGarbage = len(gc.garbage)
if (numGarbage > 0 and config.GetBool('auto-garbage-logging', 0)):
if (numGarbage != _CFGLGlobals.LastNumGarbage):
- print
+ print("")
gr = GarbageReport('found garbage', threaded=False, collect=False)
- print
+ print("")
_CFGLGlobals.LastNumGarbage = numGarbage
_CFGLGlobals.LastNumCycles = gr.getNumCycles()
messenger.send(GarbageCycleCountAnnounceEvent, [gr.getDesc2numDict()])
diff --git a/direct/src/showbase/Job.py b/direct/src/showbase/Job.py
index 4eb511d9a8..02407b29c4 100755
--- a/direct/src/showbase/Job.py
+++ b/direct/src/showbase/Job.py
@@ -44,7 +44,7 @@ class Job(DirectObject):
#
# when done, yield Job.Done
#
- raise "don't call down"
+ raise NotImplementedError("don't call down")
def getPriority(self):
return self._priority
@@ -112,14 +112,14 @@ if __debug__: # __dev__ not yet available at this point
while True:
while self._accum < 100:
self._accum += 1
- print 'counter = %s, accum = %s' % (self._counter, self._accum)
+ print('counter = %s, accum = %s' % (self._counter, self._accum))
yield None
self._accum = 0
self._counter += 1
if self._counter >= 100:
- print 'Job.Done'
+ print('Job.Done')
self.printingEnd()
yield Job.Done
else:
diff --git a/direct/src/showbase/JobManager.py b/direct/src/showbase/JobManager.py
index 3474b42f18..0c2ab09bbf 100755
--- a/direct/src/showbase/JobManager.py
+++ b/direct/src/showbase/JobManager.py
@@ -106,7 +106,7 @@ class JobManager:
job.resume()
while True:
try:
- result = gen.next()
+ result = next(gen)
except StopIteration:
# Job didn't yield Job.Done, it ran off the end and returned
# treat it as if it returned Job.Done
@@ -137,7 +137,7 @@ class JobManager:
def _getSortedPriorities(self):
# returns all job priorities in ascending order
- priorities = self._pri2jobId2job.keys()
+ priorities = list(self._pri2jobId2job.keys())
priorities.sort()
return priorities
@@ -152,11 +152,11 @@ class JobManager:
if self._jobIdGenerator is None:
# round-robin the jobs, giving high-priority jobs more timeslices
self._jobIdGenerator = flywheel(
- self._jobId2timeslices.keys(),
+ list(self._jobId2timeslices.keys()),
countFunc = lambda jobId: self._jobId2timeslices[jobId])
try:
# grab the next jobId in the sequence
- jobId = self._jobIdGenerator.next()
+ jobId = next(self._jobIdGenerator)
except StopIteration:
self._jobIdGenerator = None
continue
@@ -181,7 +181,7 @@ class JobManager:
job.resume()
while globalClock.getRealTime() < endT:
try:
- result = gen.next()
+ result = next(gen)
except StopIteration:
# Job didn't yield Job.Done, it ran off the end and returned
# treat it as if it returned Job.Done
diff --git a/direct/src/showbase/JobManagerGlobal.py b/direct/src/showbase/JobManagerGlobal.py
index c5f591715d..767f4ce342 100755
--- a/direct/src/showbase/JobManagerGlobal.py
+++ b/direct/src/showbase/JobManagerGlobal.py
@@ -1,5 +1,5 @@
__all__ = ['jobMgr']
-import JobManager
+from . import JobManager
jobMgr = JobManager.JobManager()
diff --git a/direct/src/showbase/LeakDetectors.py b/direct/src/showbase/LeakDetectors.py
index 92bc944fc8..1124d1301d 100755
--- a/direct/src/showbase/LeakDetectors.py
+++ b/direct/src/showbase/LeakDetectors.py
@@ -3,14 +3,20 @@
from pandac.PandaModules import *
from direct.showbase.DirectObject import DirectObject
from direct.showbase.Job import Job
-import __builtin__, gc
+import gc, sys
+
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
+
class LeakDetector:
def __init__(self):
# put this object just under __builtins__ where the
# ContainerLeakDetector will find it quickly
- if not hasattr(__builtin__, "leakDetectors"):
- __builtin__.leakDetectors = {}
+ if not hasattr(builtins, "leakDetectors"):
+ builtins.leakDetectors = {}
self._leakDetectorsKey = self.getLeakDetectorKey()
if __dev__:
assert self._leakDetectorsKey not in leakDetectors
@@ -52,7 +58,7 @@ class ObjectTypesLeakDetector(LeakDetector):
self._thisLdGen = 0
def destroy(self):
- for ld in self._type2ld.itervalues():
+ for ld in self._type2ld.values():
ld.destroy()
LeakDetector.destroy(self)
@@ -133,7 +139,7 @@ class CppMemoryUsage(LeakDetector):
class TaskLeakDetectorBase:
def _getTaskNamePattern(self, taskName):
# get a generic string pattern from a task name by removing numeric characters
- for i in xrange(10):
+ for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9):
taskName = taskName.replace('%s' % i, '')
return taskName
@@ -165,7 +171,7 @@ class TaskLeakDetector(LeakDetector, TaskLeakDetectorBase):
self._taskName2collector = {}
def destroy(self):
- for taskName, collector in self._taskName2collector.iteritems():
+ for taskName, collector in self._taskName2collector.items():
collector.destroy()
del self._taskName2collector
LeakDetector.destroy(self)
@@ -189,7 +195,7 @@ class TaskLeakDetector(LeakDetector, TaskLeakDetectorBase):
class MessageLeakDetectorBase:
def _getMessageNamePattern(self, msgName):
# get a generic string pattern from a message name by removing numeric characters
- for i in xrange(10):
+ for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9):
msgName = msgName.replace('%s' % i, '')
return msgName
@@ -266,7 +272,7 @@ class MessageTypesLeakDetector(LeakDetector, MessageLeakDetectorBase):
if self._createJob:
self._createJob.destroy()
self._createJob = None
- for msgName, detector in self._msgName2detector.iteritems():
+ for msgName, detector in self._msgName2detector.items():
detector.destroy()
del self._msgName2detector
LeakDetector.destroy(self)
@@ -342,7 +348,7 @@ class MessageListenerTypesLeakDetector(LeakDetector):
if self._createJob:
self._createJob.destroy()
self._createJob = None
- for typeName, detector in self._typeName2detector.iteritems():
+ for typeName, detector in self._typeName2detector.items():
detector.destroy()
del self._typeName2detector
LeakDetector.destroy(self)
diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py
index 94bc5d4e14..5aca6c4042 100644
--- a/direct/src/showbase/Loader.py
+++ b/direct/src/showbase/Loader.py
@@ -6,7 +6,6 @@ from panda3d.core import *
from panda3d.core import Loader as PandaLoader
from direct.directnotify.DirectNotifyGlobal import *
from direct.showbase.DirectObject import DirectObject
-import types
# You can specify a phaseChecker callback to check
# a modelPath to see if it is being loaded in the correct
@@ -139,8 +138,7 @@ class Loader(DirectObject):
if allowInstance:
loaderOptions.setFlags(loaderOptions.getFlags() | LoaderOptions.LFAllowInstance)
- if isinstance(modelPath, types.StringTypes) or \
- isinstance(modelPath, Filename):
+ if not isinstance(modelPath, (tuple, list, set)):
# We were given a single model pathname.
modelList = [modelPath]
if phaseChecker:
@@ -270,8 +268,7 @@ class Loader(DirectObject):
# Maybe we were given a node
modelNode = model
- elif isinstance(model, types.StringTypes) or \
- isinstance(model, Filename):
+ elif isinstance(model, (str, Filename)):
# If we were given a filename, we have to ask the loader
# to resolve it for us.
options = LoaderOptions(LoaderOptions.LFSearch | LoaderOptions.LFNoDiskCache | LoaderOptions.LFCacheOnly)
@@ -284,7 +281,7 @@ class Loader(DirectObject):
assert Loader.notify.debug("%s resolves to %s" % (model, modelNode.getFullpath()))
else:
- raise 'Invalid parameter to unloadModel: %s' % (model)
+ raise TypeError('Invalid parameter to unloadModel: %s' % (model))
assert Loader.notify.debug("Unloading model: %s" % (modelNode.getFullpath()))
ModelPool.releaseModel(modelNode)
@@ -301,8 +298,7 @@ class Loader(DirectObject):
else:
loaderOptions = LoaderOptions(loaderOptions)
- if isinstance(modelPath, types.StringTypes) or \
- isinstance(modelPath, Filename):
+ if not isinstance(modelPath, (tuple, list, set)):
# We were given a single model pathname.
modelList = [modelPath]
nodeList = [node]
@@ -324,7 +320,7 @@ class Loader(DirectObject):
nodeList[i] = nodeList[i].node()
# From here on, we deal with a list of (filename, node) pairs.
- modelList = zip(modelList, nodeList)
+ modelList = list(zip(modelList, nodeList))
if callback is None:
# We got no callback, so it's a synchronous save.
@@ -795,14 +791,10 @@ class Loader(DirectObject):
just as in loadModel(); otherwise, the loading happens before
loadSound() returns."""
- if isinstance(soundPath, types.StringTypes) or \
- isinstance(soundPath, Filename):
+ if not isinstance(soundPath, (MovieAudio, tuple, list, set)):
# We were given a single sound pathname.
soundList = [soundPath]
gotList = False
- elif isinstance(soundPath, MovieAudio):
- soundList = [soundPath]
- gotList = False
else:
# Assume we were given a list of sound pathnames.
soundList = soundPath
diff --git a/direct/src/showbase/Messenger.py b/direct/src/showbase/Messenger.py
index aba83d7d3a..20c02ce17a 100644
--- a/direct/src/showbase/Messenger.py
+++ b/direct/src/showbase/Messenger.py
@@ -3,7 +3,7 @@
__all__ = ['Messenger']
-from PythonUtil import *
+from .PythonUtil import *
from direct.directnotify import DirectNotifyGlobal
import types
@@ -87,7 +87,7 @@ class Messenger:
self.lock.acquire()
try:
objs = []
- for refCount, obj in self._id2object.itervalues():
+ for refCount, obj in self._id2object.values():
objs.append(obj)
return objs
finally:
@@ -97,7 +97,7 @@ class Messenger:
return len(self.__callbacks.get(event, {}))
def _getEvents(self):
- return self.__callbacks.keys()
+ return list(self.__callbacks.keys())
def _releaseObject(self, object):
# assumes lock is held.
@@ -132,7 +132,7 @@ class Messenger:
# Make sure extraArgs is a list or tuple
if not (isinstance(extraArgs, list) or isinstance(extraArgs, tuple) or isinstance(extraArgs, set)):
- raise TypeError, "A list is required as extraArgs argument"
+ raise TypeError("A list is required as extraArgs argument")
self.lock.acquire()
try:
@@ -214,7 +214,7 @@ class Messenger:
# Get the list of events this object is listening to
eventDict = self.__objectEvents.get(id)
if eventDict:
- for event in eventDict.keys():
+ for event in list(eventDict.keys()):
# Find the dictionary of all the objects accepting this event
acceptorDict = self.__callbacks.get(event)
# If this object is there, delete it from the dictionary
@@ -240,7 +240,7 @@ class Messenger:
# Get the list of events this object is listening to
eventDict = self.__objectEvents.get(id)
if eventDict:
- return eventDict.keys()
+ return list(eventDict.keys())
return []
finally:
self.lock.release()
@@ -307,7 +307,7 @@ class Messenger:
if not acceptorDict:
if __debug__:
if foundWatch:
- print "Messenger: \"%s\" was sent, but no function in Python listened."%(event,)
+ print("Messenger: \"%s\" was sent, but no function in Python listened."%(event,))
return
if taskChain:
@@ -357,7 +357,7 @@ class Messenger:
return task.done
def __dispatch(self, acceptorDict, event, sentArgs, foundWatch):
- for id in acceptorDict.keys():
+ for id in list(acceptorDict.keys()):
# We have to make this apparently redundant check, because
# it is possible that one object removes its own hooks
# in response to a handler called by a previous object.
@@ -389,10 +389,10 @@ class Messenger:
if __debug__:
if foundWatch:
- print "Messenger: \"%s\" --> %s%s"%(
+ print("Messenger: \"%s\" --> %s%s"%(
event,
self.__methodRepr(method),
- tuple(extraArgs + sentArgs))
+ tuple(extraArgs + sentArgs)))
#print "Messenger: \"%s\" --> %s%s"%(
# event,
@@ -428,7 +428,7 @@ class Messenger:
return (len(self.__callbacks) == 0)
def getEvents(self):
- return self.__callbacks.keys()
+ return list(self.__callbacks.keys())
def replaceMethod(self, oldMethod, newFunction):
"""
@@ -436,13 +436,13 @@ class Messenger:
you redefine functions with Control-c-Control-v
"""
retFlag = 0
- for entry in self.__callbacks.items():
+ for entry in list(self.__callbacks.items()):
event, objectDict = entry
- for objectEntry in objectDict.items():
+ for objectEntry in list(objectDict.items()):
object, params = objectEntry
method = params[0]
if (type(method) == types.MethodType):
- function = method.im_func
+ function = method.__func__
else:
function = method
#print ('function: ' + repr(function) + '\n' +
@@ -451,7 +451,7 @@ class Messenger:
# 'newFunction: ' + repr(newFunction) + '\n')
if (function == oldMethod):
newMethod = types.MethodType(
- newFunction, method.im_self, method.im_class)
+ newFunction, method.__self__, method.__self__.__class__)
params[0] = newMethod
# Found it retrun true
retFlag += 1
@@ -462,8 +462,8 @@ class Messenger:
isVerbose = 1 - Messenger.notify.getDebug()
Messenger.notify.setDebug(isVerbose)
if isVerbose:
- print "Verbose mode true. quiet list = %s"%(
- self.quieting.keys(),)
+ print("Verbose mode true. quiet list = %s"%(
+ list(self.quieting.keys()),))
if __debug__:
def watch(self, needle):
@@ -527,11 +527,11 @@ class Messenger:
return a matching event (needle) if found (in haystack).
This is primarily a debugging tool.
"""
- keys = self.__callbacks.keys()
+ keys = list(self.__callbacks.keys())
keys.sort()
for event in keys:
if repr(event).find(needle) >= 0:
- print self.__eventRepr(event),
+ print(self.__eventRepr(event))
return {event: self.__callbacks[event]}
def findAll(self, needle, limit=None):
@@ -541,11 +541,11 @@ class Messenger:
This is primarily a debugging tool.
"""
matches = {}
- keys = self.__callbacks.keys()
+ keys = list(self.__callbacks.keys())
keys.sort()
for event in keys:
if repr(event).find(needle) >= 0:
- print self.__eventRepr(event),
+ print(self.__eventRepr(event))
matches[event] = self.__callbacks[event]
# if the limit is not None, decrement and
# check for break:
@@ -560,8 +560,8 @@ class Messenger:
return string version of class.method or method.
"""
if (type(method) == types.MethodType):
- functionName = method.im_class.__name__ + '.' + \
- method.im_func.__name__
+ functionName = method.__self__.__class__.__name__ + '.' + \
+ method.__func__.__name__
else:
if hasattr(method, "__name__"):
functionName = method.__name__
@@ -575,7 +575,7 @@ class Messenger:
"""
str = event.ljust(32) + '\t'
acceptorDict = self.__callbacks[event]
- for key, (method, extraArgs, persistent) in acceptorDict.items():
+ for key, (method, extraArgs, persistent) in list(acceptorDict.items()):
str = str + self.__methodRepr(method) + ' '
str = str + '\n'
return str
@@ -585,16 +585,16 @@ class Messenger:
Compact version of event, acceptor pairs
"""
str = "The messenger is currently handling:\n" + "="*64 + "\n"
- keys = self.__callbacks.keys()
+ keys = list(self.__callbacks.keys())
keys.sort()
for event in keys:
str += self.__eventRepr(event)
# Print out the object: event dictionary too
str += "="*64 + "\n"
- for key, eventDict in self.__objectEvents.items():
+ for key, eventDict in list(self.__objectEvents.items()):
object = self._getObject(key)
str += "%s:\n" % repr(object)
- for event in eventDict.keys():
+ for event in list(eventDict.keys()):
str += " %s\n" % repr(event)
str += "="*64 + "\n" + "End of messenger info.\n"
@@ -607,12 +607,12 @@ class Messenger:
import types
str = 'Messenger\n'
str = str + '='*50 + '\n'
- keys = self.__callbacks.keys()
+ keys = list(self.__callbacks.keys())
keys.sort()
for event in keys:
acceptorDict = self.__callbacks[event]
str = str + 'Event: ' + event + '\n'
- for key in acceptorDict.keys():
+ for key in list(acceptorDict.keys()):
function, extraArgs, persistent = acceptorDict[key]
object = self._getObject(key)
if (type(object) == types.InstanceType):
@@ -629,7 +629,7 @@ class Messenger:
if (type(function) == types.MethodType):
str = (str + '\t' +
'Method: ' + repr(function) + '\n\t' +
- 'Function: ' + repr(function.im_func) + '\n')
+ 'Function: ' + repr(function.__func__) + '\n')
else:
str = (str + '\t' +
'Function: ' + repr(function) + '\n')
diff --git a/direct/src/showbase/MessengerGlobal.py b/direct/src/showbase/MessengerGlobal.py
index 38ef00539d..f5a534c0d1 100644
--- a/direct/src/showbase/MessengerGlobal.py
+++ b/direct/src/showbase/MessengerGlobal.py
@@ -2,6 +2,6 @@
__all__ = ['messenger']
-import Messenger
+from . import Messenger
messenger = Messenger.Messenger()
diff --git a/direct/src/showbase/MessengerLeakDetector.py b/direct/src/showbase/MessengerLeakDetector.py
index 50ac0c2a8c..08cbe0778f 100755
--- a/direct/src/showbase/MessengerLeakDetector.py
+++ b/direct/src/showbase/MessengerLeakDetector.py
@@ -1,7 +1,13 @@
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
from direct.showbase.Job import Job
-import gc, __builtin__
+import gc, sys
+
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
+
class MessengerLeakObject(DirectObject):
def __init__(self):
@@ -27,7 +33,7 @@ class MessengerLeakDetector(Job):
# if an object is attached to one of these, it's attached to builtin
# this cuts down on the amount of searching that needs to be done
builtinIds = set()
- builtinIds.add(id(__builtin__.__dict__))
+ builtinIds.add(id(builtins.__dict__))
try:
builtinIds.add(id(base))
builtinIds.add(id(base.cr))
@@ -49,7 +55,7 @@ class MessengerLeakDetector(Job):
while True:
yield None
- objects = messenger._Messenger__objectEvents.keys()
+ objects = list(messenger._Messenger__objectEvents.keys())
assert self.notify.debug('%s objects in the messenger' % len(objects))
for object in objects:
yield None
diff --git a/direct/src/showbase/ObjectPool.py b/direct/src/showbase/ObjectPool.py
index 506a7e2ba5..4b0c0a0731 100755
--- a/direct/src/showbase/ObjectPool.py
+++ b/direct/src/showbase/ObjectPool.py
@@ -12,14 +12,14 @@ class Diff:
self.lost=lost
self.gained=gained
def printOut(self, full=False):
- print 'lost %s objects, gained %s objects' % (len(self.lost), len(self.gained))
- print '\n\nself.lost\n'
- print self.lost.typeFreqStr()
- print '\n\nself.gained\n'
- print self.gained.typeFreqStr()
+ print('lost %s objects, gained %s objects' % (len(self.lost), len(self.gained)))
+ print('\n\nself.lost\n')
+ print(self.lost.typeFreqStr())
+ print('\n\nself.gained\n')
+ print(self.gained.typeFreqStr())
if full:
self.gained.printObjsByType()
- print '\n\nGAINED-OBJECT REFERRERS\n'
+ print('\n\nGAINED-OBJECT REFERRERS\n')
self.gained.printReferrers(1)
class ObjectPool:
@@ -53,14 +53,14 @@ class ObjectPool:
del self._count2types
def getTypes(self):
- return self._type2objs.keys()
+ return list(self._type2objs.keys())
def getObjsOfType(self, type):
return self._type2objs.get(type, [])
def printObjsOfType(self, type):
for obj in self._type2objs.get(type, []):
- print repr(obj)
+ print(repr(obj))
def diff(self, other):
"""print difference between this pool and 'other' pool"""
@@ -97,8 +97,8 @@ class ObjectPool:
return s
def printObjsByType(self):
- print 'Object Pool: Objects By Type'
- print '\n============================'
+ print('Object Pool: Objects By Type')
+ print('\n============================')
counts = list(set(self._count2types.keys()))
counts.sort()
# print types with the smallest number of instances first, in case
@@ -107,8 +107,8 @@ class ObjectPool:
for count in counts:
types = makeList(self._count2types[count])
for typ in types:
- print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ]))
- print getNumberedTypedSortedString(self._type2objs[typ])
+ print('TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])))
+ print(getNumberedTypedSortedString(self._type2objs[typ]))
def containerLenStr(self):
s = 'Object Pool: Container Lengths'
@@ -127,17 +127,17 @@ class ObjectPool:
for count in counts:
types = makeList(self._count2types[count])
for typ in types:
- print '\n\nTYPE: %s' % repr(typ)
- for i in xrange(min(numEach,len(self._type2objs[typ]))):
+ print('\n\nTYPE: %s' % repr(typ))
+ for i in range(min(numEach, len(self._type2objs[typ]))):
obj = self._type2objs[typ][i]
- print '\nOBJ: %s\n' % safeRepr(obj)
+ print('\nOBJ: %s\n' % safeRepr(obj))
referrers = gc.get_referrers(obj)
- print '%s REFERRERS:\n' % len(referrers)
+ print('%s REFERRERS:\n' % len(referrers))
if len(referrers):
- print getNumberedTypedString(referrers, maxLen=80,
- numPrefix='REF')
+ print(getNumberedTypedString(referrers, maxLen=80,
+ numPrefix='REF'))
else:
- print ''
+ print('')
def __len__(self):
return len(self._objs)
diff --git a/direct/src/showbase/ObjectReport.py b/direct/src/showbase/ObjectReport.py
index 084557f4b1..b860932d2d 100755
--- a/direct/src/showbase/ObjectReport.py
+++ b/direct/src/showbase/ObjectReport.py
@@ -7,7 +7,11 @@ from direct.showbase import DirectObject, ObjectPool, GarbageReport
from direct.showbase.PythonUtil import makeList, Sync
import gc
import sys
-import __builtin__
+
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
"""
>>> from direct.showbase import ObjectReport
@@ -134,7 +138,7 @@ class ObjectReport:
gc_objects = gc.get_objects()
# use get_referents to find everything else
objects = gc_objects
- objects.append(__builtin__.__dict__)
+ objects.append(builtins.__dict__)
nextObjList = gc_objects
found = set()
found.add(id(objects))
@@ -160,7 +164,7 @@ class ObjectReport:
else:
objs = []
stateStack = Stack()
- root = __builtins__
+ root = builtins
objIds = set([id(root)])
stateStack.push((root, None, 0))
while True:
@@ -183,7 +187,7 @@ class ObjectReport:
adjacents = newObjs
if len(adjacents) == 0:
print 'DEAD END'
- for i in xrange(resumeIndex, len(adjacents)):
+ for i in range(resumeIndex, len(adjacents)):
adj = adjacents[i]
stateStack.push((obj, adjacents, i+1))
stateStack.push((adj, None, 0))
diff --git a/direct/src/showbase/OnScreenDebug.py b/direct/src/showbase/OnScreenDebug.py
index 7dd70a2912..ba24b0637a 100755
--- a/direct/src/showbase/OnScreenDebug.py
+++ b/direct/src/showbase/OnScreenDebug.py
@@ -4,7 +4,6 @@ __all__ = ['OnScreenDebug']
from panda3d.core import *
-import types
from direct.gui import OnscreenText
from direct.directtools import DirectUtil
@@ -36,7 +35,7 @@ class OnScreenDebug:
font = loader.loadFont(fontPath)
if not font.isValid():
- print "failed to load OnScreenDebug font", fontPath
+ print("failed to load OnScreenDebug font %s" % fontPath)
font = TextNode.getDefaultFont()
self.onScreenText = OnscreenText.OnscreenText(
pos = (-1.0, 0.9), fg=fgColor, bg=bgColor,
@@ -51,7 +50,7 @@ class OnScreenDebug:
if not self.onScreenText:
self.load()
self.onScreenText.clearText()
- entries = self.data.items()
+ entries = list(self.data.items())
entries.sort()
for k, v in entries:
if v[0] == self.frame:
@@ -64,7 +63,7 @@ class OnScreenDebug:
#isNew = "was"
isNew = "~"
value = v[1]
- if type(value) == types.FloatType:
+ if type(value) == float:
value = "% 10.4f"%(value,)
# else: other types will be converted to str by the "%s"
self.onScreenText.appendText("%20s %s %-44s\n"%(k, isNew, value))
@@ -88,7 +87,7 @@ class OnScreenDebug:
def removeAllWithPrefix(self, prefix):
toRemove = []
- for key in self.data.keys():
+ for key in list(self.data.keys()):
if len(key) >= len(prefix):
if key[:len(prefix)] == prefix:
toRemove.append(key)
diff --git a/direct/src/showbase/PhasedObject.py b/direct/src/showbase/PhasedObject.py
index 43c43c4b53..4a6dad1481 100755
--- a/direct/src/showbase/PhasedObject.py
+++ b/direct/src/showbase/PhasedObject.py
@@ -37,7 +37,7 @@ class PhasedObject:
self.aliasPhaseMap = {}
self.__phasing = False
- for alias,phase in aliasMap.items():
+ for alias,phase in list(aliasMap.items()):
self.setAlias(phase, alias)
def __repr__(self):
@@ -168,26 +168,26 @@ if __debug__:
self.setPhase('Away')
def loadPhaseAway(self):
- print 'loading Away'
+ print('loading Away')
def unloadPhaseAway(self):
- print 'unloading Away'
+ print('unloading Away')
def loadPhaseFar(self):
- print 'loading Far'
+ print('loading Far')
def unloadPhaseFar(self):
- print 'unloading Far'
+ print('unloading Far')
def loadPhaseNear(self):
- print 'loading Near'
+ print('loading Near')
def unloadPhaseNear(self):
- print 'unloading Near'
+ print('unloading Near')
def loadPhaseAt(self):
- print 'loading At'
+ print('loading At')
def unloadPhaseAt(self):
- print 'unloading At'
+ print('unloading At')
diff --git a/direct/src/showbase/ProfileSession.py b/direct/src/showbase/ProfileSession.py
index 0d7c7bd8c2..3470f0dc9e 100755
--- a/direct/src/showbase/ProfileSession.py
+++ b/direct/src/showbase/ProfileSession.py
@@ -1,11 +1,18 @@
+from __future__ import print_function
from panda3d.core import TrueClock
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.PythonUtil import (
StdoutCapture, _installProfileCustomFuncs,_removeProfileCustomFuncs,
_getProfileResultFileInfo, _setProfileResultsFileInfo)
-import __builtin__
import profile
import pstats
+import sys
+
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
+
class PercentStats(pstats.Stats):
# prints more useful output when sampled durations are shorter than a millisecond
@@ -22,27 +29,27 @@ class PercentStats(pstats.Stats):
def print_stats(self, *amount):
for filename in self.files:
- print filename
- if self.files: print
+ print(filename)
+ if self.files: print()
indent = ' ' * 8
for func in self.top_level:
- print indent, func_get_function_name(func)
+ print(indent, func_get_function_name(func))
- print indent, self.total_calls, "function calls",
+ print(indent, self.total_calls, "function calls", end=' ')
if self.total_calls != self.prim_calls:
- print "(%d primitive calls)" % self.prim_calls,
+ print("(%d primitive calls)" % self.prim_calls, end=' ')
# DCR
#print "in %.3f CPU seconds" % self.total_tt
- print "in %s CPU milliseconds" % (self.total_tt * 1000.)
+ print("in %s CPU milliseconds" % (self.total_tt * 1000.))
if self._totalTime != self.total_tt:
- print indent, 'percentages are of %s CPU milliseconds' % (self._totalTime * 1000)
- print
+ print(indent, 'percentages are of %s CPU milliseconds' % (self._totalTime * 1000))
+ print()
width, list = self.get_print_list(amount)
if list:
self.print_title()
for func in list:
self.print_line(func)
- print
+ print()
# DCR
#print
return self
@@ -64,20 +71,20 @@ class PercentStats(pstats.Stats):
f8 = self.f8
if nc != cc:
c = c + '/' + str(cc)
- print c.rjust(9),
- print f8(tt),
+ print(c.rjust(9), end=' ')
+ print(f8(tt), end=' ')
if nc == 0:
- print ' '*8,
+ print(' '*8, end=' ')
else:
- print f8(tt/nc),
- print f8(ct),
+ print(f8(tt/nc), end=' ')
+ print(f8(ct), end=' ')
if cc == 0:
- print ' '*8,
+ print(' '*8, end=' ')
else:
- print f8(ct/cc),
+ print(f8(ct/cc), end=' ')
# DCR
#print func_std_string(func)
- print PercentStats.func_std_string(func)
+ print(PercentStats.func_std_string(func))
class ProfileSession:
# class that encapsulates a profile of a single callable using Python's standard
@@ -155,7 +162,7 @@ class ProfileSession:
self._reset()
# if we're already profiling, just run the func and don't profile
- if 'globalProfileSessionFunc' in __builtin__.__dict__:
+ if 'globalProfileSessionFunc' in builtins.__dict__:
self.notify.warning('could not profile %s' % self._func)
result = self._func()
if self._duration is None:
@@ -163,8 +170,8 @@ class ProfileSession:
else:
# put the function in the global namespace so that profile can find it
assert hasattr(self._func, '__call__')
- __builtin__.globalProfileSessionFunc = self._func
- __builtin__.globalProfileSessionResult = [None]
+ builtins.globalProfileSessionFunc = self._func
+ builtins.globalProfileSessionResult = [None]
# set up the RAM file
self._filenames.append(self._getNextFilename())
@@ -197,7 +204,7 @@ class ProfileSession:
# calculate the duration (this is dependent on the internal Python profile data format.
# see profile.py and pstats.py, this was copied from pstats.Stats.strip_dirs)
maxTime = 0.
- for cc, nc, tt, ct, callers in profData[1].itervalues():
+ for cc, nc, tt, ct, callers in profData[1].values():
if ct > maxTime:
maxTime = ct
self._duration = maxTime
@@ -206,8 +213,8 @@ class ProfileSession:
# clean up the globals
result = globalProfileSessionResult[0]
- del __builtin__.__dict__['globalProfileSessionFunc']
- del __builtin__.__dict__['globalProfileSessionResult']
+ del builtins.__dict__['globalProfileSessionFunc']
+ del builtins.__dict__['globalProfileSessionResult']
self._successfulProfiles += 1
diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py
index 3e8e8aa581..ebf8bce63f 100644
--- a/direct/src/showbase/PythonUtil.py
+++ b/direct/src/showbase/PythonUtil.py
@@ -11,7 +11,7 @@ __all__ = ['indent',
'boolEqual', 'lineupPos', 'formatElapsedSeconds', 'solveQuadratic',
'findPythonModule', 'mostDerivedLast',
'weightedChoice', 'randFloat', 'normalDistrib',
-'weightedRand', 'randUint31', 'randInt32', 'randUint32',
+'weightedRand', 'randUint31', 'randInt32',
'SerialNumGen', 'serialNum', 'uniqueName', 'Enum', 'Singleton',
'SingletonError', 'printListEnum', 'safeRepr',
'fastRepr', 'isDefaultValue',
@@ -33,19 +33,24 @@ if __debug__:
'getProfileResultString', 'printStack', 'printReverseStack']
import types
-import string
import math
import os
import sys
import random
import time
-import __builtin__
import importlib
__report_indent = 3
from panda3d.core import ConfigVariableBool
+if sys.version_info >= (3, 0):
+ import builtins
+ xrange = range
+else:
+ import __builtin__ as builtins
+
+
"""
# with one integer positional arg, this uses about 4/5 of the memory of the Functor class below
def Functor(function, *args, **kArgs):
@@ -93,7 +98,7 @@ class Functor:
except:
argStr = 'bad repr: %s' % arg.__class__
s += ', %s' % argStr
- for karg, value in self._kargs.items():
+ for karg, value in list(self._kargs.items()):
s += ', %s=%s' % (karg, repr(value))
s += ')'
return s
@@ -220,13 +225,13 @@ if __debug__:
return r
def printStack():
- print StackTrace(start=1).compact()
+ print(StackTrace(start=1).compact())
return True
def printReverseStack():
- print StackTrace(start=1).reverseCompact()
+ print(StackTrace(start=1).reverseCompact())
return True
def printVerboseStack():
- print StackTrace(start=1)
+ print(StackTrace(start=1))
return True
#-----------------------------------------------------------------------------
@@ -273,7 +278,7 @@ if __debug__:
return traceFunctionCall(sys._getframe(2))
def printThisCall():
- print traceFunctionCall(sys._getframe(1))
+ print(traceFunctionCall(sys._getframe(1)))
return 1 # to allow "assert printThisCall()"
# Magic numbers: These are the bit masks in func_code.co_flags that
@@ -284,7 +289,7 @@ _KEY_DICT = 8
def doc(obj):
if (isinstance(obj, types.MethodType)) or \
(isinstance(obj, types.FunctionType)):
- print obj.__doc__
+ print(obj.__doc__)
def adjust(command = None, dim = 1, parent = None, **kw):
"""
@@ -312,15 +317,15 @@ def adjust(command = None, dim = 1, parent = None, **kw):
Valuator = importlib.import_module('direct.tkwidgets.Valuator')
# Set command if specified
if command:
- kw['command'] = lambda x: apply(command, x)
+ kw['command'] = lambda x: command(*x)
if parent is None:
kw['title'] = command.__name__
kw['dim'] = dim
# Create toplevel if needed
if not parent:
- vg = apply(Valuator.ValuatorGroupPanel, (parent,), kw)
+ vg = Valuator.ValuatorGroupPanel(parent, **kw)
else:
- vg = apply(Valuator.ValuatorGroup, (parent,), kw)
+ vg = Valuator.ValuatorGroup(parent, **kw)
vg.pack(expand = 1, fill = 'x')
return vg
@@ -378,18 +383,18 @@ def sameElements(a, b):
def makeList(x):
"""returns x, converted to a list"""
- if type(x) is types.ListType:
+ if type(x) is list:
return x
- elif type(x) is types.TupleType:
+ elif type(x) is tuple:
return list(x)
else:
return [x,]
def makeTuple(x):
"""returns x, converted to a tuple"""
- if type(x) is types.ListType:
+ if type(x) is list:
return tuple(x)
- elif type(x) is types.TupleType:
+ elif type(x) is tuple:
return x
else:
return (x,)
@@ -429,7 +434,7 @@ def invertDict(D, lossy=False):
n = {}
for key, value in D.items():
if not lossy and value in n:
- raise 'duplicate key in invertDict: %s' % value
+ raise Exception('duplicate key in invertDict: %s' % value)
n[value] = key
return n
@@ -587,7 +592,7 @@ class StdoutPassthrough(StdoutCapture):
# constant profile defaults
if __debug__:
- from StringIO import StringIO
+ from io import StringIO
PyUtilProfileDefaultFilename = 'profiledata'
PyUtilProfileDefaultLines = 80
@@ -604,29 +609,29 @@ if __debug__:
def profileFunc(callback, name, terse, log=True):
global _ProfileResultStr
- if 'globalProfileFunc' in __builtin__.__dict__:
+ if 'globalProfileFunc' in builtins.__dict__:
# rats. Python profiler is not re-entrant...
base.notify.warning(
'PythonUtil.profileStart(%s): aborted, already profiling %s'
#'\nStack Trace:\n%s'
- % (name, __builtin__.globalProfileFunc,
+ % (name, builtins.globalProfileFunc,
#StackTrace()
))
return
- __builtin__.globalProfileFunc = callback
- __builtin__.globalProfileResult = [None]
+ builtins.globalProfileFunc = callback
+ builtins.globalProfileResult = [None]
prefix = '***** START PROFILE: %s *****' % name
if log:
- print prefix
+ print(prefix)
startProfile(cmd='globalProfileResult[0]=globalProfileFunc()', callInfo=(not terse), silent=not log)
suffix = '***** END PROFILE: %s *****' % name
if log:
- print suffix
+ print(suffix)
else:
_ProfileResultStr = '%s\n%s\n%s' % (prefix, _ProfileResultStr, suffix)
result = globalProfileResult[0]
- del __builtin__.__dict__['globalProfileFunc']
- del __builtin__.__dict__['globalProfileResult']
+ del builtins.__dict__['globalProfileFunc']
+ del builtins.__dict__['globalProfileResult']
return result
def profiled(category=None, terse=False):
@@ -641,7 +646,7 @@ if __debug__:
want-profile-particles 1
"""
- assert type(category) in (types.StringType, types.NoneType), "must provide a category name for @profiled"
+ assert type(category) in (str, type(None)), "must provide a category name for @profiled"
# allow profiling in published versions
"""
@@ -660,7 +665,7 @@ if __debug__:
def profileDecorator(f):
def _profiled(*args, **kArgs):
- name = '(%s) %s from %s' % (category, f.func_name, f.__module__)
+ name = '(%s) %s from %s' % (category, f.__name__, f.__module__)
# showbase might not be loaded yet, so don't use
# base.config. Instead, query the ConfigVariableBool.
@@ -720,8 +725,8 @@ if __debug__:
assert filename not in profileFilenames
profileFilenames.add(filename)
profileFilenameList.push(filename)
- movedOpenFuncs.append(__builtin__.open)
- __builtin__.open = _profileOpen
+ movedOpenFuncs.append(builtins.open)
+ builtins.open = _profileOpen
movedDumpFuncs.append(marshal.dump)
marshal.dump = _profileMarshalDump
movedLoadFuncs.append(marshal.load)
@@ -746,7 +751,7 @@ if __debug__:
assert profileFilenameList.top() == filename
marshal.load = movedLoadFuncs.pop()
marshal.dump = movedDumpFuncs.pop()
- __builtin__.open = movedOpenFuncs.pop()
+ builtins.open = movedOpenFuncs.pop()
profileFilenames.remove(filename)
profileFilenameList.pop()
profileFilename2file.pop(filename, None)
@@ -763,10 +768,10 @@ if __debug__:
#
# def func(self=self):
# self.load()
- # import __builtin__
- # __builtin__.func = func
+ # import builtins
+ # builtins.func = func
# PythonUtil.startProfile(cmd='func()', filename='profileData')
- # del __builtin__.func
+ # del builtins.func
#
def _profileWithoutGarbageLeak(cmd, filename):
# The profile module isn't necessarily installed on every Python
@@ -1162,8 +1167,8 @@ def weightedRand(valDict, rng=random.random):
-Weights need not add up to any particular value.
-The actual selection will be returned.
"""
- selections = valDict.keys()
- weights = valDict.values()
+ selections = list(valDict.keys())
+ weights = list(valDict.values())
totalWeight = 0
for weight in weights:
@@ -1195,11 +1200,6 @@ def randInt32(rng=random.random):
i *= -1
return i
-def randUint32(rng=random.random):
- """returns a random integer in [0..2^32).
- rng must return float in [0..1]"""
- return long(rng() * 0xFFFFFFFFL)
-
class SerialNumGen:
"""generates serial numbers"""
def __init__(self, start=None):
@@ -1228,15 +1228,16 @@ def uniqueName(name):
class EnumIter:
def __init__(self, enum):
- self._values = enum._stringTable.keys()
+ self._values = list(enum._stringTable.keys())
self._index = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self._index >= len(self._values):
raise StopIteration
self._index += 1
return self._values[self._index-1]
+ next = __next__
class Enum:
"""Pass in list of strings or string of comma-separated strings.
@@ -1259,18 +1260,18 @@ class Enum:
if __debug__:
# chars that cannot appear within an item string.
- InvalidChars = string.whitespace
def _checkValidIdentifier(item):
- invalidChars = string.whitespace+string.punctuation
- invalidChars = invalidChars.replace('_','')
+ import string
+ invalidChars = string.whitespace + string.punctuation
+ invalidChars = invalidChars.replace('_', '')
invalidFirstChars = invalidChars+string.digits
if item[0] in invalidFirstChars:
- raise SyntaxError, ("Enum '%s' contains invalid first char" %
+ raise SyntaxError("Enum '%s' contains invalid first char" %
item)
if not disjoint(item, invalidChars):
for char in item:
if char in invalidChars:
- raise SyntaxError, (
+ raise SyntaxError(
"Enum\n'%s'\ncontains illegal char '%s'" %
(item, char))
return 1
@@ -1389,7 +1390,7 @@ def printListEnumGen(l):
n //= 10
format = '%0' + '%s' % digits + 'i:%s'
for i in range(len(l)):
- print format % (i, l[i])
+ print(format % (i, l[i]))
yield None
def printListEnum(l):
@@ -1461,10 +1462,10 @@ def fastRepr(obj, maxLen=200, strFactor=10, _visitedIds=None):
_visitedIds = set()
if id(obj) in _visitedIds:
return '' % itype(obj)
- if type(obj) in (types.TupleType, types.ListType):
+ if type(obj) in (tuple, list):
s = ''
- s += {types.TupleType: '(',
- types.ListType: '[',}[type(obj)]
+ s += {tuple: '(',
+ list: '[',}[type(obj)]
if maxLen is not None and len(obj) > maxLen:
o = obj[:maxLen]
ellips = '...'
@@ -1477,16 +1478,16 @@ def fastRepr(obj, maxLen=200, strFactor=10, _visitedIds=None):
s += ', '
_visitedIds.remove(id(obj))
s += ellips
- s += {types.TupleType: ')',
- types.ListType: ']',}[type(obj)]
+ s += {tuple: ')',
+ list: ']',}[type(obj)]
return s
- elif type(obj) is types.DictType:
+ elif type(obj) is dict:
s = '{'
if maxLen is not None and len(obj) > maxLen:
- o = obj.keys()[:maxLen]
+ o = list(obj.keys())[:maxLen]
ellips = '...'
else:
- o = obj.keys()
+ o = list(obj.keys())
ellips = ''
_visitedIds.add(id(obj))
for key in o:
@@ -1497,7 +1498,7 @@ def fastRepr(obj, maxLen=200, strFactor=10, _visitedIds=None):
s += ellips
s += '}'
return s
- elif type(obj) is types.StringType:
+ elif type(obj) is str:
if maxLen is not None:
maxLen *= strFactor
if maxLen is not None and len(obj) > maxLen:
@@ -1515,14 +1516,14 @@ def fastRepr(obj, maxLen=200, strFactor=10, _visitedIds=None):
def convertTree(objTree, idList):
newTree = {}
- for key in objTree.keys():
+ for key in list(objTree.keys()):
obj = (idList[key],)
newTree[obj] = {}
r_convertTree(objTree[key], newTree[obj], idList)
return newTree
def r_convertTree(oldTree, newTree, idList):
- for key in oldTree.keys():
+ for key in list(oldTree.keys()):
obj = idList.get(key)
if(not obj):
@@ -1535,14 +1536,14 @@ def r_convertTree(oldTree, newTree, idList):
def pretty_print(tree):
for name in tree.keys():
- print name
+ print(name)
r_pretty_print(tree[name], 0)
def r_pretty_print(tree, num):
num+=1
for name in tree.keys():
- print " "*num,name
+ print(" "*num,name)
r_pretty_print(tree[name],num)
@@ -1568,13 +1569,13 @@ def appendStr(obj, st):
class ScratchPad:
"""empty class to stick values onto"""
def __init__(self, **kArgs):
- for key, value in kArgs.iteritems():
+ for key, value in kArgs.items():
setattr(self, key, value)
self._keys = set(kArgs.keys())
def add(self, **kArgs):
- for key, value in kArgs.iteritems():
+ for key, value in kArgs.items():
setattr(self, key, value)
- self._keys.update(kArgs.keys())
+ self._keys.update(list(kArgs.keys()))
def destroy(self):
for key in self._keys:
delattr(self, key)
@@ -1639,10 +1640,10 @@ def deeptype(obj, maxLen=100, _visitedIds=None):
if id(obj) in _visitedIds:
return '' % itype(obj)
t = type(obj)
- if t in (types.TupleType, types.ListType):
+ if t in (tuple, list):
s = ''
- s += {types.TupleType: '(',
- types.ListType: '[',}[type(obj)]
+ s += {tuple: '(',
+ list: '[',}[type(obj)]
if maxLen is not None and len(obj) > maxLen:
o = obj[:maxLen]
ellips = '...'
@@ -1655,16 +1656,16 @@ def deeptype(obj, maxLen=100, _visitedIds=None):
s += ', '
_visitedIds.remove(id(obj))
s += ellips
- s += {types.TupleType: ')',
- types.ListType: ']',}[type(obj)]
+ s += {tuple: ')',
+ list: ']',}[type(obj)]
return s
- elif type(obj) is types.DictType:
+ elif type(obj) is dict:
s = '{'
if maxLen is not None and len(obj) > maxLen:
- o = obj.keys()[:maxLen]
+ o = list(obj.keys())[:maxLen]
ellips = '...'
else:
- o = obj.keys()
+ o = list(obj.keys())
ellips = ''
_visitedIds.add(id(obj))
for key in o:
@@ -1745,7 +1746,7 @@ def printNumberedTyped(items, maxLen=5000):
if len(objStr) > maxLen:
snip = ''
objStr = '%s%s' % (objStr[:(maxLen-len(snip))], snip)
- print format % (i, itype(items[i]), objStr)
+ print(format % (i, itype(items[i]), objStr))
def printNumberedTypesGen(items, maxLen=5000):
digits = 0
@@ -1756,7 +1757,7 @@ def printNumberedTypesGen(items, maxLen=5000):
digits = digits
format = '%0' + '%s' % digits + 'i:%s'
for i in xrange(len(items)):
- print format % (i, itype(items[i]))
+ print(format % (i, itype(items[i])))
yield None
def printNumberedTypes(items, maxLen=5000):
@@ -2048,7 +2049,7 @@ def report(types = [], prefix = '', xform = None, notifyFunc = None, dConfigPara
pass
pass
- except NameError,e:
+ except NameError as e:
return decorator
globalClockDelta = importlib.import_module("direct.distributed.ClockDelta").globalClockDelta
@@ -2070,7 +2071,7 @@ def report(types = [], prefix = '', xform = None, notifyFunc = None, dConfigPara
rArgs = '(' + reduce(str.__add__,rArgs)[:-2] + ')'
- outStr = '%s%s' % (f.func_name, rArgs)
+ outStr = '%s%s' % (f.__name__, rArgs)
# Insert prefix place holder, if needed
if prefixes:
@@ -2101,18 +2102,18 @@ def report(types = [], prefix = '', xform = None, notifyFunc = None, dConfigPara
if notifyFunc:
notifyFunc(outStr % (prefix,))
else:
- print indent(outStr % (prefix,))
+ print(indent(outStr % (prefix,)))
else:
if notifyFunc:
notifyFunc(outStr)
else:
- print indent(outStr)
+ print(indent(outStr))
if 'interests' in types:
base.cr.printInterestSets()
if 'stackTrace' in types:
- print StackTrace()
+ print(StackTrace())
global __report_indent
rVal = None
@@ -2122,14 +2123,14 @@ def report(types = [], prefix = '', xform = None, notifyFunc = None, dConfigPara
finally:
__report_indent -= 1
if rVal is not None:
- print indent(' -> '+repr(rVal))
+ print(indent(' -> '+repr(rVal)))
pass
pass
return rVal
- wrap.func_name = f.func_name
- wrap.func_dict = f.func_dict
- wrap.func_doc = f.func_doc
+ wrap.__name__ = f.__name__
+ wrap.__dict__ = f.__dict__
+ wrap.__doc__ = f.__doc__
wrap.__module__ = f.__module__
return wrap
return decorator
@@ -2177,12 +2178,12 @@ if __debug__:
def _exceptionLogged(*args, **kArgs):
try:
return f(*args, **kArgs)
- except Exception, e:
+ except Exception as e:
try:
- s = '%s(' % f.func_name
+ s = '%s(' % f.__name__
for arg in args:
s += '%s, ' % arg
- for key, value in kArgs.items():
+ for key, value in list(kArgs.items()):
s += '%s=%s, ' % (key, value)
if len(args) or len(kArgs):
s = s[:-2]
@@ -2193,7 +2194,7 @@ if __debug__:
exceptionLoggedNotify.info(s)
except:
exceptionLoggedNotify.info(
- '%s: ERROR IN PRINTING' % f.func_name)
+ '%s: ERROR IN PRINTING' % f.__name__)
raise
_exceptionLogged.__doc__ = f.__doc__
return _exceptionLogged
@@ -2235,7 +2236,7 @@ def makeFlywheelGen(objects, countList=None, countFunc=None, scale=None):
def flywheel(index2objectAndCount):
# generator to produce a sequence whose elements appear a specific number of times
while len(index2objectAndCount):
- keyList = index2objectAndCount.keys()
+ keyList = list(index2objectAndCount.keys())
for key in keyList:
if index2objectAndCount[key][1] > 0:
yield index2objectAndCount[key][0]
@@ -2322,7 +2323,7 @@ if __debug__:
st=globalClock.getRealTime()
f(*args,**kArgs)
s=globalClock.getRealTime()-st
- print "Function %s.%s took %s seconds"%(f.__module__, f.__name__,s)
+ print("Function %s.%s took %s seconds"%(f.__module__, f.__name__,s))
else:
import profile as prof, pstats
@@ -2355,7 +2356,7 @@ def getTotalAnnounceTime():
def getAnnounceGenerateTime(stat):
val=0
stats=stat.stats
- for i in stats.keys():
+ for i in list(stats.keys()):
if(i[2]=="announceGenerate"):
newVal=stats[i][3]
if(newVal>val):
@@ -2418,9 +2419,9 @@ class MiniLogSentry:
del self.log
def logBlock(id, msg):
- print '<< LOGBLOCK(%03d)' % id
- print str(msg)
- print '/LOGBLOCK(%03d) >>' % id
+ print('<< LOGBLOCK(%03d)' % id)
+ print(str(msg))
+ print('/LOGBLOCK(%03d) >>' % id)
class HierarchyException(Exception):
JOSWILSO = 0
@@ -2592,9 +2593,6 @@ def endSuperLog():
superLogFile.close()
superLogFile = None
-def isInteger(n):
- return type(n) in (types.IntType, types.LongType)
-
def configIsToday(configName):
# TODO: replace usage of strptime with something else
# returns true if config string is a valid representation of today's date
@@ -2660,68 +2658,53 @@ if __debug__ and __name__ == '__main__':
assert unescapeHtmlString('as%32df') == 'as2df'
assert unescapeHtmlString('asdf%32') == 'asdf2'
-def unicodeUtf8(s):
- # * -> Unicode UTF-8
- if type(s) is types.UnicodeType:
- return s
- else:
- return unicode(str(s), 'utf-8')
-
-def encodedUtf8(s):
- # * -> 8-bit-encoded UTF-8
- return unicodeUtf8(s).encode('utf-8')
-
-import __builtin__
-__builtin__.Functor = Functor
-__builtin__.Stack = Stack
-__builtin__.Queue = Queue
-__builtin__.Enum = Enum
-__builtin__.SerialNumGen = SerialNumGen
-__builtin__.SerialMaskedGen = SerialMaskedGen
-__builtin__.ScratchPad = ScratchPad
-__builtin__.uniqueName = uniqueName
-__builtin__.serialNum = serialNum
+builtins.Functor = Functor
+builtins.Stack = Stack
+builtins.Queue = Queue
+builtins.Enum = Enum
+builtins.SerialNumGen = SerialNumGen
+builtins.SerialMaskedGen = SerialMaskedGen
+builtins.ScratchPad = ScratchPad
+builtins.uniqueName = uniqueName
+builtins.serialNum = serialNum
if __debug__:
- __builtin__.profiled = profiled
- __builtin__.exceptionLogged = exceptionLogged
-__builtin__.itype = itype
-__builtin__.appendStr = appendStr
-__builtin__.bound = bound
-__builtin__.clamp = clamp
-__builtin__.lerp = lerp
-__builtin__.makeList = makeList
-__builtin__.makeTuple = makeTuple
+ builtins.profiled = profiled
+ builtins.exceptionLogged = exceptionLogged
+builtins.itype = itype
+builtins.appendStr = appendStr
+builtins.bound = bound
+builtins.clamp = clamp
+builtins.lerp = lerp
+builtins.makeList = makeList
+builtins.makeTuple = makeTuple
if __debug__:
- __builtin__.printStack = printStack
- __builtin__.printReverseStack = printReverseStack
- __builtin__.printVerboseStack = printVerboseStack
-__builtin__.DelayedCall = DelayedCall
-__builtin__.DelayedFunctor = DelayedFunctor
-__builtin__.FrameDelayedCall = FrameDelayedCall
-__builtin__.SubframeCall = SubframeCall
-__builtin__.invertDict = invertDict
-__builtin__.invertDictLossless = invertDictLossless
-__builtin__.getBase = getBase
-__builtin__.getRepository = getRepository
-__builtin__.safeRepr = safeRepr
-__builtin__.fastRepr = fastRepr
-__builtin__.nullGen = nullGen
-__builtin__.flywheel = flywheel
-__builtin__.loopGen = loopGen
+ builtins.printStack = printStack
+ builtins.printReverseStack = printReverseStack
+ builtins.printVerboseStack = printVerboseStack
+builtins.DelayedCall = DelayedCall
+builtins.DelayedFunctor = DelayedFunctor
+builtins.FrameDelayedCall = FrameDelayedCall
+builtins.SubframeCall = SubframeCall
+builtins.invertDict = invertDict
+builtins.invertDictLossless = invertDictLossless
+builtins.getBase = getBase
+builtins.getRepository = getRepository
+builtins.safeRepr = safeRepr
+builtins.fastRepr = fastRepr
+builtins.nullGen = nullGen
+builtins.flywheel = flywheel
+builtins.loopGen = loopGen
if __debug__:
- __builtin__.StackTrace = StackTrace
-__builtin__.report = report
-__builtin__.pstatcollect = pstatcollect
-__builtin__.MiniLog = MiniLog
-__builtin__.MiniLogSentry = MiniLogSentry
-__builtin__.logBlock = logBlock
-__builtin__.HierarchyException = HierarchyException
-__builtin__.deeptype = deeptype
-__builtin__.Default = Default
-__builtin__.isInteger = isInteger
-__builtin__.configIsToday = configIsToday
-__builtin__.typeName = typeName
-__builtin__.safeTypeName = safeTypeName
-__builtin__.histogramDict = histogramDict
-__builtin__.unicodeUtf8 = unicodeUtf8
-__builtin__.encodedUtf8 = encodedUtf8
+ builtins.StackTrace = StackTrace
+builtins.report = report
+builtins.pstatcollect = pstatcollect
+builtins.MiniLog = MiniLog
+builtins.MiniLogSentry = MiniLogSentry
+builtins.logBlock = logBlock
+builtins.HierarchyException = HierarchyException
+builtins.deeptype = deeptype
+builtins.Default = Default
+builtins.configIsToday = configIsToday
+builtins.typeName = typeName
+builtins.safeTypeName = safeTypeName
+builtins.histogramDict = histogramDict
diff --git a/direct/src/showbase/RandomNumGen.py b/direct/src/showbase/RandomNumGen.py
index 0b6df19d2b..df37f1cd17 100644
--- a/direct/src/showbase/RandomNumGen.py
+++ b/direct/src/showbase/RandomNumGen.py
@@ -23,7 +23,7 @@ class RandomNumGen:
if isinstance(seed, RandomNumGen):
# seed this rng with the other rng
rng = seed
- seed = rng.randint(0, 1L << 16)
+ seed = rng.randint(0, 1 << 16)
self.notify.debug("seed: " + str(seed))
seed = int(seed)
@@ -70,11 +70,7 @@ class RandomNumGen:
assert N >= 0
assert N <= 0x7fffffff
- # the cast to 'long' prevents python from importing warnings.py,
- # presumably to warn that the multiplication result is too
- # large for an int and is implicitly being returned as a long.
- # import of warnings.py was taking a few seconds
- return int((self.__rng.getUint31() * long(N)) >> 31)
+ return int((self.__rng.getUint31() * N) >> 31)
def choice(self, seq):
"""returns a random element from seq"""
@@ -82,7 +78,7 @@ class RandomNumGen:
def shuffle(self, x):
"""randomly shuffles x in-place"""
- for i in xrange(len(x)-1, 0, -1):
+ for i in range(len(x) - 1, 0, -1):
# pick an element in x[:i+1] with which to exchange x[i]
j = int(self.__rand(i+1))
x[i], x[j] = x[j], x[i]
@@ -96,30 +92,30 @@ class RandomNumGen:
# common case while still doing adequate error checking
istart = int(start)
if istart != start:
- raise ValueError, "non-integer arg 1 for randrange()"
+ raise ValueError("non-integer arg 1 for randrange()")
if stop is None:
if istart > 0:
return self.__rand(istart)
- raise ValueError, "empty range for randrange()"
+ raise ValueError("empty range for randrange()")
istop = int(stop)
if istop != stop:
- raise ValueError, "non-integer stop for randrange()"
+ raise ValueError("non-integer stop for randrange()")
if step == 1:
if istart < istop:
return istart + self.__rand(istop - istart)
- raise ValueError, "empty range for randrange()"
+ raise ValueError("empty range for randrange()")
istep = int(step)
if istep != step:
- raise ValueError, "non-integer step for randrange()"
+ raise ValueError("non-integer step for randrange()")
if istep > 0:
n = (istop - istart + istep - 1) / istep
elif istep < 0:
n = (istop - istart + istep + 1) / istep
else:
- raise ValueError, "zero step for randrange()"
+ raise ValueError("zero step for randrange()")
if n <= 0:
- raise ValueError, "empty range for randrange()"
+ raise ValueError("empty range for randrange()")
return istart + istep*int(self.__rand(n))
def randint(self, a, b):
@@ -134,4 +130,4 @@ class RandomNumGen:
# synchronicity is critical
def random(self):
"""returns random float in [0.0, 1.0)"""
- return float(self.__rng.getUint31()) / float(1L << 31)
+ return float(self.__rng.getUint31()) / float(1 << 31)
diff --git a/direct/src/showbase/ReferrerSearch.py b/direct/src/showbase/ReferrerSearch.py
index 06272f5d05..1015c1973b 100755
--- a/direct/src/showbase/ReferrerSearch.py
+++ b/direct/src/showbase/ReferrerSearch.py
@@ -34,7 +34,7 @@ class ReferrerSearch(Job):
self.info = safeReprNotify.getInfo()
safeReprNotify.setInfo(0)
- print 'RefPath(%s): Beginning ReferrerSearch for %s' %(self._id, fastRepr(self.obj))
+ print('RefPath(%s): Beginning ReferrerSearch for %s' %(self._id, fastRepr(self.obj)))
self.visited = set()
for x in self.stepGenerator(0, [self.obj]):
@@ -45,7 +45,7 @@ class ReferrerSearch(Job):
pass
def finished(self):
- print 'RefPath(%s): Finished ReferrerSearch for %s' %(self._id, fastRepr(self.obj))
+ print('RefPath(%s): Finished ReferrerSearch for %s' %(self._id, fastRepr(self.obj)))
self.obj = None
safeReprNotify = _getSafeReprNotify()
@@ -53,7 +53,7 @@ class ReferrerSearch(Job):
pass
def __del__(self):
- print 'ReferrerSearch garbage collected'
+ print('ReferrerSearch garbage collected')
def truncateAtNewLine(self, s):
if s.find('\n') == -1:
@@ -68,13 +68,13 @@ class ReferrerSearch(Job):
def myrepr(self, referrer, refersTo):
pre = ''
if (isinstance(referrer, dict)):
- for k,v in referrer.iteritems():
+ for k,v in referrer.items():
if v is refersTo:
pre = self.truncateAtNewLine(fastRepr(k)) + ']-> '
break
elif (isinstance(referrer, (list, tuple))):
- for x in xrange(len(referrer)):
- if referrer[x] is refersTo:
+ for x, ref in enumerate(referrer):
+ if ref is refersTo:
pre = '%s]-> ' % (x)
break
@@ -114,7 +114,7 @@ class ReferrerSearch(Job):
if not (ref is path or \
inspect.isframe(ref) or \
(isinstance(ref, dict) and \
- ref.keys() == locals().keys()) or \
+ list(ref.keys()) == list(locals().keys())) or \
ref is self.__dict__ or \
id(ref) in self.visited) ]
@@ -163,7 +163,7 @@ class ReferrerSearch(Job):
# The referrer is this call frame
inspect.isframe(ref) or \
# The referrer is the locals() dictionary (closure)
- (isinstance(ref, dict) and ref.keys() == locals().keys()) or \
+ (isinstance(ref, dict) and list(ref.keys()) == list(locals().keys())) or \
# We found the reference on self
ref is self.__dict__ or \
# We've already seen this referrer
@@ -192,8 +192,8 @@ class ReferrerSearch(Job):
def printStats(self, path):
path = list(reversed(path))
path.insert(0,0)
- print 'RefPath(%s) - Stats - visited(%s) | found(%s) | depth(%s) | CurrentPath(%s)' % \
- (self._id, len(self.visited), self.found, self.depth, ''.join(self.myrepr(path[x], path[x+1]) for x in xrange(len(path)-1)))
+ print('RefPath(%s) - Stats - visited(%s) | found(%s) | depth(%s) | CurrentPath(%s)' % \
+ (self._id, len(self.visited), self.found, self.depth, ''.join(self.myrepr(path[x], path[x+1]) for x in range(len(path) - 1))))
pass
def isAtRoot(self, at, path):
@@ -205,10 +205,10 @@ class ReferrerSearch(Job):
sys.stdout.write("RefPath(%s): Circular: " % self._id)
path = list(reversed(path))
path.insert(0,0)
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
@@ -218,80 +218,80 @@ class ReferrerSearch(Job):
sys.stdout.write("RefPath(%s): __builtins__-> " % self._id)
path = list(reversed(path))
path.insert(0,0)
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# any module scope
if inspect.ismodule(at):
sys.stdout.write("RefPath(%s): Module(%s)-> " % (self._id, at.__name__))
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# any class scope
if inspect.isclass(at):
sys.stdout.write("RefPath(%s): Class(%s)-> " % (self._id, at.__name__))
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# simbase
if at is simbase:
sys.stdout.write("RefPath(%s): simbase-> " % self._id)
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# simbase.air
if at is simbase.air:
sys.stdout.write("RefPath(%s): simbase.air-> " % self._id)
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# messenger
if at is messenger:
sys.stdout.write("RefPath(%s): messenger-> " % self._id)
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# taskMgr
if at is taskMgr:
sys.stdout.write("RefPath(%s): taskMgr-> " % self._id)
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
# world
if hasattr(simbase.air, 'mainWorld') and at is simbase.air.mainWorld:
sys.stdout.write("RefPath(%s): mainWorld-> " % self._id)
path = list(reversed(path))
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
pass
@@ -304,14 +304,14 @@ class ReferrerSearch(Job):
sys.stdout.write("RefPath(%s): ManyRefs(%s)[%s]-> " % (self._id, len(referrers), fastRepr(at)))
path = list(reversed(path))
path.insert(0,0)
- for x in xrange(len(path)-1):
+ for x in range(len(path) - 1):
sys.stdout.write(self.myrepr(path[x], path[x+1]))
pass
- print
+ print("")
return True
else:
sys.stdout.write("RefPath(%s): ManyRefsAllowed(%s)[%s]-> " % (self._id, len(referrers), fastRepr(at, maxLen = 1, strFactor = 30)))
- print
+ print("")
pass
pass
return False
diff --git a/direct/src/showbase/ShadowPlacer.py b/direct/src/showbase/ShadowPlacer.py
index b05bc3e8eb..b0563d007c 100755
--- a/direct/src/showbase/ShadowPlacer.py
+++ b/direct/src/showbase/ShadowPlacer.py
@@ -13,7 +13,7 @@ the its parent node.
from direct.controls.ControlManager import CollisionHandlerRayStart
from direct.directnotify import DirectNotifyGlobal
from pandac.PandaModules import *
-import DirectObject
+from . import DirectObject
class ShadowPlacer(DirectObject.DirectObject):
notify = DirectNotifyGlobal.directNotify.newCategory("ShadowPlacer")
diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py
index 0a3abdc07b..80368ab175 100644
--- a/direct/src/showbase/ShowBase.py
+++ b/direct/src/showbase/ShowBase.py
@@ -17,35 +17,38 @@ from panda3d.direct import storeAccessibilityShortcutKeys, allowAccessibilitySho
from direct.extensions_native import NodePath_extensions
# This needs to be available early for DirectGUI imports
-import __builtin__ as builtins
+import sys
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
builtins.config = get_config_showbase()
from direct.directnotify.DirectNotifyGlobal import directNotify, giveNotify
-from MessengerGlobal import messenger
-from BulletinBoardGlobal import bulletinBoard
+from .MessengerGlobal import messenger
+from .BulletinBoardGlobal import bulletinBoard
from direct.task.TaskManagerGlobal import taskMgr
-from JobManagerGlobal import jobMgr
-from EventManagerGlobal import eventMgr
+from .JobManagerGlobal import jobMgr
+from .EventManagerGlobal import eventMgr
#from PythonUtil import *
from direct.interval import IntervalManager
from direct.showbase.BufferViewer import BufferViewer
from direct.task import Task
-import sys
-import Loader
+from . import Loader
import time
import atexit
import importlib
from direct.showbase import ExceptionVarDump
-import DirectObject
-import SfxPlayer
+from . import DirectObject
+from . import SfxPlayer
if __debug__:
from direct.showbase import GarbageReport
from direct.directutil import DeltaProfiler
- import OnScreenDebug
-import AppRunnerGlobal
+ from . import OnScreenDebug
+from . import AppRunnerGlobal
def legacyRun():
- builtins.base.notify.warning("run() is deprecated, use base.run() instead")
+ assert builtins.base.notify.warning("run() is deprecated, use base.run() instead")
builtins.base.run()
@atexit.register
@@ -338,7 +341,7 @@ class ShowBase(DirectObject.DirectObject):
# Make sure we're not making more than one ShowBase.
if hasattr(builtins, 'base'):
- raise StandardError, "Attempt to spawn multiple ShowBase instances!"
+ raise Exception("Attempt to spawn multiple ShowBase instances!")
# DO NOT ADD TO THIS LIST. We're trying to phase out the use of
# built-in variables by ShowBase. Use a Global module if necessary.
@@ -402,7 +405,7 @@ class ShowBase(DirectObject.DirectObject):
self.accept('window-event', self.windowEvent)
# Transition effects (fade, iris, etc)
- import Transitions
+ from . import Transitions
self.transitions = Transitions.Transitions(self.loader)
if self.win:
@@ -478,12 +481,12 @@ class ShowBase(DirectObject.DirectObject):
add stuff to this.
"""
if self.config.GetBool('want-env-debug-info', 0):
- print "\n\nEnvironment Debug Info {"
- print "* model path:"
- print getModelPath()
+ print("\n\nEnvironment Debug Info {")
+ print("* model path:")
+ print(getModelPath())
#print "* dna path:"
#print getDnaPath()
- print "}"
+ print("}")
def destroy(self):
""" Call this function to destroy the ShowBase and stop all
@@ -695,7 +698,7 @@ class ShowBase(DirectObject.DirectObject):
if requireWindow:
# Unless require-window is set to false, it is an
# error not to open a window.
- raise StandardError, 'Could not open window.'
+ raise Exception('Could not open window.')
else:
self.notify.info("Successfully opened window of type %s (%s)" % (
win.getType(), win.getPipe().getInterfaceName()))
@@ -1793,14 +1796,14 @@ class ShowBase(DirectObject.DirectObject):
# backwards compatibility. Please do not add code here, add
# it to the loader.
def loadSfx(self, name):
- self.notify.warning("base.loadSfx is deprecated, use base.loader.loadSfx instead.")
+ assert self.notify.warning("base.loadSfx is deprecated, use base.loader.loadSfx instead.")
return self.loader.loadSfx(name)
# This function should only be in the loader but is here for
# backwards compatibility. Please do not add code here, add
# it to the loader.
def loadMusic(self, name):
- self.notify.warning("base.loadMusic is deprecated, use base.loader.loadMusic instead.")
+ assert self.notify.warning("base.loadMusic is deprecated, use base.loader.loadMusic instead.")
return self.loader.loadMusic(name)
def playSfx(
@@ -2519,7 +2522,7 @@ class ShowBase(DirectObject.DirectObject):
rig = NodePath(namePrefix)
buffer = source.makeCubeMap(namePrefix, size, rig, cameraMask, 1)
if buffer == None:
- raise StandardError, "Could not make cube map."
+ raise Exception("Could not make cube map.")
# Set the near and far planes from the default lens.
lens = rig.find('**/+Camera').node().getLens()
@@ -2589,7 +2592,7 @@ class ShowBase(DirectObject.DirectObject):
buffer = toSphere.makeCubeMap(namePrefix, size, rig, cameraMask, 0)
if buffer == None:
self.graphicsEngine.removeWindow(toSphere)
- raise StandardError, "Could not make cube map."
+ raise Exception("Could not make cube map.")
# Set the near and far planes from the default lens.
lens = rig.find('**/+Camera').node().getLens()
@@ -2904,7 +2907,7 @@ class ShowBase(DirectObject.DirectObject):
# Use importlib to prevent this import from being picked up
# by modulefinder when packaging an application.
- tkinter = importlib.import_module('Tkinter').tkinter
+ tkinter = importlib.import_module('_tkinter')
Pmw = importlib.import_module('Pmw')
# Create a new Tk root.
@@ -2938,7 +2941,7 @@ class ShowBase(DirectObject.DirectObject):
# dooneevent will return 0 if there are no more events
# waiting or 1 if there are still more.
# DONT_WAIT tells tkinter not to block waiting for events
- while tkinter.dooneevent(tkinter.ALL_EVENTS | tkinter.DONT_WAIT):
+ while self.tkRoot.dooneevent(tkinter.ALL_EVENTS | tkinter.DONT_WAIT):
pass
return task.again
diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py
index 451f411f15..0781b06f0e 100644
--- a/direct/src/showbase/ShowBaseGlobal.py
+++ b/direct/src/showbase/ShowBaseGlobal.py
@@ -2,7 +2,7 @@
__all__ = []
-from ShowBase import *
+from .ShowBase import *
# Create the showbase instance
# This should be created by the game specific "start" file
@@ -20,8 +20,12 @@ def inspect(anObject):
Inspector = importlib.import_module('direct.tkpanels.Inspector')
return Inspector.inspect(anObject)
-import __builtin__
-__builtin__.inspect = inspect
+if sys.version_info >= (3, 0):
+ import builtins
+else:
+ import __builtin__ as builtins
+builtins.inspect = inspect
+
# this also appears in AIBaseGlobal
if (not __debug__) and __dev__:
notify = directNotify.newCategory('ShowBaseGlobal')
diff --git a/direct/src/showbase/ThreeUpShow.py b/direct/src/showbase/ThreeUpShow.py
index 5d32153ede..6449033c50 100644
--- a/direct/src/showbase/ThreeUpShow.py
+++ b/direct/src/showbase/ThreeUpShow.py
@@ -3,7 +3,7 @@
__all__ = ['ThreeUpShow']
-import ShowBase
+from . import ShowBase
class ThreeUpShow(ShowBase.ShowBase):
def __init__(self):
diff --git a/direct/src/showbase/TkGlobal.py b/direct/src/showbase/TkGlobal.py
index 1fdb89ac1a..bfdeb9b48f 100644
--- a/direct/src/showbase/TkGlobal.py
+++ b/direct/src/showbase/TkGlobal.py
@@ -1,8 +1,12 @@
""" This module is now vestigial. """
-from Tkinter import *
import sys, Pmw
+if sys.version_info >= (3, 0):
+ from tkinter import *
+else:
+ from Tkinter import *
+
# This is required by the ihooks.py module used by Squeeze (used by
# pandaSqueezer.py) so that Pmw initializes properly
if '_Pmw' in sys.modules:
diff --git a/direct/src/showbase/VFSImporter.py b/direct/src/showbase/VFSImporter.py
index eb2b7bd7d4..807b931ab0 100644
--- a/direct/src/showbase/VFSImporter.py
+++ b/direct/src/showbase/VFSImporter.py
@@ -6,7 +6,6 @@ import sys
import marshal
import imp
import types
-import __builtin__
# The sharedPackages dictionary lists all of the "shared packages",
# special Python packages that automatically span multiple directories
@@ -305,7 +304,7 @@ class VFSLoader:
if source and source[-1] != '\n':
source = source + '\n'
- code = __builtin__.compile(source, filename.toOsSpecific(), 'exec')
+ code = compile(source, filename.toOsSpecific(), 'exec')
# try to cache the compiled code
pycFilename = Filename(filename)
@@ -449,7 +448,7 @@ class VFSSharedLoader:
mod = loader.load_module(fullname, loadingShared = True)
except ImportError:
etype, evalue, etraceback = sys.exc_info()
- print "%s on %s: %s" % (etype.__name__, fullname, evalue)
+ print("%s on %s: %s" % (etype.__name__, fullname, evalue))
if not message:
message = '%s: %s' % (fullname, evalue)
continue
@@ -509,7 +508,7 @@ def reloadSharedPackage(mod):
# Also force any child packages to become shared packages, if
# they aren't already.
- for basename, child in mod.__dict__.items():
+ for basename, child in list(mod.__dict__.items()):
if isinstance(child, types.ModuleType):
childname = child.__name__
if childname == fullname + '.' + basename and \
diff --git a/direct/src/showbase/VerboseImport.py b/direct/src/showbase/VerboseImport.py
index a8e2ef7317..56efc33b23 100644
--- a/direct/src/showbase/VerboseImport.py
+++ b/direct/src/showbase/VerboseImport.py
@@ -19,13 +19,13 @@ def newimport(*args, **kw):
name = args[0]
# Only print the name if we have not imported this before
if name not in sys.modules:
- print (" "*indentLevel + "import " + args[0])
+ print((" "*indentLevel + "import " + args[0]))
fPrint = 1
indentLevel += 1
result = oldimport(*args, **kw)
indentLevel -= 1
if fPrint:
- print (" "*indentLevel + "DONE: import " + args[0])
+ print((" "*indentLevel + "DONE: import " + args[0]))
return result
# Replace the builtin import with our new import
diff --git a/direct/src/showbase/pandaSqueezeTool.py b/direct/src/showbase/pandaSqueezeTool.py
index fd87135930..e19d660c22 100755
--- a/direct/src/showbase/pandaSqueezeTool.py
+++ b/direct/src/showbase/pandaSqueezeTool.py
@@ -52,15 +52,14 @@ __all__ = ['usage', 'Squeezer', 'Loader', 'boot', 'open', 'explode', 'getloader'
VERSION = "1.6/98-05-04"
MAGIC = "[PANDASQUEEZE]"
-import base64, imp, marshal, os, string, sys
+import base64, imp, marshal, os, sys
# --------------------------------------------------------------------
# usage
def usage():
- print
- print "SQUEEZE", VERSION, "(c) 1997-1998 by Secret Labs AB"
- print """\
+ print("\nSQUEEZE", VERSION, "(c) 1997-1998 by Secret Labs AB")
+ print("""\
Convert a Python application to a compressed module package.
Usage: squeeze [-1ux] -o app [-b start] modules... [-d files...]
@@ -87,7 +86,7 @@ StringIO file object).
The -x option can be used with -d to create a self-extracting archive,
instead of a package. When the resulting script is executed, the
data files are extracted. Omit the -b option in this case.
-"""
+""")
sys.exit(1)
@@ -199,9 +198,9 @@ def boot(name, fp, size, offset = 0):
loaderopen = """
def open(name):
- import StringIO
+ from io import StringIO
try:
- return StringIO.StringIO(data["+"+name])
+ return StringIO(data["+"+name])
except KeyError:
raise IOError, (0, "no such file")
"""
@@ -268,12 +267,12 @@ def squeeze(app, start, filelist, outputDir):
try:
fp = open(bootstrap)
s = fp.readline()
- string.index(s, MAGIC)
+ s.index(MAGIC)
except IOError:
pass
except ValueError:
- print bootstrap, "was not created by squeeze. You have to manually"
- print "remove the file to proceed."
+ print("%s was not created by squeeze. You have to manually" % (bootstrap))
+ print("remove the file to proceed.")
sys.exit(1)
#
@@ -298,7 +297,7 @@ def squeeze(app, start, filelist, outputDir):
loaderlen = len(loader)
magic = repr(imp.get_magic())
- version = string.split(sys.version)[0]
+ version = sys.version.split()[0]
#
# generate script and package files
@@ -372,5 +371,4 @@ exec "from %(start)s import *"
dummy, rawbytes = sq.getstatus()
- print "squeezed", rawbytes, "to", bytes, "bytes",
- print "(%d%%)" % (bytes * 100 / rawbytes)
+ print("squeezed %s to %s (%d%%)" % (rawbytes, bytes, bytes * 100 / rawbytes))
diff --git a/direct/src/showbase/pandaSqueezer.py b/direct/src/showbase/pandaSqueezer.py
index 707bafc204..84beee7813 100644
--- a/direct/src/showbase/pandaSqueezer.py
+++ b/direct/src/showbase/pandaSqueezer.py
@@ -5,18 +5,18 @@ __all__ = []
import os
import sys
import getopt
-import pandaSqueezeTool
+from . import pandaSqueezeTool
# Assumption: We will be squeezing the files from the current directory or the -d directory.
if __name__ == "__main__":
try:
opts, pargs = getopt.getopt(sys.argv[1:], 'Od:')
- except Exception, e:
+ except Exception as e:
# User passed in a bad option, print the error and the help, then exit
- print e
- print 'Usage: pass in -O for optimized'
- print ' pass in -d directory'
+ print(e)
+ print('Usage: pass in -O for optimized')
+ print(' pass in -d directory')
sys.exit()
fOptimized = 0
@@ -25,7 +25,7 @@ if __name__ == "__main__":
flag, value = opt
if (flag == '-O'):
fOptimized = 1
- print 'Squeezing pyo files'
+ print('Squeezing pyo files')
elif (flag == '-d'):
os.chdir(value)
diff --git a/direct/src/showutil/Effects.py b/direct/src/showutil/Effects.py
index effaa426c6..d98223711b 100644
--- a/direct/src/showutil/Effects.py
+++ b/direct/src/showutil/Effects.py
@@ -105,7 +105,7 @@ def createBounce(nodeObj, numBounces, startValues, totalTime, amplitude,
newVec3 = Vec3(startValues)
newVec3.setCell(index, currBounceVal)
- print "### newVec3 = ", newVec3
+ print("### newVec3 = %s" % newVec3)
# create the right type of lerp
if ((bounceType == SX_BOUNCE) or (bounceType == SY_BOUNCE) or
diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py
index 04f8dc8baf..89016e274d 100644
--- a/direct/src/showutil/FreezeTool.py
+++ b/direct/src/showutil/FreezeTool.py
@@ -7,8 +7,7 @@ import os
import marshal
import imp
import platform
-import types
-from StringIO import StringIO
+from io import StringIO
from distutils.sysconfig import PREFIX, get_python_inc, get_python_version, get_config_var
# Temporary (?) try..except to protect against unbuilt p3extend_frozen.
@@ -97,7 +96,7 @@ class CompilationEnvironment:
elif (Filename('/c/Program Files/Microsoft Visual Studio .NET 2003/Vc7').exists()):
self.MSVC = Filename('/c/Program Files/Microsoft Visual Studio .NET 2003/Vc7').toOsSpecific()
else:
- print 'Could not locate Microsoft Visual C++ Compiler! Try running from the Visual Studio Command Prompt.'
+ print('Could not locate Microsoft Visual C++ Compiler! Try running from the Visual Studio Command Prompt.')
sys.exit(1)
if ('WindowsSdkDir' in os.environ):
@@ -107,7 +106,7 @@ class CompilationEnvironment:
elif (os.path.exists(os.path.join(self.MSVC, 'PlatformSDK'))):
self.PSDK = os.path.join(self.MSVC, 'PlatformSDK')
else:
- print 'Could not locate the Microsoft Windows Platform SDK! Try running from the Visual Studio Command Prompt.'
+ print('Could not locate the Microsoft Windows Platform SDK! Try running from the Visual Studio Command Prompt.')
sys.exit(1)
# We need to use the correct compiler setting for debug vs. release builds.
@@ -169,9 +168,9 @@ class CompilationEnvironment:
'filename' : filename,
'basename' : basename,
}
- print >> sys.stderr, compile
+ sys.stderr.write(compile + '\n')
if os.system(compile) != 0:
- raise StandardError, 'failed to compile %s.' % basename
+ raise Exception('failed to compile %s.' % basename)
link = self.linkExe % {
'python' : self.Python,
@@ -184,9 +183,9 @@ class CompilationEnvironment:
'filename' : filename,
'basename' : basename,
}
- print >> sys.stderr, link
+ sys.stderr.write(link + '\n')
if os.system(link) != 0:
- raise StandardError, 'failed to link %s.' % basename
+ raise Exception('failed to link %s.' % basename)
def compileDll(self, filename, basename):
compile = self.compileObj % {
@@ -201,9 +200,9 @@ class CompilationEnvironment:
'filename' : filename,
'basename' : basename,
}
- print >> sys.stderr, compile
+ sys.stderr.write(compile + '\n')
if os.system(compile) != 0:
- raise StandardError, 'failed to compile %s.' % basename
+ raise Exception('failed to compile %s.' % basename)
link = self.linkDll % {
'python' : self.Python,
@@ -217,9 +216,9 @@ class CompilationEnvironment:
'basename' : basename,
'dllext' : self.dllext,
}
- print >> sys.stderr, link
+ sys.stderr.write(link + '\n')
if os.system(link) != 0:
- raise StandardError, 'failed to link %s.' % basename
+ raise Exception('failed to link %s.' % basename)
# The code from frozenmain.c in the Python source repository.
frozenMainCode = """
@@ -227,6 +226,10 @@ frozenMainCode = """
#include "Python.h"
+#if PY_MAJOR_VERSION >= 3
+#include
+#endif
+
#ifdef MS_WINDOWS
extern void PyWinFreeze_ExeInit(void);
extern void PyWinFreeze_ExeTerm(void);
@@ -239,10 +242,27 @@ int
Py_FrozenMain(int argc, char **argv)
{
char *p;
- int n, sts;
+ int n, sts = 1;
int inspect = 0;
int unbuffered = 0;
+#if PY_MAJOR_VERSION >= 3
+ int i;
+ char *oldloc = NULL;
+ wchar_t **argv_copy = NULL;
+ /* We need a second copies, as Python might modify the first one. */
+ wchar_t **argv_copy2 = NULL;
+
+ if (argc > 0) {
+ argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc);
+ argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc);
+ if (!argv_copy || !argv_copy2) {
+ fprintf(stderr, \"out of memory\\n\");
+ goto error;
+ }
+ }
+#endif
+
Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\\0')
@@ -256,10 +276,41 @@ Py_FrozenMain(int argc, char **argv)
setbuf(stderr, (char *)NULL);
}
+#if PY_MAJOR_VERSION >= 3
+ oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
+ if (!oldloc) {
+ fprintf(stderr, \"out of memory\\n\");
+ goto error;
+ }
+
+ setlocale(LC_ALL, \"\");
+ for (i = 0; i < argc; i++) {
+ argv_copy[i] = Py_DecodeLocale(argv[i], NULL);
+ argv_copy2[i] = argv_copy[i];
+ if (!argv_copy[i]) {
+ fprintf(stderr, \"Unable to decode the command line argument #%i\\n\",
+ i + 1);
+ argc = i;
+ goto error;
+ }
+ }
+ setlocale(LC_ALL, oldloc);
+ PyMem_RawFree(oldloc);
+ oldloc = NULL;
+#endif
+
#ifdef MS_WINDOWS
PyInitFrozenExtensions();
#endif /* MS_WINDOWS */
- Py_SetProgramName(argv[0]);
+
+ if (argc >= 1) {
+#if PY_MAJOR_VERSION >= 3
+ Py_SetProgramName(argv_copy[0]);
+#else
+ Py_SetProgramName(argv[0]);
+#endif
+ }
+
Py_Initialize();
#ifdef MS_WINDOWS
PyWinFreeze_ExeInit();
@@ -269,7 +320,11 @@ Py_FrozenMain(int argc, char **argv)
fprintf(stderr, "Python %s\\n%s\\n",
Py_GetVersion(), Py_GetCopyright());
+#if PY_MAJOR_VERSION >= 3
+ PySys_SetArgv(argc, argv_copy);
+#else
PySys_SetArgv(argc, argv);
+#endif
n = PyImport_ImportFrozenModule("__main__");
if (n == 0)
@@ -288,6 +343,17 @@ Py_FrozenMain(int argc, char **argv)
PyWinFreeze_ExeTerm();
#endif
Py_Finalize();
+
+error:
+#if PY_MAJOR_VERSION >= 3
+ PyMem_RawFree(argv_copy);
+ if (argv_copy2) {
+ for (i = 0; i < argc; i++)
+ PyMem_RawFree(argv_copy2[i]);
+ PyMem_RawFree(argv_copy2);
+ }
+ PyMem_RawFree(oldloc);
+#endif
return sts;
}
"""
@@ -480,14 +546,15 @@ int PyInitFrozenExtensions()
"""
okMissing = [
+ '__main__', '_dummy_threading', 'Carbon', 'Carbon.Files',
'Carbon.Folder', 'Carbon.Folders', 'HouseGlobals', 'Carbon.File',
'MacOS', '_emx_link', 'ce', 'mac', 'org.python.core', 'os.path',
'os2', 'posix', 'pwd', 'readline', 'riscos', 'riscosenviron',
- 'riscospath', 'dbm', 'fcntl', 'win32api', 'usercustomize',
- '_winreg', 'ctypes', 'ctypes.wintypes', 'nt','msvcrt',
- 'EasyDialogs', 'SOCKS', 'ic', 'rourl2path', 'termios',
+ 'riscospath', 'dbm', 'fcntl', 'win32api', 'win32pipe', 'usercustomize',
+ '_winreg', 'winreg', 'ctypes', 'ctypes.wintypes', 'nt','msvcrt',
+ 'EasyDialogs', 'SOCKS', 'ic', 'rourl2path', 'termios', 'vms_lib',
'OverrideFrom23._Res', 'email', 'email.Utils', 'email.Generator',
- 'email.Iterators', '_subprocess', 'gestalt',
+ 'email.Iterators', '_subprocess', 'gestalt', 'java.lang',
'direct.extensions_native.extensions_darwin',
]
@@ -503,7 +570,7 @@ class Freezer:
# The file on disk it was loaded from, if any.
self.filename = filename
- if isinstance(filename, types.StringTypes):
+ if filename is not None and not isinstance(filename, Filename):
self.filename = Filename(filename)
# True if the module was found via the modulefinder.
@@ -614,7 +681,7 @@ class Freezer:
# Actually, make sure we know how to find all of the
# already-imported modules. (Some of them might do their own
# special path mangling.)
- for moduleName, module in sys.modules.items():
+ for moduleName, module in list(sys.modules.items()):
if module and hasattr(module, '__path__'):
path = getattr(module, '__path__')
if path:
@@ -627,7 +694,7 @@ class Freezer:
constructor, but it may be called at any point during
processing. """
- for key, value in freezer.modules.items():
+ for key, value in list(freezer.modules.items()):
self.previousModules[key] = value
self.modules[key] = value
@@ -670,7 +737,7 @@ class Freezer:
try:
module = __import__(moduleName)
except:
- print "couldn't import %s" % (moduleName)
+ print("couldn't import %s" % (moduleName))
module = None
if module != None:
@@ -709,7 +776,7 @@ class Freezer:
try:
module = __import__(moduleName)
except:
- print "couldn't import %s" % (moduleName)
+ print("couldn't import %s" % (moduleName))
module = None
if module != None:
@@ -832,6 +899,7 @@ class Freezer:
# bring in Python's startup modules.
if addStartupModules:
self.modules['_frozen_importlib'] = self.ModuleDef('importlib._bootstrap', implicit = True)
+ self.modules['_frozen_importlib_external'] = self.ModuleDef('importlib._bootstrap_external', implicit = True)
for moduleName in startupModules:
if moduleName not in self.modules:
@@ -843,7 +911,7 @@ class Freezer:
# Walk through the list in sorted order, so we reach parents
# before children.
- names = self.modules.items()
+ names = list(self.modules.items())
names.sort()
excludeDict = {}
@@ -868,7 +936,7 @@ class Freezer:
else:
includes.append(mdef)
- self.mf = PandaModuleFinder(excludes = excludeDict.keys())
+ self.mf = PandaModuleFinder(excludes = list(excludeDict.keys()))
# Attempt to import the explicit modules into the modulefinder.
@@ -884,7 +952,7 @@ class Freezer:
try:
self.__loadModule(mdef)
except ImportError:
- print "Unknown module: %s" % (mdef.moduleName)
+ print("Unknown module: %s" % (mdef.moduleName))
# Also attempt to import any implicit modules. If any of
# these fail to import, we don't really care.
@@ -899,7 +967,7 @@ class Freezer:
pass
# Now, any new modules we found get added to the export list.
- for origName in self.mf.modules.keys():
+ for origName in list(self.mf.modules.keys()):
if origName not in origToNewName:
self.modules[origName] = self.ModuleDef(origName, implicit = True)
@@ -928,7 +996,7 @@ class Freezer:
if missing:
missing.sort()
- print "There are some missing modules: %r" % missing
+ print("There are some missing modules: %r" % missing)
def __sortModuleKey(self, mdef):
""" A sort key function to sort a list of mdef's into order,
@@ -1004,7 +1072,7 @@ class Freezer:
moduleNames = []
- for newName, mdef in self.modules.items():
+ for newName, mdef in list(self.modules.items()):
if mdef.guess:
# Not really a module.
pass
@@ -1024,7 +1092,7 @@ class Freezer:
moduleDefs = []
- for newName, mdef in self.modules.items():
+ for newName, mdef in list(self.modules.items()):
prev = self.previousModules.get(newName, None)
if not mdef.exclude:
# Include this module (even if a previous pass
@@ -1050,7 +1118,7 @@ class Freezer:
# actual filename we put in there is meaningful only for stack
# traces, so we'll just use the module name.
replace_paths = []
- for moduleName, module in self.mf.modules.items():
+ for moduleName, module in list(self.mf.modules.items()):
if module.__code__:
origPathname = module.__code__.co_filename
replace_paths.append((origPathname, moduleName))
@@ -1058,7 +1126,7 @@ class Freezer:
# Now that we have built up the replacement mapping, go back
# through and actually replace the paths.
- for moduleName, module in self.mf.modules.items():
+ for moduleName, module in list(self.mf.modules.items()):
if module.__code__:
co = self.mf.replace_paths_in_code(module.__code__)
module.__code__ = co;
@@ -1206,7 +1274,7 @@ class Freezer:
Filename(mfname).unlink()
multifile = Multifile()
if not multifile.openReadWrite(mfname):
- raise StandardError
+ raise Exception
self.addToMultifile(multifile)
@@ -1283,7 +1351,7 @@ class Freezer:
# We must have a __main__ module to make an exe file.
if not self.__writingModule('__main__'):
message = "Can't generate an executable without a __main__ module."
- raise StandardError, message
+ raise Exception(message)
filename = basename + self.sourceExtension
@@ -1406,9 +1474,11 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
return (None, name, ('', '', imp.PY_FROZEN))
message = "DLL loader cannot find %s." % (name)
- raise ImportError, message
+ raise ImportError(message)
+
+ def load_module(self, fqname, fp, pathname, file_info):
+ suffix, mode, type = file_info
- def load_module(self, fqname, fp, pathname, (suffix, mode, type)):
if type == imp.PY_FROZEN:
# It's a frozen module.
co, isPackage = p3extend_frozen.get_frozen_module_code(pathname)
diff --git a/direct/src/showutil/Rope.py b/direct/src/showutil/Rope.py
index 1e65411684..1c3af011d6 100644
--- a/direct/src/showutil/Rope.py
+++ b/direct/src/showutil/Rope.py
@@ -1,5 +1,5 @@
from panda3d.core import *
-import types
+
class Rope(NodePath):
"""
@@ -96,7 +96,7 @@ class Rope(NodePath):
for i in range(numVerts):
v = self.verts[i]
- if isinstance(v, types.TupleType):
+ if isinstance(v, tuple):
nodePath, point = v
color = defaultColor
thickness = defaultThickness
@@ -106,7 +106,7 @@ class Rope(NodePath):
color = v.get('color', defaultColor)
thickness = v.get('thickness', defaultThickness)
- if isinstance(point, types.TupleType):
+ if isinstance(point, tuple):
if (len(point) >= 4):
self.curve.setVertex(i, VBase4(point[0], point[1], point[2], point[3]))
else:
diff --git a/direct/src/showutil/TexMemWatcher.py b/direct/src/showutil/TexMemWatcher.py
index d4d91ae1d3..843395d58d 100644
--- a/direct/src/showutil/TexMemWatcher.py
+++ b/direct/src/showutil/TexMemWatcher.py
@@ -729,7 +729,7 @@ class TexMemWatcher(DirectObject):
# Sort the regions from largest to smallest to maximize
# packing effectiveness.
- texRecords = self.texRecordsByTex.values()
+ texRecords = list(self.texRecordsByTex.values())
texRecords.sort(key = lambda tr: (tr.tw, tr.th), reverse = True)
for tr in texRecords:
diff --git a/direct/src/showutil/pfreeze.py b/direct/src/showutil/pfreeze.py
index 5bcc3c41ee..8676251026 100755
--- a/direct/src/showutil/pfreeze.py
+++ b/direct/src/showutil/pfreeze.py
@@ -53,8 +53,9 @@ import os
from direct.showutil import FreezeTool
def usage(code, msg = ''):
- print >> sys.stderr, __doc__
- print >> sys.stderr, msg
+ if __doc__:
+ sys.stderr.write(__doc__ + '\n')
+ sys.stderr.write(msg + '\n')
sys.exit(code)
# We're not protecting the next part under a __name__ == __main__
@@ -67,7 +68,7 @@ addStartupModules = False
try:
opts, args = getopt.getopt(sys.argv[1:], 'o:i:x:p:sh')
-except getopt.error, msg:
+except getopt.error as msg:
usage(1, msg)
for opt, arg in opts:
@@ -87,7 +88,7 @@ for opt, arg in opts:
elif opt == '-h':
usage(0)
else:
- print 'illegal option: ' + flag
+ print('illegal option: ' + flag)
sys.exit(1)
if not basename:
diff --git a/direct/src/stdpy/file.py b/direct/src/stdpy/file.py
index d6ef48cd9e..222739612a 100644
--- a/direct/src/stdpy/file.py
+++ b/direct/src/stdpy/file.py
@@ -26,6 +26,12 @@ if sys.version_info < (3, 0):
FileExistsError = IOError
PermissionError = IOError
+ unicodeType = unicode
+ strType = str
+else:
+ unicodeType = str
+ strType = ()
+
def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True):
if sys.version_info >= (3, 0):
@@ -70,11 +76,11 @@ def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
# We can also "open" a VirtualFile object for reading.
vfile = file
filename = vfile.getFilename()
- elif isinstance(file, unicode):
+ elif isinstance(file, unicodeType):
# If a raw string is given, assume it's an os-specific
# filename.
filename = core.Filename.fromOsSpecificW(file)
- elif isinstance(file, str):
+ elif isinstance(file, strType):
filename = core.Filename.fromOsSpecific(file)
else:
# If a Filename is given, make a writable copy anyway.
diff --git a/direct/src/stdpy/glob.py b/direct/src/stdpy/glob.py
index 3d1cce60f4..28eee2cb6e 100755
--- a/direct/src/stdpy/glob.py
+++ b/direct/src/stdpy/glob.py
@@ -53,7 +53,7 @@ def iglob(pathname):
def glob1(dirname, pattern):
if not dirname:
dirname = os.curdir
- if isinstance(pattern, unicode) and not isinstance(dirname, unicode):
+ if sys.version_info < (3, 0) and isinstance(pattern, unicode) and not isinstance(dirname, unicode):
dirname = unicode(dirname, sys.getfilesystemencoding() or
sys.getdefaultencoding())
try:
@@ -61,7 +61,7 @@ def glob1(dirname, pattern):
except os.error:
return []
if pattern[0] != '.':
- names = filter(lambda x: x[0] != '.', names)
+ names = [x for x in names if x[0] != '.']
return fnmatch.filter(names, pattern)
def glob0(dirname, basename):
diff --git a/direct/src/stdpy/pickle.py b/direct/src/stdpy/pickle.py
index ae46f3967b..027888e281 100644
--- a/direct/src/stdpy/pickle.py
+++ b/direct/src/stdpy/pickle.py
@@ -21,10 +21,14 @@ context between all objects written by that Pickler.
Unfortunately, cPickle cannot be supported, because it does not
support extensions of this nature. """
-from types import *
-from copy_reg import dispatch_table
+import sys
from panda3d.core import BamWriter, BamReader
+if sys.version_info >= (3, 0):
+ from copyreg import dispatch_table
+else:
+ from copy_reg import dispatch_table
+
# A funny replacement for "import pickle" so we don't get confused
# with the local pickle.py.
pickle = __import__('pickle')
@@ -60,7 +64,7 @@ class Pickler(pickle.Pickler):
# Check for a class with a custom metaclass; treat as regular class
try:
- issc = issubclass(t, TypeType)
+ issc = issubclass(t, type)
except TypeError: # t is not a class (old Boost; see SF #502085)
issc = 0
if issc:
@@ -91,12 +95,12 @@ class Pickler(pickle.Pickler):
(t.__name__, obj))
# Check for string returned by reduce(), meaning "save as global"
- if type(rv) is StringType:
+ if type(rv) is str:
self.save_global(obj, rv)
return
# Assert that reduce() returned a tuple
- if type(rv) is not TupleType:
+ if type(rv) is not tuple:
raise PicklingError("%s must return string or tuple" % reduce)
# Assert that it returned an appropriately sized tuple
@@ -131,21 +135,20 @@ class Unpickler(pickle.Unpickler):
value = func(*args)
stack[-1] = value
- pickle.Unpickler.dispatch[pickle.REDUCE] = load_reduce
+
+ #FIXME: how to replace in Python 3?
+ if sys.version_info < (3, 0):
+ pickle.Unpickler.dispatch[pickle.REDUCE] = load_reduce
# Shorthands
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+from io import BytesIO
def dump(obj, file, protocol=None):
Pickler(file, protocol).dump(obj)
def dumps(obj, protocol=None):
- file = StringIO()
+ file = BytesIO()
Pickler(file, protocol).dump(obj)
return file.getvalue()
@@ -153,5 +156,5 @@ def load(file):
return Unpickler(file).load()
def loads(str):
- file = StringIO(str)
+ file = BytesIO(str)
return Unpickler(file).load()
diff --git a/direct/src/stdpy/thread.py b/direct/src/stdpy/thread.py
index f8291488d1..d10a47fb54 100644
--- a/direct/src/stdpy/thread.py
+++ b/direct/src/stdpy/thread.py
@@ -21,7 +21,7 @@ from panda3d import core
forceYield = core.Thread.forceYield
considerYield = core.Thread.considerYield
-class error(StandardError):
+class error(Exception):
pass
class LockType:
@@ -54,7 +54,7 @@ class LockType:
self.__lock.acquire()
try:
if not self.__locked:
- raise error, 'Releasing unheld lock.'
+ raise error('Releasing unheld lock.')
self.__locked = False
self.__cvar.notify()
@@ -240,7 +240,7 @@ class _local(object):
# Delete this key from all threads.
_threadsLock.acquire()
try:
- for thread, locals, wrapper in _threads.values():
+ for thread, locals, wrapper in list(_threads.values()):
try:
del locals[i]
except KeyError:
diff --git a/direct/src/stdpy/threading.py b/direct/src/stdpy/threading.py
index 3fa576e712..5c8af3cc62 100644
--- a/direct/src/stdpy/threading.py
+++ b/direct/src/stdpy/threading.py
@@ -21,7 +21,6 @@ easier to use and understand.
It is permissible to mix-and-match both threading and threading2
within the same application. """
-import direct
from panda3d import core
from direct.stdpy import thread as _thread
import sys as _sys
@@ -54,12 +53,6 @@ class ThreadBase:
def getName(self):
return self.name
- def is_alive(self):
- return self.__thread.isStarted()
-
- def isAlive(self):
- return self.__thread.isStarted()
-
def isDaemon(self):
return self.daemon
@@ -115,6 +108,12 @@ class Thread(ThreadBase):
if _thread and _thread._remove_thread_id:
_thread._remove_thread_id(self.ident)
+ def is_alive(self):
+ return self.__thread.isStarted()
+
+ def isAlive(self):
+ return self.__thread.isStarted()
+
def start(self):
if self.__thread.isStarted():
raise RuntimeError
@@ -152,6 +151,12 @@ class ExternalThread(ThreadBase):
self.__dict__['name'] = self.__thread.getName()
self.__dict__['ident'] = threadId
+ def is_alive(self):
+ return self.__thread.isStarted()
+
+ def isAlive(self):
+ return self.__thread.isStarted()
+
def start(self):
raise RuntimeError
@@ -380,7 +385,7 @@ def enumerate():
tlist = []
_thread._threadsLock.acquire()
try:
- for thread, locals, wrapper in _thread._threads.values():
+ for thread, locals, wrapper in list(_thread._threads.values()):
if wrapper and thread.isStarted():
tlist.append(wrapper)
return tlist
@@ -484,7 +489,7 @@ if __debug__:
def run(self):
while self.count > 0:
item = self.queue.get()
- print item
+ print(item)
self.count = self.count - 1
NP = 3
diff --git a/direct/src/stdpy/threading2.py b/direct/src/stdpy/threading2.py
index d03ac01c3c..9beee770c0 100644
--- a/direct/src/stdpy/threading2.py
+++ b/direct/src/stdpy/threading2.py
@@ -139,10 +139,9 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, (count, owner)):
+ def _acquire_restore(self, state):
self.__block.acquire()
- self.__count = count
- self.__owner = owner
+ self.__count, self.__owner = state
if __debug__:
self._note("%s._acquire_restore()", self)
@@ -334,7 +333,7 @@ class _BoundedSemaphore(_Semaphore):
def release(self):
if self._Semaphore__value >= self._initial_value:
- raise ValueError, "Semaphore released too many times"
+ raise ValueError("Semaphore released too many times")
return _Semaphore.release(self)
@@ -481,19 +480,16 @@ class Thread(_Verbose):
# Lib/traceback.py)
exc_type, exc_value, exc_tb = self.__exc_info()
try:
- print>>self.__stderr, (
- "Exception in thread " + self.getName() +
- " (most likely raised during interpreter shutdown):")
- print>>self.__stderr, (
- "Traceback (most recent call last):")
+ self.__stderr.write("Exception in thread " + self.getName() +
+ " (most likely raised during interpreter shutdown):\n")
+ self.__stderr.write("Traceback (most recent call last):\n")
while exc_tb:
- print>>self.__stderr, (
- ' File "%s", line %s, in %s' %
+ self.__stderr.write(' File "%s", line %s, in %s\n' %
(exc_tb.tb_frame.f_code.co_filename,
exc_tb.tb_lineno,
exc_tb.tb_frame.f_code.co_name))
exc_tb = exc_tb.tb_next
- print>>self.__stderr, ("%s: %s" % (exc_type, exc_value))
+ self.__stderr.write("%s: %s\n" % (exc_type, exc_value))
# Make sure that exc_tb gets deleted since it is a memory
# hog; deleting everything else is just for thoroughness
finally:
@@ -711,7 +707,7 @@ def activeCount():
def enumerate():
_active_limbo_lock.acquire()
- active = _active.values() + _limbo.values()
+ active = list(_active.values()) + list(_limbo.values())
_active_limbo_lock.release()
return active
@@ -795,7 +791,7 @@ if __debug__:
def run(self):
while self.count > 0:
item = self.queue.get()
- print item
+ print(item)
self.count = self.count - 1
NP = 3
diff --git a/direct/src/task/FrameProfiler.py b/direct/src/task/FrameProfiler.py
index b524dbf1c1..4207937d1c 100755
--- a/direct/src/task/FrameProfiler.py
+++ b/direct/src/task/FrameProfiler.py
@@ -35,15 +35,15 @@ class FrameProfiler:
24 * FrameProfiler.Minute,
]
for t in self._logSchedule:
- assert isInteger(t)
+ #assert isInteger(t)
# make sure the period is evenly divisible into each element of the log schedule
assert (t % self._period) == 0
# make sure each element of the schedule is evenly divisible into each subsequent element
- for i in xrange(len(self._logSchedule)):
+ for i in range(len(self._logSchedule)):
e = self._logSchedule[i]
- for j in xrange(i, len(self._logSchedule)):
+ for j in range(i, len(self._logSchedule)):
assert (self._logSchedule[j] % e) == 0
- assert isInteger(self._period)
+ #assert isInteger(self._period)
self._enableFC = FunctionCall(self._setEnabled, taskMgr.getProfileFramesSV())
self._enableFC.pushCurrentState()
@@ -66,13 +66,13 @@ class FrameProfiler:
else:
self._task.remove()
del self._task
- for session in self._period2aggregateProfile.itervalues:
+ for session in self._period2aggregateProfile.values():
session.release()
del self._period2aggregateProfile
- for task in self._id2task.itervalues():
+ for task in self._id2task.values():
task.remove()
del self._id2task
- for session in self._id2session.itervalues():
+ for session in self._id2session.values():
session.release()
del self._id2session
self.notify.info('frame profiler stopped')
@@ -84,7 +84,7 @@ class FrameProfiler:
def _scheduleNextProfile(self):
self._profileCounter += 1
self._timeElapsed = self._profileCounter * self._period
- assert isInteger(self._timeElapsed)
+ #assert isInteger(self._timeElapsed)
time = self._startTime + self._timeElapsed
# vary the actual delay between profiles by a random amount to prevent interaction
@@ -121,7 +121,7 @@ class FrameProfiler:
else:
gen = self._doAnalysisGen(sessionId)
task._generator = gen
- result = gen.next()
+ result = next(gen)
if result == Task.done:
del task._generator
return result
@@ -150,7 +150,7 @@ class FrameProfiler:
# log profiles when it's time, and aggregate them upwards into the
# next-longer profile
- for pi in xrange(len(self._logSchedule)):
+ for pi in range(len(self._logSchedule)):
period = self._logSchedule[pi]
if (self._timeElapsed % period) == 0:
if period in p2ap:
diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py
index 5d4a831f32..e12b64078d 100644
--- a/direct/src/task/Task.py
+++ b/direct/src/task/Task.py
@@ -42,21 +42,21 @@ def print_exc_plus():
f = f.f_back
stack.reverse()
traceback.print_exc()
- print "Locals by frame, innermost last"
+ print("Locals by frame, innermost last")
for frame in stack:
- print
- print "Frame %s in %s at line %s" % (frame.f_code.co_name,
+ print("")
+ print("Frame %s in %s at line %s" % (frame.f_code.co_name,
frame.f_code.co_filename,
- frame.f_lineno)
- for key, value in frame.f_locals.items():
- print "\t%20s = " % key,
+ frame.f_lineno))
+ for key, value in list(frame.f_locals.items()):
#We have to be careful not to cause a new error in our error
#printer! Calling str() on an unknown object could cause an
#error we don't want.
try:
- print value
+ valueStr = str(value)
except:
- print ""
+ valueStr = ""
+ print("\t%20s = %s" % (key, valueStr))
# For historical purposes, we remap the C++-defined enumeration to
# these Python names, and define them both at the module level, here,
@@ -153,7 +153,7 @@ class TaskManager:
clock = property(lambda self: self.mgr.getClock(), setClock)
def invokeDefaultHandler(self, signalNumber, stackFrame):
- print '*** allowing mid-frame keyboard interrupt.'
+ print('*** allowing mid-frame keyboard interrupt.')
# Restore default interrupt handler
if signal:
signal.signal(signal.SIGINT, signal.default_int_handler)
@@ -164,9 +164,9 @@ class TaskManager:
self.fKeyboardInterrupt = 1
self.interruptCount += 1
if self.interruptCount == 1:
- print '* interrupt by keyboard'
+ print('* interrupt by keyboard')
elif self.interruptCount == 2:
- print '** waiting for end of frame before interrupting...'
+ print('** waiting for end of frame before interrupting...')
# The user must really want to interrupt this process
# Next time around invoke the default handler
signal.signal(signal.SIGINT, self.invokeDefaultHandler)
@@ -397,7 +397,7 @@ class TaskManager:
'Task %s does not accept arguments.' % (repr(task)))
if name is not None:
- assert isinstance(name, types.StringTypes), 'Name must be a string type'
+ assert isinstance(name, str), 'Name must be a string type'
task.setName(name)
assert task.hasName()
@@ -431,12 +431,12 @@ class TaskManager:
all tasks with the indicated name are removed. Returns the
number of tasks removed. """
- if isinstance(taskOrName, types.StringTypes):
+ if isinstance(taskOrName, str):
tasks = self.mgr.findTasks(taskOrName)
return self.mgr.remove(tasks)
elif isinstance(taskOrName, AsyncTask):
return self.mgr.remove(taskOrName)
- elif isinstance(taskOrName, types.ListType):
+ elif isinstance(taskOrName, list):
for task in taskOrName:
self.remove(task)
else:
@@ -520,7 +520,7 @@ class TaskManager:
except SystemExit:
self.stop()
raise
- except IOError, ioError:
+ except IOError as ioError:
code, message = self._unpackIOError(ioError)
# Since upgrading to Python 2.4.1, pausing the execution
# often gives this IOError during the sleep function:
@@ -532,7 +532,7 @@ class TaskManager:
self.stop()
else:
raise
- except Exception, e:
+ except Exception as e:
if self.extendedExceptions:
self.stop()
print_exc_plus()
@@ -571,13 +571,13 @@ class TaskManager:
method = task.getFunction()
if (type(method) == types.MethodType):
- function = method.im_func
+ function = method.__func__
else:
function = method
if (function == oldMethod):
newMethod = types.MethodType(newFunction,
- method.im_self,
- method.im_class)
+ method.__self__,
+ method.__self__.__class__)
task.setFunction(newMethod)
# Found a match
return 1
@@ -615,7 +615,7 @@ class TaskManager:
self._frameProfileQueue.push((num, session, callback))
def _doProfiledFrames(self, numFrames):
- for i in xrange(numFrames):
+ for i in range(numFrames):
result = self.step()
return result
@@ -1261,22 +1261,22 @@ if __debug__:
return task.done
obj = TestClass()
startRefCount = sys.getrefcount(obj)
- print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
- print '** addTask'
+ print('sys.getrefcount(obj): %s' % sys.getrefcount(obj))
+ print('** addTask')
t = obj.addTask(obj.doTask, 'test')
- print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
- print 'task.getRefCount(): %s' % t.getRefCount()
- print '** removeTask'
+ print('sys.getrefcount(obj): %s' % sys.getrefcount(obj))
+ print('task.getRefCount(): %s' % t.getRefCount())
+ print('** removeTask')
obj.removeTask('test')
- print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
- print 'task.getRefCount(): %s' % t.getRefCount()
- print '** step'
+ print('sys.getrefcount(obj): %s' % sys.getrefcount(obj))
+ print('task.getRefCount(): %s' % t.getRefCount())
+ print('** step')
taskMgr.step()
taskMgr.step()
taskMgr.step()
- print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
- print 'task.getRefCount(): %s' % t.getRefCount()
- print '** task release'
+ print('sys.getrefcount(obj): %s' % sys.getrefcount(obj))
+ print('task.getRefCount(): %s' % t.getRefCount())
+ print('** task release')
t = None
- print 'sys.getrefcount(obj): %s' % sys.getrefcount(obj)
+ print('sys.getrefcount(obj): %s' % sys.getrefcount(obj))
assert sys.getrefcount(obj) == startRefCount
diff --git a/direct/src/task/TaskManagerGlobal.py b/direct/src/task/TaskManagerGlobal.py
index 4c95232c4d..60587d7a4f 100644
--- a/direct/src/task/TaskManagerGlobal.py
+++ b/direct/src/task/TaskManagerGlobal.py
@@ -2,6 +2,6 @@
__all__ = ['taskMgr']
-import Task
+from . import Task
taskMgr = Task.TaskManager()
diff --git a/direct/src/task/TaskProfiler.py b/direct/src/task/TaskProfiler.py
index ceb83b2e15..e099f82905 100755
--- a/direct/src/task/TaskProfiler.py
+++ b/direct/src/task/TaskProfiler.py
@@ -100,7 +100,7 @@ class TaskProfiler:
if taskMgr.getProfileTasks():
self._setEnabled(False)
self._enableFC.destroy()
- for tracker in self._namePrefix2tracker.itervalues():
+ for tracker in self._namePrefix2tracker.values():
tracker.destroy()
del self._namePrefix2tracker
del self._task
@@ -119,7 +119,7 @@ class TaskProfiler:
def logProfiles(self, name=None):
if name:
name = name.lower()
- for namePrefix, tracker in self._namePrefix2tracker.iteritems():
+ for namePrefix, tracker in self._namePrefix2tracker.items():
if (name and (name not in namePrefix.lower())):
continue
tracker.log()
@@ -128,7 +128,7 @@ class TaskProfiler:
if name:
name = name.lower()
# flush stored task profiles
- for namePrefix, tracker in self._namePrefix2tracker.iteritems():
+ for namePrefix, tracker in self._namePrefix2tracker.items():
if (name and (name not in namePrefix.lower())):
continue
tracker.flush()
diff --git a/direct/src/task/Timer.py b/direct/src/task/Timer.py
index fb773a7c42..be7957183c 100644
--- a/direct/src/task/Timer.py
+++ b/direct/src/task/Timer.py
@@ -2,7 +2,7 @@
__all__ = ['Timer']
-import Task
+from . import Task
class Timer:
id = 0
diff --git a/direct/src/tkpanels/AnimPanel.py b/direct/src/tkpanels/AnimPanel.py
index c48320efab..8cee51e1a6 100644
--- a/direct/src/tkpanels/AnimPanel.py
+++ b/direct/src/tkpanels/AnimPanel.py
@@ -9,11 +9,15 @@ __all__ = ['AnimPanel', 'ActorControl']
# Import Tkinter, Pmw, and the floater code from this directory tree.
from direct.tkwidgets.AppShell import *
from direct.showbase.TkGlobal import *
-from tkSimpleDialog import askfloat
-from Tkinter import *
-import Pmw, string, types
+import Pmw, sys
from direct.task import Task
+if sys.version_info >= (3, 0):
+ from tkinter.simpledialog import askfloat
+else:
+ from tkSimpleDialog import askfloat
+
+
FRAMES = 0
SECONDS = 1
@@ -28,8 +32,7 @@ class AnimPanel(AppShell):
def __init__(self, aList = [], parent = None, session = None, **kw):
INITOPT = Pmw.INITOPT
- if ((type(aList) == types.ListType) or
- (type(aList) == types.TupleType)):
+ if isinstance(aList, (list, tuple)):
kw['actorList'] = aList
else:
kw['actorList'] = [aList]
@@ -201,7 +204,7 @@ class AnimPanel(AppShell):
self.actorControlList = []
for actor in self['actorList']:
anims = actor.getAnimNames()
- print "actor animnames: %s"%anims
+ print("actor animnames: %s"%anims)
topAnims = []
if 'neutral' in anims:
i = anims.index('neutral')
@@ -518,7 +521,7 @@ class ActorControl(Pmw.MegaWidget):
if (self.fps == None):
# there was probably a problem loading the
# active animation, set default anim properties
- print "unable to get animation fps, zeroing out animation info"
+ print("unable to get animation fps, zeroing out animation info")
self.fps = 24
self.duration = 0
self.maxFrame = 0
@@ -624,7 +627,7 @@ class ActorControl(Pmw.MegaWidget):
def goTo(self, t):
# Convert scale value to float
- t = string.atof(t)
+ t = float(t)
# Now convert t to seconds for offset calculations
if self.unitsVar.get() == FRAMES:
t = t / self.fps
diff --git a/direct/src/tkpanels/DirectSessionPanel.py b/direct/src/tkpanels/DirectSessionPanel.py
index 54a515895d..65a262eda3 100644
--- a/direct/src/tkpanels/DirectSessionPanel.py
+++ b/direct/src/tkpanels/DirectSessionPanel.py
@@ -5,15 +5,14 @@ __all__ = ['DirectSessionPanel']
# Import Tkinter, Pmw, and the dial code
from direct.showbase.TkGlobal import *
from direct.tkwidgets.AppShell import *
-from Tkinter import *
from panda3d.core import *
-import Pmw, string
+import Pmw
from direct.tkwidgets import Dial
from direct.tkwidgets import Floater
from direct.tkwidgets import Slider
from direct.tkwidgets import VectorWidgets
from direct.tkwidgets import SceneGraphExplorer
-from TaskManagerPanel import TaskManagerWidget
+from .TaskManagerPanel import TaskManagerWidget
from direct.tkwidgets import MemoryExplorer
"""
@@ -744,8 +743,8 @@ class DirectSessionPanel(AppShell):
color[2]/255.0)
def selectDisplayRegionNamed(self, name):
- if (string.find(name, 'Display Region ') >= 0):
- drIndex = string.atoi(name[-1:])
+ if name.find('Display Region ') >= 0:
+ drIndex = int(name[-1:])
self.activeDisplayRegion = base.direct.drList[drIndex]
else:
self.activeDisplayRegion = None
diff --git a/direct/src/tkpanels/FSMInspector.py b/direct/src/tkpanels/FSMInspector.py
index 398cd1583f..14b307b300 100644
--- a/direct/src/tkpanels/FSMInspector.py
+++ b/direct/src/tkpanels/FSMInspector.py
@@ -4,9 +4,13 @@ __all__ = ['FSMInspector', 'StateInspector']
from direct.tkwidgets.AppShell import *
from direct.showbase.TkGlobal import *
-from tkSimpleDialog import askstring
-from Tkinter import *
-import Pmw, math, operator
+import Pmw, math, operator, sys
+
+if sys.version_info >= (3, 0):
+ from tkinter.simpledialog import askstring
+else:
+ from tkSimpleDialog import askstring
+
DELTA = (5.0 / 360.) * 2.0 * math.pi
@@ -115,14 +119,14 @@ class FSMInspector(AppShell):
self._canvas.itemconfigure('labels', font = ('MS Sans Serif', size))
def setMarkerSize(self, size):
- for key in self.stateInspectorDict.keys():
+ for key in self.stateInspectorDict:
self.stateInspectorDict[key].setRadius(size)
self.drawConnections()
def drawConnections(self, event = None):
# Get rid of existing arrows
self._canvas.delete('arrow')
- for key in self.stateInspectorDict.keys():
+ for key in self.stateInspectorDict:
si = self.stateInspectorDict[key]
state = si.state
if state.getTransitions():
@@ -151,7 +155,7 @@ class FSMInspector(AppShell):
toCenter,
self.computePoint(toState.radius,
angle - DELTA))
- return newFromPt + newToPt
+ return list(newFromPt) + list(newToPt)
def computePoint(self, radius, angle):
x = radius * math.cos(angle)
@@ -236,7 +240,7 @@ class FSMInspector(AppShell):
self.setGridSize(self._gridSize)
def setGridSize(self, size):
- for key in self.stateInspectorDict.keys():
+ for key in self.stateInspectorDict:
self.stateInspectorDict[key].setGridSize(size)
def popupGridDialog(self):
@@ -253,29 +257,27 @@ class FSMInspector(AppShell):
def printLayout(self):
dict = self.stateInspectorDict
- keys = dict.keys()
- keys.sort
- print "ClassicFSM.ClassicFSM('%s', [" % self.name
+ keys = list(dict.keys())
+ keys.sort()
+ print("ClassicFSM.ClassicFSM('%s', [" % self.name)
for key in keys[:-1]:
si = dict[key]
center = si.center()
- print " State.State('%s'," % si.state.getName()
- print " %s," % si.state.getEnterFunc().__name__
- print " %s," % si.state.getExitFunc().__name__
- print " %s," % si.state.getTransitions()
- print " inspectorPos = ",
- print "[%.1f, %.1f])," % (center[0], center[1])
+ print(" State.State('%s'," % si.state.getName())
+ print(" %s," % si.state.getEnterFunc().__name__)
+ print(" %s," % si.state.getExitFunc().__name__)
+ print(" %s," % si.state.getTransitions())
+ print(" inspectorPos = [%.1f, %.1f])," % (center[0], center[1]))
for key in keys[-1:]:
si = dict[key]
center = si.center()
- print " State.State('%s'," % si.state.getName()
- print " %s," % si.state.getEnterFunc().__name__
- print " %s," % si.state.getExitFunc().__name__
- print " %s," % si.state.getTransitions()
- print " inspectorPos = ",
- print "[%.1f, %.1f])]," % (center[0], center[1])
- print " '%s'," % self.fsm.getInitialState().getName()
- print " '%s')" % self.fsm.getFinalState().getName()
+ print(" State.State('%s'," % si.state.getName())
+ print(" %s," % si.state.getEnterFunc().__name__)
+ print(" %s," % si.state.getExitFunc().__name__)
+ print(" %s," % si.state.getTransitions())
+ print(" inspectorPos = [%.1f, %.1f])]," % (center[0], center[1]))
+ print(" '%s'," % self.fsm.getInitialState().getName())
+ print(" '%s')" % self.fsm.getFinalState().getName())
def toggleBalloon(self):
if self.toggleBalloonVar.get():
@@ -434,7 +436,7 @@ class StateInspector(Pmw.MegaArchetype):
self.fsm.request(self.getName())
def inspectSubMachine(self):
- print 'inspect ' + self.tag + ' subMachine'
+ print('inspect ' + self.tag + ' subMachine')
for childFSM in self.state.getChildren():
FSMInspector(childFSM)
diff --git a/direct/src/tkpanels/Inspector.py b/direct/src/tkpanels/Inspector.py
index 47d3b4f6a6..4480332699 100644
--- a/direct/src/tkpanels/Inspector.py
+++ b/direct/src/tkpanels/Inspector.py
@@ -8,7 +8,6 @@ so that I can just type: inspect(anObject) any time."""
__all__ = ['inspect', 'inspectorFor', 'Inspector', 'ModuleInspector', 'ClassInspector', 'InstanceInspector', 'FunctionInspector', 'InstanceMethodInspector', 'CodeInspector', 'ComplexInspector', 'DictionaryInspector', 'SequenceInspector', 'SliceInspector', 'InspectorWindow']
from direct.showbase.TkGlobal import *
-from Tkinter import *
import Pmw
### public API
@@ -26,7 +25,7 @@ def inspectorFor(anObject):
if typeName in _InspectorMap:
inspectorName = _InspectorMap[typeName]
else:
- print("Can't find an inspector for " + typeName)
+ print(("Can't find an inspector for " + typeName))
inspectorName = 'Inspector'
inspector = globals()[inspectorName](anObject)
return inspector
@@ -147,7 +146,7 @@ class ModuleInspector(Inspector):
class ClassInspector(Inspector):
def namedParts(self):
- return ['__bases__'] + self.object.__dict__.keys()
+ return ['__bases__'] + list(self.object.__dict__.keys())
def title(self):
return self.object.__name__ + ' Class'
@@ -166,7 +165,7 @@ class FunctionInspector(Inspector):
class InstanceMethodInspector(Inspector):
def title(self):
- return str(self.object.im_class) + "." + self.object.__name__ + "()"
+ return str(self.object.__self__.__class__) + "." + self.object.__name__ + "()"
class CodeInspector(Inspector):
def title(self):
@@ -184,7 +183,7 @@ class DictionaryInspector(Inspector):
def initializePartsList(self):
Inspector.initializePartsList(self)
- keys = self.object.keys()
+ keys = list(self.object.keys())
keys.sort()
for each in keys:
self._partsList.append(each)
@@ -391,10 +390,10 @@ class InspectorWindow:
#Private
def selectedIndex(self):
- indicies = map(int, self.listWidget.curselection())
- if len(indicies) == 0:
+ indices = list(map(int, self.listWidget.curselection()))
+ if len(indices) == 0:
return None
- partNumber = indicies[0]
+ partNumber = indices[0]
return partNumber
def inspectorForSelectedPart(self):
@@ -422,7 +421,7 @@ class InspectorWindow:
('Place', NodePath.place),
('Set Color', NodePath.rgbPanel)])
elif isinstance(part, ClassicFSM.ClassicFSM):
- import FSMInspector
+ from . import FSMInspector
popupMenu = self.createPopupMenu(
part,
[('Inspect ClassicFSM', FSMInspector.FSMInspector)])
diff --git a/direct/src/tkpanels/MopathRecorder.py b/direct/src/tkpanels/MopathRecorder.py
index 3e7bc3e0c5..e829ce233f 100644
--- a/direct/src/tkpanels/MopathRecorder.py
+++ b/direct/src/tkpanels/MopathRecorder.py
@@ -11,15 +11,18 @@ from direct.directtools.DirectGlobals import *
from direct.directtools.DirectUtil import *
from direct.directtools.DirectGeometry import *
from direct.directtools.DirectSelection import *
-from tkFileDialog import *
-from Tkinter import *
-import Pmw, os, string
+import Pmw, os, sys
from direct.tkwidgets import Dial
from direct.tkwidgets import Floater
from direct.tkwidgets import Slider
from direct.tkwidgets import EntryScale
from direct.tkwidgets import VectorWidgets
-import __builtin__
+
+if sys.version_info >= (3, 0):
+ from tkinter.filedialog import *
+else:
+ from tkFileDialog import *
+
PRF_UTILITIES = [
'lambda: base.direct.camera.lookAt(render)',
@@ -347,7 +350,7 @@ class MopathRecorder(AppShell, DirectObject):
self.speedEntry.bind(
'',
lambda e = None, s = self: s.setSpeedScale(
- string.atof(s.speedVar.get())))
+ float(s.speedVar.get())))
self.speedEntry.pack(side = LEFT, expand = 0)
frame.pack(fill = X, expand = 1)
@@ -662,7 +665,7 @@ class MopathRecorder(AppShell, DirectObject):
marker if subnode selected
"""
taskMgr.remove(self.name + '-curveEditTask')
- print nodePath.id()
+ print(nodePath.getKey())
if nodePath.id() in self.playbackMarkerIds:
base.direct.select(self.playbackMarker)
elif nodePath.id() in self.tangentMarkerIds:
@@ -1105,7 +1108,7 @@ class MopathRecorder(AppShell, DirectObject):
def computeCurves(self):
# Check to make sure curve fitters have points
if (self.curveFitter.getNumSamples() == 0):
- print 'MopathRecorder.computeCurves: Must define curve first'
+ print('MopathRecorder.computeCurves: Must define curve first')
return
# Create curves
# XYZ
@@ -1351,7 +1354,7 @@ class MopathRecorder(AppShell, DirectObject):
def desampleCurve(self):
if (self.curveFitter.getNumSamples() == 0):
- print 'MopathRecorder.desampleCurve: Must define curve first'
+ print('MopathRecorder.desampleCurve: Must define curve first')
return
# NOTE: This is destructive, points will be deleted from curve fitter
self.curveFitter.desample(self.desampleFrequency)
@@ -1365,7 +1368,7 @@ class MopathRecorder(AppShell, DirectObject):
def sampleCurve(self, fCompute = 1):
if self.curveCollection == None:
- print 'MopathRecorder.sampleCurve: Must define curve first'
+ print('MopathRecorder.sampleCurve: Must define curve first')
return
# Reset curve fitters
self.curveFitter.reset()
@@ -1580,7 +1583,7 @@ class MopathRecorder(AppShell, DirectObject):
def cropCurve(self):
if self.pointSet == None:
- print 'Empty Point Set'
+ print('Empty Point Set')
return
# Keep handle on old points
oldPoints = self.pointSet
@@ -1623,8 +1626,8 @@ class MopathRecorder(AppShell, DirectObject):
else:
path = '.'
if not os.path.isdir(path):
- print 'MopathRecorder Info: Empty Model Path!'
- print 'Using current directory'
+ print('MopathRecorder Info: Empty Model Path!')
+ print('Using current directory')
path = '.'
mopathFilename = askopenfilename(
defaultextension = '.egg',
@@ -1662,8 +1665,8 @@ class MopathRecorder(AppShell, DirectObject):
else:
path = '.'
if not os.path.isdir(path):
- print 'MopathRecorder Info: Empty Model Path!'
- print 'Using current directory'
+ print('MopathRecorder Info: Empty Model Path!')
+ print('Using current directory')
path = '.'
mopathFilename = asksaveasfilename(
defaultextension = '.egg',
@@ -1760,7 +1763,7 @@ class MopathRecorder(AppShell, DirectObject):
kw['min'] = min
kw['maxVelocity'] = maxVelocity
kw['resolution'] = resolution
- widget = apply(Floater.Floater, (parent,), kw)
+ widget = Floater.Floater(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1771,7 +1774,7 @@ class MopathRecorder(AppShell, DirectObject):
def createAngleDial(self, parent, category, text, balloonHelp,
command = None, **kw):
kw['text'] = text
- widget = apply(Dial.AngleDial, (parent,), kw)
+ widget = Dial.AngleDial(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1789,7 +1792,7 @@ class MopathRecorder(AppShell, DirectObject):
kw['resolution'] = resolution
#widget = apply(EntryScale.EntryScale, (parent,), kw)
from direct.tkwidgets import Slider
- widget = apply(Slider.Slider, (parent,), kw)
+ widget = Slider.Slider(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(side = side, fill = fill, expand = expand)
@@ -1805,7 +1808,7 @@ class MopathRecorder(AppShell, DirectObject):
kw['min'] = min
kw['max'] = max
kw['resolution'] = resolution
- widget = apply(EntryScale.EntryScale, (parent,), kw)
+ widget = EntryScale.EntryScale(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(side = side, fill = fill, expand = expand)
@@ -1817,7 +1820,7 @@ class MopathRecorder(AppShell, DirectObject):
command = None, **kw):
# Set label's text
kw['text'] = text
- widget = apply(VectorWidgets.Vector2Entry, (parent,), kw)
+ widget = VectorWidgets.Vector2Entry(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1829,7 +1832,7 @@ class MopathRecorder(AppShell, DirectObject):
command = None, **kw):
# Set label's text
kw['text'] = text
- widget = apply(VectorWidgets.Vector3Entry, (parent,), kw)
+ widget = VectorWidgets.Vector3Entry(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1841,7 +1844,7 @@ class MopathRecorder(AppShell, DirectObject):
command = None, **kw):
# Set label's text
kw['text'] = text
- widget = apply(VectorWidgets.ColorEntry, (parent,), kw)
+ widget = VectorWidgets.ColorEntry(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1913,4 +1916,3 @@ class MopathRecorder(AppShell, DirectObject):
self.cCam = self.cCamera.attachNewNode(self.cCamNode)
self.cDr.setCamera(self.cCam)
-
diff --git a/direct/src/tkpanels/NotifyPanel.py b/direct/src/tkpanels/NotifyPanel.py
index f1b8a0720b..9712903f7a 100644
--- a/direct/src/tkpanels/NotifyPanel.py
+++ b/direct/src/tkpanels/NotifyPanel.py
@@ -131,7 +131,7 @@ class NotifyPanel:
def _getPandaCategoriesAsList(self, pc, list):
import types
for item in pc:
- if type(item) == types.ListType:
+ if type(item) == list:
self._getPandaCategoriesAsList(item, list)
else:
list.append(item)
diff --git a/direct/src/tkpanels/ParticlePanel.py b/direct/src/tkpanels/ParticlePanel.py
index f07e9c4102..b712d7c7fb 100644
--- a/direct/src/tkpanels/ParticlePanel.py
+++ b/direct/src/tkpanels/ParticlePanel.py
@@ -5,8 +5,6 @@ __all__ = ['ParticlePanel']
# Import Tkinter, Pmw, and the floater code from this directory tree.
from direct.tkwidgets.AppShell import *
from direct.showbase.TkGlobal import *
-from tkFileDialog import *
-from tkSimpleDialog import askstring
from direct.tkwidgets import Dial
from direct.tkwidgets import Floater
from direct.tkwidgets import Slider
@@ -15,8 +13,14 @@ from direct.tkpanels import Placer
from direct.particles import ForceGroup
from direct.particles import Particles
from direct.particles import ParticleEffect
-from Tkinter import *
-import Pmw, os
+import Pmw, os, sys
+
+if sys.version_info >= (3, 0):
+ from tkinter.filedialog import *
+ from tkinter.simpledialog import askstring
+else:
+ from tkFileDialog import *
+ from tkSimpleDialog import askstring
from panda3d.core import *
from panda3d.physics import *
@@ -67,7 +71,7 @@ class ParticlePanel(AppShell):
self.initialiseoptions(ParticlePanel)
# Update panel values to reflect particle effect's state
- self.selectEffectNamed(self.effectsDict.keys()[0])
+ self.selectEffectNamed(next(iter(self.effectsDict)))
# Make sure labels/menus reflect current state
self.updateMenusAndLabels()
# Make sure there is a page for each forceGroup objects
@@ -976,7 +980,7 @@ class ParticlePanel(AppShell):
kw['min'] = min
kw['resolution'] = resolution
kw['numDigits'] = numDigits
- widget = apply(Floater.Floater, (parent,), kw)
+ widget = Floater.Floater(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -988,7 +992,7 @@ class ParticlePanel(AppShell):
command = None, **kw):
kw['text'] = text
kw['style'] = 'mini'
- widget = apply(Dial.AngleDial, (parent,), kw)
+ widget = Dial.AngleDial(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1003,7 +1007,7 @@ class ParticlePanel(AppShell):
kw['min'] = min
kw['max'] = max
kw['resolution'] = resolution
- widget = apply(Slider.Slider, (parent,), kw)
+ widget = Slider.Slider(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1015,7 +1019,7 @@ class ParticlePanel(AppShell):
command = None, **kw):
# Set label's text
kw['text'] = text
- widget = apply(VectorWidgets.Vector2Entry, (parent,), kw)
+ widget = VectorWidgets.Vector2Entry(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1027,7 +1031,7 @@ class ParticlePanel(AppShell):
command = None, **kw):
# Set label's text
kw['text'] = text
- widget = apply(VectorWidgets.Vector3Entry, (parent,), kw)
+ widget = VectorWidgets.Vector3Entry(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1039,7 +1043,7 @@ class ParticlePanel(AppShell):
command = None, **kw):
# Set label's text
kw['text'] = text
- widget = apply(VectorWidgets.ColorEntry, (parent,), kw)
+ widget = VectorWidgets.ColorEntry(parent, **kw)
# Do this after the widget so command isn't called on creation
widget['command'] = command
widget.pack(fill = X)
@@ -1111,8 +1115,7 @@ class ParticlePanel(AppShell):
self.effectsLabelMenu.delete(5, 'end')
self.effectsLabelMenu.add_separator()
# Add in a checkbutton for each effect (to toggle on/off)
- keys = self.effectsDict.keys()
- keys.sort()
+ keys = sorted(self.effectsDict.keys())
for name in keys:
effect = self.effectsDict[name]
self.effectsLabelMenu.add_command(
@@ -1194,7 +1197,7 @@ class ParticlePanel(AppShell):
self.mainNotebook.selectpage('System')
self.updateInfo('System')
else:
- print 'ParticlePanel: No effect named ' + name
+ print('ParticlePanel: No effect named ' + name)
def toggleEffect(self, effect, var):
if var.get():
@@ -1250,8 +1253,8 @@ class ParticlePanel(AppShell):
else:
path = '.'
if not os.path.isdir(path):
- print 'ParticlePanel Warning: Invalid default DNA directory!'
- print 'Using current directory'
+ print('ParticlePanel Warning: Invalid default DNA directory!')
+ print('Using current directory')
path = '.'
particleFilename = askopenfilename(
defaultextension = '.ptf',
@@ -1278,8 +1281,8 @@ class ParticlePanel(AppShell):
else:
path = '.'
if not os.path.isdir(path):
- print 'ParticlePanel Warning: Invalid default DNA directory!'
- print 'Using current directory'
+ print('ParticlePanel Warning: Invalid default DNA directory!')
+ print('Using current directory')
path = '.'
particleFilename = asksaveasfilename(
defaultextension = '.ptf',
diff --git a/direct/src/tkpanels/Placer.py b/direct/src/tkpanels/Placer.py
index 9b52343bf7..8cda08310b 100644
--- a/direct/src/tkpanels/Placer.py
+++ b/direct/src/tkpanels/Placer.py
@@ -9,7 +9,6 @@ from direct.tkwidgets.AppShell import *
from direct.tkwidgets import Dial
from direct.tkwidgets import Floater
from direct.directtools.DirectGlobals import ZERO_VEC, UNIT_VEC
-from Tkinter import *
import Pmw
"""
@@ -770,12 +769,12 @@ class Placer(AppShell):
posString = '%.2f, %.2f, %.2f' % (pos[0], pos[1], pos[2])
hprString = '%.2f, %.2f, %.2f' % (hpr[0], hpr[1], hpr[2])
scaleString = '%.2f, %.2f, %.2f' % (scale[0], scale[1], scale[2])
- print 'NodePath: %s' % name
- print 'Pos: %s' % posString
- print 'Hpr: %s' % hprString
- print 'Scale: %s' % scaleString
- print ('%s.setPosHprScale(%s, %s, %s)' %
- (name, posString, hprString, scaleString))
+ print('NodePath: %s' % name)
+ print('Pos: %s' % posString)
+ print('Hpr: %s' % hprString)
+ print('Scale: %s' % scaleString)
+ print(('%s.setPosHprScale(%s, %s, %s)' %
+ (name, posString, hprString, scaleString)))
def onDestroy(self, event):
# Remove hooks
diff --git a/direct/src/tkpanels/TaskManagerPanel.py b/direct/src/tkpanels/TaskManagerPanel.py
index 8030f06c2a..1283044b59 100644
--- a/direct/src/tkpanels/TaskManagerPanel.py
+++ b/direct/src/tkpanels/TaskManagerPanel.py
@@ -3,9 +3,16 @@
__all__ = ['TaskManagerPanel', 'TaskManagerWidget']
from direct.tkwidgets.AppShell import *
-from Tkinter import *
from direct.showbase.DirectObject import DirectObject
-import Pmw
+import Pmw, sys
+
+if sys.version_info >= (3, 0):
+ from tkinter import *
+ from tkinter.messagebox import askokcancel
+else:
+ from Tkinter import *
+ from tkMessageBox import askokcancel
+
class TaskManagerPanel(AppShell):
# Override class variables here
@@ -188,7 +195,6 @@ class TaskManagerWidget(DirectObject):
(name == 'tkLoop') or
(name == 'eventManager') or
(name == 'igLoop')):
- from tkMessageBox import askokcancel
ok = askokcancel('TaskManagerControls',
'Remove: %s?' % name,
parent = self.parent,
@@ -205,7 +211,6 @@ class TaskManagerWidget(DirectObject):
(name == 'tkLoop') or
(name == 'eventManager') or
(name == 'igLoop')):
- from tkMessageBox import askokcancel
ok = askokcancel('TaskManagerControls',
'Remove tasks named: %s?' % name,
parent = self.parent,
diff --git a/direct/src/tkwidgets/AppShell.py b/direct/src/tkwidgets/AppShell.py
index 67a7e6b794..6c5d930976 100644
--- a/direct/src/tkwidgets/AppShell.py
+++ b/direct/src/tkwidgets/AppShell.py
@@ -9,15 +9,19 @@ __all__ = ['AppShell']
from direct.showbase.DirectObject import DirectObject
from direct.showbase.TkGlobal import *
-from tkFileDialog import *
-from Tkinter import *
-import Pmw
-import Dial
-import Floater
-import Slider
-import EntryScale
-import VectorWidgets
-import ProgressBar
+import Pmw, sys
+from . import Dial
+from . import Floater
+from . import Slider
+from . import EntryScale
+from . import VectorWidgets
+from . import ProgressBar
+
+if sys.version_info >= (3, 0):
+ from tkinter.filedialog import *
+else:
+ from tkFileDialog import *
+
"""
TO FIX:
@@ -318,7 +322,7 @@ class AppShell(Pmw.MegaWidget, DirectObject):
# Update kw to reflect user inputs
kw['text'] = text
# Create widget
- widget = apply(widgetClass, (parent,), kw)
+ widget = widgetClass(parent, **kw)
# Do this after so command isn't called on widget creation
widget['command'] = command
# Pack widget
@@ -475,7 +479,7 @@ class AppShell(Pmw.MegaWidget, DirectObject):
kw['menu_tearoff'] = menu_tearoff
kw['menubutton_textvariable'] = variable
# Create widget
- widget = apply(Pmw.OptionMenu, (parent,), kw)
+ widget = Pmw.OptionMenu(parent, **kw)
# Do this after so command isn't called on widget creation
widget['command'] = command
# Pack widget
@@ -502,7 +506,7 @@ class AppShell(Pmw.MegaWidget, DirectObject):
kw['scrolledlist_items'] = items
kw['entryfield_entry_state'] = state
# Create widget
- widget = apply(Pmw.ComboBox, (parent,), kw)
+ widget = Pmw.ComboBox(parent, **kw)
# Bind selection command
widget['selectioncommand'] = command
# Select first item if it exists
diff --git a/direct/src/tkwidgets/Dial.py b/direct/src/tkwidgets/Dial.py
index 13a3cc8472..5b10cdb95a 100644
--- a/direct/src/tkwidgets/Dial.py
+++ b/direct/src/tkwidgets/Dial.py
@@ -6,10 +6,9 @@ Dial Class: Velocity style controller for floating point values with
__all__ = ['Dial', 'AngleDial', 'DialWidget']
from direct.showbase.TkGlobal import *
-from Tkinter import *
-from Valuator import Valuator, VALUATOR_MINI, VALUATOR_FULL
+from .Valuator import Valuator, VALUATOR_MINI, VALUATOR_FULL
from direct.task import Task
-import math, string, operator, Pmw
+import math, operator, Pmw
TWO_PI = 2.0 * math.pi
ONEPOINTFIVE_PI = 1.5 * math.pi
@@ -258,7 +257,7 @@ class DialWidget(Pmw.MegaWidget):
value = self['base'] + ((value - self['base']) % self['delta'])
# Send command if any
if fCommand and (self['command'] != None):
- apply(self['command'], [value] + self['commandData'])
+ self['command'](*[value] + self['commandData'])
# Record value
self.value = value
@@ -411,12 +410,12 @@ class DialWidget(Pmw.MegaWidget):
def _onButtonPress(self, *args):
""" User redefinable callback executed on button press """
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
def _onButtonRelease(self, *args):
""" User redefinable callback executed on button release """
if self['postCallback']:
- apply(self['postCallback'], self['callbackData'])
+ self['postCallback'](*self['callbackData'])
if __name__ == '__main__':
diff --git a/direct/src/tkwidgets/EntryScale.py b/direct/src/tkwidgets/EntryScale.py
index e4c8a96a60..c9685fcf6c 100644
--- a/direct/src/tkwidgets/EntryScale.py
+++ b/direct/src/tkwidgets/EntryScale.py
@@ -5,10 +5,14 @@ EntryScale Class: Scale with a label, and a linked and validated entry
__all__ = ['EntryScale', 'EntryScaleGroup']
from direct.showbase.TkGlobal import *
-from Tkinter import *
-import string, Pmw
-import tkColorChooser
-from tkSimpleDialog import *
+import Pmw, sys
+
+if sys.version_info >= (3, 0):
+ from tkinter.simpledialog import *
+ from tkinter.colorchooser import askcolor
+else:
+ from tkSimpleDialog import *
+ from tkColorChooser import askcolor
"""
Change Min/Max buttons to labels, add highlight binding
@@ -204,7 +208,7 @@ class EntryScale(Pmw.MegaWidget):
if not self.fScaleCommand:
return
# convert scale val to float
- self.set(string.atof(strVal))
+ self.set(float(strVal))
"""
# Update entry to reflect formatted value
self.entryValue.set(self.entryFormat % self.value)
@@ -215,10 +219,10 @@ class EntryScale(Pmw.MegaWidget):
def _entryCommand(self, event = None):
try:
- val = string.atof(self.entryValue.get())
- apply(self.onReturn, self['callbackData'])
+ val = float(self.entryValue.get())
+ self.onReturn(*self['callbackData'])
self.set(val)
- apply(self.onReturnRelease, self['callbackData'])
+ self.onReturnRelease(*self['callbackData'])
except ValueError:
pass
@@ -266,7 +270,7 @@ class EntryScale(Pmw.MegaWidget):
def __onPress(self, event):
# First execute onpress callback
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
# Now enable slider command
self.fScaleCommand = 1
@@ -279,7 +283,7 @@ class EntryScale(Pmw.MegaWidget):
self.fScaleCommand = 0
# First execute onpress callback
if self['postCallback']:
- apply(self['postCallback'], self['callbackData'])
+ self['postCallback'](*self['callbackData'])
def onRelease(self, *args):
""" User redefinable callback executed on button release """
@@ -417,7 +421,7 @@ class EntryScaleGroup(Pmw.MegaToplevel):
def __onReturn(self, esg):
# Execute onReturn callback
- apply(self.onReturn, esg.get())
+ self.onReturn(*esg.get())
def onReturn(self, *args):
""" User redefinable callback executed on button press """
@@ -425,7 +429,7 @@ class EntryScaleGroup(Pmw.MegaToplevel):
def __onReturnRelease(self, esg):
# Execute onReturnRelease callback
- apply(self.onReturnRelease, esg.get())
+ self.onReturnRelease(*esg.get())
def onReturnRelease(self, *args):
""" User redefinable callback executed on button press """
@@ -434,7 +438,7 @@ class EntryScaleGroup(Pmw.MegaToplevel):
def __onPress(self, esg):
# Execute onPress callback
if self['preCallback']:
- apply(self['preCallback'], esg.get())
+ self['preCallback'](*esg.get())
def onPress(self, *args):
""" User redefinable callback executed on button press """
@@ -443,7 +447,7 @@ class EntryScaleGroup(Pmw.MegaToplevel):
def __onRelease(self, esg):
# Execute onRelease callback
if self['postCallback']:
- apply(self['postCallback'], esg.get())
+ self['postCallback'](*esg.get())
def onRelease(self, *args):
""" User redefinable callback executed on button release """
@@ -492,7 +496,7 @@ def rgbPanel(nodePath, callback = None):
# System color picker
def popupColorPicker(esg = esg):
# Can pass in current color with: color = (255, 0, 0)
- color = tkColorChooser.askcolor(
+ color = askcolor(
parent = esg.interior(),
# Initialize it to current color
initialcolor = tuple(esg.get()[:3]))[0]
@@ -502,7 +506,7 @@ def rgbPanel(nodePath, callback = None):
command = popupColorPicker)
def printToLog(nodePath=nodePath):
c=nodePath.getColor()
- print "Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3])
+ print("Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3]))
menu.insert_command(index = 5, label = 'Print to log',
command = printToLog)
@@ -520,7 +524,7 @@ if __name__ == '__main__':
# Dummy command
def printVal(val):
- print val
+ print(val)
# Create and pack a EntryScale megawidget.
mega1 = EntryScale(root, command = printVal)
diff --git a/direct/src/tkwidgets/Floater.py b/direct/src/tkwidgets/Floater.py
index 655b7728be..d8a1b83534 100644
--- a/direct/src/tkwidgets/Floater.py
+++ b/direct/src/tkwidgets/Floater.py
@@ -6,8 +6,7 @@ Floater Class: Velocity style controller for floating point values with
__all__ = ['Floater', 'FloaterWidget', 'FloaterGroup']
from direct.showbase.TkGlobal import *
-from Tkinter import *
-from Valuator import Valuator, VALUATOR_MINI, VALUATOR_FULL
+from .Valuator import Valuator, VALUATOR_MINI, VALUATOR_FULL
from direct.task import Task
import math, Pmw
@@ -123,7 +122,7 @@ class FloaterWidget(Pmw.MegaWidget):
"""
# Send command if any
if fCommand and (self['command'] != None):
- apply(self['command'], [value] + self['commandData'])
+ self['command'](*[value] + self['commandData'])
# Record value
self.value = value
@@ -145,7 +144,7 @@ class FloaterWidget(Pmw.MegaWidget):
# Exectute user redefinable callback function (if any)
self['relief'] = SUNKEN
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
self.velocitySF = 0.0
self.updateTask = taskMgr.add(self.updateFloaterTask,
'updateFloater')
@@ -183,7 +182,7 @@ class FloaterWidget(Pmw.MegaWidget):
self.velocitySF = 0.0
# Execute user redefinable callback function (if any)
if self['postCallback']:
- apply(self['postCallback'], self['callbackData'])
+ self['postCallback'](*self['callbackData'])
self['relief'] = RAISED
def setNumDigits(self):
@@ -336,7 +335,7 @@ if __name__ == '__main__':
# Dummy command
def printVal(val):
- print val
+ print(val)
# Create and pack a Floater megawidget.
mega1 = Floater(root, command = printVal)
diff --git a/direct/src/tkwidgets/MemoryExplorer.py b/direct/src/tkwidgets/MemoryExplorer.py
index 325e95b74d..62e74a6202 100755
--- a/direct/src/tkwidgets/MemoryExplorer.py
+++ b/direct/src/tkwidgets/MemoryExplorer.py
@@ -1,7 +1,6 @@
from direct.showbase.DirectObject import DirectObject
from direct.showbase.TkGlobal import *
-from Tkinter import *
-from Tree import *
+from .Tree import *
import Pmw
#--------------------------------------------------------------------------
diff --git a/direct/src/tkwidgets/ProgressBar.py b/direct/src/tkwidgets/ProgressBar.py
index d9ed5d3824..81b1d480b3 100644
--- a/direct/src/tkwidgets/ProgressBar.py
+++ b/direct/src/tkwidgets/ProgressBar.py
@@ -5,7 +5,7 @@ A basic widget for showing the progress being made in a task.
__all__ = ['ProgressBar']
from direct.showbase.TkGlobal import *
-from Tkinter import *
+
class ProgressBar:
def __init__(self, master=None, orientation="horizontal",
diff --git a/direct/src/tkwidgets/SceneGraphExplorer.py b/direct/src/tkwidgets/SceneGraphExplorer.py
index 2c5c965056..7e39dbeac1 100644
--- a/direct/src/tkwidgets/SceneGraphExplorer.py
+++ b/direct/src/tkwidgets/SceneGraphExplorer.py
@@ -4,8 +4,7 @@ __all__ = ['SceneGraphExplorer', 'SceneGraphExplorerItem', 'explore']
from direct.showbase.DirectObject import DirectObject
from direct.showbase.TkGlobal import *
-from Tkinter import *
-from Tree import *
+from .Tree import *
import Pmw
# changing these strings requires changing DirectSession.py SGE_ strs too!
diff --git a/direct/src/tkwidgets/Slider.py b/direct/src/tkwidgets/Slider.py
index f2d9bb1246..ceb36287d3 100644
--- a/direct/src/tkwidgets/Slider.py
+++ b/direct/src/tkwidgets/Slider.py
@@ -6,9 +6,7 @@ Slider Class: Velocity style controller for floating point values with
__all__ = ['Slider', 'SliderWidget', 'rgbPanel']
from direct.showbase.TkGlobal import *
-from Tkinter import *
-from Valuator import Valuator, rgbPanel, VALUATOR_MINI, VALUATOR_FULL
-import string
+from .Valuator import Valuator, rgbPanel, VALUATOR_MINI, VALUATOR_FULL
import Pmw
class Slider(Valuator):
@@ -282,7 +280,7 @@ class SliderWidget(Pmw.MegaWidget):
"""
# Send command if any
if fCommand and (self['command'] != None):
- apply(self['command'], [value] + self['commandData'])
+ self['command'](*[value] + self['commandData'])
# Record value
self.value = value
@@ -322,11 +320,11 @@ class SliderWidget(Pmw.MegaWidget):
# Find screen space position of bottom/center of arrow button
x = (self._arrowBtn.winfo_rootx() + self._arrowBtn.winfo_width()/2.0 -
self.interior()['bd'])
-# string.atoi(self.interior()['bd']))
+# int(self.interior()['bd']))
y = self._arrowBtn.winfo_rooty() + self._arrowBtn.winfo_height()
# Popup border width
bd = self._popup['bd']
-# bd = string.atoi(self._popup['bd'])
+# bd = int(self._popup['bd'])
# Get width of label
minW = self._minLabel.winfo_width()
# Width of canvas to adjust for
@@ -378,7 +376,7 @@ class SliderWidget(Pmw.MegaWidget):
self._fPressInside = 1
self._fUpdate = 1
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
self._updateValue(event)
else:
self._fPressInside = 0
@@ -391,24 +389,24 @@ class SliderWidget(Pmw.MegaWidget):
if canvasY > 0:
self._fUpdate = 1
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
self._unpostOnNextRelease()
elif self._fUpdate:
self._updateValue(event)
def _scaleBtnPress(self, event):
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
def _scaleBtnRelease(self, event):
# Do post callback if any
if self['postCallback']:
- apply(self['postCallback'], self['callbackData'])
+ self['postCallback'](*self['callbackData'])
def _widgetBtnRelease(self, event):
# Do post callback if any
if self._fUpdate and self['postCallback']:
- apply(self['postCallback'], self['callbackData'])
+ self['postCallback'](*self['callbackData'])
if (self._fUnpost or
(not (self._firstPress or self._fPressInside))):
self._unpostSlider()
@@ -460,7 +458,7 @@ class SliderWidget(Pmw.MegaWidget):
self._widget['command'] = self._scaleCommand
def _scaleCommand(self, val):
- self.set(string.atof(val))
+ self.set(float(val))
# Methods to modify floater characteristics
def setMin(self):
diff --git a/direct/src/tkwidgets/Tree.py b/direct/src/tkwidgets/Tree.py
index 7e864aaad3..e3e49b925f 100644
--- a/direct/src/tkwidgets/Tree.py
+++ b/direct/src/tkwidgets/Tree.py
@@ -21,13 +21,12 @@ __all__ = ['TreeNode', 'TreeItem']
import os
from direct.showbase.TkGlobal import *
-from Tkinter import *
from panda3d.core import *
# Initialize icon directory
ICONDIR = ConfigVariableSearchPath('model-path').findFile(Filename('icons')).toOsSpecific()
if not os.path.isdir(ICONDIR):
- raise RuntimeError, "can't find DIRECT icon directory (%s)" % repr(ICONDIR)
+ raise RuntimeError("can't find DIRECT icon directory (%s)" % repr(ICONDIR))
class TreeNode:
@@ -233,7 +232,7 @@ class TreeNode:
self.kidKeys.append(key)
# Remove unused children
- for key in self.children.keys():
+ for key in list(self.children.keys()):
if key not in self.kidKeys:
del(self.children[key])
@@ -304,14 +303,14 @@ class TreeNode:
if self.fModeChildrenTag:
if self.childrenTag:
showThisItem = False
- for tagKey in self.childrenTag.keys():
+ for tagKey in list(self.childrenTag.keys()):
if item.nodePath.hasTag(tagKey):
showThisItem = self.childrenTag[tagKey]
if not showThisItem:
self.kidKeys.remove(key)
# Remove unused children
- for key in self.children.keys():
+ for key in list(self.children.keys()):
if key not in self.kidKeys:
del(self.children[key])
cx = x+20
@@ -437,7 +436,7 @@ class TreeNode:
if self.fModeChildrenTag:
if self.childrenTag:
showThisItem = False
- for tagKey in self.childrenTag.keys():
+ for tagKey in list(self.childrenTag.keys()):
if self.item.nodePath.hasTag(tagKey):
showThisItem = self.childrenTag[tagKey]
if not showThisItem:
diff --git a/direct/src/tkwidgets/Valuator.py b/direct/src/tkwidgets/Valuator.py
index 652640a8cf..8b88d98680 100644
--- a/direct/src/tkwidgets/Valuator.py
+++ b/direct/src/tkwidgets/Valuator.py
@@ -4,12 +4,15 @@ __all__ = ['Valuator', 'ValuatorGroup', 'ValuatorGroupPanel']
from direct.showbase.DirectObject import *
from direct.showbase.TkGlobal import *
-from Tkinter import *
-import tkColorChooser
-import WidgetPropertiesDialog
-import string, Pmw
+from . import WidgetPropertiesDialog
+import Pmw
from direct.directtools.DirectUtil import getTkColorString
+if sys.version_info >= (3, 0):
+ from tkinter.colorchooser import askcolor
+else:
+ from tkColorChooser import askcolor
+
VALUATOR_MINI = 'mini'
VALUATOR_FULL = 'full'
@@ -204,7 +207,7 @@ class Valuator(Pmw.MegaWidget):
self._valuator.updateIndicator(value)
# Execute command if required
if fCommand and self.fInit and (self['command'] is not None):
- apply(self['command'], [value] + self['commandData'])
+ self['command'](*[value] + self['commandData'])
# Record adjusted value
self.adjustedValue = value
# Once initialization is finished, allow commands to execute
@@ -228,7 +231,7 @@ class Valuator(Pmw.MegaWidget):
# Reset background
self._entry.configure(background = self._entryBackground)
# Get new value and check validity
- newValue = string.atof(input)
+ newValue = float(input)
# If OK, execute preCallback if one defined
self._preCallback()
# Call set to update valuator
@@ -259,12 +262,12 @@ class Valuator(Pmw.MegaWidget):
# Callback functions
def _preCallback(self):
if self['preCallback']:
- apply(self['preCallback'], self['callbackData'])
+ self['preCallback'](*self['callbackData'])
def _postCallback(self):
# Exectute post callback if one defined
if self['postCallback']:
- apply(self['postCallback'], self['callbackData'])
+ self['postCallback'](*self['callbackData'])
def setState(self):
""" Enable/disable widget """
@@ -391,16 +394,16 @@ class ValuatorGroup(Pmw.MegaWidget):
# Add a group alias so you can configure the valuators via:
# fg.configure(Valuator_XXX = YYY)
if self['type'] == DIAL:
- import Dial
+ from . import Dial
valuatorType = Dial.Dial
elif self['type'] == ANGLEDIAL:
- import Dial
+ from . import Dial
valuatorType = Dial.AngleDial
elif self['type'] == SLIDER:
- import Slider
+ from . import Slider
valuatorType = Slider.Slider
else:
- import Floater
+ from . import Floater
valuatorType = Floater.Floater
f = self.createcomponent(
'valuator%d' % index, (), 'valuator', valuatorType,
@@ -459,12 +462,12 @@ class ValuatorGroup(Pmw.MegaWidget):
def _preCallback(self, valGroup):
# Execute pre callback
if self['preCallback']:
- apply(self['preCallback'], valGroup.get())
+ self['preCallback'](*valGroup.get())
def _postCallback(self, valGroup):
# Execute post callback
if self['postCallback']:
- apply(self['postCallback'], valGroup.get())
+ self['postCallback'](*valGroup.get())
def __len__(self):
return self['dim']
@@ -607,7 +610,7 @@ def rgbPanel(nodePath, callback = None, style = 'mini'):
def popupColorPicker():
# Can pass in current color with: color = (255, 0, 0)
- color = tkColorChooser.askcolor(
+ color = askcolor(
parent = vgp.interior(),
# Initialize it to current color
initialcolor = tuple(vgp.get()[:3]))[0]
@@ -616,7 +619,7 @@ def rgbPanel(nodePath, callback = None, style = 'mini'):
def printToLog():
c=nodePath.getColor()
- print "Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3])
+ print("Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3]))
# Check init color
if nodePath.hasColor():
@@ -689,7 +692,7 @@ def lightRGBPanel(light, style = 'mini'):
# Color picker for lights
def popupColorPicker():
# Can pass in current color with: color = (255, 0, 0)
- color = tkColorChooser.askcolor(
+ color = askcolor(
parent = vgp.interior(),
# Initialize it to current color
initialcolor = tuple(vgp.get()[:3]))[0]
@@ -698,8 +701,8 @@ def lightRGBPanel(light, style = 'mini'):
def printToLog():
n = light.getName()
c=light.getColor()
- print n + (".setColor(Vec4(%.3f, %.3f, %.3f, %.3f))" %
- (c[0], c[1], c[2], c[3]))
+ print(n + (".setColor(Vec4(%.3f, %.3f, %.3f, %.3f))" %
+ (c[0], c[1], c[2], c[3])))
# Check init color
initColor = light.getColor() * 255.0
# Create entry scale group
diff --git a/direct/src/tkwidgets/VectorWidgets.py b/direct/src/tkwidgets/VectorWidgets.py
index 8fa64d31d9..1edfa951dd 100644
--- a/direct/src/tkwidgets/VectorWidgets.py
+++ b/direct/src/tkwidgets/VectorWidgets.py
@@ -3,14 +3,15 @@
__all__ = ['VectorEntry', 'Vector2Entry', 'Vector3Entry', 'Vector4Entry', 'ColorEntry']
from direct.showbase.TkGlobal import *
-from Tkinter import *
-import Valuator
-import Floater
-import Slider
-import string
-import tkColorChooser
-import types
+from . import Valuator
import Pmw
+import sys
+
+if sys.version_info >= (3, 0):
+ from tkinter.colorchooser import askcolor
+else:
+ from tkColorChooser import askcolor
+
class VectorEntry(Pmw.MegaWidget):
def __init__(self, parent = None, **kw):
@@ -176,7 +177,7 @@ class VectorEntry(Pmw.MegaWidget):
return self._value[index]
def set(self, value, fCommand = 1):
- if type(value) in (types.FloatType, types.IntType, types.LongType):
+ if type(value) in (float, int):
value = [value] * self['dim']
for i in range(self['dim']):
self._value[i] = value[i]
@@ -192,7 +193,7 @@ class VectorEntry(Pmw.MegaWidget):
entryVar = self.variableList[index]
# Did we get a valid float?
try:
- newVal = string.atof(entryVar.get())
+ newVal = float(entryVar.get())
except ValueError:
return
@@ -330,7 +331,7 @@ class ColorEntry(VectorEntry):
def popupColorPicker(self):
# Can pass in current color with: color = (255, 0, 0)
- color = tkColorChooser.askcolor(
+ color = askcolor(
parent = self.interior(),
# Initialize it to current color
initialcolor = tuple(self.get()[:3]))[0]
diff --git a/direct/src/tkwidgets/WidgetPropertiesDialog.py b/direct/src/tkwidgets/WidgetPropertiesDialog.py
index 6418d89c0a..0693a885d1 100644
--- a/direct/src/tkwidgets/WidgetPropertiesDialog.py
+++ b/direct/src/tkwidgets/WidgetPropertiesDialog.py
@@ -3,8 +3,7 @@
__all__ = ['WidgetPropertiesDialog']
from direct.showbase.TkGlobal import *
-from Tkinter import *
-import types, string, Pmw
+import Pmw, sys
"""
TODO:
@@ -28,12 +27,16 @@ class WidgetPropertiesDialog(Toplevel):
self.propertyDict = propertyDict
self.propertyList = propertyList
if self.propertyList is None:
- self.propertyList = self.propertyDict.keys()
+ self.propertyList = list(self.propertyDict.keys())
self.propertyList.sort()
# Use default parent if none specified
if not parent:
- import Tkinter
- parent = Tkinter._default_root
+ if sys.version_info >= (3, 0):
+ import tkinter
+ parent = tkinter._default_root
+ else:
+ import Tkinter
+ parent = Tkinter._default_root
# Create toplevel window
Toplevel.__init__(self, parent)
self.transient(parent)
@@ -172,8 +175,8 @@ class WidgetPropertiesDialog(Toplevel):
box.pack()
def realOrNone(self, val):
- val = string.lower(val)
- if string.find('none', val) != -1:
+ val = val.lower()
+ if 'none'.find(val) != -1:
if val == 'none':
return Pmw.OK
else:
@@ -181,8 +184,8 @@ class WidgetPropertiesDialog(Toplevel):
return Pmw.realvalidator(val)
def intOrNone(self, val):
- val = string.lower(val)
- if string.find('none', val) != -1:
+ val = val.lower()
+ if 'none'.find(val) != -1:
if val == 'none':
return Pmw.OK
else:
@@ -204,22 +207,22 @@ class WidgetPropertiesDialog(Toplevel):
self.destroy()
def validateChanges(self):
- for property in self.modifiedDict.keys():
+ for property in self.modifiedDict:
tuple = self.modifiedDict[property]
widget = tuple[0]
entry = tuple[1]
type = tuple[2]
fNone = tuple[3]
value = entry.get()
- lValue = string.lower(value)
- if (string.find('none', lValue) != -1):
+ lValue = value.lower()
+ if 'none'.find(lValue) != -1:
if fNone and (lValue == 'none'):
widget[property] = None
else:
if type == 'real':
- value = string.atof(value)
+ value = float(value)
elif type == 'integer':
- value = string.atoi(value)
+ value = int(value)
widget[property] = value
def apply(self):
diff --git a/direct/src/wxwidgets/ViewPort.py b/direct/src/wxwidgets/ViewPort.py
index b0d03d88c9..57d7d4fc13 100755
--- a/direct/src/wxwidgets/ViewPort.py
+++ b/direct/src/wxwidgets/ViewPort.py
@@ -12,7 +12,7 @@ from direct.showbase.DirectObject import DirectObject
from direct.directtools.DirectGrid import DirectGrid
from direct.showbase.ShowBase import WindowControls
from direct.directtools.DirectGlobals import *
-from WxPandaWindow import WxPandaWindow
+from .WxPandaWindow import WxPandaWindow
from panda3d.core import OrthographicLens, Point3, Plane, CollisionPlane, CollisionNode, NodePath
import wx
@@ -171,7 +171,7 @@ class Viewport(WxPandaWindow, DirectObject):
if vpType == VPFRONT: return Viewport.makeFront(parent)
if vpType == VPTOP: return Viewport.makeTop(parent)
if vpType == VPPERSPECTIVE: return Viewport.makePerspective(parent)
- raise TypeError, "Unknown viewport type: %s" % vpType
+ raise TypeError("Unknown viewport type: %s" % vpType)
@staticmethod
def makeOrthographic(parent, name, campos):
diff --git a/direct/src/wxwidgets/WxPandaShell.py b/direct/src/wxwidgets/WxPandaShell.py
index 128eea64b4..cae5fb9332 100755
--- a/direct/src/wxwidgets/WxPandaShell.py
+++ b/direct/src/wxwidgets/WxPandaShell.py
@@ -10,8 +10,8 @@ try:
except NameError:
base = ShowBase(False, windowType = 'none')
-from WxAppShell import *
-from ViewPort import *
+from .WxAppShell import *
+from .ViewPort import *
ID_FOUR_VIEW = 401
ID_TOP_VIEW = 402
diff --git a/direct/src/wxwidgets/WxPandaStart.py b/direct/src/wxwidgets/WxPandaStart.py
index 015181144b..80cd385bf1 100755
--- a/direct/src/wxwidgets/WxPandaStart.py
+++ b/direct/src/wxwidgets/WxPandaStart.py
@@ -1,3 +1,3 @@
-from WxPandaShell import *
+from .WxPandaShell import *
base.app = WxPandaShell()
diff --git a/direct/src/wxwidgets/WxPandaWindow.py b/direct/src/wxwidgets/WxPandaWindow.py
index 6d4ccd335b..79a4ebc68d 100644
--- a/direct/src/wxwidgets/WxPandaWindow.py
+++ b/direct/src/wxwidgets/WxPandaWindow.py
@@ -172,7 +172,7 @@ else:
break
if pipe.getInterfaceName() != 'OpenGL':
- raise StandardError, "Couldn't get an OpenGL pipe."
+ raise Exception("Couldn't get an OpenGL pipe.")
self.win = base.openWindow(callbackWindowDict = callbackWindowDict, pipe = pipe, gsg = gsg, type = 'onscreen')
self.hasCapture = False
diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes
index da1575fcdd..90c661c63a 100644
--- a/doc/ReleaseNotes
+++ b/doc/ReleaseNotes
@@ -1,3 +1,27 @@
+------------------------ RELEASE 1.9.2 ------------------------
+
+This is a minor bugfix release, fixing a few minor issues that
+remained in the 1.9.1 release, including:
+
+* Fix compile errors with more recent versions of ffmpeg
+* Include .lib files for pyd modules in Windows SDK
+* packp3d now recognizes default egg-object-type definitions
+* Fix issues with sphere-into-box and box-into-sphere collisions
+* Texture VRAM usage is now correctly reported by pstats
+* Support for reading BMP files with alpha channel
+* Fix OpenGL crashes in very ancient OpenGL versions
+* Fix rare compile issues and crashes with esoteric Python set-ups
+* Fix crash when extracting texture that's not a multiple of 4 bytes
+* Work around buggy NVIDIA driver that reports _main_* shader inputs
+* Add version of transform_vertices that accepts a SparseArray
+* Clamp shininess to 0 to avoid GL error when shininess < 0
+* Fix various bugs in RopeNode and NurbsCurveEvaluator
+* Fix clock-mode Config.prc settings
+* NodePath render_mode setters no longer reset wireframe color
+* Fix constant reloading of texture when gl-ignore-mipmaps is set
+* BamReader now releases the GIL (so it can be used threaded)
+* Fix AttributeError in direct.stdpy.threading module
+
------------------------ RELEASE 1.9.1 ------------------------
This minor release fixes some important regressions and bugs found
diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h
index c9d89fe942..74f51d2d50 100644
--- a/dtool/src/dtoolbase/pvector.h
+++ b/dtool/src/dtoolbase/pvector.h
@@ -39,11 +39,25 @@ public:
typedef vector base_class;
typedef TYPENAME base_class::size_type size_type;
- pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { }
+ explicit pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { }
pvector(const pvector ©) : base_class(copy) { }
- pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
- pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { }
+ explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
+ explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { }
pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { }
+
+#ifdef USE_MOVE_SEMANTICS
+ pvector(pvector &&from) NOEXCEPT : base_class(move(from)) {};
+
+ pvector &operator =(pvector &&from) NOEXCEPT {
+ base_class::operator =(move(from));
+ return *this;
+ }
+#endif
+
+ pvector &operator =(const pvector ©) {
+ base_class::operator =(copy);
+ return *this;
+ }
};
#endif // USE_STL_ALLOCATOR
diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h
index 1526b6bc2f..6c668a6190 100644
--- a/dtool/src/dtoolbase/typeRegistry.h
+++ b/dtool/src/dtoolbase/typeRegistry.h
@@ -37,14 +37,15 @@ class EXPCL_DTOOL TypeRegistry : public MemoryBase {
public:
// User code shouldn't generally need to call TypeRegistry::register_type()
// or record_derivation() directly; instead, use the register_type
- // convenience function, defined below.
+ // convenience function, defined in register_type.h.
bool register_type(TypeHandle &type_handle, const string &name);
+
+PUBLISHED:
TypeHandle register_dynamic_type(const string &name);
void record_derivation(TypeHandle child, TypeHandle parent);
void record_alternate_name(TypeHandle type, const string &name);
-PUBLISHED:
TypeHandle find_type(const string &name) const;
TypeHandle find_type_by_id(int id) const;
diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx
index ac5eb548af..bcf4584ab0 100644
--- a/dtool/src/dtoolutil/executionEnvironment.cxx
+++ b/dtool/src/dtoolutil/executionEnvironment.cxx
@@ -247,7 +247,7 @@ ns_get_environment_variable(const string &var) const {
} else if (var == "MAIN_DIR") {
// Return the binary name's parent directory. If we're running inside the
// Python interpreter, this will be overridden by a setting from
- // panda3dcore.py.
+ // panda3d/core.py.
if (!_binary_name.empty()) {
Filename main_dir (_binary_name);
main_dir.make_absolute();
diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx
index b97a4691b0..a23d2f64df 100644
--- a/dtool/src/dtoolutil/pfstreamBuf.cxx
+++ b/dtool/src/dtoolutil/pfstreamBuf.cxx
@@ -121,7 +121,7 @@ int PipeStreamBuf::underflow(void) {
#endif /* PHAVE_IOSTREAM */
gbump(-((int)n));
}
- delete buf;
+ delete[] buf;
return ret;
}
diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx
index 5ab6f54768..c07e6af50f 100644
--- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx
+++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx
@@ -4703,9 +4703,18 @@ write_function_instance(ostream &out, FunctionRemap *remap,
if (args_type == AT_single_arg) {
out << "#if PY_MAJOR_VERSION >= 3\n";
- indent(out, indent_level)
- << param_name << "_str = PyUnicode_AsUTF8AndSize(arg, &"
- << param_name << "_len);\n";
+ // As a special hack to fix pickling in Python 3, if the method name
+ // starts with py_decode_, we take a bytes object instead of a str.
+ if (remap->_cppfunc->get_local_name().substr(0, 10) == "py_decode_") {
+ indent(out, indent_level) << "if (PyBytes_AsStringAndSize(arg, &"
+ << param_name << "_str, &" << param_name << "_len) == -1) {\n";
+ indent(out, indent_level + 2) << param_name << "_str = NULL;\n";
+ indent(out, indent_level) << "}\n";
+ } else {
+ indent(out, indent_level)
+ << param_name << "_str = PyUnicode_AsUTF8AndSize(arg, &"
+ << param_name << "_len);\n";
+ }
out << "#else\n"; // NB. PyString_AsStringAndSize also accepts a PyUnicode.
indent(out, indent_level) << "if (PyString_AsStringAndSize(arg, &"
<< param_name << "_str, &" << param_name << "_len) == -1) {\n";
@@ -4720,11 +4729,11 @@ write_function_instance(ostream &out, FunctionRemap *remap,
+ "_str, &" + param_name + "_len";
}
-// if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) {
-// pexpr_string = "&std::string(" + param_name + "_str, " + param_name +
-// "_len)"; } else {
- pexpr_string = param_name + "_str, " + param_name + "_len";
-// }
+ //if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) {
+ // pexpr_string = "&std::string(" + param_name + "_str, " + param_name + "_len)";
+ //} else {
+ pexpr_string = param_name + "_str, " + param_name + "_len";
+ //}
expected_params += "str";
}
// Remember to clear the TypeError that any of the above methods raise.
diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py
index 11868cf829..59667a33ad 100755
--- a/makepanda/makepanda.py
+++ b/makepanda/makepanda.py
@@ -2621,7 +2621,7 @@ CreatePandaVersionFiles()
##########################################################################################
if (PkgSkip("DIRECT")==0):
- CopyPythonTree(GetOutputDir() + '/direct', 'direct/src', lib2to3_fixers=['all'])
+ CopyPythonTree(GetOutputDir() + '/direct', 'direct/src', threads=THREADCOUNT)
ConditionalWriteFile(GetOutputDir() + '/direct/__init__.py', "")
# This file used to be copied, but would nowadays cause conflicts.
@@ -2671,7 +2671,8 @@ if not PkgSkip("PYTHON"):
# Also add this file, for backward compatibility.
ConditionalWriteFile(GetOutputDir() + '/panda3d/dtoolconfig.py', """
-print("Warning: panda3d.dtoolconfig is deprecated, use panda3d.interrogatedb instead.")
+if __debug__:
+ print("Warning: panda3d.dtoolconfig is deprecated, use panda3d.interrogatedb instead.")
from .interrogatedb import *
""")
@@ -2702,7 +2703,8 @@ if not PkgSkip("VRPN"):
panda_modules_code = """
"This module is deprecated. Import from panda3d.core and other panda3d.* modules instead."
-print("Warning: pandac.PandaModules is deprecated, import from panda3d.core instead")
+if __debug__:
+ print("Warning: pandac.PandaModules is deprecated, import from panda3d.core instead")
"""
for module in panda_modules:
@@ -3405,8 +3407,7 @@ if (not RUNTIME):
TargetAdd('libp3putil.in', opts=OPTS, input=IGATEFILES)
TargetAdd('libp3putil.in', opts=['IMOD:panda3d.core', 'ILIB:libp3putil', 'SRCDIR:panda/src/putil'])
TargetAdd('libp3putil_igate.obj', input='libp3putil.in', opts=["DEPENDENCYONLY"])
- TargetAdd('p3putil_typedWritable_ext.obj', opts=OPTS, input='typedWritable_ext.cxx')
- TargetAdd('p3putil_pythonCallbackObject.obj', opts=OPTS, input='pythonCallbackObject.cxx')
+ TargetAdd('p3putil_ext_composite.obj', opts=OPTS, input='p3putil_ext_composite.cxx')
#
# DIRECTORY: panda/src/audio/
@@ -4007,8 +4008,7 @@ if (not RUNTIME):
if PkgSkip("FREETYPE")==0:
TargetAdd('core.pyd', input="libp3pnmtext_igate.obj")
- TargetAdd('core.pyd', input='p3putil_typedWritable_ext.obj')
- TargetAdd('core.pyd', input='p3putil_pythonCallbackObject.obj')
+ TargetAdd('core.pyd', input='p3putil_ext_composite.obj')
TargetAdd('core.pyd', input='p3pnmimage_pfmFile_ext.obj')
TargetAdd('core.pyd', input='p3event_pythonTask.obj')
TargetAdd('core.pyd', input='p3gobj_ext_composite.obj')
@@ -4539,8 +4539,7 @@ if (PkgSkip("EGL")==0 and PkgSkip("GLES")==0 and PkgSkip("X11")==0 and not RUNTI
TargetAdd('pandagles_egldisplay_composite1.obj', opts=OPTS, input='p3egldisplay_composite1.cxx')
OPTS=['DIR:panda/metalibs/pandagles', 'BUILDING:PANDAGLES', 'GLES', 'EGL']
TargetAdd('pandagles_pandagles.obj', opts=OPTS, input='pandagles.cxx')
- # Uncomment this as soon as x11-specific stuff is removed from p3egldisplay
- #TargetAdd('libpandagles.dll', input='p3x11display_composite1.obj')
+ TargetAdd('libpandagles.dll', input='p3x11display_composite1.obj')
TargetAdd('libpandagles.dll', input='pandagles_pandagles.obj')
TargetAdd('libpandagles.dll', input='p3glesgsg_config_glesgsg.obj')
TargetAdd('libpandagles.dll', input='p3glesgsg_glesgsg.obj')
@@ -4558,8 +4557,7 @@ if (PkgSkip("EGL")==0 and PkgSkip("GLES2")==0 and PkgSkip("X11")==0 and not RUNT
TargetAdd('pandagles2_egldisplay_composite1.obj', opts=OPTS, input='p3egldisplay_composite1.cxx')
OPTS=['DIR:panda/metalibs/pandagles2', 'BUILDING:PANDAGLES2', 'GLES2', 'EGL']
TargetAdd('pandagles2_pandagles2.obj', opts=OPTS, input='pandagles2.cxx')
- # Uncomment this as soon as x11-specific stuff is removed from p3egldisplay
- #TargetAdd('libpandagles2.dll', input='p3x11display_composite1.obj')
+ TargetAdd('libpandagles2.dll', input='p3x11display_composite1.obj')
TargetAdd('libpandagles2.dll', input='pandagles2_pandagles2.obj')
TargetAdd('libpandagles2.dll', input='p3gles2gsg_config_gles2gsg.obj')
TargetAdd('libpandagles2.dll', input='p3gles2gsg_gles2gsg.obj')
@@ -6887,8 +6885,8 @@ def MakeInstallerOSX():
oscmd("cp -R %s/pandac dstroot/pythoncode/Developer/Panda3D/pandac" % GetOutputDir())
oscmd("cp -R %s/direct dstroot/pythoncode/Developer/Panda3D/direct" % GetOutputDir())
oscmd("ln -s %s dstroot/pythoncode/usr/local/bin/ppython" % SDK["PYTHONEXEC"])
- oscmd("cp -R %s/*.so dstroot/pythoncode/Developer/Panda3D/" % GetOutputDir())
- oscmd("cp -R %s/*.py dstroot/pythoncode/Developer/Panda3D/" % GetOutputDir())
+ oscmd("cp -R %s/*.so dstroot/pythoncode/Developer/Panda3D/" % GetOutputDir(), True)
+ oscmd("cp -R %s/*.py dstroot/pythoncode/Developer/Panda3D/" % GetOutputDir(), True)
if os.path.isdir(GetOutputDir()+"/Pmw"):
oscmd("cp -R %s/Pmw dstroot/pythoncode/Developer/Panda3D/Pmw" % GetOutputDir())
compileall.compile_dir("dstroot/pythoncode/Developer/Panda3D/Pmw")
diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py
index f395693c3f..05b6053053 100644
--- a/makepanda/makepandacore.py
+++ b/makepanda/makepandacore.py
@@ -2640,18 +2640,25 @@ def CopyTree(dstdir, srcdir, omitVCS=True):
if omitVCS:
DeleteVCS(dstdir)
-def CopyPythonTree(dstdir, srcdir, lib2to3_fixers=[]):
+def CopyPythonTree(dstdir, srcdir, lib2to3_fixers=[], threads=0):
if (not os.path.isdir(dstdir)):
os.mkdir(dstdir)
lib2to3 = None
+ lib2to3_args = ['-w', '-n', '--no-diffs']
+
if len(lib2to3_fixers) > 0 and sys.version_info >= (3, 0):
from lib2to3.main import main as lib2to3
- lib2to3_args = ['-w', '-n', '--no-diffs', '-x', 'buffer', '-x', 'idioms', '-x', 'set_literal', '-x', 'ws_comma']
- if lib2to3_fixers != ['all']:
+
+ if lib2to3_fixers == ['all']:
+ lib2to3_args += ['-x', 'buffer', '-x', 'idioms', '-x', 'set_literal', '-x', 'ws_comma']
+ else:
for fixer in lib2to3_fixers:
lib2to3_args += ['-f', fixer]
+ if threads:
+ lib2to3_args += ['-j', str(threads)]
+
exclude_files = set(VCS_FILES)
exclude_files.add('panda3d.py')
@@ -2667,20 +2674,23 @@ def CopyPythonTree(dstdir, srcdir, lib2to3_fixers=[]):
if ext == '.py' and not entry.endswith('-extensions.py'):
refactor.append((dstpth, srcpth))
+ lib2to3_args.append(dstpth)
else:
JustBuilt([dstpth], [srcpth])
elif entry not in VCS_DIRS:
- CopyPythonTree(dstpth, srcpth, lib2to3_fixers)
+ CopyPythonTree(dstpth, srcpth, lib2to3_fixers, threads=threads)
- for dstpth, srcpth in refactor:
- if lib2to3 is not None:
- ret = lib2to3("lib2to3.fixes", lib2to3_args + [dstpth])
- if ret != 0:
+ if refactor and lib2to3 is not None:
+ ret = lib2to3("lib2to3.fixes", lib2to3_args)
+
+ if ret != 0:
+ for dstpth, srcpth in refactor:
os.remove(dstpth)
exit("Error in lib2to3.")
- JustBuilt([dstpth], [srcpth])
-
+ else:
+ for dstpth, srcpth in refactor:
+ JustBuilt([dstpth], [srcpth])
########################################################################
##
diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx
index 8952a1d1bc..f6843d199b 100644
--- a/panda/src/bullet/bulletHeightfieldShape.cxx
+++ b/panda/src/bullet/bulletHeightfieldShape.cxx
@@ -16,7 +16,9 @@
TypeHandle BulletHeightfieldShape::_type_handle;
/**
- *
+ * @brief Creates a collision shape suited for terrains from a rectangular image.
+ * @details Stores the image's brightness values in a vector Bullet can use,
+ * while rotating it 90 degrees to the right.
*/
BulletHeightfieldShape::
BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up) {
@@ -28,8 +30,10 @@ BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAx
for (int row=0; row < _num_rows; row++) {
for (int column=0; column < _num_cols; column++) {
- _data[_num_cols * row + column] =
- max_height * image.get_bright(column, _num_cols - row - 1);
+ // Transpose
+ _data[_num_rows * column + row] =
+ // Flip y
+ max_height * image.get_bright(row, _num_cols - column - 1);
}
}
@@ -59,3 +63,41 @@ set_use_diamond_subdivision(bool flag) {
return _shape->setUseDiamondSubdivision(flag);
}
+
+/**
+ * @brief Creates a collision shape suited for terrains from a rectangular texture.
+ * @details Alternative constructor intended for use with ShaderTerrainMesh. This will
+ * do bilinear sampling at the corners of all texels. Also works with textures
+ * that are non-power-of-two and/or rectangular.
+ */
+BulletHeightfieldShape::
+BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) {
+
+ _num_rows = tex->get_x_size() + 1;
+ _num_cols = tex->get_y_size() + 1;
+ _data = new float[_num_rows * _num_cols];
+
+ PN_stdfloat step_x = 1.0 / (PN_stdfloat)tex->get_x_size();
+ PN_stdfloat step_y = 1.0 / (PN_stdfloat)tex->get_y_size();
+
+ PT(TexturePeeker) peeker = tex->peek();
+ LColor sample;
+
+ for (int row=0; row < _num_rows; row++) {
+ for (int column=0; column < _num_cols; column++) {
+ if (!peeker->lookup_bilinear(sample, row * step_x, column * step_y)) {
+ bullet_cat.error() << "Could not sample texture." << endl;
+ }
+ // Transpose
+ _data[_num_rows * column + row] = max_height * sample.get_x();
+ }
+ }
+
+ _shape = new btHeightfieldTerrainShape(_num_rows,
+ _num_cols,
+ _data,
+ max_height,
+ up,
+ true, false);
+ _shape->setUserPointer(this);
+}
\ No newline at end of file
diff --git a/panda/src/bullet/bulletHeightfieldShape.h b/panda/src/bullet/bulletHeightfieldShape.h
index 495b6752f9..c8bf6f7730 100644
--- a/panda/src/bullet/bulletHeightfieldShape.h
+++ b/panda/src/bullet/bulletHeightfieldShape.h
@@ -21,6 +21,8 @@
#include "bulletShape.h"
#include "pnmImage.h"
+#include "texture.h"
+#include "texturePeeker.h"
/**
*
@@ -29,6 +31,7 @@ class EXPCL_PANDABULLET BulletHeightfieldShape : public BulletShape {
PUBLISHED:
BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up);
+ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up=Z_up);
INLINE BulletHeightfieldShape(const BulletHeightfieldShape ©);
INLINE void operator = (const BulletHeightfieldShape ©);
INLINE ~BulletHeightfieldShape();
diff --git a/panda/src/bullet/bulletManifoldPoint.cxx b/panda/src/bullet/bulletManifoldPoint.cxx
index 05ec4e8b87..00651186f0 100644
--- a/panda/src/bullet/bulletManifoldPoint.cxx
+++ b/panda/src/bullet/bulletManifoldPoint.cxx
@@ -89,10 +89,10 @@ get_position_world_on_b() const {
/**
*
*/
-LPoint3 BulletManifoldPoint::
+LVector3 BulletManifoldPoint::
get_normal_world_on_b() const {
- return btVector3_to_LPoint3(_pt.m_normalWorldOnB);
+ return btVector3_to_LVector3(_pt.m_normalWorldOnB);
}
/**
diff --git a/panda/src/bullet/bulletManifoldPoint.h b/panda/src/bullet/bulletManifoldPoint.h
index 0488272885..4184ed9d97 100644
--- a/panda/src/bullet/bulletManifoldPoint.h
+++ b/panda/src/bullet/bulletManifoldPoint.h
@@ -34,7 +34,7 @@ PUBLISHED:
PN_stdfloat get_applied_impulse() const;
LPoint3 get_position_world_on_a() const;
LPoint3 get_position_world_on_b() const;
- LPoint3 get_normal_world_on_b() const;
+ LVector3 get_normal_world_on_b() const;
LPoint3 get_local_point_a() const;
LPoint3 get_local_point_b() const;
diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I
index db8e1f198f..ea3a9b61ac 100644
--- a/panda/src/display/graphicsStateGuardian.I
+++ b/panda/src/display/graphicsStateGuardian.I
@@ -684,6 +684,15 @@ get_max_color_targets() const {
return _max_color_targets;
}
+/**
+ * Returns true if dual source (incoming1_color and incoming1_alpha) blend
+ * operands are supported by this GSG.
+ */
+INLINE bool GraphicsStateGuardian::
+get_supports_dual_source_blending() const {
+ return _supports_dual_source_blending;
+}
+
/**
* Deprecated. Use get_max_color_targets() instead, which returns the exact
* same value.
diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx
index 6f5e873779..35603fcea6 100644
--- a/panda/src/display/graphicsStateGuardian.cxx
+++ b/panda/src/display/graphicsStateGuardian.cxx
@@ -246,6 +246,7 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system,
// Assume a maximum of 1 render target in absence of MRT.
_max_color_targets = 1;
+ _supports_dual_source_blending = false;
_supported_geom_rendering = 0;
@@ -3101,7 +3102,7 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) {
if (display_cat.is_debug()) {
display_cat.debug()
<< "Constructing shadow buffer for light '" << light->get_name()
- << "', size=" << light->_sb_xsize << "x" << light->_sb_ysize
+ << "', size=" << light->_sb_size[0] << "x" << light->_sb_size[1]
<< ", sort=" << light->_sb_sort << "\n";
}
@@ -3109,7 +3110,7 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) {
FrameBufferProperties fbp;
fbp.set_depth_bits(shadow_depth_bits);
- WindowProperties props = WindowProperties::size(light->_sb_xsize, light->_sb_ysize);
+ WindowProperties props = WindowProperties::size(light->_sb_size[0], light->_sb_size[1]);
int flags = GraphicsPipe::BF_refuse_window;
if (is_point) {
flags |= GraphicsPipe::BF_size_square;
@@ -3124,13 +3125,13 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) {
// error
PT(Texture) tex = new Texture(light->get_name());
if (is_point) {
- if (light->_sb_xsize != light->_sb_ysize) {
+ if (light->_sb_size[0] != light->_sb_size[1]) {
display_cat.error()
<< "PointLight shadow buffers must have an equal width and height!\n";
}
- tex->setup_cube_map(light->_sb_xsize, Texture::T_unsigned_byte, Texture::F_depth_component);
+ tex->setup_cube_map(light->_sb_size[0], Texture::T_unsigned_byte, Texture::F_depth_component);
} else {
- tex->setup_2d_texture(light->_sb_xsize, light->_sb_ysize, Texture::T_unsigned_byte, Texture::F_depth_component);
+ tex->setup_2d_texture(light->_sb_size[0], light->_sb_size[1], Texture::T_unsigned_byte, Texture::F_depth_component);
}
tex->make_ram_image();
sbuffer->add_render_texture(tex, GraphicsOutput::RTM_bind_or_copy, GraphicsOutput::RTP_depth);
diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h
index 401c538b31..825b03286d 100644
--- a/panda/src/display/graphicsStateGuardian.h
+++ b/panda/src/display/graphicsStateGuardian.h
@@ -172,6 +172,7 @@ PUBLISHED:
INLINE int get_max_color_targets() const;
INLINE int get_maximum_simultaneous_render_targets() const;
+ INLINE bool get_supports_dual_source_blending() const;
MAKE_PROPERTY(max_vertices_per_array, get_max_vertices_per_array);
MAKE_PROPERTY(max_vertices_per_primitive, get_max_vertices_per_primitive);
@@ -217,6 +218,7 @@ PUBLISHED:
MAKE_PROPERTY(supports_timer_query, get_supports_timer_query);
MAKE_PROPERTY(timer_queries_active, get_timer_queries_active);
MAKE_PROPERTY(max_color_targets, get_max_color_targets);
+ MAKE_PROPERTY(supports_dual_source_blending, get_supports_dual_source_blending);
INLINE ShaderModel get_shader_model() const;
INLINE void set_shader_model(ShaderModel shader_model);
@@ -609,6 +611,7 @@ protected:
bool _supports_indirect_draw;
int _max_color_targets;
+ bool _supports_dual_source_blending;
int _supported_geom_rendering;
bool _color_scale_via_lighting;
diff --git a/panda/src/downloader/download_utils.cxx b/panda/src/downloader/download_utils.cxx
index 48f717145f..e090627362 100644
--- a/panda/src/downloader/download_utils.cxx
+++ b/panda/src/downloader/download_utils.cxx
@@ -40,7 +40,7 @@ check_crc(Filename name) {
unsigned long crc = crc32(0L, Z_NULL, 0);
crc = crc32(crc, (unsigned char *)buffer, buffer_length);
- delete buffer;
+ delete[] buffer;
return crc;
}
@@ -66,7 +66,7 @@ check_adler(Filename name) {
unsigned long adler = adler32(0L, Z_NULL, 0);
adler = adler32(adler, (unsigned char *)buffer, buffer_length);
- delete buffer;
+ delete[] buffer;
return adler;
}
diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx
index f71e01d298..505fe7b10d 100644
--- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx
+++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx
@@ -3766,43 +3766,24 @@ do_issue_blending() {
}
}
- const ColorBlendAttrib *target_color_blend = DCAST(ColorBlendAttrib, _target_rs->get_attrib_def(ColorBlendAttrib::get_class_slot()));
- CPT(ColorBlendAttrib) color_blend = target_color_blend;
- ColorBlendAttrib::Mode color_blend_mode = target_color_blend->get_mode();
+ const ColorBlendAttrib *color_blend;
+ _target_rs->get_attrib_def(color_blend);
+ ColorBlendAttrib::Mode color_blend_mode = color_blend->get_mode();
- const TransparencyAttrib *target_transparency = DCAST(TransparencyAttrib, _target_rs->get_attrib_def(TransparencyAttrib::get_class_slot()));
+ const TransparencyAttrib *target_transparency;
+ _target_rs->get_attrib_def(target_transparency);
TransparencyAttrib::Mode transparency_mode = target_transparency->get_mode();
// Is there a color blend set?
if (color_blend_mode != ColorBlendAttrib::M_none) {
set_render_state(D3DRS_ALPHABLENDENABLE, TRUE);
-
- switch (color_blend_mode) {
- case ColorBlendAttrib::M_add:
- set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD);
- break;
-
- case ColorBlendAttrib::M_subtract:
- set_render_state(D3DRS_BLENDOP, D3DBLENDOP_SUBTRACT);
- break;
-
- case ColorBlendAttrib::M_inv_subtract:
- set_render_state(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
- break;
-
- case ColorBlendAttrib::M_min:
- set_render_state(D3DRS_BLENDOP, D3DBLENDOP_MIN);
- break;
-
- case ColorBlendAttrib::M_max:
- set_render_state(D3DRS_BLENDOP, D3DBLENDOP_MAX);
- break;
- }
-
- set_render_state(D3DRS_SRCBLEND,
- get_blend_func(color_blend->get_operand_a()));
- set_render_state(D3DRS_DESTBLEND,
- get_blend_func(color_blend->get_operand_b()));
+ set_render_state(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
+ set_render_state(D3DRS_BLENDOP, get_blend_mode(color_blend_mode));
+ set_render_state(D3DRS_BLENDOPALPHA, get_blend_mode(color_blend->get_alpha_mode()));
+ set_render_state(D3DRS_SRCBLEND, get_blend_func(color_blend->get_operand_a()));
+ set_render_state(D3DRS_DESTBLEND, get_blend_func(color_blend->get_operand_b()));
+ set_render_state(D3DRS_SRCBLENDALPHA, get_blend_func(color_blend->get_alpha_operand_a()));
+ set_render_state(D3DRS_DESTBLENDALPHA, get_blend_func(color_blend->get_alpha_operand_b()));
return;
}
@@ -3817,6 +3798,7 @@ do_issue_blending() {
case TransparencyAttrib::M_multisample_mask:
case TransparencyAttrib::M_dual:
set_render_state(D3DRS_ALPHABLENDENABLE, TRUE);
+ set_render_state(D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD);
set_render_state(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
set_render_state(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
@@ -3824,6 +3806,7 @@ do_issue_blending() {
case TransparencyAttrib::M_premultiplied_alpha:
set_render_state(D3DRS_ALPHABLENDENABLE, TRUE);
+ set_render_state(D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD);
set_render_state(D3DRS_SRCBLEND, D3DBLEND_ONE);
set_render_state(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
@@ -4052,6 +4035,33 @@ get_light_color(Light *light) const {
return *(D3DCOLORVALUE *)cf.get_data();
}
+/**
+ * Maps from ColorBlendAttrib::Mode to D3DBLENDOP vaule.
+ */
+D3DBLENDOP DXGraphicsStateGuardian9::
+get_blend_mode(ColorBlendAttrib::Mode mode) {
+ switch (mode) {
+ case ColorBlendAttrib::M_add:
+ return D3DBLENDOP_ADD;
+
+ case ColorBlendAttrib::M_subtract:
+ return D3DBLENDOP_SUBTRACT;
+
+ case ColorBlendAttrib::M_inv_subtract:
+ return D3DBLENDOP_REVSUBTRACT;
+
+ case ColorBlendAttrib::M_min:
+ return D3DBLENDOP_MIN;
+
+ case ColorBlendAttrib::M_max:
+ return D3DBLENDOP_MAX;
+ }
+
+ dxgsg9_cat.error()
+ << "Unknown color blend mode " << (int)mode << endl;
+ return D3DBLENDOP_ADD;
+}
+
/**
* Maps from ColorBlendAttrib::Operand to D3DBLEND value.
*/
@@ -4106,6 +4116,21 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
case ColorBlendAttrib::O_incoming_color_saturate:
return D3DBLEND_SRCALPHASAT;
+
+ case ColorBlendAttrib::O_incoming1_color:
+ return D3DBLEND_SRCCOLOR2;
+
+ case ColorBlendAttrib::O_one_minus_incoming1_color:
+ return D3DBLEND_INVSRCCOLOR2;
+
+ case ColorBlendAttrib::O_incoming1_alpha:
+ // Not supported by DX.
+ return D3DBLEND_SRCCOLOR2;
+
+ case ColorBlendAttrib::O_one_minus_incoming1_alpha:
+ // Not supported by DX.
+ return D3DBLEND_INVSRCCOLOR2;
+
}
dxgsg9_cat.error()
diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h
index 4a51d214cb..512cedbda2 100644
--- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h
+++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h
@@ -217,6 +217,7 @@ protected:
const D3DCOLORVALUE &get_light_color(Light *light) const;
INLINE static D3DTRANSFORMSTATETYPE get_tex_mat_sym(int stage_index);
+ static D3DBLENDOP get_blend_mode(ColorBlendAttrib::Mode mode);
static D3DBLEND get_blend_func(ColorBlendAttrib::Operand operand);
void report_texmgr_stats();
diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx
index 103ba24fe2..6767d5c287 100644
--- a/panda/src/egg2pg/eggSaver.cxx
+++ b/panda/src/egg2pg/eggSaver.cxx
@@ -578,8 +578,8 @@ convert_primitive(const GeomVertexData *vertex_data,
// Check for a color scale.
LVecBase4 color_scale(1.0f, 1.0f, 1.0f, 1.0f);
- const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, net_state->get_attrib(ColorScaleAttrib::get_class_type()));
- if (csa != (const ColorScaleAttrib *)NULL) {
+ const ColorScaleAttrib *csa;
+ if (net_state->get_attrib(csa)) {
color_scale = csa->get_scale();
}
@@ -587,8 +587,8 @@ convert_primitive(const GeomVertexData *vertex_data,
bool has_color_override = false;
bool has_color_off = false;
LColor color_override;
- const ColorAttrib *ca = DCAST(ColorAttrib, net_state->get_attrib(ColorAttrib::get_class_type()));
- if (ca != (const ColorAttrib *)NULL) {
+ const ColorAttrib *ca;
+ if (net_state->get_attrib(ca)) {
if (ca->get_color_type() == ColorAttrib::T_flat) {
has_color_override = true;
color_override = ca->get_color();
@@ -604,15 +604,15 @@ convert_primitive(const GeomVertexData *vertex_data,
// Check for a material.
EggMaterial *egg_mat = (EggMaterial *)NULL;
- const MaterialAttrib *ma = DCAST(MaterialAttrib, net_state->get_attrib(MaterialAttrib::get_class_type()));
- if (ma != (const MaterialAttrib *)NULL) {
+ const MaterialAttrib *ma;
+ if (net_state->get_attrib(ma)) {
egg_mat = get_egg_material(ma->get_material());
}
// Check for a texture.
EggTexture *egg_tex = (EggTexture *)NULL;
- const TextureAttrib *ta = DCAST(TextureAttrib, net_state->get_attrib(TextureAttrib::get_class_type()));
- if (ta != (const TextureAttrib *)NULL) {
+ const TextureAttrib *ta;
+ if (net_state->get_attrib(ta)) {
egg_tex = get_egg_texture(ta->get_texture());
}
@@ -651,9 +651,8 @@ convert_primitive(const GeomVertexData *vertex_data,
// Check the backface flag.
bool bface = false;
- const RenderAttrib *cf_attrib = net_state->get_attrib(CullFaceAttrib::get_class_type());
- if (cf_attrib != (const RenderAttrib *)NULL) {
- const CullFaceAttrib *cfa = DCAST(CullFaceAttrib, cf_attrib);
+ const CullFaceAttrib *cfa;
+ if (net_state->get_attrib(cfa)) {
if (cfa->get_effective_mode() == CullFaceAttrib::M_cull_none) {
bface = true;
}
@@ -662,9 +661,8 @@ convert_primitive(const GeomVertexData *vertex_data,
// Check the depth write flag - only needed for AM_blend_no_occlude
bool has_depthwrite = false;
DepthWriteAttrib::Mode depthwrite = DepthWriteAttrib::M_on;
- const RenderAttrib *dw_attrib = net_state->get_attrib(DepthWriteAttrib::get_class_type());
- if (dw_attrib != (const RenderAttrib *)NULL) {
- const DepthWriteAttrib *dwa = DCAST(DepthWriteAttrib, dw_attrib);
+ const DepthWriteAttrib *dwa;
+ if (net_state->get_attrib(dwa)) {
depthwrite = dwa->get_mode();
has_depthwrite = true;
}
@@ -672,9 +670,8 @@ convert_primitive(const GeomVertexData *vertex_data,
// Check the transparency flag.
bool has_transparency = false;
TransparencyAttrib::Mode transparency = TransparencyAttrib::M_none;
- const RenderAttrib *tr_attrib = net_state->get_attrib(TransparencyAttrib::get_class_type());
- if (tr_attrib != (const RenderAttrib *)NULL) {
- const TransparencyAttrib *tra = DCAST(TransparencyAttrib, tr_attrib);
+ const TransparencyAttrib *tra;
+ if (net_state->get_attrib(tra)) {
transparency = tra->get_mode();
has_transparency = true;
}
@@ -715,6 +712,16 @@ convert_primitive(const GeomVertexData *vertex_data,
}
}
+ // Check for line thickness and such.
+ bool has_render_mode = false;
+ bool perspective = false;
+ PN_stdfloat thickness = 1;
+ const RenderModeAttrib *rma;
+ if (net_state->get_attrib(rma)) {
+ has_render_mode = true;
+ thickness = rma->get_thickness();
+ perspective = rma->get_perspective();
+ }
LNormal normal;
LColor color;
@@ -754,6 +761,18 @@ convert_primitive(const GeomVertexData *vertex_data,
egg_prim->set_bface_flag(true);
}
+ if (has_render_mode) {
+ if (egg_prim->is_of_type(EggPoint::get_class_type())) {
+ EggPoint *egg_point = (EggPoint *)egg_prim.p();
+ egg_point->set_thick(thickness);
+ egg_point->set_perspective(perspective);
+
+ } else if (egg_prim->is_of_type(EggLine::get_class_type())) {
+ EggLine *egg_line = (EggLine *)egg_prim.p();
+ egg_line->set_thick(thickness);
+ }
+ }
+
for (int j = 0; j < num_vertices; j++) {
EggVertex egg_vert;
diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx
index 7277e517f8..809e73916c 100644
--- a/panda/src/egldisplay/config_egldisplay.cxx
+++ b/panda/src/egldisplay/config_egldisplay.cxx
@@ -26,41 +26,6 @@ ConfigureFn(config_egldisplay) {
init_libegldisplay();
}
-ConfigVariableString display_cfg
-("display", "",
- PRC_DESC("Specify the X display string for the default display. If this "
- "is not specified, $DISPLAY is used."));
-
-ConfigVariableBool x_error_abort
-("x-error-abort", false,
- PRC_DESC("Set this true to trigger and abort (and a stack trace) on receipt "
- "of an error from the X window system. This can make it easier "
- "to discover where these errors are generated."));
-
-ConfigVariableInt x_wheel_up_button
-("x-wheel-up-button", 4,
- PRC_DESC("This is the mouse button index of the wheel_up event: which "
- "mouse button number does the system report when the mouse wheel "
- "is rolled one notch up?"));
-
-ConfigVariableInt x_wheel_down_button
-("x-wheel-down-button", 5,
- PRC_DESC("This is the mouse button index of the wheel_down event: which "
- "mouse button number does the system report when the mouse wheel "
- "is rolled one notch down?"));
-
-ConfigVariableInt x_wheel_left_button
-("x-wheel-left-button", 6,
- PRC_DESC("This is the mouse button index of the wheel_left event: which "
- "mouse button number does the system report when one scrolls "
- "to the left?"));
-
-ConfigVariableInt x_wheel_right_button
-("x-wheel-right-button", 7,
- PRC_DESC("This is the mouse button index of the wheel_right event: which "
- "mouse button number does the system report when one scrolls "
- "to the right?"));
-
/**
* Initializes the library. This must be called at least once before any of
* the functions or classes in this library can be used. Normally it will be
diff --git a/panda/src/egldisplay/config_egldisplay.h b/panda/src/egldisplay/config_egldisplay.h
index 1c403ec513..2df5bcc1f4 100644
--- a/panda/src/egldisplay/config_egldisplay.h
+++ b/panda/src/egldisplay/config_egldisplay.h
@@ -39,12 +39,4 @@
extern EXPCL_PANDAGLES const string get_egl_error_string(int error);
#endif
-extern ConfigVariableString display_cfg;
-extern ConfigVariableBool x_error_abort;
-
-extern ConfigVariableInt x_wheel_up_button;
-extern ConfigVariableInt x_wheel_down_button;
-extern ConfigVariableInt x_wheel_left_button;
-extern ConfigVariableInt x_wheel_right_button;
-
#endif
diff --git a/panda/src/egldisplay/eglGraphicsPipe.I b/panda/src/egldisplay/eglGraphicsPipe.I
index bec9e98a34..53d9c311af 100644
--- a/panda/src/egldisplay/eglGraphicsPipe.I
+++ b/panda/src/egldisplay/eglGraphicsPipe.I
@@ -10,49 +10,3 @@
* @author rdb
* @date 2009-05-21
*/
-
-/**
- * Returns a pointer to the X display associated with the pipe: the display on
- * which to create the windows.
- */
-INLINE X11_Display *eglGraphicsPipe::
-get_display() const {
- return _display;
-}
-
-/**
- * Returns the X screen number associated with the pipe.
- */
-INLINE int eglGraphicsPipe::
-get_screen() const {
- return _screen;
-}
-
-/**
- * Returns the handle to the root window on the pipe's display.
- */
-INLINE X11_Window eglGraphicsPipe::
-get_root() const {
- return _root;
-}
-
-/**
- * Returns the input method opened for the pipe, or NULL if the input method
- * could not be opened for some reason.
- */
-INLINE XIM eglGraphicsPipe::
-get_im() const {
- return _im;
-}
-
-/**
- * Returns an invisible Cursor suitable for assigning to windows that have the
- * cursor_hidden property set.
- */
-INLINE X11_Cursor eglGraphicsPipe::
-get_hidden_cursor() {
- if (_hidden_cursor == None) {
- make_hidden_cursor();
- }
- return _hidden_cursor;
-}
diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx
index 0280b2bd7d..441fc10512 100644
--- a/panda/src/egldisplay/eglGraphicsPipe.cxx
+++ b/panda/src/egldisplay/eglGraphicsPipe.cxx
@@ -21,67 +21,11 @@
TypeHandle eglGraphicsPipe::_type_handle;
-bool eglGraphicsPipe::_error_handlers_installed = false;
-eglGraphicsPipe::ErrorHandlerFunc *eglGraphicsPipe::_prev_error_handler;
-eglGraphicsPipe::IOErrorHandlerFunc *eglGraphicsPipe::_prev_io_error_handler;
-
-LightReMutex eglGraphicsPipe::_x_mutex;
-
/**
*
*/
eglGraphicsPipe::
-eglGraphicsPipe(const string &display) {
- string display_spec = display;
- if (display_spec.empty()) {
- display_spec = display_cfg;
- }
- if (display_spec.empty()) {
- display_spec = ExecutionEnvironment::get_environment_variable("DISPLAY");
- }
- if (display_spec.empty()) {
- display_spec = ":0.0";
- }
-
- // The X docs say we should do this to get international character support
- // from the keyboard.
- setlocale(LC_ALL, "");
-
- // But it's important that we use the "C" locale for numeric formatting,
- // since all of the internal Panda code assumes this--we need a decimal
- // point to mean a decimal point.
- setlocale(LC_NUMERIC, "C");
-
- _is_valid = false;
- _supported_types = OT_window | OT_buffer | OT_texture_buffer;
- _display = NULL;
- _screen = 0;
- _root = (X11_Window)NULL;
- _im = (XIM)NULL;
- _hidden_cursor = None;
- _egl_display = NULL;
-
- install_error_handlers();
-
- _display = XOpenDisplay(display_spec.c_str());
- if (!_display) {
- egldisplay_cat.error()
- << "Could not open display \"" << display_spec << "\".\n";
- return;
- }
-
- if (!XSupportsLocale()) {
- egldisplay_cat.warning()
- << "X does not support locale " << setlocale(LC_ALL, NULL) << "\n";
- }
- XSetLocaleModifiers("");
-
- _screen = DefaultScreen(_display);
- _root = RootWindow(_display, _screen);
- _display_width = DisplayWidth(_display, _screen);
- _display_height = DisplayHeight(_display, _screen);
- _is_valid = true;
-
+eglGraphicsPipe(const string &display) : x11GraphicsPipe(display) {
_egl_display = eglGetDisplay((NativeDisplayType) _display);
if (!eglInitialize(_egl_display, NULL, NULL)) {
egldisplay_cat.error()
@@ -94,38 +38,6 @@ eglGraphicsPipe(const string &display) {
<< "Couldn't bind EGL to the OpenGL ES API: "
<< get_egl_error_string(eglGetError()) << "\n";
}
-
- // Connect to an input method for supporting international text entry.
- _im = XOpenIM(_display, NULL, NULL, NULL);
- if (_im == (XIM)NULL) {
- egldisplay_cat.warning()
- << "Couldn't open input method.\n";
- }
-
- // What styles does the current input method support?
- /*
- XIMStyles *im_supported_styles;
- XGetIMValues(_im, XNQueryInputStyle, &im_supported_styles, NULL);
-
- for (int i = 0; i < im_supported_styles->count_styles; i++) {
- XIMStyle style = im_supported_styles->supported_styles[i];
- cerr << "style " << i << ". " << hex << style << dec << "\n";
- }
-
- XFree(im_supported_styles);
- */
-
- // Get some X atom numbers.
- _wm_delete_window = XInternAtom(_display, "WM_DELETE_WINDOW", false);
- _net_wm_window_type = XInternAtom(_display, "_NET_WM_WINDOW_TYPE", false);
- _net_wm_window_type_splash = XInternAtom(_display, "_NET_WM_WINDOW_TYPE_SPLASH", false);
- _net_wm_window_type_fullscreen = XInternAtom(_display, "_NET_WM_WINDOW_TYPE_FULLSCREEN", false);
- _net_wm_state = XInternAtom(_display, "_NET_WM_STATE", false);
- _net_wm_state_fullscreen = XInternAtom(_display, "_NET_WM_STATE_FULLSCREEN", false);
- _net_wm_state_above = XInternAtom(_display, "_NET_WM_STATE_ABOVE", false);
- _net_wm_state_below = XInternAtom(_display, "_NET_WM_STATE_BELOW", false);
- _net_wm_state_add = XInternAtom(_display, "_NET_WM_STATE_ADD", false);
- _net_wm_state_remove = XInternAtom(_display, "_NET_WM_STATE_REMOVE", false);
}
/**
@@ -133,13 +45,6 @@ eglGraphicsPipe(const string &display) {
*/
eglGraphicsPipe::
~eglGraphicsPipe() {
- release_hidden_cursor();
- if (_im) {
- XCloseIM(_im);
- }
- if (_display) {
- XCloseDisplay(_display);
- }
if (_egl_display) {
if (!eglTerminate(_egl_display)) {
egldisplay_cat.error() << "Failed to terminate EGL display: "
@@ -168,26 +73,6 @@ pipe_constructor() {
return new eglGraphicsPipe;
}
-/**
- * Returns an indication of the thread in which this GraphicsPipe requires its
- * window processing to be performed: typically either the app thread (e.g.
- * X) or the draw thread (Windows).
- */
-GraphicsPipe::PreferredWindowThread
-eglGraphicsPipe::get_preferred_window_thread() const {
- // Actually, since we're creating the graphics context in open_window() now,
- // it appears we need to ensure the open_window() call is performed in the
- // draw thread for now, even though X wants all of its calls to be single-
- // threaded.
-
- // This means that all X windows may have to be handled by the same draw
- // thread, which we didn't intend (though the global _x_mutex may allow them
- // to be technically served by different threads, even though the actual X
- // calls will be serialized). There might be a better way.
-
- return PWT_draw;
-}
-
/**
* Creates a new window on the pipe, if possible.
*/
@@ -318,89 +203,3 @@ make_output(const string &name,
// Nothing else left to try.
return NULL;
}
-
-/**
- * Called once to make an invisible Cursor for return from
- * get_hidden_cursor().
- */
-void eglGraphicsPipe::
-make_hidden_cursor() {
- nassertv(_hidden_cursor == None);
-
- unsigned int x_size, y_size;
- XQueryBestCursor(_display, _root, 1, 1, &x_size, &y_size);
-
- Pixmap empty = XCreatePixmap(_display, _root, x_size, y_size, 1);
-
- XColor black;
- memset(&black, 0, sizeof(black));
-
- _hidden_cursor = XCreatePixmapCursor(_display, empty, empty,
- &black, &black, x_size, y_size);
- XFreePixmap(_display, empty);
-}
-
-/**
- * Called once to release the invisible cursor created by
- * make_hidden_cursor().
- */
-void eglGraphicsPipe::
-release_hidden_cursor() {
- if (_hidden_cursor != None) {
- XFreeCursor(_display, _hidden_cursor);
- _hidden_cursor = None;
- }
-}
-
-/**
- * Installs new Xlib error handler functions if this is the first time this
- * function has been called. These error handler functions will attempt to
- * reduce Xlib's annoying tendency to shut down the client at the first error.
- * Unfortunately, it is difficult to play nice with the client if it has
- * already installed its own error handlers.
- */
-void eglGraphicsPipe::
-install_error_handlers() {
- if (_error_handlers_installed) {
- return;
- }
-
- _prev_error_handler = (ErrorHandlerFunc *)XSetErrorHandler(error_handler);
- _prev_io_error_handler = (IOErrorHandlerFunc *)XSetIOErrorHandler(io_error_handler);
- _error_handlers_installed = true;
-}
-
-/**
- * This function is installed as the error handler for a non-fatal Xlib error.
- */
-int eglGraphicsPipe::
-error_handler(X11_Display *display, XErrorEvent *error) {
- static const int msg_len = 80;
- char msg[msg_len];
- XGetErrorText(display, error->error_code, msg, msg_len);
- egldisplay_cat.error()
- << msg << "\n";
-
- if (x_error_abort) {
- abort();
- }
-
- // We return to allow the application to continue running, unlike the
- // default X error handler which exits.
- return 0;
-}
-
-/**
- * This function is installed as the error handler for a fatal Xlib error.
- */
-int eglGraphicsPipe::
-io_error_handler(X11_Display *display) {
- egldisplay_cat.fatal()
- << "X fatal error on display " << (void *)display << "\n";
-
- // Unfortunately, we can't continue from this function, even if we promise
- // never to use X again. We're supposed to terminate without returning, and
- // if we do return, the caller will exit anyway. Sigh. Very poor design on
- // X's part.
- return 0;
-}
diff --git a/panda/src/egldisplay/eglGraphicsPipe.h b/panda/src/egldisplay/eglGraphicsPipe.h
index 3cd9682350..aea34925e6 100644
--- a/panda/src/egldisplay/eglGraphicsPipe.h
+++ b/panda/src/egldisplay/eglGraphicsPipe.h
@@ -15,11 +15,7 @@
#define EGLGRAPHICSPIPE_H
#include "pandabase.h"
-#include "graphicsWindow.h"
-#include "graphicsPipe.h"
-#include "lightMutex.h"
-#include "lightReMutex.h"
-#include "get_x11.h"
+#include "x11GraphicsPipe.h"
#ifdef OPENGLES_2
#include "gles2gsg.h"
@@ -46,7 +42,7 @@ class eglGraphicsWindow;
* This graphics pipe represents the interface for creating OpenGL ES graphics
* windows on an X-based (e.g. Unix) client.
*/
-class eglGraphicsPipe : public GraphicsPipe {
+class eglGraphicsPipe : public x11GraphicsPipe {
public:
eglGraphicsPipe(const string &display = string());
virtual ~eglGraphicsPipe();
@@ -54,29 +50,6 @@ public:
virtual string get_interface_name() const;
static PT(GraphicsPipe) pipe_constructor();
- INLINE X11_Display *get_display() const;
- INLINE int get_screen() const;
- INLINE X11_Window get_root() const;
- INLINE XIM get_im() const;
-
- INLINE X11_Cursor get_hidden_cursor();
-
-public:
- virtual PreferredWindowThread get_preferred_window_thread() const;
-
-public:
- // Atom specifications.
- Atom _wm_delete_window;
- Atom _net_wm_window_type;
- Atom _net_wm_window_type_splash;
- Atom _net_wm_window_type_fullscreen;
- Atom _net_wm_state;
- Atom _net_wm_state_fullscreen;
- Atom _net_wm_state_above;
- Atom _net_wm_state_below;
- Atom _net_wm_state_add;
- Atom _net_wm_state_remove;
-
protected:
virtual PT(GraphicsOutput) make_output(const string &name,
const FrameBufferProperties &fb_prop,
@@ -89,40 +62,16 @@ protected:
bool &precertify);
private:
- void make_hidden_cursor();
- void release_hidden_cursor();
-
- static void install_error_handlers();
- static int error_handler(X11_Display *display, XErrorEvent *error);
- static int io_error_handler(X11_Display *display);
-
- X11_Display *_display;
- int _screen;
- X11_Window _root;
- XIM _im;
EGLDisplay _egl_display;
- X11_Cursor _hidden_cursor;
-
- typedef int ErrorHandlerFunc(X11_Display *, XErrorEvent *);
- typedef int IOErrorHandlerFunc(X11_Display *);
- static bool _error_handlers_installed;
- static ErrorHandlerFunc *_prev_error_handler;
- static IOErrorHandlerFunc *_prev_io_error_handler;
-
-public:
- // This Mutex protects any X library calls, which all have to be single-
- // threaded. In particular, it protects eglMakeCurrent().
- static LightReMutex _x_mutex;
-
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
- GraphicsPipe::init_type();
+ x11GraphicsPipe::init_type();
register_type(_type_handle, "eglGraphicsPipe",
- GraphicsPipe::get_class_type());
+ x11GraphicsPipe::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx
index 5168bd575e..84fc303efb 100644
--- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx
+++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx
@@ -257,8 +257,9 @@ reset() {
// If "Mesa" is present, assume software. However, if "Mesa DRI" is found,
// it's actually a Mesa-based OpenGL layer running over a hardware driver.
- if (_gl_renderer.find("Mesa") != string::npos &&
- _gl_renderer.find("Mesa DRI") == string::npos) {
+ if (_gl_renderer == "Software Rasterizer" ||
+ (_gl_renderer.find("Mesa") != string::npos &&
+ _gl_renderer.find("Mesa DRI") == string::npos)) {
// It's Mesa, therefore probably a software context.
_fbprops.set_force_software(1);
_fbprops.set_force_hardware(0);
diff --git a/panda/src/egldisplay/eglGraphicsWindow.I b/panda/src/egldisplay/eglGraphicsWindow.I
index 0f3a6bb472..54fa89ab46 100644
--- a/panda/src/egldisplay/eglGraphicsWindow.I
+++ b/panda/src/egldisplay/eglGraphicsWindow.I
@@ -10,11 +10,3 @@
* @author rdb
* @date 2009-05-21
*/
-
-/**
- * Returns the X11 Window handle.
- */
-INLINE X11_Window eglGraphicsWindow::
-get_xwindow() const {
- return _xwindow;
-}
diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx
index 7299815739..b7e7d5dccf 100644
--- a/panda/src/egldisplay/eglGraphicsWindow.cxx
+++ b/panda/src/egldisplay/eglGraphicsWindow.cxx
@@ -27,17 +27,8 @@
#include "nativeWindowHandle.h"
#include "get_x11.h"
-#include
-#include
-
-#ifdef HAVE_LINUX_INPUT_H
-#include
-#endif
-
TypeHandle eglGraphicsWindow::_type_handle;
-#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)&7)))
-
/**
*
*/
@@ -49,31 +40,12 @@ eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
int flags,
GraphicsStateGuardian *gsg,
GraphicsOutput *host) :
- GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
+ x11GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
{
eglGraphicsPipe *egl_pipe;
DCAST_INTO_V(egl_pipe, _pipe);
- _display = egl_pipe->get_display();
- _screen = egl_pipe->get_screen();
- _xwindow = (X11_Window)NULL;
- _ic = (XIC)NULL;
_egl_display = egl_pipe->_egl_display;
_egl_surface = 0;
- _awaiting_configure = false;
- _wm_delete_window = egl_pipe->_wm_delete_window;
- _net_wm_window_type = egl_pipe->_net_wm_window_type;
- _net_wm_window_type_splash = egl_pipe->_net_wm_window_type_splash;
- _net_wm_window_type_fullscreen = egl_pipe->_net_wm_window_type_fullscreen;
- _net_wm_state = egl_pipe->_net_wm_state;
- _net_wm_state_fullscreen = egl_pipe->_net_wm_state_fullscreen;
- _net_wm_state_above = egl_pipe->_net_wm_state_above;
- _net_wm_state_below = egl_pipe->_net_wm_state_below;
- _net_wm_state_add = egl_pipe->_net_wm_state_add;
- _net_wm_state_remove = egl_pipe->_net_wm_state_remove;
-
- GraphicsWindowInputDevice device =
- GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
- add_input_device(device);
}
/**
@@ -222,327 +194,6 @@ end_flip() {
GraphicsWindow::end_flip();
}
-/**
- * Do whatever processing is necessary to ensure that the window responds to
- * user events. Also, honor any requests recently made via
- * request_properties()
- *
- * This function is called only within the window thread.
- */
-void eglGraphicsWindow::
-process_events() {
- LightReMutexHolder holder(eglGraphicsPipe::_x_mutex);
-
- GraphicsWindow::process_events();
-
- if (_xwindow == (X11_Window)0) {
- return;
- }
-
- poll_raw_mice();
-
- XEvent event;
- XKeyEvent keyrelease_event;
- bool got_keyrelease_event = false;
-
- while (XCheckIfEvent(_display, &event, check_event, (char *)this)) {
- if (XFilterEvent(&event, None)) {
- continue;
- }
-
- if (got_keyrelease_event) {
- // If a keyrelease event is immediately followed by a matching keypress
- // event, that's just key repeat and we should treat the two events
- // accordingly. It would be nice if X provided a way to differentiate
- // between keyrepeat and explicit keypresses more generally.
- got_keyrelease_event = false;
-
- if (event.type == KeyPress &&
- event.xkey.keycode == keyrelease_event.keycode &&
- (event.xkey.time - keyrelease_event.time <= 1)) {
- // In particular, we only generate down messages for the repeated
- // keys, not down-and-up messages.
- handle_keystroke(event.xkey);
-
- // We thought about not generating the keypress event, but we need
- // that repeat for backspace. Rethink later.
- handle_keypress(event.xkey);
- continue;
-
- } else {
- // This keyrelease event is not immediately followed by a matching
- // keypress event, so it's a genuine release.
- handle_keyrelease(keyrelease_event);
- }
- }
-
- WindowProperties properties;
- ButtonHandle button;
-
- switch (event.type) {
- case ReparentNotify:
- break;
-
- case ConfigureNotify:
- _awaiting_configure = false;
- if (_properties.get_fixed_size()) {
- // If the window properties indicate a fixed size only, undo any
- // attempt by the user to change them. In X, there doesn't appear to
- // be a way to universally disallow this directly (although we do set
- // the min_size and max_size to the same value, which seems to work
- // for most window managers.)
- WindowProperties current_props = get_properties();
- if (event.xconfigure.width != current_props.get_x_size() ||
- event.xconfigure.height != current_props.get_y_size()) {
- XWindowChanges changes;
- changes.width = current_props.get_x_size();
- changes.height = current_props.get_y_size();
- int value_mask = (CWWidth | CWHeight);
- XConfigureWindow(_display, _xwindow, value_mask, &changes);
- }
-
- } else {
- // A normal window may be resized by the user at will.
- properties.set_size(event.xconfigure.width, event.xconfigure.height);
- system_changed_properties(properties);
- }
- break;
-
- case ButtonPress:
- // This refers to the mouse buttons.
- button = get_mouse_button(event.xbutton);
- _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
- _input_devices[0].button_down(button);
- break;
-
- case ButtonRelease:
- button = get_mouse_button(event.xbutton);
- _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
- _input_devices[0].button_up(button);
- break;
-
- case MotionNotify:
- _input_devices[0].set_pointer_in_window(event.xmotion.x, event.xmotion.y);
- break;
-
- case KeyPress:
- handle_keystroke(event.xkey);
- handle_keypress(event.xkey);
- break;
-
- case KeyRelease:
- // The KeyRelease can't be processed immediately, because we have to
- // check first if it's immediately followed by a matching KeyPress
- // event.
- keyrelease_event = event.xkey;
- got_keyrelease_event = true;
- break;
-
- case EnterNotify:
- _input_devices[0].set_pointer_in_window(event.xcrossing.x, event.xcrossing.y);
- break;
-
- case LeaveNotify:
- _input_devices[0].set_pointer_out_of_window();
- break;
-
- case FocusIn:
- properties.set_foreground(true);
- system_changed_properties(properties);
- break;
-
- case FocusOut:
- properties.set_foreground(false);
- system_changed_properties(properties);
- break;
-
- case UnmapNotify:
- properties.set_minimized(true);
- system_changed_properties(properties);
- break;
-
- case MapNotify:
- properties.set_minimized(false);
- system_changed_properties(properties);
-
- // Auto-focus the window when it is mapped.
- XSetInputFocus(_display, _xwindow, RevertToPointerRoot, CurrentTime);
- break;
-
- case ClientMessage:
- if ((Atom)(event.xclient.data.l[0]) == _wm_delete_window) {
- // This is a message from the window manager indicating that the user
- // has requested to close the window.
- string close_request_event = get_close_request_event();
- if (!close_request_event.empty()) {
- // In this case, the app has indicated a desire to intercept the
- // request and process it directly.
- throw_event(close_request_event);
-
- } else {
- // In this case, the default case, the app does not intend to
- // service the request, so we do by closing the window.
-
- // TODO: don't release the gsg in the window thread.
- close_window();
- properties.set_open(false);
- system_changed_properties(properties);
- }
- }
- break;
-
- case DestroyNotify:
- // Apparently, we never get a DestroyNotify on a toplevel window.
- // Instead, we rely on hints from the window manager (see above).
- egldisplay_cat.info()
- << "DestroyNotify\n";
- break;
-
- default:
- egldisplay_cat.error()
- << "unhandled X event type " << event.type << "\n";
- }
- }
-
- if (got_keyrelease_event) {
- // This keyrelease event is not immediately followed by a matching
- // keypress event, so it's a genuine release.
- handle_keyrelease(keyrelease_event);
- }
-}
-
-/**
- * Applies the requested set of properties to the window, if possible, for
- * instance to request a change in size or minimization status.
- *
- * The window properties are applied immediately, rather than waiting until
- * the next frame. This implies that this method may *only* be called from
- * within the window thread.
- *
- * The return value is true if the properties are set, false if they are
- * ignored. This is mainly useful for derived classes to implement extensions
- * to this function.
- */
-void eglGraphicsWindow::
-set_properties_now(WindowProperties &properties) {
- if (_pipe == (GraphicsPipe *)NULL) {
- // If the pipe is null, we're probably closing down.
- GraphicsWindow::set_properties_now(properties);
- return;
- }
-
- eglGraphicsPipe *egl_pipe;
- DCAST_INTO_V(egl_pipe, _pipe);
-
- // Fullscreen mode is implemented with a hint to the window manager.
- // However, we also implicitly set the origin to (0, 0) and the size to the
- // desktop size, and request undecorated mode, in case the user has a less-
- // capable window manager (or no window manager at all).
- if (properties.get_fullscreen()) {
- properties.set_undecorated(true);
- properties.set_origin(0, 0);
- properties.set_size(egl_pipe->get_display_width(),
- egl_pipe->get_display_height());
- }
-
- GraphicsWindow::set_properties_now(properties);
- if (!properties.is_any_specified()) {
- // The base class has already handled this case.
- return;
- }
-
- // The window is already open; we are limited to what we can change on the
- // fly.
-
- // We'll pass some property requests on as a window manager hint.
- WindowProperties wm_properties = _properties;
- wm_properties.add_properties(properties);
-
- // The window title may be changed by issuing another hint request. Assume
- // this will be honored.
- if (properties.has_title()) {
- _properties.set_title(properties.get_title());
- properties.clear_title();
- }
-
- // Ditto for fullscreen mode.
- if (properties.has_fullscreen()) {
- _properties.set_fullscreen(properties.get_fullscreen());
- properties.clear_fullscreen();
- }
-
- // The size and position of an already-open window are changed via explicit
- // X calls. These may still get intercepted by the window manager. Rather
- // than changing _properties immediately, we'll wait for the ConfigureNotify
- // message to come back.
- XWindowChanges changes;
- int value_mask = 0;
-
- if (properties.has_origin()) {
- changes.x = properties.get_x_origin();
- changes.y = properties.get_y_origin();
- value_mask |= (CWX | CWY);
- properties.clear_origin();
- }
- if (properties.has_size()) {
- changes.width = properties.get_x_size();
- changes.height = properties.get_y_size();
- value_mask |= (CWWidth | CWHeight);
- properties.clear_size();
- }
- if (properties.has_z_order()) {
- // We'll send the classic stacking request through the standard interface,
- // for users of primitive window managers; but we'll also send it as a
- // window manager hint, for users of modern window managers.
- _properties.set_z_order(properties.get_z_order());
- switch (properties.get_z_order()) {
- case WindowProperties::Z_bottom:
- changes.stack_mode = Below;
- break;
-
- case WindowProperties::Z_normal:
- changes.stack_mode = TopIf;
- break;
-
- case WindowProperties::Z_top:
- changes.stack_mode = Above;
- break;
- }
-
- value_mask |= (CWStackMode);
- properties.clear_z_order();
- }
-
- if (value_mask != 0) {
- XReconfigureWMWindow(_display, _xwindow, _screen, value_mask, &changes);
-
- // Don't draw anything until this is done reconfiguring.
- _awaiting_configure = true;
- }
-
- // We hide the cursor by setting it to an invisible pixmap.
- if (properties.has_cursor_hidden()) {
- _properties.set_cursor_hidden(properties.get_cursor_hidden());
- if (properties.get_cursor_hidden()) {
- XDefineCursor(_display, _xwindow, egl_pipe->get_hidden_cursor());
- } else {
- XDefineCursor(_display, _xwindow, None);
- }
- properties.clear_cursor_hidden();
- }
-
- if (properties.has_foreground()) {
- if (properties.get_foreground()) {
- XSetInputFocus(_display, _xwindow, RevertToPointerRoot, CurrentTime);
- } else {
- XSetInputFocus(_display, PointerRoot, RevertToPointerRoot, CurrentTime);
- }
- properties.clear_foreground();
- }
-
- set_wm_properties(wm_properties, true);
-}
-
/**
* Closes the window right now. Called from the window thread.
*/
@@ -606,97 +257,19 @@ open_window() {
}
}
- XVisualInfo *visual_info = eglgsg->_visual;
- if (visual_info == NULL) {
+ _visual_info = eglgsg->_visual;
+ if (_visual_info == NULL) {
// No X visual for this fbconfig; how can we open the window?
egldisplay_cat.error()
<< "No X visual: cannot open window.\n";
return false;
}
- Visual *visual = visual_info->visual;
- int depth = visual_info->depth;
- if (!_properties.has_origin()) {
- _properties.set_origin(0, 0);
- }
- if (!_properties.has_size()) {
- _properties.set_size(100, 100);
- }
+ setup_colormap(_visual_info);
- X11_Window parent_window = egl_pipe->get_root();
- WindowHandle *window_handle = _properties.get_parent_window();
- if (window_handle != NULL) {
- egldisplay_cat.info()
- << "Got parent_window " << *window_handle << "\n";
- WindowHandle::OSHandle *os_handle = window_handle->get_os_handle();
- if (os_handle != NULL) {
- egldisplay_cat.info()
- << "os_handle type " << os_handle->get_type() << "\n";
-
- if (os_handle->is_of_type(NativeWindowHandle::X11Handle::get_class_type())) {
- NativeWindowHandle::X11Handle *x11_handle = DCAST(NativeWindowHandle::X11Handle, os_handle);
- parent_window = x11_handle->get_handle();
- } else if (os_handle->is_of_type(NativeWindowHandle::IntHandle::get_class_type())) {
- NativeWindowHandle::IntHandle *int_handle = DCAST(NativeWindowHandle::IntHandle, os_handle);
- parent_window = (X11_Window)int_handle->get_handle();
- }
- }
- }
- _parent_window_handle = window_handle;
-
- setup_colormap(visual_info);
-
- _event_mask =
- ButtonPressMask | ButtonReleaseMask |
- KeyPressMask | KeyReleaseMask |
- EnterWindowMask | LeaveWindowMask |
- PointerMotionMask |
- FocusChangeMask |
- StructureNotifyMask;
-
- // Initialize window attributes
- XSetWindowAttributes wa;
- wa.background_pixel = XBlackPixel(_display, _screen);
- wa.border_pixel = 0;
- wa.colormap = _colormap;
- wa.event_mask = _event_mask;
-
- unsigned long attrib_mask =
- CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
-
- _xwindow = XCreateWindow
- (_display, parent_window,
- _properties.get_x_origin(), _properties.get_y_origin(),
- _properties.get_x_size(), _properties.get_y_size(),
- 0, depth, InputOutput, visual, attrib_mask, &wa);
-
- if (_xwindow == (X11_Window)0) {
- egldisplay_cat.error()
- << "failed to create X window.\n";
+ if (!x11GraphicsWindow::open_window()) {
return false;
}
- set_wm_properties(_properties, false);
-
- // We don't specify any fancy properties of the XIC. It would be nicer if
- // we could support fancy IM's that want preedit callbacks, etc., but that
- // can wait until we have an X server that actually supports these to test
- // it on.
- XIM im = egl_pipe->get_im();
- _ic = NULL;
- if (im) {
- _ic = XCreateIC
- (im,
- XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
- (void*)NULL);
- if (_ic == (XIC)NULL) {
- egldisplay_cat.warning()
- << "Couldn't create input context.\n";
- }
- }
-
- if (_properties.get_cursor_hidden()) {
- XDefineCursor(_display, _xwindow, egl_pipe->get_hidden_cursor());
- }
_egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow, NULL);
if (eglGetError() != EGL_SUCCESS) {
@@ -721,923 +294,5 @@ open_window() {
}
_fb_properties = eglgsg->get_fb_properties();
- XMapWindow(_display, _xwindow);
-
- if (_properties.get_raw_mice()) {
- open_raw_mice();
- } else {
- if (egldisplay_cat.is_debug()) {
- egldisplay_cat.debug()
- << "Raw mice not requested.\n";
- }
- }
-
- // Create a WindowHandle for ourselves
- _window_handle = NativeWindowHandle::make_x11(_xwindow);
-
- // And tell our parent window that we're now its child.
- if (_parent_window_handle != (WindowHandle *)NULL) {
- _parent_window_handle->attach_child(_window_handle);
- }
-
return true;
}
-
-/**
- * Asks the window manager to set the appropriate properties. In X, these
- * properties cannot be specified directly by the application; they must be
- * requested via the window manager, which may or may not choose to honor the
- * request.
- *
- * If already_mapped is true, the window has already been mapped (manifested)
- * on the display. This means we may need to use a different action in some
- * cases.
- */
-void eglGraphicsWindow::
-set_wm_properties(const WindowProperties &properties, bool already_mapped) {
- // Name the window if there is a name
- XTextProperty window_name;
- XTextProperty *window_name_p = (XTextProperty *)NULL;
- if (properties.has_title()) {
- char *name = (char *)properties.get_title().c_str();
- if (XStringListToTextProperty(&name, 1, &window_name) != 0) {
- window_name_p = &window_name;
- }
- }
-
- // The size hints request a window of a particular size andor a particular
- // placement onscreen.
- XSizeHints *size_hints_p = NULL;
- if (properties.has_origin() || properties.has_size()) {
- size_hints_p = XAllocSizeHints();
- if (size_hints_p != (XSizeHints *)NULL) {
- if (properties.has_origin()) {
- size_hints_p->x = properties.get_x_origin();
- size_hints_p->y = properties.get_y_origin();
- size_hints_p->flags |= USPosition;
- }
- if (properties.has_size()) {
- size_hints_p->width = properties.get_x_size();
- size_hints_p->height = properties.get_y_size();
- size_hints_p->flags |= USSize;
-
- if (properties.get_fixed_size()) {
- size_hints_p->min_width = properties.get_x_size();
- size_hints_p->min_height = properties.get_y_size();
- size_hints_p->max_width = properties.get_x_size();
- size_hints_p->max_height = properties.get_y_size();
- size_hints_p->flags |= (PMinSize | PMaxSize);
- }
- }
- }
- }
-
- // The window manager hints include requests to the window manager other
- // than those specific to window geometry.
- XWMHints *wm_hints_p = NULL;
- wm_hints_p = XAllocWMHints();
- if (wm_hints_p != (XWMHints *)NULL) {
- if (properties.has_minimized() && properties.get_minimized()) {
- wm_hints_p->initial_state = IconicState;
- } else {
- wm_hints_p->initial_state = NormalState;
- }
- wm_hints_p->flags = StateHint;
- }
-
- // Two competing window manager interfaces have evolved. One of them allows
- // to set certain properties as a "type"; the other one as a "state". We'll
- // try to honor both.
- static const int max_type_data = 32;
- PN_int32 type_data[max_type_data];
- int next_type_data = 0;
-
- static const int max_state_data = 32;
- PN_int32 state_data[max_state_data];
- int next_state_data = 0;
-
- static const int max_set_data = 32;
- class SetAction {
- public:
- inline SetAction() { }
- inline SetAction(Atom state, Atom action) : _state(state), _action(action) { }
- Atom _state;
- Atom _action;
- };
- SetAction set_data[max_set_data];
- int next_set_data = 0;
-
- if (properties.get_fullscreen()) {
- // For a "fullscreen" request, we pass this through, hoping the window
- // manager will support EWMH.
- type_data[next_type_data++] = _net_wm_window_type_fullscreen;
-
- // We also request it as a state.
- state_data[next_state_data++] = _net_wm_state_fullscreen;
- set_data[next_set_data++] = SetAction(_net_wm_state_fullscreen, _net_wm_state_add);
- } else {
- set_data[next_set_data++] = SetAction(_net_wm_state_fullscreen, _net_wm_state_remove);
- }
-
- // If we asked for a window without a border, there's no excellent way to
- // arrange that. For users whose window managers follow the EWMH
- // specification, we can ask for a "splash" screen, which is usually
- // undecorated. It's not exactly right, but the spec doesn't give us an
- // exactly-right option.
-
- // For other users, we'll totally punt and just set the window's Class to
- // "Undecorated", and let the user configure hisher window manager not to
- // put a border around windows of this class.
- XClassHint *class_hints_p = NULL;
- if (properties.get_undecorated()) {
- class_hints_p = XAllocClassHint();
- class_hints_p->res_class = (char*) "Undecorated";
-
- if (!properties.get_fullscreen()) {
- type_data[next_type_data++] = _net_wm_window_type_splash;
- }
- }
-
- if (properties.has_z_order()) {
- switch (properties.get_z_order()) {
- case WindowProperties::Z_bottom:
- state_data[next_state_data++] = _net_wm_state_below;
- set_data[next_set_data++] = SetAction(_net_wm_state_below, _net_wm_state_add);
- set_data[next_set_data++] = SetAction(_net_wm_state_above, _net_wm_state_remove);
- break;
-
- case WindowProperties::Z_normal:
- set_data[next_set_data++] = SetAction(_net_wm_state_below, _net_wm_state_remove);
- set_data[next_set_data++] = SetAction(_net_wm_state_above, _net_wm_state_remove);
- break;
-
- case WindowProperties::Z_top:
- state_data[next_state_data++] = _net_wm_state_above;
- set_data[next_set_data++] = SetAction(_net_wm_state_below, _net_wm_state_remove);
- set_data[next_set_data++] = SetAction(_net_wm_state_above, _net_wm_state_add);
- break;
- }
- }
-
- nassertv(next_type_data < max_type_data);
- nassertv(next_state_data < max_state_data);
- nassertv(next_set_data < max_set_data);
-
- XChangeProperty(_display, _xwindow, _net_wm_window_type,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *)type_data, next_type_data);
-
- // Request the state properties all at once.
- XChangeProperty(_display, _xwindow, _net_wm_state,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *)state_data, next_state_data);
-
- if (already_mapped) {
- // We have to request state changes differently when the window has been
- // mapped. To do this, we need to send a client message to the root
- // window for each change.
-
- eglGraphicsPipe *egl_pipe;
- DCAST_INTO_V(egl_pipe, _pipe);
-
- for (int i = 0; i < next_set_data; ++i) {
- XClientMessageEvent event;
- memset(&event, 0, sizeof(event));
-
- event.type = ClientMessage;
- event.send_event = True;
- event.display = _display;
- event.window = _xwindow;
- event.message_type = _net_wm_state;
- event.format = 32;
- event.data.l[0] = set_data[i]._action;
- event.data.l[1] = set_data[i]._state;
- event.data.l[2] = 0;
- event.data.l[3] = 1;
-
- XSendEvent(_display, egl_pipe->get_root(), True, 0, (XEvent *)&event);
- }
- }
-
- XSetWMProperties(_display, _xwindow, window_name_p, window_name_p,
- NULL, 0, size_hints_p, wm_hints_p, class_hints_p);
-
- if (size_hints_p != (XSizeHints *)NULL) {
- XFree(size_hints_p);
- }
- if (wm_hints_p != (XWMHints *)NULL) {
- XFree(wm_hints_p);
- }
- if (class_hints_p != (XClassHint *)NULL) {
- XFree(class_hints_p);
- }
-
- // Also, indicate to the window manager that we'd like to get a chance to
- // close our windows cleanly, rather than being rudely disconnected from the
- // X server if the user requests a window close.
- Atom protocols[] = {
- _wm_delete_window,
- };
-
- XSetWMProtocols(_display, _xwindow, protocols,
- sizeof(protocols) / sizeof(Atom));
-}
-
-/**
- * Allocates a colormap appropriate to the visual and stores in in the
- * _colormap method.
- */
-void eglGraphicsWindow::
-setup_colormap(XVisualInfo *visual) {
- eglGraphicsPipe *egl_pipe;
- DCAST_INTO_V(egl_pipe, _pipe);
- X11_Window root_window = egl_pipe->get_root();
-
- int visual_class = visual->c_class;
- int rc, is_rgb;
-
- switch (visual_class) {
- case PseudoColor:
- _colormap = XCreateColormap(_display, root_window,
- visual->visual, AllocAll);
- break;
- case TrueColor:
- case DirectColor:
- _colormap = XCreateColormap(_display, root_window,
- visual->visual, AllocNone);
- break;
- case StaticColor:
- case StaticGray:
- case GrayScale:
- _colormap = XCreateColormap(_display, root_window,
- visual->visual, AllocNone);
- break;
- default:
- egldisplay_cat.error()
- << "Could not allocate a colormap for visual class "
- << visual_class << ".\n";
- break;
- }
-}
-
-/**
- * Adds raw mice to the _input_devices list.
- */
-void eglGraphicsWindow::
-open_raw_mice()
-{
-#ifdef HAVE_LINUX_INPUT_H
- bool any_present = false;
- bool any_mice = false;
-
- for (int i=0; i<64; i++) {
- uint8_t evtypes[EV_MAX/8 + 1];
- ostringstream fnb;
- fnb << "/dev/input/event" << i;
- string fn = fnb.str();
- int fd = open(fn.c_str(), O_RDONLY | O_NONBLOCK, 0);
- if (fd >= 0) {
- any_present = true;
- char name[256];
- char phys[256];
- char uniq[256];
- if ((ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0)||
- (ioctl(fd, EVIOCGPHYS(sizeof(phys)), phys) < 0)||
- (ioctl(fd, EVIOCGPHYS(sizeof(uniq)), uniq) < 0)||
- (ioctl(fd, EVIOCGBIT(0, EV_MAX), &evtypes) < 0)) {
- close(fd);
- egldisplay_cat.error() <<
- "Opening raw mice: ioctl failed on " << fn << "\n";
- } else {
- if (test_bit(EV_REL, evtypes) || test_bit(EV_ABS, evtypes)) {
- for (char *p=name; *p; p++) {
- if (((*p<'a')||(*p>'z')) && ((*p<'A')||(*p>'Z')) && ((*p<'0')||(*p>'9'))) {
- *p = '_';
- }
- }
- for (char *p=uniq; *p; p++) {
- if (((*p<'a')||(*p>'z')) && ((*p<'A')||(*p>'Z')) && ((*p<'0')||(*p>'9'))) {
- *p = '_';
- }
- }
- string full_id = ((string)name) + "." + uniq;
- MouseDeviceInfo inf;
- inf._fd = fd;
- inf._input_device_index = _input_devices.size();
- inf._io_buffer = "";
- _mouse_device_info.push_back(inf);
- GraphicsWindowInputDevice device =
- GraphicsWindowInputDevice::pointer_only(this, full_id);
- add_input_device(device);
- egldisplay_cat.info() << "Raw mouse " <<
- inf._input_device_index << " detected: " << full_id << "\n";
- any_mice = true;
- } else {
- close(fd);
- }
- }
- } else {
- if ((errno == ENOENT)||(errno == ENOTDIR)) {
- break;
- } else {
- any_present = true;
- egldisplay_cat.error() <<
- "Opening raw mice: " << strerror(errno) << " " << fn << "\n";
- }
- }
- }
-
- if (!any_present) {
- egldisplay_cat.error() <<
- "Opening raw mice: files not found: /dev/input/event*\n";
- } else if (!any_mice) {
- egldisplay_cat.error() <<
- "Opening raw mice: no mouse devices detected in /dev/input/event*\n";
- }
-#else
- egldisplay_cat.error() <<
- "Opening raw mice: panda not compiled with raw mouse support.\n";
-#endif
-}
-
-/**
- * Reads events from the raw mouse device files.
- */
-void eglGraphicsWindow::
-poll_raw_mice()
-{
-#ifdef HAVE_LINUX_INPUT_H
- for (int dev=0; dev<_mouse_device_info.size(); dev++) {
- MouseDeviceInfo &inf = _mouse_device_info[dev];
-
- // Read all bytes into buffer.
- if (inf._fd >= 0) {
- while (1) {
- char tbuf[1024];
- int nread = read(inf._fd, tbuf, sizeof(tbuf));
- if (nread > 0) {
- inf._io_buffer += string(tbuf, nread);
- } else {
- if ((nread < 0)&&((errno == EWOULDBLOCK) || (errno==EAGAIN))) {
- break;
- }
- close(inf._fd);
- inf._fd = -1;
- break;
- }
- }
- }
-
- // Process events.
- int nevents = inf._io_buffer.size() / sizeof(struct input_event);
- if (nevents == 0) {
- continue;
- }
- const input_event *events = (const input_event *)(inf._io_buffer.c_str());
- GraphicsWindowInputDevice &dev = _input_devices[inf._input_device_index];
- int x = dev.get_raw_pointer().get_x();
- int y = dev.get_raw_pointer().get_y();
- for (int i=0; i= BTN_MOUSE)&&(events[i].code < BTN_MOUSE+8)) {
- int btn = events[i].code - BTN_MOUSE;
- dev.set_pointer_in_window(x,y);
- if (events[i].value) {
- dev.button_down(MouseButton::button(btn));
- } else {
- dev.button_up(MouseButton::button(btn));
- }
- }
- }
- }
- inf._io_buffer.erase(0,nevents*sizeof(struct input_event));
- dev.set_pointer_in_window(x,y);
- }
-#endif
-}
-
-/**
- * Generates a keystroke corresponding to the indicated X KeyPress event.
- */
-void eglGraphicsWindow::
-handle_keystroke(XKeyEvent &event) {
- _input_devices[0].set_pointer_in_window(event.x, event.y);
-
- if (_ic) {
- // First, get the keystroke as a wide-character sequence.
- static const int buffer_size = 256;
- wchar_t buffer[buffer_size];
- Status status;
- int len = XwcLookupString(_ic, &event, buffer, buffer_size, NULL,
- &status);
- if (status == XBufferOverflow) {
- egldisplay_cat.error()
- << "Overflowed input buffer.\n";
- }
-
- // Now each of the returned wide characters represents a keystroke.
- for (int i = 0; i < len; i++) {
- _input_devices[0].keystroke(buffer[i]);
- }
-
- } else {
- // Without an input context, just get the ascii keypress.
- ButtonHandle button = get_button(event, true);
- if (button.has_ascii_equivalent()) {
- _input_devices[0].keystroke(button.get_ascii_equivalent());
- }
- }
-}
-
-/**
- * Generates a keypress corresponding to the indicated X KeyPress event.
- */
-void eglGraphicsWindow::
-handle_keypress(XKeyEvent &event) {
- _input_devices[0].set_pointer_in_window(event.x, event.y);
-
- // Now get the raw unshifted button.
- ButtonHandle button = get_button(event, false);
- if (button != ButtonHandle::none()) {
- if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
- _input_devices[0].button_down(KeyboardButton::control());
- }
- if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
- _input_devices[0].button_down(KeyboardButton::shift());
- }
- if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
- _input_devices[0].button_down(KeyboardButton::alt());
- }
- if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
- _input_devices[0].button_down(KeyboardButton::meta());
- }
- _input_devices[0].button_down(button);
- }
-}
-
-/**
- * Generates a keyrelease corresponding to the indicated X KeyRelease event.
- */
-void eglGraphicsWindow::
-handle_keyrelease(XKeyEvent &event) {
- _input_devices[0].set_pointer_in_window(event.x, event.y);
-
- // Now get the raw unshifted button.
- ButtonHandle button = get_button(event, false);
- if (button != ButtonHandle::none()) {
- if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
- _input_devices[0].button_up(KeyboardButton::control());
- }
- if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
- _input_devices[0].button_up(KeyboardButton::shift());
- }
- if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
- _input_devices[0].button_up(KeyboardButton::alt());
- }
- if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
- _input_devices[0].button_up(KeyboardButton::meta());
- }
- _input_devices[0].button_up(button);
- }
-}
-
-/**
- * Returns the Panda ButtonHandle corresponding to the keyboard button
- * indicated by the given key event.
- */
-ButtonHandle eglGraphicsWindow::
-get_button(XKeyEvent &key_event, bool allow_shift) {
- KeySym key = XLookupKeysym(&key_event, 0);
-
- if ((key_event.state & Mod2Mask) != 0) {
- // Mod2Mask corresponds to NumLock being in effect. In this case, we want
- // to get the alternate keysym associated with any keypad keys. Weird
- // system.
- KeySym k2;
- ButtonHandle button;
- switch (key) {
- case XK_KP_Space:
- case XK_KP_Tab:
- case XK_KP_Enter:
- case XK_KP_F1:
- case XK_KP_F2:
- case XK_KP_F3:
- case XK_KP_F4:
- case XK_KP_Equal:
- case XK_KP_Multiply:
- case XK_KP_Add:
- case XK_KP_Separator:
- case XK_KP_Subtract:
- case XK_KP_Divide:
- case XK_KP_Left:
- case XK_KP_Up:
- case XK_KP_Right:
- case XK_KP_Down:
- case XK_KP_Begin:
- case XK_KP_Prior:
- case XK_KP_Next:
- case XK_KP_Home:
- case XK_KP_End:
- case XK_KP_Insert:
- case XK_KP_Delete:
- case XK_KP_0:
- case XK_KP_1:
- case XK_KP_2:
- case XK_KP_3:
- case XK_KP_4:
- case XK_KP_5:
- case XK_KP_6:
- case XK_KP_7:
- case XK_KP_8:
- case XK_KP_9:
- k2 = XLookupKeysym(&key_event, 1);
- button = map_button(k2);
- if (button != ButtonHandle::none()) {
- return button;
- }
- // If that didn't produce a button we know, just fall through and handle
- // the normal, un-numlocked key.
- break;
-
- default:
- break;
- }
- }
-
- if (allow_shift) {
- // If shift is held down, get the shifted keysym.
- if ((key_event.state & ShiftMask) != 0) {
- KeySym k2 = XLookupKeysym(&key_event, 1);
- ButtonHandle button = map_button(k2);
- if (button != ButtonHandle::none()) {
- return button;
- }
- }
-
- // If caps lock is down, shift lowercase letters to uppercase. We can do
- // this in just the ASCII set, because we handle international keyboards
- // elsewhere (via an input context).
- if ((key_event.state & (ShiftMask | LockMask)) != 0) {
- if (key >= XK_a and key <= XK_z) {
- key += (XK_A - XK_a);
- }
- }
- }
-
- return map_button(key);
-}
-
-/**
- * Maps from a single X keysym to Panda's ButtonHandle. Called by
- * get_button(), above.
- */
-ButtonHandle eglGraphicsWindow::
-map_button(KeySym key) {
- switch (key) {
- case XK_BackSpace:
- return KeyboardButton::backspace();
- case XK_Tab:
- case XK_KP_Tab:
- return KeyboardButton::tab();
- case XK_Return:
- case XK_KP_Enter:
- return KeyboardButton::enter();
- case XK_Escape:
- return KeyboardButton::escape();
- case XK_KP_Space:
- case XK_space:
- return KeyboardButton::space();
- case XK_exclam:
- return KeyboardButton::ascii_key('!');
- case XK_quotedbl:
- return KeyboardButton::ascii_key('"');
- case XK_numbersign:
- return KeyboardButton::ascii_key('#');
- case XK_dollar:
- return KeyboardButton::ascii_key('$');
- case XK_percent:
- return KeyboardButton::ascii_key('%');
- case XK_ampersand:
- return KeyboardButton::ascii_key('&');
- case XK_apostrophe: // == XK_quoteright
- return KeyboardButton::ascii_key('\'');
- case XK_parenleft:
- return KeyboardButton::ascii_key('(');
- case XK_parenright:
- return KeyboardButton::ascii_key(')');
- case XK_asterisk:
- case XK_KP_Multiply:
- return KeyboardButton::ascii_key('*');
- case XK_plus:
- case XK_KP_Add:
- return KeyboardButton::ascii_key('+');
- case XK_comma:
- case XK_KP_Separator:
- return KeyboardButton::ascii_key(',');
- case XK_minus:
- case XK_KP_Subtract:
- return KeyboardButton::ascii_key('-');
- case XK_period:
- case XK_KP_Decimal:
- return KeyboardButton::ascii_key('.');
- case XK_slash:
- case XK_KP_Divide:
- return KeyboardButton::ascii_key('/');
- case XK_0:
- case XK_KP_0:
- return KeyboardButton::ascii_key('0');
- case XK_1:
- case XK_KP_1:
- return KeyboardButton::ascii_key('1');
- case XK_2:
- case XK_KP_2:
- return KeyboardButton::ascii_key('2');
- case XK_3:
- case XK_KP_3:
- return KeyboardButton::ascii_key('3');
- case XK_4:
- case XK_KP_4:
- return KeyboardButton::ascii_key('4');
- case XK_5:
- case XK_KP_5:
- return KeyboardButton::ascii_key('5');
- case XK_6:
- case XK_KP_6:
- return KeyboardButton::ascii_key('6');
- case XK_7:
- case XK_KP_7:
- return KeyboardButton::ascii_key('7');
- case XK_8:
- case XK_KP_8:
- return KeyboardButton::ascii_key('8');
- case XK_9:
- case XK_KP_9:
- return KeyboardButton::ascii_key('9');
- case XK_colon:
- return KeyboardButton::ascii_key(':');
- case XK_semicolon:
- return KeyboardButton::ascii_key(';');
- case XK_less:
- return KeyboardButton::ascii_key('<');
- case XK_equal:
- case XK_KP_Equal:
- return KeyboardButton::ascii_key('=');
- case XK_greater:
- return KeyboardButton::ascii_key('>');
- case XK_question:
- return KeyboardButton::ascii_key('?');
- case XK_at:
- return KeyboardButton::ascii_key('@');
- case XK_A:
- return KeyboardButton::ascii_key('A');
- case XK_B:
- return KeyboardButton::ascii_key('B');
- case XK_C:
- return KeyboardButton::ascii_key('C');
- case XK_D:
- return KeyboardButton::ascii_key('D');
- case XK_E:
- return KeyboardButton::ascii_key('E');
- case XK_F:
- return KeyboardButton::ascii_key('F');
- case XK_G:
- return KeyboardButton::ascii_key('G');
- case XK_H:
- return KeyboardButton::ascii_key('H');
- case XK_I:
- return KeyboardButton::ascii_key('I');
- case XK_J:
- return KeyboardButton::ascii_key('J');
- case XK_K:
- return KeyboardButton::ascii_key('K');
- case XK_L:
- return KeyboardButton::ascii_key('L');
- case XK_M:
- return KeyboardButton::ascii_key('M');
- case XK_N:
- return KeyboardButton::ascii_key('N');
- case XK_O:
- return KeyboardButton::ascii_key('O');
- case XK_P:
- return KeyboardButton::ascii_key('P');
- case XK_Q:
- return KeyboardButton::ascii_key('Q');
- case XK_R:
- return KeyboardButton::ascii_key('R');
- case XK_S:
- return KeyboardButton::ascii_key('S');
- case XK_T:
- return KeyboardButton::ascii_key('T');
- case XK_U:
- return KeyboardButton::ascii_key('U');
- case XK_V:
- return KeyboardButton::ascii_key('V');
- case XK_W:
- return KeyboardButton::ascii_key('W');
- case XK_X:
- return KeyboardButton::ascii_key('X');
- case XK_Y:
- return KeyboardButton::ascii_key('Y');
- case XK_Z:
- return KeyboardButton::ascii_key('Z');
- case XK_bracketleft:
- return KeyboardButton::ascii_key('[');
- case XK_backslash:
- return KeyboardButton::ascii_key('\\');
- case XK_bracketright:
- return KeyboardButton::ascii_key(']');
- case XK_asciicircum:
- return KeyboardButton::ascii_key('^');
- case XK_underscore:
- return KeyboardButton::ascii_key('_');
- case XK_grave: // == XK_quoteleft
- return KeyboardButton::ascii_key('`');
- case XK_a:
- return KeyboardButton::ascii_key('a');
- case XK_b:
- return KeyboardButton::ascii_key('b');
- case XK_c:
- return KeyboardButton::ascii_key('c');
- case XK_d:
- return KeyboardButton::ascii_key('d');
- case XK_e:
- return KeyboardButton::ascii_key('e');
- case XK_f:
- return KeyboardButton::ascii_key('f');
- case XK_g:
- return KeyboardButton::ascii_key('g');
- case XK_h:
- return KeyboardButton::ascii_key('h');
- case XK_i:
- return KeyboardButton::ascii_key('i');
- case XK_j:
- return KeyboardButton::ascii_key('j');
- case XK_k:
- return KeyboardButton::ascii_key('k');
- case XK_l:
- return KeyboardButton::ascii_key('l');
- case XK_m:
- return KeyboardButton::ascii_key('m');
- case XK_n:
- return KeyboardButton::ascii_key('n');
- case XK_o:
- return KeyboardButton::ascii_key('o');
- case XK_p:
- return KeyboardButton::ascii_key('p');
- case XK_q:
- return KeyboardButton::ascii_key('q');
- case XK_r:
- return KeyboardButton::ascii_key('r');
- case XK_s:
- return KeyboardButton::ascii_key('s');
- case XK_t:
- return KeyboardButton::ascii_key('t');
- case XK_u:
- return KeyboardButton::ascii_key('u');
- case XK_v:
- return KeyboardButton::ascii_key('v');
- case XK_w:
- return KeyboardButton::ascii_key('w');
- case XK_x:
- return KeyboardButton::ascii_key('x');
- case XK_y:
- return KeyboardButton::ascii_key('y');
- case XK_z:
- return KeyboardButton::ascii_key('z');
- case XK_braceleft:
- return KeyboardButton::ascii_key('{');
- case XK_bar:
- return KeyboardButton::ascii_key('|');
- case XK_braceright:
- return KeyboardButton::ascii_key('}');
- case XK_asciitilde:
- return KeyboardButton::ascii_key('~');
- case XK_F1:
- case XK_KP_F1:
- return KeyboardButton::f1();
- case XK_F2:
- case XK_KP_F2:
- return KeyboardButton::f2();
- case XK_F3:
- case XK_KP_F3:
- return KeyboardButton::f3();
- case XK_F4:
- case XK_KP_F4:
- return KeyboardButton::f4();
- case XK_F5:
- return KeyboardButton::f5();
- case XK_F6:
- return KeyboardButton::f6();
- case XK_F7:
- return KeyboardButton::f7();
- case XK_F8:
- return KeyboardButton::f8();
- case XK_F9:
- return KeyboardButton::f9();
- case XK_F10:
- return KeyboardButton::f10();
- case XK_F11:
- return KeyboardButton::f11();
- case XK_F12:
- return KeyboardButton::f12();
- case XK_KP_Left:
- case XK_Left:
- return KeyboardButton::left();
- case XK_KP_Up:
- case XK_Up:
- return KeyboardButton::up();
- case XK_KP_Right:
- case XK_Right:
- return KeyboardButton::right();
- case XK_KP_Down:
- case XK_Down:
- return KeyboardButton::down();
- case XK_KP_Prior:
- case XK_Prior:
- return KeyboardButton::page_up();
- case XK_KP_Next:
- case XK_Next:
- return KeyboardButton::page_down();
- case XK_KP_Home:
- case XK_Home:
- return KeyboardButton::home();
- case XK_KP_End:
- case XK_End:
- return KeyboardButton::end();
- case XK_KP_Insert:
- case XK_Insert:
- return KeyboardButton::insert();
- case XK_KP_Delete:
- case XK_Delete:
- return KeyboardButton::del();
- case XK_Num_Lock:
- return KeyboardButton::num_lock();
- case XK_Scroll_Lock:
- return KeyboardButton::scroll_lock();
- case XK_Print:
- return KeyboardButton::print_screen();
- case XK_Pause:
- return KeyboardButton::pause();
- case XK_Menu:
- return KeyboardButton::menu();
- case XK_Shift_L:
- return KeyboardButton::lshift();
- case XK_Shift_R:
- return KeyboardButton::rshift();
- case XK_Control_L:
- return KeyboardButton::lcontrol();
- case XK_Control_R:
- return KeyboardButton::rcontrol();
- case XK_Alt_L:
- return KeyboardButton::lalt();
- case XK_Alt_R:
- return KeyboardButton::ralt();
- case XK_Meta_L:
- return KeyboardButton::lmeta();
- case XK_Meta_R:
- return KeyboardButton::rmeta();
- case XK_Caps_Lock:
- return KeyboardButton::caps_lock();
- case XK_Shift_Lock:
- return KeyboardButton::shift_lock();
- }
-
- return ButtonHandle::none();
-}
-
-/**
- * Returns the Panda ButtonHandle corresponding to the mouse button indicated
- * by the given button event.
- */
-ButtonHandle eglGraphicsWindow::
-get_mouse_button(XButtonEvent &button_event) {
- int index = button_event.button;
- if (index == x_wheel_up_button) {
- return MouseButton::wheel_up();
- } else if (index == x_wheel_down_button) {
- return MouseButton::wheel_down();
- } else if (index == x_wheel_left_button) {
- return MouseButton::wheel_left();
- } else if (index == x_wheel_right_button) {
- return MouseButton::wheel_right();
- } else {
- return MouseButton::button(index - 1);
- }
-}
-/**
- * This function is used as a predicate to XCheckIfEvent() to determine if the
- * indicated queued X event is relevant and should be returned to this window.
- */
-Bool eglGraphicsWindow::
-check_event(X11_Display *display, XEvent *event, char *arg) {
- const eglGraphicsWindow *self = (eglGraphicsWindow *)arg;
-
- // We accept any event that is sent to our window.
- return (event->xany.window == self->_xwindow);
-}
diff --git a/panda/src/egldisplay/eglGraphicsWindow.h b/panda/src/egldisplay/eglGraphicsWindow.h
index 4a17920791..508365cc65 100644
--- a/panda/src/egldisplay/eglGraphicsWindow.h
+++ b/panda/src/egldisplay/eglGraphicsWindow.h
@@ -17,14 +17,12 @@
#include "pandabase.h"
#include "eglGraphicsPipe.h"
-#include "graphicsWindow.h"
-#include "buttonHandle.h"
-#include "get_x11.h"
+#include "x11GraphicsWindow.h"
/**
* An interface to the egl system for managing GLES windows under X.
*/
-class eglGraphicsWindow : public GraphicsWindow {
+class eglGraphicsWindow : public x11GraphicsWindow {
public:
eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
const string &name,
@@ -40,70 +38,22 @@ public:
virtual void end_frame(FrameMode mode, Thread *current_thread);
virtual void end_flip();
- virtual void process_events();
- virtual void set_properties_now(WindowProperties &properties);
-
- INLINE X11_Window get_xwindow() const;
-
protected:
virtual void close_window();
virtual bool open_window();
private:
- void set_wm_properties(const WindowProperties &properties,
- bool already_mapped);
-
- void setup_colormap(XVisualInfo *visual);
- void handle_keystroke(XKeyEvent &event);
- void handle_keypress(XKeyEvent &event);
- void handle_keyrelease(XKeyEvent &event);
-
- ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift);
- ButtonHandle map_button(KeySym key);
- ButtonHandle get_mouse_button(XButtonEvent &button_event);
-
- static Bool check_event(X11_Display *display, XEvent *event, char *arg);
-
- void open_raw_mice();
- void poll_raw_mice();
-
-private:
- X11_Display *_display;
- int _screen;
- X11_Window _xwindow;
- Colormap _colormap;
- XIC _ic;
EGLDisplay _egl_display;
EGLSurface _egl_surface;
- long _event_mask;
- bool _awaiting_configure;
- Atom _wm_delete_window;
- Atom _net_wm_window_type;
- Atom _net_wm_window_type_splash;
- Atom _net_wm_window_type_fullscreen;
- Atom _net_wm_state;
- Atom _net_wm_state_fullscreen;
- Atom _net_wm_state_above;
- Atom _net_wm_state_below;
- Atom _net_wm_state_add;
- Atom _net_wm_state_remove;
-
- struct MouseDeviceInfo {
- int _fd;
- int _input_device_index;
- string _io_buffer;
- };
- pvector _mouse_device_info;
-
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
- GraphicsWindow::init_type();
+ x11GraphicsWindow::init_type();
register_type(_type_handle, "eglGraphicsWindow",
- GraphicsWindow::get_class_type());
+ x11GraphicsWindow::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx
index 14283fe19b..132f2ff9f9 100644
--- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx
+++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx
@@ -203,7 +203,11 @@ cleanup() {
if (_packet) {
if (_packet->data) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(_packet);
+#else
av_free_packet(_packet);
+#endif
}
delete _packet;
_packet = NULL;
@@ -242,7 +246,11 @@ cleanup() {
void FfmpegAudioCursor::
fetch_packet() {
if (_packet->data) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(_packet);
+#else
av_free_packet(_packet);
+#endif
}
while (av_read_frame(_format_ctx, _packet) >= 0) {
if (_packet->stream_index == _audio_index) {
@@ -250,7 +258,11 @@ fetch_packet() {
_packet_data = _packet->data;
return;
}
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(_packet);
+#else
av_free_packet(_packet);
+#endif
}
_packet->data = 0;
_packet_size = 0;
@@ -300,7 +312,11 @@ reload_buffer() {
pkt.size = _packet_size;
int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, &pkt);
movies_debug("avcodec_decode_audio4 returned " << len);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(&pkt);
+#else
av_free_packet(&pkt);
+#endif
bufsize = 0;
if (got_frame) {
diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx
index ec79cd40b2..eb33490384 100644
--- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx
+++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx
@@ -82,9 +82,13 @@ init_from(FfmpegVideo *source) {
#ifdef HAVE_SWSCALE
nassertv(_convert_ctx == NULL);
- _convert_ctx = sws_getContext(_size_x, _size_y,
- _video_ctx->pix_fmt, _size_x, _size_y,
- PIX_FMT_BGR24, SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
+ _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt,
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 74, 100)
+ _size_x, _size_y, AV_PIX_FMT_BGR24,
+#else
+ _size_x, _size_y, PIX_FMT_BGR24,
+#endif
+ SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
#endif // HAVE_SWSCALE
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100)
@@ -568,7 +572,11 @@ cleanup() {
if (_packet) {
if (_packet->data) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(_packet);
+#else
av_free_packet(_packet);
+#endif
}
delete _packet;
_packet = NULL;
@@ -737,14 +745,22 @@ fetch_packet(int default_frame) {
bool FfmpegVideoCursor::
do_fetch_packet(int default_frame) {
if (_packet->data) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(_packet);
+#else
av_free_packet(_packet);
+#endif
}
while (av_read_frame(_format_ctx, _packet) >= 0) {
if (_packet->stream_index == _video_index) {
_packet_frame = _packet->dts;
return false;
}
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
+ av_packet_unref(_packet);
+#else
av_free_packet(_packet);
+#endif
}
_packet->data = 0;
diff --git a/panda/src/gles2gsg/gles2gsg.h b/panda/src/gles2gsg/gles2gsg.h
index cd905832a1..f88d40c3fc 100644
--- a/panda/src/gles2gsg/gles2gsg.h
+++ b/panda/src/gles2gsg/gles2gsg.h
@@ -80,7 +80,6 @@ typedef char GLchar;
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT GL_FRAMEBUFFER_INCOMPLETE_FORMATS
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
-#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT
#define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES
#define GL_DEPTH_STENCIL_EXT GL_DEPTH_STENCIL_OES
@@ -88,7 +87,6 @@ typedef char GLchar;
#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
#define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES
-#define GL_TEXTURE_3D GL_TEXTURE_3D_OES
#define GL_MAX_3D_TEXTURE_SIZE GL_MAX_3D_TEXTURE_SIZE_OES
#define GL_SAMPLER_3D GL_SAMPLER_3D_OES
#define GL_BGRA GL_BGRA_EXT
@@ -120,8 +118,119 @@ typedef char GLchar;
#define GL_COMPARE_R_TO_TEXTURE_ARB GL_COMPARE_REF_TO_TEXTURE_EXT
#define GL_SAMPLER_2D_SHADOW GL_SAMPLER_2D_SHADOW_EXT
#define GL_MAX_DRAW_BUFFERS GL_MAX_DRAW_BUFFERS_NV
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE
+#define GL_SRC1_COLOR GL_SRC1_COLOR_EXT
+#define GL_ONE_MINUS_SRC1_COLOR GL_ONE_MINUS_SRC1_COLOR_EXT
+#define GL_SRC1_ALPHA GL_SRC1_ALPHA_EXT
+#define GL_ONE_MINUS_SRC1_ALPHA GL_ONE_MINUS_SRC1_ALPHA_EXT
+
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR
+#define GL_DEBUG_TYPE_PERFORMANCE GL_DEBUG_TYPE_PERFORMANCE_KHR
+#define GL_DEBUG_SEVERITY_HIGH GL_DEBUG_SEVERITY_HIGH_KHR
+#define GL_DEBUG_SEVERITY_MEDIUM GL_DEBUG_SEVERITY_MEDIUM_KHR
+#define GL_DEBUG_SEVERITY_LOW GL_DEBUG_SEVERITY_LOW_KHR
+#define GL_DEBUG_SEVERITY_NOTIFICATION GL_DEBUG_SEVERITY_NOTIFICATION_KHR
+#define GL_BUFFER GL_BUFFER_KHR
+#define GL_SHADER GL_SHADER_KHR
+#define GL_PROGRAM GL_PROGRAM_KHR
+#define GL_DEBUG_OUTPUT GL_DEBUG_OUTPUT_KHR
+
+// For GLES 3 compat - need a better solution for this
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x1
+#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x2
+#define GL_UNIFORM_BARRIER_BIT 0x4
+#define GL_TEXTURE_FETCH_BARRIER_BIT 0x8
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x20
+#define GL_COMMAND_BARRIER_BIT 0x40
+#define GL_PIXEL_BUFFER_BARRIER_BIT 0x80
+#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x100
+#define GL_BUFFER_UPDATE_BARRIER_BIT 0x200
+#define GL_FRAMEBUFFER_BARRIER_BIT 0x400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x1000
+#define GL_HALF_FLOAT 0x140B
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_RGB10_A2 0x8059
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_RG_INTEGER 0x8228
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS 0x87FF
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_READ_WRITE 0x88BA
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_RGB9_E5 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
+#define GL_RED_INTEGER 0x8D94
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_MAX_IMAGE_UNITS 0x8F38
+#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
+#define GL_IMAGE_2D 0x904D
+#define GL_IMAGE_3D 0x904E
+#define GL_IMAGE_CUBE 0x9050
+#define GL_IMAGE_2D_ARRAY 0x9053
+#define GL_INT_IMAGE_2D 0x9058
+#define GL_INT_IMAGE_3D 0x9059
+#define GL_INT_IMAGE_CUBE 0x905B
+#define GL_INT_IMAGE_2D_ARRAY 0x905E
+#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
+#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
+#define GL_COMPUTE_SHADER 0x91B9
+#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310
+#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311
+#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313
+#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
#undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY
diff --git a/panda/src/gles2gsg/panda_esgl2ext.h b/panda/src/gles2gsg/panda_esgl2ext.h
index 7e6ff9c32a..46812c63a4 100644
--- a/panda/src/gles2gsg/panda_esgl2ext.h
+++ b/panda/src/gles2gsg/panda_esgl2ext.h
@@ -1,1243 +1,964 @@
#ifndef __panda_esgl2ext_h_
-#define __panda_esgl2ext_h_
-
-/* $Revision$ on $Date$ */
+#define __panda_esgl2ext_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
- * This document is licensed under the SGI Free Software B License Version
- * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
- */
+** Copyright (c) 2013-2016 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+** http://www.opengl.org/registry/
+**
+** Khronos $Revision: 32518 $ on $Date: 2016-03-11 02:42:11 -0800 (Fri, 11 Mar 2016) $
+*/
#ifndef GL_APIENTRYP
-# define GL_APIENTRYP GL_APIENTRY*
+#define GL_APIENTRYP GL_APIENTRY*
#endif
-/*------------------------------------------------------------------------*
- * OES extension tokens
- *------------------------------------------------------------------------*/
+/* Generated on date 20160311 */
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_ETC1_RGB8_OES 0x8D64
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2\.[0-9]
+ * Versions emitted: _nomatch_^
+ * Default extensions included: gles2
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
+
+#ifndef GL_KHR_blend_equation_advanced
+#define GL_KHR_blend_equation_advanced 1
+#define GL_MULTIPLY_KHR 0x9294
+#define GL_SCREEN_KHR 0x9295
+#define GL_OVERLAY_KHR 0x9296
+#define GL_DARKEN_KHR 0x9297
+#define GL_LIGHTEN_KHR 0x9298
+#define GL_COLORDODGE_KHR 0x9299
+#define GL_COLORBURN_KHR 0x929A
+#define GL_HARDLIGHT_KHR 0x929B
+#define GL_SOFTLIGHT_KHR 0x929C
+#define GL_DIFFERENCE_KHR 0x929E
+#define GL_EXCLUSION_KHR 0x92A0
+#define GL_HSL_HUE_KHR 0x92AD
+#define GL_HSL_SATURATION_KHR 0x92AE
+#define GL_HSL_COLOR_KHR 0x92AF
+#define GL_HSL_LUMINOSITY_KHR 0x92B0
+typedef void (GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void);
#endif
+#endif /* GL_KHR_blend_equation_advanced */
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_PALETTE4_RGB8_OES 0x8B90
-#define GL_PALETTE4_RGBA8_OES 0x8B91
-#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
-#define GL_PALETTE4_RGBA4_OES 0x8B93
-#define GL_PALETTE4_RGB5_A1_OES 0x8B94
-#define GL_PALETTE8_RGB8_OES 0x8B95
-#define GL_PALETTE8_RGBA8_OES 0x8B96
-#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
-#define GL_PALETTE8_RGBA4_OES 0x8B98
-#define GL_PALETTE8_RGB5_A1_OES 0x8B99
-#endif
+#ifndef GL_KHR_blend_equation_advanced_coherent
+#define GL_KHR_blend_equation_advanced_coherent 1
+#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
+#endif /* GL_KHR_blend_equation_advanced_coherent */
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_DEPTH_COMPONENT24_OES 0x81A6
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_DEPTH_COMPONENT32_OES 0x81A7
-#endif
-
-/* GL_OES_depth_texture */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-typedef void* GLeglImageOES;
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-/* GLeglImageOES defined in GL_OES_EGL_image already. */
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#define GL_SAMPLER_EXTERNAL_OES 0x8D66
-#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
-#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_UNSIGNED_INT 0x1405
-#endif
-
-/* GL_OES_get_program_binary */
-#ifndef GL_OES_get_program_binary
-#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
-#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_WRITE_ONLY_OES 0x88B9
-#define GL_BUFFER_ACCESS_OES 0x88BB
-#define GL_BUFFER_MAPPED_OES 0x88BC
-#define GL_BUFFER_MAP_POINTER_OES 0x88BD
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_DEPTH_STENCIL_OES 0x84F9
-#define GL_UNSIGNED_INT_24_8_OES 0x84FA
-#define GL_DEPTH24_STENCIL8_OES 0x88F0
-#endif
-
-/* GL_OES_required_internalformat */
-#ifndef GL_OES_required_internalformat
-#define GL_ALPHA8_OES 0x803C
-#define GL_DEPTH_COMPONENT16_OES 0x81A5
-/* reuse GL_DEPTH_COMPONENT24_OES */
-/* reuse GL_DEPTH24_STENCIL8_OES */
-/* reuse GL_DEPTH_COMPONENT32_OES */
-#define GL_LUMINANCE4_ALPHA4_OES 0x8043
-#define GL_LUMINANCE8_ALPHA8_OES 0x8045
-#define GL_LUMINANCE8_OES 0x8040
-#define GL_RGBA4_OES 0x8056
-#define GL_RGB5_A1_OES 0x8057
-#define GL_RGB565_OES 0x8D62
-/* reuse GL_RGB8_OES */
-/* reuse GL_RGBA8_OES */
-/* reuse GL_RGB10_EXT */
-/* reuse GL_RGB10_A2_EXT */
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_RGB8_OES 0x8051
-#define GL_RGBA8_OES 0x8058
-#endif
-
-/* GL_OES_standard_derivatives */
-#ifndef GL_OES_standard_derivatives
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_STENCIL_INDEX1_OES 0x8D46
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_STENCIL_INDEX4_OES 0x8D47
-#endif
-
-#ifndef GL_OES_surfaceless_context
-#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
-#endif
-
-/* GL_OES_texture_3D */
-#ifndef GL_OES_texture_3D
-#define GL_TEXTURE_WRAP_R_OES 0x8072
-#define GL_TEXTURE_3D_OES 0x806F
-#define GL_TEXTURE_BINDING_3D_OES 0x806A
-#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
-#define GL_SAMPLER_3D_OES 0x8B5F
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
-#endif
-
-/* GL_OES_texture_float */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_half_float */
-#ifndef GL_OES_texture_half_float
-#define GL_HALF_FLOAT_OES 0x8D61
-#endif
-
-/* GL_OES_texture_half_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_npot */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
-#endif
-
-/* GL_OES_vertex_half_float */
-/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */
-
-/* GL_OES_vertex_type_10_10_10_2 */
-#ifndef GL_OES_vertex_type_10_10_10_2
-#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
-#define GL_INT_10_10_10_2_OES 0x8DF7
-#endif
-
-/*------------------------------------------------------------------------*
- * KHR extension tokens
- *------------------------------------------------------------------------*/
+#ifndef GL_KHR_context_flush_control
+#define GL_KHR_context_flush_control 1
+#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC
+#endif /* GL_KHR_context_flush_control */
#ifndef GL_KHR_debug
-typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
-#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
-#define GL_DEBUG_SOURCE_API 0x8246
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
-#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
-#define GL_DEBUG_SOURCE_APPLICATION 0x824A
-#define GL_DEBUG_SOURCE_OTHER 0x824B
-#define GL_DEBUG_TYPE_ERROR 0x824C
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
-#define GL_DEBUG_TYPE_PORTABILITY 0x824F
-#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
-#define GL_DEBUG_TYPE_OTHER 0x8251
-#define GL_DEBUG_TYPE_MARKER 0x8268
-#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
-#define GL_DEBUG_TYPE_POP_GROUP 0x826A
-#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
-#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
-#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
-#define GL_BUFFER 0x82E0
-#define GL_SHADER 0x82E1
-#define GL_PROGRAM 0x82E2
-#define GL_QUERY 0x82E3
-/* PROGRAM_PIPELINE only in GL */
-#define GL_SAMPLER 0x82E6
-/* DISPLAY_LIST only in GL */
-#define GL_MAX_LABEL_LENGTH 0x82E8
-#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
-#define GL_DEBUG_LOGGED_MESSAGES 0x9145
-#define GL_DEBUG_SEVERITY_HIGH 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
-#define GL_DEBUG_SEVERITY_LOW 0x9148
-#define GL_DEBUG_OUTPUT 0x92E0
-#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
-#define GL_STACK_OVERFLOW 0x0503
-#define GL_STACK_UNDERFLOW 0x0504
+#define GL_KHR_debug 1
+typedef void (GL_APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+#define GL_SAMPLER 0x82E6
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
+#define GL_DEBUG_SOURCE_API_KHR 0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
+#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
+#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
+#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
+#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
+#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
+#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
+#define GL_BUFFER_KHR 0x82E0
+#define GL_SHADER_KHR 0x82E1
+#define GL_PROGRAM_KHR 0x82E2
+#define GL_VERTEX_ARRAY_KHR 0x8074
+#define GL_QUERY_KHR 0x82E3
+#define GL_PROGRAM_PIPELINE_KHR 0x82E4
+#define GL_SAMPLER_KHR 0x82E6
+#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
+#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
+#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
+#define GL_DEBUG_OUTPUT_KHR 0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
+#define GL_STACK_OVERFLOW_KHR 0x0503
+#define GL_STACK_UNDERFLOW_KHR 0x0504
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam);
+typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void);
+typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam);
+GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void);
+GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params);
#endif
+#endif /* GL_KHR_debug */
+
+#ifndef GL_KHR_no_error
+#define GL_KHR_no_error 1
+#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
+#endif /* GL_KHR_no_error */
+
+#ifndef GL_KHR_robust_buffer_access_behavior
+#define GL_KHR_robust_buffer_access_behavior 1
+#endif /* GL_KHR_robust_buffer_access_behavior */
+
+#ifndef GL_KHR_robustness
+#define GL_KHR_robustness 1
+#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
+#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
+#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
+#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
+#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
+#define GL_NO_RESET_NOTIFICATION_KHR 0x8261
+#define GL_CONTEXT_LOST_KHR 0x0507
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSKHRPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR (void);
+GL_APICALL void GL_APIENTRY glReadnPixelsKHR (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GL_APICALL void GL_APIENTRY glGetnUniformfvKHR (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetnUniformivKHR (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+GL_APICALL void GL_APIENTRY glGetnUniformuivKHR (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+#endif
+#endif /* GL_KHR_robustness */
+
+#ifndef GL_KHR_texture_compression_astc_hdr
+#define GL_KHR_texture_compression_astc_hdr 1
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
+#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
+#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
+#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
+#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
+#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#endif /* GL_KHR_texture_compression_astc_hdr */
#ifndef GL_KHR_texture_compression_astc_ldr
-#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
-#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
-#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
-#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
-#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
-#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
-#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
-#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
-#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
-#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
-#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
-#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
-#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
-#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
-#endif
+#define GL_KHR_texture_compression_astc_ldr 1
+#endif /* GL_KHR_texture_compression_astc_ldr */
-/*------------------------------------------------------------------------*
- * AMD extension tokens
- *------------------------------------------------------------------------*/
+#ifndef GL_KHR_texture_compression_astc_sliced_3d
+#define GL_KHR_texture_compression_astc_sliced_3d 1
+#endif /* GL_KHR_texture_compression_astc_sliced_3d */
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_3DC_X_AMD 0x87F9
-#define GL_3DC_XY_AMD 0x87FA
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_ATC_RGB_AMD 0x8C92
-#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
-#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
-#endif
-
-/* GL_AMD_performance_monitor */
-#ifndef GL_AMD_performance_monitor
-#define GL_COUNTER_TYPE_AMD 0x8BC0
-#define GL_COUNTER_RANGE_AMD 0x8BC1
-#define GL_UNSIGNED_INT64_AMD 0x8BC2
-#define GL_PERCENTAGE_AMD 0x8BC3
-#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
-#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
-#define GL_PERFMON_RESULT_AMD 0x8BC6
-#endif
-
-/* GL_AMD_program_binary_Z400 */
-#ifndef GL_AMD_program_binary_Z400
-#define GL_Z400_BINARY_AMD 0x8740
-#endif
-
-/*------------------------------------------------------------------------*
- * ANGLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ANGLE_framebuffer_blit */
-#ifndef GL_ANGLE_framebuffer_blit
-#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA
-#endif
-
-/* GL_ANGLE_framebuffer_multisample */
-#ifndef GL_ANGLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
-#define GL_MAX_SAMPLES_ANGLE 0x8D57
-#endif
-
-/* GL_ANGLE_instanced_arrays */
-#ifndef GL_ANGLE_instanced_arrays
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
-#endif
-
-/* GL_ANGLE_pack_reverse_row_order */
-#ifndef GL_ANGLE_pack_reverse_row_order
-#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
-#endif
-
-/* GL_ANGLE_texture_compression_dxt3 */
-#ifndef GL_ANGLE_texture_compression_dxt3
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
-#endif
-
-/* GL_ANGLE_texture_compression_dxt5 */
-#ifndef GL_ANGLE_texture_compression_dxt5
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
-#endif
-
-/* GL_ANGLE_texture_usage */
-#ifndef GL_ANGLE_texture_usage
-#define GL_TEXTURE_USAGE_ANGLE 0x93A2
-#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
-#endif
-
-/* GL_ANGLE_translated_shader_source */
-#ifndef GL_ANGLE_translated_shader_source
-#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_copy_texture_levels */
-/* No new tokens introduced by this extension. */
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56
-#define GL_MAX_SAMPLES_APPLE 0x8D57
-#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
-#endif
-
-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_RGB_422_APPLE 0x8A1F
-#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
-#endif
-
-/* GL_APPLE_sync */
-#ifndef GL_APPLE_sync
-
-#ifndef __gl3_h_
-/* These types are defined with reference to
- * in the Apple extension spec, but here we use the Khronos
- * portable types in khrplatform.h, and assume those types
- * are always defined.
- * If any other extensions using these types are defined,
- * the typedefs must move out of this block and be shared.
- */
-typedef khronos_int64_t GLint64;
-typedef khronos_uint64_t GLuint64;
-typedef struct __GLsync *GLsync;
-#endif
-
-#define GL_SYNC_OBJECT_APPLE 0x8A53
-#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
-#define GL_OBJECT_TYPE_APPLE 0x9112
-#define GL_SYNC_CONDITION_APPLE 0x9113
-#define GL_SYNC_STATUS_APPLE 0x9114
-#define GL_SYNC_FLAGS_APPLE 0x9115
-#define GL_SYNC_FENCE_APPLE 0x9116
-#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
-#define GL_UNSIGNALED_APPLE 0x9118
-#define GL_SIGNALED_APPLE 0x9119
-#define GL_ALREADY_SIGNALED_APPLE 0x911A
-#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
-#define GL_CONDITION_SATISFIED_APPLE 0x911C
-#define GL_WAIT_FAILED_APPLE 0x911D
-#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
-#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_BGRA_EXT 0x80E1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_mali_program_binary */
-#ifndef GL_ARM_mali_program_binary
-#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61
-#endif
-
-/* GL_ARM_mali_shader_binary */
-#ifndef GL_ARM_mali_shader_binary
-#define GL_MALI_SHADER_BINARY_ARM 0x8F60
-#endif
-
-/* GL_ARM_rgba8 */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * EXT extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_MIN_EXT 0x8007
-#define GL_MAX_EXT 0x8008
-#endif
-
-/* GL_EXT_color_buffer_half_float */
-#ifndef GL_EXT_color_buffer_half_float
-#define GL_RGBA16F_EXT 0x881A
-#define GL_RGB16F_EXT 0x881B
-#define GL_RG16F_EXT 0x822F
-#define GL_R16F_EXT 0x822D
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
-#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
-#endif
-
-/* GL_EXT_debug_label */
-#ifndef GL_EXT_debug_label
-#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
-#define GL_PROGRAM_OBJECT_EXT 0x8B40
-#define GL_SHADER_OBJECT_EXT 0x8B48
-#define GL_BUFFER_OBJECT_EXT 0x9151
-#define GL_QUERY_OBJECT_EXT 0x9153
-#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
-#endif
-
-/* GL_EXT_debug_marker */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_discard_framebuffer */
-#ifndef GL_EXT_discard_framebuffer
-#define GL_COLOR_EXT 0x1800
-#define GL_DEPTH_EXT 0x1801
-#define GL_STENCIL_EXT 0x1802
-#endif
-
-/* GL_EXT_map_buffer_range */
-#ifndef GL_EXT_map_buffer_range
-#define GL_MAP_READ_BIT_EXT 0x0001
-#define GL_MAP_WRITE_BIT_EXT 0x0002
-#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
-#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
-#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
-#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
-#endif
-
-/* GL_EXT_multisampled_render_to_texture */
-#ifndef GL_EXT_multisampled_render_to_texture
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
-/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */
-#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
-#define GL_MAX_SAMPLES_EXT 0x8D57
-#endif
-
-/* GL_EXT_multiview_draw_buffers */
-#ifndef GL_EXT_multiview_draw_buffers
-#define GL_COLOR_ATTACHMENT_EXT 0x90F0
-#define GL_MULTIVIEW_EXT 0x90F1
-#define GL_DRAW_BUFFER_EXT 0x0C01
-#define GL_READ_BUFFER_EXT 0x0C02
-#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
-#endif
-
-/* GL_EXT_multi_draw_arrays */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_occlusion_query_boolean */
-#ifndef GL_EXT_occlusion_query_boolean
-#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
-#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
-#define GL_CURRENT_QUERY_EXT 0x8865
-#define GL_QUERY_RESULT_EXT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
-#endif
-
-/* GL_EXT_read_format_bgra */
-#ifndef GL_EXT_read_format_bgra
-#define GL_BGRA_EXT 0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
-#endif
-
-/* GL_EXT_robustness */
-#ifndef GL_EXT_robustness
-/* reuse GL_NO_ERROR */
-#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
-#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
-#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
-#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
-#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
-#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
-#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
-#endif
-
-/* GL_EXT_separate_shader_objects */
-#ifndef GL_EXT_separate_shader_objects
-#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
-#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
-#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
-#define GL_PROGRAM_SEPARABLE_EXT 0x8258
-#define GL_ACTIVE_PROGRAM_EXT 0x8259
-#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
-#endif
-
-/* GL_EXT_shader_framebuffer_fetch */
-#ifndef GL_EXT_shader_framebuffer_fetch
-#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
-#endif
-
-/* GL_EXT_shader_texture_lod */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_shadow_samplers */
-#ifndef GL_EXT_shadow_samplers
-#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
-#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
-#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
-#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
-#endif
-
-/* GL_EXT_sRGB */
-#ifndef GL_EXT_sRGB
-#define GL_SRGB_EXT 0x8C40
-#define GL_SRGB_ALPHA_EXT 0x8C42
-#define GL_SRGB8_ALPHA8_EXT 0x8C43
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
-#endif
-
-/* GL_EXT_texture_compression_dxt1 */
-#ifndef GL_EXT_texture_compression_dxt1
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-#endif
-
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#endif
-
-/* GL_EXT_texture_format_BGRA8888 */
-#ifndef GL_EXT_texture_format_BGRA8888
-#define GL_BGRA_EXT 0x80E1
-#endif
-
-/* GL_EXT_texture_rg */
-#ifndef GL_EXT_texture_rg
-#define GL_RED_EXT 0x1903
-#define GL_RG_EXT 0x8227
-#define GL_R8_EXT 0x8229
-#define GL_RG8_EXT 0x822B
-#endif
-
-/* GL_EXT_texture_storage */
-#ifndef GL_EXT_texture_storage
-#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
-#define GL_ALPHA8_EXT 0x803C
-#define GL_LUMINANCE8_EXT 0x8040
-#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
-#define GL_RGBA32F_EXT 0x8814
-#define GL_RGB32F_EXT 0x8815
-#define GL_ALPHA32F_EXT 0x8816
-#define GL_LUMINANCE32F_EXT 0x8818
-#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
-/* reuse GL_RGBA16F_EXT */
-/* reuse GL_RGB16F_EXT */
-#define GL_ALPHA16F_EXT 0x881C
-#define GL_LUMINANCE16F_EXT 0x881E
-#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
-#define GL_RGB10_A2_EXT 0x8059
-#define GL_RGB10_EXT 0x8052
-#define GL_BGRA8_EXT 0x93A1
-#define GL_R8_EXT 0x8229
-#define GL_RG8_EXT 0x822B
-#define GL_R32F_EXT 0x822E
-#define GL_RG32F_EXT 0x8230
-#define GL_R16F_EXT 0x822D
-#define GL_RG16F_EXT 0x822F
-#endif
-
-/* GL_EXT_texture_type_2_10_10_10_REV */
-#ifndef GL_EXT_texture_type_2_10_10_10_REV
-#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
-#endif
-
-/* GL_EXT_unpack_subimage */
-#ifndef GL_EXT_unpack_subimage
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#endif
-
-/*------------------------------------------------------------------------*
- * DMP extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_SHADER_BINARY_DMP 0x9250
-#endif
-
-/*------------------------------------------------------------------------*
- * FJ extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_FJ_shader_binary_GCCSO */
-#ifndef GL_FJ_shader_binary_GCCSO
-#define GCCSO_SHADER_BINARY_FJ 0x9260
-#endif
-
-/*------------------------------------------------------------------------*
- * IMG extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_program_binary */
-#ifndef GL_IMG_program_binary
-#define GL_SGX_PROGRAM_BINARY_IMG 0x9130
-#endif
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_BGRA_IMG 0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365
-#endif
-
-/* GL_IMG_shader_binary */
-#ifndef GL_IMG_shader_binary
-#define GL_SGX_BINARY_IMG 0x8C0A
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
-#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
-#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
-#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
-#define GL_MAX_SAMPLES_IMG 0x9135
-#define GL_TEXTURE_SAMPLES_IMG 0x9136
-#endif
-
-/*------------------------------------------------------------------------*
- * NV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_NV_coverage_sample */
-#ifndef GL_NV_coverage_sample
-#define GL_COVERAGE_COMPONENT_NV 0x8ED0
-#define GL_COVERAGE_COMPONENT4_NV 0x8ED1
-#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2
-#define GL_COVERAGE_BUFFERS_NV 0x8ED3
-#define GL_COVERAGE_SAMPLES_NV 0x8ED4
-#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5
-#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6
-#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7
-#define GL_COVERAGE_BUFFER_BIT_NV 0x8000
-#endif
-
-/* GL_NV_depth_nonlinear */
-#ifndef GL_NV_depth_nonlinear
-#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
-#endif
-
-/* GL_NV_draw_buffers */
-#ifndef GL_NV_draw_buffers
-#define GL_MAX_DRAW_BUFFERS_NV 0x8824
-#define GL_DRAW_BUFFER0_NV 0x8825
-#define GL_DRAW_BUFFER1_NV 0x8826
-#define GL_DRAW_BUFFER2_NV 0x8827
-#define GL_DRAW_BUFFER3_NV 0x8828
-#define GL_DRAW_BUFFER4_NV 0x8829
-#define GL_DRAW_BUFFER5_NV 0x882A
-#define GL_DRAW_BUFFER6_NV 0x882B
-#define GL_DRAW_BUFFER7_NV 0x882C
-#define GL_DRAW_BUFFER8_NV 0x882D
-#define GL_DRAW_BUFFER9_NV 0x882E
-#define GL_DRAW_BUFFER10_NV 0x882F
-#define GL_DRAW_BUFFER11_NV 0x8830
-#define GL_DRAW_BUFFER12_NV 0x8831
-#define GL_DRAW_BUFFER13_NV 0x8832
-#define GL_DRAW_BUFFER14_NV 0x8833
-#define GL_DRAW_BUFFER15_NV 0x8834
-#define GL_COLOR_ATTACHMENT0_NV 0x8CE0
-#define GL_COLOR_ATTACHMENT1_NV 0x8CE1
-#define GL_COLOR_ATTACHMENT2_NV 0x8CE2
-#define GL_COLOR_ATTACHMENT3_NV 0x8CE3
-#define GL_COLOR_ATTACHMENT4_NV 0x8CE4
-#define GL_COLOR_ATTACHMENT5_NV 0x8CE5
-#define GL_COLOR_ATTACHMENT6_NV 0x8CE6
-#define GL_COLOR_ATTACHMENT7_NV 0x8CE7
-#define GL_COLOR_ATTACHMENT8_NV 0x8CE8
-#define GL_COLOR_ATTACHMENT9_NV 0x8CE9
-#define GL_COLOR_ATTACHMENT10_NV 0x8CEA
-#define GL_COLOR_ATTACHMENT11_NV 0x8CEB
-#define GL_COLOR_ATTACHMENT12_NV 0x8CEC
-#define GL_COLOR_ATTACHMENT13_NV 0x8CED
-#define GL_COLOR_ATTACHMENT14_NV 0x8CEE
-#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
-#endif
-
-/* GL_NV_fbo_color_attachments */
-#ifndef GL_NV_fbo_color_attachments
-#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
-/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
-#endif
-
-/* GL_NV_fence */
-#ifndef GL_NV_fence
-#define GL_ALL_COMPLETED_NV 0x84F2
-#define GL_FENCE_STATUS_NV 0x84F3
-#define GL_FENCE_CONDITION_NV 0x84F4
-#endif
-
-/* GL_NV_read_buffer */
-#ifndef GL_NV_read_buffer
-#define GL_READ_BUFFER_NV 0x0C02
-#endif
-
-/* GL_NV_read_buffer_front */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_depth */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_depth_stencil */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_stencil */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_texture_compression_s3tc_update */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_texture_npot_2D_mipmap */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * QCOM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_alpha_test */
-#ifndef GL_QCOM_alpha_test
-#define GL_ALPHA_TEST_QCOM 0x0BC0
-#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
-#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
-#endif
-
-/* GL_QCOM_binning_control */
-#ifndef GL_QCOM_binning_control
-#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0
-#define GL_CPU_OPTIMIZED_QCOM 0x8FB1
-#define GL_GPU_OPTIMIZED_QCOM 0x8FB2
-#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3
-#endif
-
-/* GL_QCOM_driver_control */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_extended_get */
-#ifndef GL_QCOM_extended_get
-#define GL_TEXTURE_WIDTH_QCOM 0x8BD2
-#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3
-#define GL_TEXTURE_DEPTH_QCOM 0x8BD4
-#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5
-#define GL_TEXTURE_FORMAT_QCOM 0x8BD6
-#define GL_TEXTURE_TYPE_QCOM 0x8BD7
-#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8
-#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9
-#define GL_TEXTURE_TARGET_QCOM 0x8BDA
-#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB
-#define GL_STATE_RESTORE 0x8BDC
-#endif
-
-/* GL_QCOM_extended_get2 */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_perfmon_global_mode */
-#ifndef GL_QCOM_perfmon_global_mode
-#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0
-#endif
-
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_WRITEONLY_RENDERING_QCOM 0x8823
-#endif
-
-/* GL_QCOM_tiled_rendering */
-#ifndef GL_QCOM_tiled_rendering
-#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001
-#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002
-#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004
-#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008
-#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010
-#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020
-#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040
-#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080
-#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100
-#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200
-#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400
-#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800
-#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000
-#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000
-#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000
-#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000
-#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000
-#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000
-#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000
-#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000
-#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000
-#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000
-#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000
-#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000
-#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000
-#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000
-#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000
-#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000
-#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000
-#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000
-#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000
-#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000
-#endif
-
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_VIV_shader_binary */
-#ifndef GL_VIV_shader_binary
-#define GL_SHADER_BINARY_VIV 0x8FC4
-#endif
-
-/*------------------------------------------------------------------------*
- * End of extension tokens, start of corresponding extension functions
- *------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*
- * OES extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_OES_compressed_ETC1_RGB8_texture 1
-#endif
-
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_OES_compressed_paletted_texture 1
-#endif
-
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_OES_depth24 1
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_OES_depth32 1
-#endif
-
-/* GL_OES_depth_texture */
-#ifndef GL_OES_depth_texture
-#define GL_OES_depth_texture 1
-#endif
-
-/* GL_OES_EGL_image */
#ifndef GL_OES_EGL_image
#define GL_OES_EGL_image 1
+typedef void *GLeglImageOES;
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
#endif
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
-#endif
+#endif /* GL_OES_EGL_image */
-/* GL_OES_EGL_image_external */
#ifndef GL_OES_EGL_image_external
#define GL_OES_EGL_image_external 1
-/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
-#endif
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#endif /* GL_OES_EGL_image_external */
+
+#ifndef GL_OES_EGL_image_external_essl3
+#define GL_OES_EGL_image_external_essl3 1
+#endif /* GL_OES_EGL_image_external_essl3 */
+
+#ifndef GL_OES_compressed_ETC1_RGB8_sub_texture
+#define GL_OES_compressed_ETC1_RGB8_sub_texture 1
+#endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */
+
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+#define GL_ETC1_RGB8_OES 0x8D64
+#endif /* GL_OES_compressed_ETC1_RGB8_texture */
+
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_OES_compressed_paletted_texture 1
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+#endif /* GL_OES_compressed_paletted_texture */
+
+#ifndef GL_OES_copy_image
+#define GL_OES_copy_image 1
+typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAOESPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyImageSubDataOES (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif
+#endif /* GL_OES_copy_image */
+
+#ifndef GL_OES_depth24
+#define GL_OES_depth24 1
+#define GL_DEPTH_COMPONENT24_OES 0x81A6
+#endif /* GL_OES_depth24 */
+
+#ifndef GL_OES_depth32
+#define GL_OES_depth32 1
+#define GL_DEPTH_COMPONENT32_OES 0x81A7
+#endif /* GL_OES_depth32 */
+
+#ifndef GL_OES_depth_texture
+#define GL_OES_depth_texture 1
+#endif /* GL_OES_depth_texture */
+
+#ifndef GL_OES_draw_buffers_indexed
+#define GL_OES_draw_buffers_indexed 1
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+typedef void (GL_APIENTRYP PFNGLENABLEIOESPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLDISABLEIOESPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIOESPROC) (GLuint buf, GLenum mode);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIOESPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCIOESPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIOESPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GL_APIENTRYP PFNGLCOLORMASKIOESPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIOESPROC) (GLenum target, GLuint index);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glEnableiOES (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glDisableiOES (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glBlendEquationiOES (GLuint buf, GLenum mode);
+GL_APICALL void GL_APIENTRY glBlendEquationSeparateiOES (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunciOES (GLuint buf, GLenum src, GLenum dst);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparateiOES (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void GL_APIENTRY glColorMaskiOES (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES (GLenum target, GLuint index);
+#endif
+#endif /* GL_OES_draw_buffers_indexed */
+
+#ifndef GL_OES_draw_elements_base_vertex
+#define GL_OES_draw_elements_base_vertex 1
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexOES (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexOES (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex);
+#endif
+#endif /* GL_OES_draw_elements_base_vertex */
-/* GL_OES_element_index_uint */
#ifndef GL_OES_element_index_uint
#define GL_OES_element_index_uint 1
-#endif
+#endif /* GL_OES_element_index_uint */
-/* GL_OES_fbo_render_mipmap */
#ifndef GL_OES_fbo_render_mipmap
#define GL_OES_fbo_render_mipmap 1
-#endif
+#endif /* GL_OES_fbo_render_mipmap */
-/* GL_OES_fragment_precision_high */
#ifndef GL_OES_fragment_precision_high
#define GL_OES_fragment_precision_high 1
-#endif
+#endif /* GL_OES_fragment_precision_high */
+
+#ifndef GL_OES_geometry_point_size
+#define GL_OES_geometry_point_size 1
+#endif /* GL_OES_geometry_point_size */
+
+#ifndef GL_OES_geometry_shader
+#define GL_OES_geometry_shader 1
+#define GL_GEOMETRY_SHADER_OES 0x8DD9
+#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918
+#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F
+#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E
+#define GL_LINES_ADJACENCY_OES 0x000A
+#define GL_LINE_STRIP_ADJACENCY_OES 0x000B
+#define GL_TRIANGLES_ADJACENCY_OES 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7
+#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E
+#define GL_UNDEFINED_VERTEX_OES 0x8260
+#define GL_PRIMITIVES_GENERATED_OES 0x8C87
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312
+#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREOESPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTextureOES (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif
+#endif /* GL_OES_geometry_shader */
-/* GL_OES_get_program_binary */
#ifndef GL_OES_get_program_binary
#define GL_OES_get_program_binary 1
+#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
#endif
+#endif /* GL_OES_get_program_binary */
+
+#ifndef GL_OES_gpu_shader5
+#define GL_OES_gpu_shader5 1
+#endif /* GL_OES_gpu_shader5 */
-/* GL_OES_mapbuffer */
#ifndef GL_OES_mapbuffer
#define GL_OES_mapbuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
-GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
-GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params);
-#endif
-typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
+#define GL_WRITE_ONLY_OES 0x88B9
+#define GL_BUFFER_ACCESS_OES 0x88BB
+#define GL_BUFFER_MAPPED_OES 0x88BC
+#define GL_BUFFER_MAP_POINTER_OES 0x88BD
+typedef void *(GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);
+typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void *GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
+GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
+GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void **params);
#endif
+#endif /* GL_OES_mapbuffer */
-/* GL_OES_packed_depth_stencil */
#ifndef GL_OES_packed_depth_stencil
#define GL_OES_packed_depth_stencil 1
-#endif
+#define GL_DEPTH_STENCIL_OES 0x84F9
+#define GL_UNSIGNED_INT_24_8_OES 0x84FA
+#define GL_DEPTH24_STENCIL8_OES 0x88F0
+#endif /* GL_OES_packed_depth_stencil */
+
+#ifndef GL_OES_primitive_bounding_box
+#define GL_OES_primitive_bounding_box 1
+#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE
+typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXOESPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxOES (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#endif
+#endif /* GL_OES_primitive_bounding_box */
-/* GL_OES_required_internalformat */
#ifndef GL_OES_required_internalformat
#define GL_OES_required_internalformat 1
-#endif
+#define GL_ALPHA8_OES 0x803C
+#define GL_DEPTH_COMPONENT16_OES 0x81A5
+#define GL_LUMINANCE4_ALPHA4_OES 0x8043
+#define GL_LUMINANCE8_ALPHA8_OES 0x8045
+#define GL_LUMINANCE8_OES 0x8040
+#define GL_RGBA4_OES 0x8056
+#define GL_RGB5_A1_OES 0x8057
+#define GL_RGB565_OES 0x8D62
+#define GL_RGB8_OES 0x8051
+#define GL_RGBA8_OES 0x8058
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB10_A2_EXT 0x8059
+#endif /* GL_OES_required_internalformat */
-/* GL_OES_rgb8_rgba8 */
#ifndef GL_OES_rgb8_rgba8
#define GL_OES_rgb8_rgba8 1
-#endif
+#endif /* GL_OES_rgb8_rgba8 */
+
+#ifndef GL_OES_sample_shading
+#define GL_OES_sample_shading 1
+#define GL_SAMPLE_SHADING_OES 0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37
+typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC) (GLfloat value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMinSampleShadingOES (GLfloat value);
+#endif
+#endif /* GL_OES_sample_shading */
+
+#ifndef GL_OES_sample_variables
+#define GL_OES_sample_variables 1
+#endif /* GL_OES_sample_variables */
+
+#ifndef GL_OES_shader_image_atomic
+#define GL_OES_shader_image_atomic 1
+#endif /* GL_OES_shader_image_atomic */
+
+#ifndef GL_OES_shader_io_blocks
+#define GL_OES_shader_io_blocks 1
+#endif /* GL_OES_shader_io_blocks */
+
+#ifndef GL_OES_shader_multisample_interpolation
+#define GL_OES_shader_multisample_interpolation 1
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D
+#endif /* GL_OES_shader_multisample_interpolation */
-/* GL_OES_standard_derivatives */
#ifndef GL_OES_standard_derivatives
#define GL_OES_standard_derivatives 1
-#endif
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
+#endif /* GL_OES_standard_derivatives */
-/* GL_OES_stencil1 */
#ifndef GL_OES_stencil1
#define GL_OES_stencil1 1
-#endif
+#define GL_STENCIL_INDEX1_OES 0x8D46
+#endif /* GL_OES_stencil1 */
-/* GL_OES_stencil4 */
#ifndef GL_OES_stencil4
#define GL_OES_stencil4 1
-#endif
+#define GL_STENCIL_INDEX4_OES 0x8D47
+#endif /* GL_OES_stencil4 */
#ifndef GL_OES_surfaceless_context
#define GL_OES_surfaceless_context 1
-#endif
+#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
+#endif /* GL_OES_surfaceless_context */
+
+#ifndef GL_OES_tessellation_point_size
+#define GL_OES_tessellation_point_size 1
+#endif /* GL_OES_tessellation_point_size */
+
+#ifndef GL_OES_tessellation_shader
+#define GL_OES_tessellation_shader 1
+#define GL_PATCHES_OES 0x000E
+#define GL_PATCH_VERTICES_OES 0x8E72
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75
+#define GL_TESS_GEN_MODE_OES 0x8E76
+#define GL_TESS_GEN_SPACING_OES 0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78
+#define GL_TESS_GEN_POINT_MODE_OES 0x8E79
+#define GL_ISOLINES_OES 0x8E7A
+#define GL_QUADS_OES 0x0007
+#define GL_FRACTIONAL_ODD_OES 0x8E7B
+#define GL_FRACTIONAL_EVEN_OES 0x8E7C
+#define GL_MAX_PATCH_VERTICES_OES 0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221
+#define GL_IS_PER_PATCH_OES 0x92E7
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308
+#define GL_TESS_CONTROL_SHADER_OES 0x8E88
+#define GL_TESS_EVALUATION_SHADER_OES 0x8E87
+#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010
+typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIOESPROC) (GLenum pname, GLint value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPatchParameteriOES (GLenum pname, GLint value);
+#endif
+#endif /* GL_OES_tessellation_shader */
-/* GL_OES_texture_3D */
#ifndef GL_OES_texture_3D
#define GL_OES_texture_3D 1
+#define GL_TEXTURE_WRAP_R_OES 0x8072
+#define GL_TEXTURE_3D_OES 0x806F
+#define GL_TEXTURE_BINDING_3D_OES 0x806A
+#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
+#define GL_SAMPLER_3D_OES 0x8B5F
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
+typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
+typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
+typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
+typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
#endif
-typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
-typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-#endif
+#endif /* GL_OES_texture_3D */
+
+#ifndef GL_OES_texture_border_clamp
+#define GL_OES_texture_border_clamp 1
+#define GL_TEXTURE_BORDER_COLOR_OES 0x1004
+#define GL_CLAMP_TO_BORDER_OES 0x812D
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, const GLuint *param);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, GLuint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexParameterIivOES (GLenum target, GLenum pname, const GLint *params);
+GL_APICALL void GL_APIENTRY glTexParameterIuivOES (GLenum target, GLenum pname, const GLuint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIivOES (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIuivOES (GLenum target, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glSamplerParameterIivOES (GLuint sampler, GLenum pname, const GLint *param);
+GL_APICALL void GL_APIENTRY glSamplerParameterIuivOES (GLuint sampler, GLenum pname, const GLuint *param);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIivOES (GLuint sampler, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivOES (GLuint sampler, GLenum pname, GLuint *params);
+#endif
+#endif /* GL_OES_texture_border_clamp */
+
+#ifndef GL_OES_texture_buffer
+#define GL_OES_texture_buffer 1
+#define GL_TEXTURE_BUFFER_OES 0x8C2A
+#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F
+#define GL_SAMPLER_BUFFER_OES 0x8DC2
+#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8
+#define GL_IMAGE_BUFFER_OES 0x9051
+#define GL_INT_IMAGE_BUFFER_OES 0x905C
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067
+#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D
+#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E
+typedef void (GL_APIENTRYP PFNGLTEXBUFFEROESPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEOESPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexBufferOES (GLenum target, GLenum internalformat, GLuint buffer);
+GL_APICALL void GL_APIENTRY glTexBufferRangeOES (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif
+#endif /* GL_OES_texture_buffer */
+
+#ifndef GL_OES_texture_compression_astc
+#define GL_OES_texture_compression_astc 1
+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
+#endif /* GL_OES_texture_compression_astc */
+
+#ifndef GL_OES_texture_cube_map_array
+#define GL_OES_texture_cube_map_array 1
+#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A
+#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F
+#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A
+#endif /* GL_OES_texture_cube_map_array */
-/* GL_OES_texture_float */
#ifndef GL_OES_texture_float
#define GL_OES_texture_float 1
-#endif
+#endif /* GL_OES_texture_float */
-/* GL_OES_texture_float_linear */
#ifndef GL_OES_texture_float_linear
#define GL_OES_texture_float_linear 1
-#endif
+#endif /* GL_OES_texture_float_linear */
-/* GL_OES_texture_half_float */
#ifndef GL_OES_texture_half_float
#define GL_OES_texture_half_float 1
-#endif
+#define GL_HALF_FLOAT_OES 0x8D61
+#endif /* GL_OES_texture_half_float */
-/* GL_OES_texture_half_float_linear */
#ifndef GL_OES_texture_half_float_linear
#define GL_OES_texture_half_float_linear 1
-#endif
+#endif /* GL_OES_texture_half_float_linear */
-/* GL_OES_texture_npot */
#ifndef GL_OES_texture_npot
#define GL_OES_texture_npot 1
-#endif
+#endif /* GL_OES_texture_npot */
+
+#ifndef GL_OES_texture_stencil8
+#define GL_OES_texture_stencil8 1
+#define GL_STENCIL_INDEX_OES 0x1901
+#define GL_STENCIL_INDEX8_OES 0x8D48
+#endif /* GL_OES_texture_stencil8 */
+
+#ifndef GL_OES_texture_storage_multisample_2d_array
+#define GL_OES_texture_storage_multisample_2d_array 1
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexStorage3DMultisampleOES (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#endif
+#endif /* GL_OES_texture_storage_multisample_2d_array */
+
+#ifndef GL_OES_texture_view
+#define GL_OES_texture_view 1
+#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
+typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWOESPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTextureViewOES (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif
+#endif /* GL_OES_texture_view */
-/* GL_OES_vertex_array_object */
#ifndef GL_OES_vertex_array_object
#define GL_OES_vertex_array_object 1
+#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
+typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
+typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
+typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array);
GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
#endif
-typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
-typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
-typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
-typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
-#endif
+#endif /* GL_OES_vertex_array_object */
-/* GL_OES_vertex_half_float */
#ifndef GL_OES_vertex_half_float
#define GL_OES_vertex_half_float 1
-#endif
+#endif /* GL_OES_vertex_half_float */
-/* GL_OES_vertex_type_10_10_10_2 */
#ifndef GL_OES_vertex_type_10_10_10_2
#define GL_OES_vertex_type_10_10_10_2 1
-#endif
+#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
+#define GL_INT_10_10_10_2_OES 0x8DF7
+#endif /* GL_OES_vertex_type_10_10_10_2 */
-/*------------------------------------------------------------------------*
- * KHR extension functions
- *------------------------------------------------------------------------*/
-
-#ifndef GL_KHR_debug
-#define GL_KHR_debug 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
-GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
-GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
-GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
-GL_APICALL void GL_APIENTRY glPopDebugGroup (void);
-GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
-GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
-GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
-GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
-GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params);
-#endif
-typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
-typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
-typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
-typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
-typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
-typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
-typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params);
-#endif
-
-#ifndef GL_KHR_texture_compression_astc_ldr
-#define GL_KHR_texture_compression_astc_ldr 1
-#endif
-
-
-/*------------------------------------------------------------------------*
- * AMD extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
#ifndef GL_AMD_compressed_3DC_texture
#define GL_AMD_compressed_3DC_texture 1
-#endif
+#define GL_3DC_X_AMD 0x87F9
+#define GL_3DC_XY_AMD 0x87FA
+#endif /* GL_AMD_compressed_3DC_texture */
-/* GL_AMD_compressed_ATC_texture */
#ifndef GL_AMD_compressed_ATC_texture
#define GL_AMD_compressed_ATC_texture 1
-#endif
+#define GL_ATC_RGB_AMD 0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
+#endif /* GL_AMD_compressed_ATC_texture */
-/* AMD_performance_monitor */
#ifndef GL_AMD_performance_monitor
#define GL_AMD_performance_monitor 1
+#define GL_COUNTER_TYPE_AMD 0x8BC0
+#define GL_COUNTER_RANGE_AMD 0x8BC1
+#define GL_UNSIGNED_INT64_AMD 0x8BC2
+#define GL_PERCENTAGE_AMD 0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
+#define GL_PERFMON_RESULT_AMD 0x8BC6
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data);
+typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data);
GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
-GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
+GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor);
GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
#endif
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
-typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
-#endif
+#endif /* GL_AMD_performance_monitor */
-/* GL_AMD_program_binary_Z400 */
#ifndef GL_AMD_program_binary_Z400
#define GL_AMD_program_binary_Z400 1
-#endif
+#define GL_Z400_BINARY_AMD 0x8740
+#endif /* GL_AMD_program_binary_Z400 */
-/*------------------------------------------------------------------------*
- * ANGLE extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_ANDROID_extension_pack_es31a
+#define GL_ANDROID_extension_pack_es31a 1
+#endif /* GL_ANDROID_extension_pack_es31a */
+
+#ifndef GL_ANGLE_depth_texture
+#define GL_ANGLE_depth_texture 1
+#endif /* GL_ANGLE_depth_texture */
-/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_ANGLE_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA
+typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
-typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
+#endif /* GL_ANGLE_framebuffer_blit */
-/* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_framebuffer_multisample
#define GL_ANGLE_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
+#define GL_MAX_SAMPLES_ANGLE 0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
+#endif /* GL_ANGLE_framebuffer_multisample */
-#ifndef GL_ANGLE_instanced_arrays
+#ifndef GL_ANGLE_instanced_arrays
#define GL_ANGLE_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
#endif
-typedef void (GL_APIENTRYP PFLGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFLGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
-typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
-#endif
+#endif /* GL_ANGLE_instanced_arrays */
-/* GL_ANGLE_pack_reverse_row_order */
-#ifndef GL_ANGLE_pack_reverse_row_order
+#ifndef GL_ANGLE_pack_reverse_row_order
#define GL_ANGLE_pack_reverse_row_order 1
-#endif
+#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
+#endif /* GL_ANGLE_pack_reverse_row_order */
-/* GL_ANGLE_texture_compression_dxt3 */
-#ifndef GL_ANGLE_texture_compression_dxt3
+#ifndef GL_ANGLE_program_binary
+#define GL_ANGLE_program_binary 1
+#define GL_PROGRAM_BINARY_ANGLE 0x93A6
+#endif /* GL_ANGLE_program_binary */
+
+#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_ANGLE_texture_compression_dxt3 1
-#endif
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
+#endif /* GL_ANGLE_texture_compression_dxt3 */
-/* GL_ANGLE_texture_compression_dxt5 */
-#ifndef GL_ANGLE_texture_compression_dxt5
+#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_ANGLE_texture_compression_dxt5 1
-#endif
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
+#endif /* GL_ANGLE_texture_compression_dxt5 */
-/* GL_ANGLE_texture_usage */
-#ifndef GL_ANGLE_texture_usage
+#ifndef GL_ANGLE_texture_usage
#define GL_ANGLE_texture_usage 1
-#endif
+#define GL_TEXTURE_USAGE_ANGLE 0x93A2
+#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
+#endif /* GL_ANGLE_texture_usage */
-#ifndef GL_ANGLE_translated_shader_source
+#ifndef GL_ANGLE_translated_shader_source
#define GL_ANGLE_translated_shader_source 1
+#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
+typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#endif
-typedef void (GL_APIENTRYP PFLGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
-#endif
+#endif /* GL_ANGLE_translated_shader_source */
-/*------------------------------------------------------------------------*
- * APPLE extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_APPLE_clip_distance
+#define GL_APPLE_clip_distance 1
+#define GL_MAX_CLIP_DISTANCES_APPLE 0x0D32
+#define GL_CLIP_DISTANCE0_APPLE 0x3000
+#define GL_CLIP_DISTANCE1_APPLE 0x3001
+#define GL_CLIP_DISTANCE2_APPLE 0x3002
+#define GL_CLIP_DISTANCE3_APPLE 0x3003
+#define GL_CLIP_DISTANCE4_APPLE 0x3004
+#define GL_CLIP_DISTANCE5_APPLE 0x3005
+#define GL_CLIP_DISTANCE6_APPLE 0x3006
+#define GL_CLIP_DISTANCE7_APPLE 0x3007
+#endif /* GL_APPLE_clip_distance */
+
+#ifndef GL_APPLE_color_buffer_packed_float
+#define GL_APPLE_color_buffer_packed_float 1
+#endif /* GL_APPLE_color_buffer_packed_float */
-/* GL_APPLE_copy_texture_levels */
#ifndef GL_APPLE_copy_texture_levels
#define GL_APPLE_copy_texture_levels 1
+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
#endif
-typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
-#endif
+#endif /* GL_APPLE_copy_texture_levels */
-/* GL_APPLE_framebuffer_multisample */
#ifndef GL_APPLE_framebuffer_multisample
#define GL_APPLE_framebuffer_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
-#endif /* GL_GLEXT_PROTOTYPES */
+#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56
+#define GL_MAX_SAMPLES_APPLE 0x8D57
+#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
#endif
+#endif /* GL_APPLE_framebuffer_multisample */
-/* GL_APPLE_rgb_422 */
#ifndef GL_APPLE_rgb_422
#define GL_APPLE_rgb_422 1
-#endif
+#define GL_RGB_422_APPLE 0x8A1F
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#define GL_RGB_RAW_422_APPLE 0x8A51
+#endif /* GL_APPLE_rgb_422 */
-/* GL_APPLE_sync */
#ifndef GL_APPLE_sync
#define GL_APPLE_sync 1
+#define GL_SYNC_OBJECT_APPLE 0x8A53
+#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
+#define GL_OBJECT_TYPE_APPLE 0x9112
+#define GL_SYNC_CONDITION_APPLE 0x9113
+#define GL_SYNC_STATUS_APPLE 0x9114
+#define GL_SYNC_FLAGS_APPLE 0x9115
+#define GL_SYNC_FENCE_APPLE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
+#define GL_UNSIGNALED_APPLE 0x9118
+#define GL_SIGNALED_APPLE 0x9119
+#define GL_ALREADY_SIGNALED_APPLE 0x911A
+#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
+#define GL_CONDITION_SATISFIED_APPLE 0x911C
+#define GL_WAIT_FAILED_APPLE 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
+#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
+typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
+typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
+typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
@@ -1247,287 +968,920 @@ GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLui
GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
#endif
-typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
-typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
-typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
-typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
-typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
-typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
-typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
-#endif
+#endif /* GL_APPLE_sync */
-/* GL_APPLE_texture_format_BGRA8888 */
#ifndef GL_APPLE_texture_format_BGRA8888
#define GL_APPLE_texture_format_BGRA8888 1
-#endif
+#define GL_BGRA_EXT 0x80E1
+#define GL_BGRA8_EXT 0x93A1
+#endif /* GL_APPLE_texture_format_BGRA8888 */
-/* GL_APPLE_texture_max_level */
#ifndef GL_APPLE_texture_max_level
#define GL_APPLE_texture_max_level 1
-#endif
+#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D
+#endif /* GL_APPLE_texture_max_level */
-/*------------------------------------------------------------------------*
- * ARM extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_APPLE_texture_packed_float
+#define GL_APPLE_texture_packed_float 1
+#define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B
+#define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E
+#define GL_R11F_G11F_B10F_APPLE 0x8C3A
+#define GL_RGB9_E5_APPLE 0x8C3D
+#endif /* GL_APPLE_texture_packed_float */
-/* GL_ARM_mali_program_binary */
#ifndef GL_ARM_mali_program_binary
#define GL_ARM_mali_program_binary 1
-#endif
+#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61
+#endif /* GL_ARM_mali_program_binary */
-/* GL_ARM_mali_shader_binary */
#ifndef GL_ARM_mali_shader_binary
#define GL_ARM_mali_shader_binary 1
-#endif
+#define GL_MALI_SHADER_BINARY_ARM 0x8F60
+#endif /* GL_ARM_mali_shader_binary */
-/* GL_ARM_rgba8 */
#ifndef GL_ARM_rgba8
#define GL_ARM_rgba8 1
+#endif /* GL_ARM_rgba8 */
+
+#ifndef GL_ARM_shader_framebuffer_fetch
+#define GL_ARM_shader_framebuffer_fetch 1
+#define GL_FETCH_PER_SAMPLE_ARM 0x8F65
+#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66
+#endif /* GL_ARM_shader_framebuffer_fetch */
+
+#ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil
+#define GL_ARM_shader_framebuffer_fetch_depth_stencil 1
+#endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */
+
+#ifndef GL_DMP_program_binary
+#define GL_DMP_program_binary 1
+#define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251
+#define GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252
+#define GL_DMP_PROGRAM_BINARY_DMP 0x9253
+#endif /* GL_DMP_program_binary */
+
+#ifndef GL_DMP_shader_binary
+#define GL_DMP_shader_binary 1
+#define GL_SHADER_BINARY_DMP 0x9250
+#endif /* GL_DMP_shader_binary */
+
+#ifndef GL_EXT_YUV_target
+#define GL_EXT_YUV_target 1
+#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7
+#endif /* GL_EXT_YUV_target */
+
+#ifndef GL_EXT_base_instance
+#define GL_EXT_base_instance 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedBaseInstanceEXT (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
#endif
+#endif /* GL_EXT_base_instance */
-/*------------------------------------------------------------------------*
- * EXT extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_EXT_blend_func_extended
+#define GL_EXT_blend_func_extended 1
+#define GL_SRC1_COLOR_EXT 0x88F9
+#define GL_SRC1_ALPHA_EXT 0x8589
+#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA
+#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB
+#define GL_SRC_ALPHA_SATURATE_EXT 0x0308
+#define GL_LOCATION_INDEX_EXT 0x930F
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC
+typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATAINDEXEXTPROC) (GLuint program, const GLchar *name);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBindFragDataLocationIndexedEXT (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+GL_APICALL void GL_APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name);
+GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocationIndexEXT (GLuint program, GLenum programInterface, const GLchar *name);
+GL_APICALL GLint GL_APIENTRY glGetFragDataIndexEXT (GLuint program, const GLchar *name);
+#endif
+#endif /* GL_EXT_blend_func_extended */
-/* GL_EXT_blend_minmax */
#ifndef GL_EXT_blend_minmax
#define GL_EXT_blend_minmax 1
-#endif
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#endif /* GL_EXT_blend_minmax */
+
+#ifndef GL_EXT_buffer_storage
+#define GL_EXT_buffer_storage 1
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_PERSISTENT_BIT_EXT 0x0040
+#define GL_MAP_COHERENT_BIT_EXT 0x0080
+#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100
+#define GL_CLIENT_STORAGE_BIT_EXT 0x0200
+#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000
+#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F
+#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220
+typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBufferStorageEXT (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
+#endif
+#endif /* GL_EXT_buffer_storage */
+
+#ifndef GL_EXT_color_buffer_float
+#define GL_EXT_color_buffer_float 1
+#endif /* GL_EXT_color_buffer_float */
-/* GL_EXT_color_buffer_half_float */
#ifndef GL_EXT_color_buffer_half_float
#define GL_EXT_color_buffer_half_float 1
-#endif
+#define GL_RGBA16F_EXT 0x881A
+#define GL_RGB16F_EXT 0x881B
+#define GL_RG16F_EXT 0x822F
+#define GL_R16F_EXT 0x822D
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
+#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
+#endif /* GL_EXT_color_buffer_half_float */
+
+#ifndef GL_EXT_copy_image
+#define GL_EXT_copy_image 1
+typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif
+#endif /* GL_EXT_copy_image */
-/* GL_EXT_debug_label */
#ifndef GL_EXT_debug_label
#define GL_EXT_debug_label 1
+#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
+#define GL_PROGRAM_OBJECT_EXT 0x8B40
+#define GL_SHADER_OBJECT_EXT 0x8B48
+#define GL_BUFFER_OBJECT_EXT 0x9151
+#define GL_QUERY_OBJECT_EXT 0x9153
+#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label);
GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
#endif
-typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
-#endif
+#endif /* GL_EXT_debug_label */
-/* GL_EXT_debug_marker */
#ifndef GL_EXT_debug_marker
#define GL_EXT_debug_marker 1
+typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker);
GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker);
GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void);
#endif
-typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
-typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
-typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
-#endif
+#endif /* GL_EXT_debug_marker */
-/* GL_EXT_discard_framebuffer */
#ifndef GL_EXT_discard_framebuffer
#define GL_EXT_discard_framebuffer 1
+#define GL_COLOR_EXT 0x1800
+#define GL_DEPTH_EXT 0x1801
+#define GL_STENCIL_EXT 0x1802
+typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
#endif
-typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-#endif
+#endif /* GL_EXT_discard_framebuffer */
-/* GL_EXT_map_buffer_range */
-#ifndef GL_EXT_map_buffer_range
-#define GL_EXT_map_buffer_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
-#endif
-typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
-#endif
-
-/* GL_EXT_multisampled_render_to_texture */
-#ifndef GL_EXT_multisampled_render_to_texture
-#define GL_EXT_multisampled_render_to_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
-#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
-#endif
-
-/* GL_EXT_multiview_draw_buffers */
-#ifndef GL_EXT_multiview_draw_buffers
-#define GL_EXT_multiview_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
-GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
-GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
-#endif
-typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index);
-typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices);
-typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data);
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
-GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#endif
-
-/* GL_EXT_occlusion_query_boolean */
-#ifndef GL_EXT_occlusion_query_boolean
-#define GL_EXT_occlusion_query_boolean 1
+#ifndef GL_EXT_disjoint_timer_query
+#define GL_EXT_disjoint_timer_query 1
+#define GL_QUERY_COUNTER_BITS_EXT 0x8864
+#define GL_CURRENT_QUERY_EXT 0x8865
+#define GL_QUERY_RESULT_EXT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
+#define GL_TIME_ELAPSED_EXT 0x88BF
+#define GL_TIMESTAMP_EXT 0x8E28
+#define GL_GPU_DISJOINT_EXT 0x8FBB
+typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
+typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
+typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
+typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids);
GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids);
GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id);
GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id);
GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target);
+GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target);
GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params);
#endif
-typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
-typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
-typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
-typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
-#endif
+#endif /* GL_EXT_disjoint_timer_query */
+
+#ifndef GL_EXT_draw_buffers
+#define GL_EXT_draw_buffers 1
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_MAX_DRAW_BUFFERS_EXT 0x8824
+#define GL_DRAW_BUFFER0_EXT 0x8825
+#define GL_DRAW_BUFFER1_EXT 0x8826
+#define GL_DRAW_BUFFER2_EXT 0x8827
+#define GL_DRAW_BUFFER3_EXT 0x8828
+#define GL_DRAW_BUFFER4_EXT 0x8829
+#define GL_DRAW_BUFFER5_EXT 0x882A
+#define GL_DRAW_BUFFER6_EXT 0x882B
+#define GL_DRAW_BUFFER7_EXT 0x882C
+#define GL_DRAW_BUFFER8_EXT 0x882D
+#define GL_DRAW_BUFFER9_EXT 0x882E
+#define GL_DRAW_BUFFER10_EXT 0x882F
+#define GL_DRAW_BUFFER11_EXT 0x8830
+#define GL_DRAW_BUFFER12_EXT 0x8831
+#define GL_DRAW_BUFFER13_EXT 0x8832
+#define GL_DRAW_BUFFER14_EXT 0x8833
+#define GL_DRAW_BUFFER15_EXT 0x8834
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs);
+#endif
+#endif /* GL_EXT_draw_buffers */
+
+#ifndef GL_EXT_draw_buffers_indexed
+#define GL_EXT_draw_buffers_indexed 1
+typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode);
+GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index);
+#endif
+#endif /* GL_EXT_draw_buffers_indexed */
+
+#ifndef GL_EXT_draw_elements_base_vertex
+#define GL_EXT_draw_elements_base_vertex 1
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex);
+#endif
+#endif /* GL_EXT_draw_elements_base_vertex */
+
+#ifndef GL_EXT_draw_instanced
+#define GL_EXT_draw_instanced 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#endif
+#endif /* GL_EXT_draw_instanced */
+
+#ifndef GL_EXT_float_blend
+#define GL_EXT_float_blend 1
+#endif /* GL_EXT_float_blend */
+
+#ifndef GL_EXT_geometry_point_size
+#define GL_EXT_geometry_point_size 1
+#endif /* GL_EXT_geometry_point_size */
+
+#ifndef GL_EXT_geometry_shader
+#define GL_EXT_geometry_shader 1
+#define GL_GEOMETRY_SHADER_EXT 0x8DD9
+#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918
+#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F
+#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E
+#define GL_LINES_ADJACENCY_EXT 0x000A
+#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B
+#define GL_TRIANGLES_ADJACENCY_EXT 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7
+#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
+#define GL_UNDEFINED_VERTEX_EXT 0x8260
+#define GL_PRIMITIVES_GENERATED_EXT 0x8C87
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312
+#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif
+#endif /* GL_EXT_geometry_shader */
+
+#ifndef GL_EXT_gpu_shader5
+#define GL_EXT_gpu_shader5 1
+#endif /* GL_EXT_gpu_shader5 */
+
+#ifndef GL_EXT_instanced_arrays
+#define GL_EXT_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor);
+#endif
+#endif /* GL_EXT_instanced_arrays */
+
+#ifndef GL_EXT_map_buffer_range
+#define GL_EXT_map_buffer_range 1
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void *GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+#endif /* GL_EXT_map_buffer_range */
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);
+#endif
+#endif /* GL_EXT_multi_draw_arrays */
+
+#ifndef GL_EXT_multi_draw_indirect
+#define GL_EXT_multi_draw_indirect 1
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMultiDrawArraysIndirectEXT (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsIndirectEXT (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+#endif
+#endif /* GL_EXT_multi_draw_indirect */
+
+#ifndef GL_EXT_multisampled_compatibility
+#define GL_EXT_multisampled_compatibility 1
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#endif /* GL_EXT_multisampled_compatibility */
+
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_EXT_multisampled_render_to_texture 1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT 0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+#endif /* GL_EXT_multisampled_render_to_texture */
+
+#ifndef GL_EXT_multiview_draw_buffers
+#define GL_EXT_multiview_draw_buffers 1
+#define GL_COLOR_ATTACHMENT_EXT 0x90F0
+#define GL_MULTIVIEW_EXT 0x90F1
+#define GL_DRAW_BUFFER_EXT 0x0C01
+#define GL_READ_BUFFER_EXT 0x0C02
+#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
+typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index);
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices);
+typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
+GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
+GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
+#endif
+#endif /* GL_EXT_multiview_draw_buffers */
+
+#ifndef GL_EXT_occlusion_query_boolean
+#define GL_EXT_occlusion_query_boolean 1
+#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
+#endif /* GL_EXT_occlusion_query_boolean */
+
+#ifndef GL_EXT_polygon_offset_clamp
+#define GL_EXT_polygon_offset_clamp 1
+#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B
+typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp);
+#endif
+#endif /* GL_EXT_polygon_offset_clamp */
+
+#ifndef GL_EXT_post_depth_coverage
+#define GL_EXT_post_depth_coverage 1
+#endif /* GL_EXT_post_depth_coverage */
+
+#ifndef GL_EXT_primitive_bounding_box
+#define GL_EXT_primitive_bounding_box 1
+#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE
+typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#endif
+#endif /* GL_EXT_primitive_bounding_box */
+
+#ifndef GL_EXT_pvrtc_sRGB
+#define GL_EXT_pvrtc_sRGB 1
+#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
+#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
+#endif /* GL_EXT_pvrtc_sRGB */
+
+#ifndef GL_EXT_raster_multisample
+#define GL_EXT_raster_multisample 1
+#define GL_RASTER_MULTISAMPLE_EXT 0x9327
+#define GL_RASTER_SAMPLES_EXT 0x9328
+#define GL_MAX_RASTER_SAMPLES_EXT 0x9329
+#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A
+#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B
+#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C
+typedef void (GL_APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations);
+#endif
+#endif /* GL_EXT_raster_multisample */
-/* GL_EXT_read_format_bgra */
#ifndef GL_EXT_read_format_bgra
#define GL_EXT_read_format_bgra 1
-#endif
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
+#endif /* GL_EXT_read_format_bgra */
+
+#ifndef GL_EXT_render_snorm
+#define GL_EXT_render_snorm 1
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_R16_SNORM_EXT 0x8F98
+#define GL_RG16_SNORM_EXT 0x8F99
+#define GL_RGBA16_SNORM_EXT 0x8F9B
+#endif /* GL_EXT_render_snorm */
-/* GL_EXT_robustness */
#ifndef GL_EXT_robustness
#define GL_EXT_robustness 1
+#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
+#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
+#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
+#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void);
GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
-GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params);
+GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params);
#endif
-typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
-typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
-typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params);
-typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
-#endif
+#endif /* GL_EXT_robustness */
+
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
+#endif /* GL_EXT_sRGB */
+
+#ifndef GL_EXT_sRGB_write_control
+#define GL_EXT_sRGB_write_control 1
+#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
+#endif /* GL_EXT_sRGB_write_control */
-/* GL_EXT_separate_shader_objects */
#ifndef GL_EXT_separate_shader_objects
#define GL_EXT_separate_shader_objects 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
-GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program);
-GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
-GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline);
-GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines);
-GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines);
-GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline);
-GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
-GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
-GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x);
-GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y);
-GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z);
-GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
-GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x);
-GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline);
-GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-#endif
-typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
+#define GL_ACTIVE_PROGRAM_EXT 0x8259
+#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
+#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
+#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE_EXT 0x8258
+#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program);
-typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines);
typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program);
+GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline);
+GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
+GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
+GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
+GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
#endif
+#endif /* GL_EXT_separate_shader_objects */
-/* GL_EXT_shader_framebuffer_fetch */
#ifndef GL_EXT_shader_framebuffer_fetch
#define GL_EXT_shader_framebuffer_fetch 1
-#endif
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#endif /* GL_EXT_shader_framebuffer_fetch */
+
+#ifndef GL_EXT_shader_group_vote
+#define GL_EXT_shader_group_vote 1
+#endif /* GL_EXT_shader_group_vote */
+
+#ifndef GL_EXT_shader_implicit_conversions
+#define GL_EXT_shader_implicit_conversions 1
+#endif /* GL_EXT_shader_implicit_conversions */
+
+#ifndef GL_EXT_shader_integer_mix
+#define GL_EXT_shader_integer_mix 1
+#endif /* GL_EXT_shader_integer_mix */
+
+#ifndef GL_EXT_shader_io_blocks
+#define GL_EXT_shader_io_blocks 1
+#endif /* GL_EXT_shader_io_blocks */
+
+#ifndef GL_EXT_shader_pixel_local_storage
+#define GL_EXT_shader_pixel_local_storage 1
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67
+#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64
+#endif /* GL_EXT_shader_pixel_local_storage */
+
+#ifndef GL_EXT_shader_pixel_local_storage2
+#define GL_EXT_shader_pixel_local_storage2 1
+#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650
+#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651
+#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target, GLsizei size);
+typedef GLsizei (GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target);
+typedef void (GL_APIENTRYP PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) (GLsizei offset, GLsizei n, const GLuint *values);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferPixelLocalStorageSizeEXT (GLuint target, GLsizei size);
+GL_APICALL GLsizei GL_APIENTRY glGetFramebufferPixelLocalStorageSizeEXT (GLuint target);
+GL_APICALL void GL_APIENTRY glClearPixelLocalStorageuiEXT (GLsizei offset, GLsizei n, const GLuint *values);
+#endif
+#endif /* GL_EXT_shader_pixel_local_storage2 */
-/* GL_EXT_shader_texture_lod */
#ifndef GL_EXT_shader_texture_lod
#define GL_EXT_shader_texture_lod 1
-#endif
+#endif /* GL_EXT_shader_texture_lod */
-/* GL_EXT_shadow_samplers */
#ifndef GL_EXT_shadow_samplers
#define GL_EXT_shadow_samplers 1
-#endif
+#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
+#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
+#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
+#endif /* GL_EXT_shadow_samplers */
-/* GL_EXT_sRGB */
-#ifndef GL_EXT_sRGB
-#define GL_EXT_sRGB 1
+#ifndef GL_EXT_sparse_texture
+#define GL_EXT_sparse_texture 1
+#define GL_TEXTURE_SPARSE_EXT 0x91A6
+#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7
+#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA
+#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8
+#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195
+#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196
+#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_3D 0x806F
+#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198
+#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199
+#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A
+#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9
+typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexPageCommitmentEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
#endif
+#endif /* GL_EXT_sparse_texture */
+
+#ifndef GL_EXT_tessellation_point_size
+#define GL_EXT_tessellation_point_size 1
+#endif /* GL_EXT_tessellation_point_size */
+
+#ifndef GL_EXT_tessellation_shader
+#define GL_EXT_tessellation_shader 1
+#define GL_PATCHES_EXT 0x000E
+#define GL_PATCH_VERTICES_EXT 0x8E72
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
+#define GL_TESS_GEN_MODE_EXT 0x8E76
+#define GL_TESS_GEN_SPACING_EXT 0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78
+#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79
+#define GL_ISOLINES_EXT 0x8E7A
+#define GL_QUADS_EXT 0x0007
+#define GL_FRACTIONAL_ODD_EXT 0x8E7B
+#define GL_FRACTIONAL_EVEN_EXT 0x8E7C
+#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
+#define GL_IS_PER_PATCH_EXT 0x92E7
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308
+#define GL_TESS_CONTROL_SHADER_EXT 0x8E88
+#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87
+#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010
+typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value);
+#endif
+#endif /* GL_EXT_tessellation_shader */
+
+#ifndef GL_EXT_texture_border_clamp
+#define GL_EXT_texture_border_clamp 1
+#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004
+#define GL_CLAMP_TO_BORDER_EXT 0x812D
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
+GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param);
+GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params);
+#endif
+#endif /* GL_EXT_texture_border_clamp */
+
+#ifndef GL_EXT_texture_buffer
+#define GL_EXT_texture_buffer 1
+#define GL_TEXTURE_BUFFER_EXT 0x8C2A
+#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F
+#define GL_SAMPLER_BUFFER_EXT 0x8DC2
+#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#define GL_IMAGE_BUFFER_EXT 0x9051
+#define GL_INT_IMAGE_BUFFER_EXT 0x905C
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067
+#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D
+#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E
+typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);
+GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif
+#endif /* GL_EXT_texture_buffer */
-/* GL_EXT_texture_compression_dxt1 */
#ifndef GL_EXT_texture_compression_dxt1
#define GL_EXT_texture_compression_dxt1 1
-#endif
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#endif /* GL_EXT_texture_compression_dxt1 */
+
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_EXT_texture_compression_s3tc 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#endif /* GL_EXT_texture_compression_s3tc */
+
+#ifndef GL_EXT_texture_cube_map_array
+#define GL_EXT_texture_cube_map_array 1
+#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A
+#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#endif /* GL_EXT_texture_cube_map_array */
-/* GL_EXT_texture_filter_anisotropic */
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_EXT_texture_filter_anisotropic 1
-#endif
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif /* GL_EXT_texture_filter_anisotropic */
+
+#ifndef GL_EXT_texture_filter_minmax
+#define GL_EXT_texture_filter_minmax 1
+#endif /* GL_EXT_texture_filter_minmax */
-/* GL_EXT_texture_format_BGRA8888 */
#ifndef GL_EXT_texture_format_BGRA8888
#define GL_EXT_texture_format_BGRA8888 1
-#endif
+#endif /* GL_EXT_texture_format_BGRA8888 */
+
+#ifndef GL_EXT_texture_norm16
+#define GL_EXT_texture_norm16 1
+#define GL_R16_EXT 0x822A
+#define GL_RG16_EXT 0x822C
+#define GL_RGBA16_EXT 0x805B
+#define GL_RGB16_EXT 0x8054
+#define GL_RGB16_SNORM_EXT 0x8F9A
+#endif /* GL_EXT_texture_norm16 */
-/* GL_EXT_texture_rg */
#ifndef GL_EXT_texture_rg
#define GL_EXT_texture_rg 1
-#endif
+#define GL_RED_EXT 0x1903
+#define GL_RG_EXT 0x8227
+#define GL_R8_EXT 0x8229
+#define GL_RG8_EXT 0x822B
+#endif /* GL_EXT_texture_rg */
+
+#ifndef GL_EXT_texture_sRGB_R8
+#define GL_EXT_texture_sRGB_R8 1
+#define GL_SR8_EXT 0x8FBD
+#endif /* GL_EXT_texture_sRGB_R8 */
+
+#ifndef GL_EXT_texture_sRGB_RG8
+#define GL_EXT_texture_sRGB_RG8 1
+#define GL_SRG8_EXT 0x8FBE
+#endif /* GL_EXT_texture_sRGB_RG8 */
+
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_EXT_texture_sRGB_decode 1
+#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
+#define GL_DECODE_EXT 0x8A49
+#define GL_SKIP_DECODE_EXT 0x8A4A
+#endif /* GL_EXT_texture_sRGB_decode */
-/* GL_EXT_texture_storage */
#ifndef GL_EXT_texture_storage
#define GL_EXT_texture_storage 1
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
+#define GL_ALPHA8_EXT 0x803C
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_RGBA32F_EXT 0x8814
+#define GL_RGB32F_EXT 0x8815
+#define GL_ALPHA32F_EXT 0x8816
+#define GL_LUMINANCE32F_EXT 0x8818
+#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
+#define GL_ALPHA16F_EXT 0x881C
+#define GL_LUMINANCE16F_EXT 0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
+#define GL_R32F_EXT 0x822E
+#define GL_RG32F_EXT 0x8230
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
@@ -1536,123 +1890,377 @@ GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target
GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif
-typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-#endif
+#endif /* GL_EXT_texture_storage */
-/* GL_EXT_texture_type_2_10_10_10_REV */
#ifndef GL_EXT_texture_type_2_10_10_10_REV
#define GL_EXT_texture_type_2_10_10_10_REV 1
-#endif
+#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
+#endif /* GL_EXT_texture_type_2_10_10_10_REV */
+
+#ifndef GL_EXT_texture_view
+#define GL_EXT_texture_view 1
+#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE
+typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif
+#endif /* GL_EXT_texture_view */
-/* GL_EXT_unpack_subimage */
#ifndef GL_EXT_unpack_subimage
#define GL_EXT_unpack_subimage 1
-#endif
+#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
+#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
+#endif /* GL_EXT_unpack_subimage */
-/*------------------------------------------------------------------------*
- * DMP extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_DMP_shader_binary 1
-#endif
-
-/*------------------------------------------------------------------------*
- * FJ extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_FJ_shader_binary_GCCSO */
#ifndef GL_FJ_shader_binary_GCCSO
#define GL_FJ_shader_binary_GCCSO 1
+#define GL_GCCSO_SHADER_BINARY_FJ 0x9260
+#endif /* GL_FJ_shader_binary_GCCSO */
+
+#ifndef GL_IMG_framebuffer_downsample
+#define GL_IMG_framebuffer_downsample 1
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_AND_DOWNSAMPLE_IMG 0x913C
+#define GL_NUM_DOWNSAMPLE_SCALES_IMG 0x913D
+#define GL_DOWNSAMPLE_SCALES_IMG 0x913E
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SCALE_IMG 0x913F
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DDownsampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale);
+GL_APICALL void GL_APIENTRY glFramebufferTextureLayerDownsampleIMG (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale);
#endif
+#endif /* GL_IMG_framebuffer_downsample */
-/*------------------------------------------------------------------------*
- * IMG extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_program_binary */
-#ifndef GL_IMG_program_binary
-#define GL_IMG_program_binary 1
-#endif
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_IMG_read_format 1
-#endif
-
-/* GL_IMG_shader_binary */
-#ifndef GL_IMG_shader_binary
-#define GL_IMG_shader_binary 1
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_IMG_texture_compression_pvrtc 1
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
#ifndef GL_IMG_multisampled_render_to_texture
#define GL_IMG_multisampled_render_to_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
-#endif
+#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
+#define GL_MAX_SAMPLES_IMG 0x9135
+#define GL_TEXTURE_SAMPLES_IMG 0x9136
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
#endif
+#endif /* GL_IMG_multisampled_render_to_texture */
-/*------------------------------------------------------------------------*
- * NV extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_IMG_program_binary
+#define GL_IMG_program_binary 1
+#define GL_SGX_PROGRAM_BINARY_IMG 0x9130
+#endif /* GL_IMG_program_binary */
+
+#ifndef GL_IMG_read_format
+#define GL_IMG_read_format 1
+#define GL_BGRA_IMG 0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365
+#endif /* GL_IMG_read_format */
+
+#ifndef GL_IMG_shader_binary
+#define GL_IMG_shader_binary 1
+#define GL_SGX_BINARY_IMG 0x8C0A
+#endif /* GL_IMG_shader_binary */
+
+#ifndef GL_IMG_texture_compression_pvrtc
+#define GL_IMG_texture_compression_pvrtc 1
+#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
+#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
+#endif /* GL_IMG_texture_compression_pvrtc */
+
+#ifndef GL_IMG_texture_compression_pvrtc2
+#define GL_IMG_texture_compression_pvrtc2 1
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
+#endif /* GL_IMG_texture_compression_pvrtc2 */
+
+#ifndef GL_IMG_texture_filter_cubic
+#define GL_IMG_texture_filter_cubic 1
+#define GL_CUBIC_IMG 0x9139
+#define GL_CUBIC_MIPMAP_NEAREST_IMG 0x913A
+#define GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B
+#endif /* GL_IMG_texture_filter_cubic */
+
+#ifndef GL_INTEL_framebuffer_CMAA
+#define GL_INTEL_framebuffer_CMAA 1
+typedef void (GL_APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void);
+#endif
+#endif /* GL_INTEL_framebuffer_CMAA */
+
+#ifndef GL_INTEL_performance_query
+#define GL_INTEL_performance_query 1
+#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000
+#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001
+#define GL_PERFQUERY_WAIT_INTEL 0x83FB
+#define GL_PERFQUERY_FLUSH_INTEL 0x83FA
+#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9
+#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0
+#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1
+#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2
+#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3
+#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4
+#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5
+#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8
+#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9
+#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA
+#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB
+#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC
+#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD
+#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE
+#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF
+#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500
+typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle);
+typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId);
+typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId);
+typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle);
+GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId);
+GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId);
+GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);
+GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);
+GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId);
+GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);
+#endif
+#endif /* GL_INTEL_performance_query */
+
+#ifndef GL_NV_bindless_texture
+#define GL_NV_bindless_texture 1
+typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);
+typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler);
+typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);
+typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle);
+typedef GLuint64 (GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
+typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access);
+typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle);
+typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
+typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);
+typedef GLboolean (GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV (GLuint texture);
+GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler);
+GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle);
+GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle);
+GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
+GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access);
+GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle);
+GL_APICALL void GL_APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value);
+GL_APICALL void GL_APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value);
+GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value);
+GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
+GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV (GLuint64 handle);
+GL_APICALL GLboolean GL_APIENTRY glIsImageHandleResidentNV (GLuint64 handle);
+#endif
+#endif /* GL_NV_bindless_texture */
+
+#ifndef GL_NV_blend_equation_advanced
+#define GL_NV_blend_equation_advanced 1
+#define GL_BLEND_OVERLAP_NV 0x9281
+#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280
+#define GL_BLUE_NV 0x1905
+#define GL_COLORBURN_NV 0x929A
+#define GL_COLORDODGE_NV 0x9299
+#define GL_CONJOINT_NV 0x9284
+#define GL_CONTRAST_NV 0x92A1
+#define GL_DARKEN_NV 0x9297
+#define GL_DIFFERENCE_NV 0x929E
+#define GL_DISJOINT_NV 0x9283
+#define GL_DST_ATOP_NV 0x928F
+#define GL_DST_IN_NV 0x928B
+#define GL_DST_NV 0x9287
+#define GL_DST_OUT_NV 0x928D
+#define GL_DST_OVER_NV 0x9289
+#define GL_EXCLUSION_NV 0x92A0
+#define GL_GREEN_NV 0x1904
+#define GL_HARDLIGHT_NV 0x929B
+#define GL_HARDMIX_NV 0x92A9
+#define GL_HSL_COLOR_NV 0x92AF
+#define GL_HSL_HUE_NV 0x92AD
+#define GL_HSL_LUMINOSITY_NV 0x92B0
+#define GL_HSL_SATURATION_NV 0x92AE
+#define GL_INVERT_OVG_NV 0x92B4
+#define GL_INVERT_RGB_NV 0x92A3
+#define GL_LIGHTEN_NV 0x9298
+#define GL_LINEARBURN_NV 0x92A5
+#define GL_LINEARDODGE_NV 0x92A4
+#define GL_LINEARLIGHT_NV 0x92A7
+#define GL_MINUS_CLAMPED_NV 0x92B3
+#define GL_MINUS_NV 0x929F
+#define GL_MULTIPLY_NV 0x9294
+#define GL_OVERLAY_NV 0x9296
+#define GL_PINLIGHT_NV 0x92A8
+#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2
+#define GL_PLUS_CLAMPED_NV 0x92B1
+#define GL_PLUS_DARKER_NV 0x9292
+#define GL_PLUS_NV 0x9291
+#define GL_RED_NV 0x1903
+#define GL_SCREEN_NV 0x9295
+#define GL_SOFTLIGHT_NV 0x929C
+#define GL_SRC_ATOP_NV 0x928E
+#define GL_SRC_IN_NV 0x928A
+#define GL_SRC_NV 0x9286
+#define GL_SRC_OUT_NV 0x928C
+#define GL_SRC_OVER_NV 0x9288
+#define GL_UNCORRELATED_NV 0x9282
+#define GL_VIVIDLIGHT_NV 0x92A6
+#define GL_XOR_NV 0x1506
+typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glBlendBarrierNV (void);
+#endif
+#endif /* GL_NV_blend_equation_advanced */
+
+#ifndef GL_NV_blend_equation_advanced_coherent
+#define GL_NV_blend_equation_advanced_coherent 1
+#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285
+#endif /* GL_NV_blend_equation_advanced_coherent */
+
+#ifndef GL_NV_conditional_render
+#define GL_NV_conditional_render 1
+#define GL_QUERY_WAIT_NV 0x8E13
+#define GL_QUERY_NO_WAIT_NV 0x8E14
+#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16
+typedef void (GL_APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);
+typedef void (GL_APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode);
+GL_APICALL void GL_APIENTRY glEndConditionalRenderNV (void);
+#endif
+#endif /* GL_NV_conditional_render */
+
+#ifndef GL_NV_conservative_raster
+#define GL_NV_conservative_raster 1
+#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346
+#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347
+#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348
+#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349
+typedef void (GL_APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits);
+#endif
+#endif /* GL_NV_conservative_raster */
+
+#ifndef GL_NV_copy_buffer
+#define GL_NV_copy_buffer 1
+#define GL_COPY_READ_BUFFER_NV 0x8F36
+#define GL_COPY_WRITE_BUFFER_NV 0x8F37
+typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif
+#endif /* GL_NV_copy_buffer */
-/* GL_NV_coverage_sample */
#ifndef GL_NV_coverage_sample
#define GL_NV_coverage_sample 1
+#define GL_COVERAGE_COMPONENT_NV 0x8ED0
+#define GL_COVERAGE_COMPONENT4_NV 0x8ED1
+#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2
+#define GL_COVERAGE_BUFFERS_NV 0x8ED3
+#define GL_COVERAGE_SAMPLES_NV 0x8ED4
+#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5
+#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6
+#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7
+#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000
+typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
+typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
#endif
-typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
-typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
-#endif
+#endif /* GL_NV_coverage_sample */
-/* GL_NV_depth_nonlinear */
#ifndef GL_NV_depth_nonlinear
#define GL_NV_depth_nonlinear 1
-#endif
+#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
+#endif /* GL_NV_depth_nonlinear */
-/* GL_NV_draw_buffers */
#ifndef GL_NV_draw_buffers
#define GL_NV_draw_buffers 1
+#define GL_MAX_DRAW_BUFFERS_NV 0x8824
+#define GL_DRAW_BUFFER0_NV 0x8825
+#define GL_DRAW_BUFFER1_NV 0x8826
+#define GL_DRAW_BUFFER2_NV 0x8827
+#define GL_DRAW_BUFFER3_NV 0x8828
+#define GL_DRAW_BUFFER4_NV 0x8829
+#define GL_DRAW_BUFFER5_NV 0x882A
+#define GL_DRAW_BUFFER6_NV 0x882B
+#define GL_DRAW_BUFFER7_NV 0x882C
+#define GL_DRAW_BUFFER8_NV 0x882D
+#define GL_DRAW_BUFFER9_NV 0x882E
+#define GL_DRAW_BUFFER10_NV 0x882F
+#define GL_DRAW_BUFFER11_NV 0x8830
+#define GL_DRAW_BUFFER12_NV 0x8831
+#define GL_DRAW_BUFFER13_NV 0x8832
+#define GL_DRAW_BUFFER14_NV 0x8833
+#define GL_DRAW_BUFFER15_NV 0x8834
+#define GL_COLOR_ATTACHMENT0_NV 0x8CE0
+#define GL_COLOR_ATTACHMENT1_NV 0x8CE1
+#define GL_COLOR_ATTACHMENT2_NV 0x8CE2
+#define GL_COLOR_ATTACHMENT3_NV 0x8CE3
+#define GL_COLOR_ATTACHMENT4_NV 0x8CE4
+#define GL_COLOR_ATTACHMENT5_NV 0x8CE5
+#define GL_COLOR_ATTACHMENT6_NV 0x8CE6
+#define GL_COLOR_ATTACHMENT7_NV 0x8CE7
+#define GL_COLOR_ATTACHMENT8_NV 0x8CE8
+#define GL_COLOR_ATTACHMENT9_NV 0x8CE9
+#define GL_COLOR_ATTACHMENT10_NV 0x8CEA
+#define GL_COLOR_ATTACHMENT11_NV 0x8CEB
+#define GL_COLOR_ATTACHMENT12_NV 0x8CEC
+#define GL_COLOR_ATTACHMENT13_NV 0x8CED
+#define GL_COLOR_ATTACHMENT14_NV 0x8CEE
+#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
#endif
-typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
-#endif
+#endif /* GL_NV_draw_buffers */
+
+#ifndef GL_NV_draw_instanced
+#define GL_NV_draw_instanced 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#endif
+#endif /* GL_NV_draw_instanced */
+
+#ifndef GL_NV_explicit_attrib_location
+#define GL_NV_explicit_attrib_location 1
+#endif /* GL_NV_explicit_attrib_location */
-/* GL_NV_fbo_color_attachments */
#ifndef GL_NV_fbo_color_attachments
#define GL_NV_fbo_color_attachments 1
-#endif
+#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
+#endif /* GL_NV_fbo_color_attachments */
-/* GL_NV_fence */
#ifndef GL_NV_fence
#define GL_NV_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
-GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
-GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint);
-GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint);
-GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
-GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint);
-GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
-#endif
+#define GL_ALL_COMPLETED_NV 0x84F2
+#define GL_FENCE_STATUS_NV 0x84F3
+#define GL_FENCE_CONDITION_NV 0x84F4
typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
@@ -1660,83 +2268,636 @@ typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
+GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
+GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence);
+GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence);
+GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence);
+GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
#endif
+#endif /* GL_NV_fence */
+
+#ifndef GL_NV_fill_rectangle
+#define GL_NV_fill_rectangle 1
+#define GL_FILL_RECTANGLE_NV 0x933C
+#endif /* GL_NV_fill_rectangle */
+
+#ifndef GL_NV_fragment_coverage_to_color
+#define GL_NV_fragment_coverage_to_color 1
+#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD
+#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE
+typedef void (GL_APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFragmentCoverageColorNV (GLuint color);
+#endif
+#endif /* GL_NV_fragment_coverage_to_color */
+
+#ifndef GL_NV_fragment_shader_interlock
+#define GL_NV_fragment_shader_interlock 1
+#endif /* GL_NV_fragment_shader_interlock */
+
+#ifndef GL_NV_framebuffer_blit
+#define GL_NV_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_NV 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA
+typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+#endif /* GL_NV_framebuffer_blit */
+
+#ifndef GL_NV_framebuffer_mixed_samples
+#define GL_NV_framebuffer_mixed_samples 1
+#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331
+#define GL_COLOR_SAMPLES_NV 0x8E20
+#define GL_DEPTH_SAMPLES_NV 0x932D
+#define GL_STENCIL_SAMPLES_NV 0x932E
+#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F
+#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330
+#define GL_COVERAGE_MODULATION_NV 0x9332
+#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333
+typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glGetCoverageModulationTableNV (GLsizei bufsize, GLfloat *v);
+GL_APICALL void GL_APIENTRY glCoverageModulationNV (GLenum components);
+#endif
+#endif /* GL_NV_framebuffer_mixed_samples */
+
+#ifndef GL_NV_framebuffer_multisample
+#define GL_NV_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56
+#define GL_MAX_SAMPLES_NV 0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+#endif /* GL_NV_framebuffer_multisample */
+
+#ifndef GL_NV_generate_mipmap_sRGB
+#define GL_NV_generate_mipmap_sRGB 1
+#endif /* GL_NV_generate_mipmap_sRGB */
+
+#ifndef GL_NV_geometry_shader_passthrough
+#define GL_NV_geometry_shader_passthrough 1
+#endif /* GL_NV_geometry_shader_passthrough */
+
+#ifndef GL_NV_image_formats
+#define GL_NV_image_formats 1
+#endif /* GL_NV_image_formats */
+
+#ifndef GL_NV_instanced_arrays
+#define GL_NV_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor);
+#endif
+#endif /* GL_NV_instanced_arrays */
+
+#ifndef GL_NV_internalformat_sample_query
+#define GL_NV_internalformat_sample_query 1
+#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
+#define GL_MULTISAMPLES_NV 0x9371
+#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372
+#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373
+#define GL_CONFORMANT_NV 0x9374
+typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params);
+#endif
+#endif /* GL_NV_internalformat_sample_query */
+
+#ifndef GL_NV_non_square_matrices
+#define GL_NV_non_square_matrices 1
+#define GL_FLOAT_MAT2x3_NV 0x8B65
+#define GL_FLOAT_MAT2x4_NV 0x8B66
+#define GL_FLOAT_MAT3x2_NV 0x8B67
+#define GL_FLOAT_MAT3x4_NV 0x8B68
+#define GL_FLOAT_MAT4x2_NV 0x8B69
+#define GL_FLOAT_MAT4x3_NV 0x8B6A
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif
+#endif /* GL_NV_non_square_matrices */
+
+#ifndef GL_NV_path_rendering
+#define GL_NV_path_rendering 1
+#define GL_PATH_FORMAT_SVG_NV 0x9070
+#define GL_PATH_FORMAT_PS_NV 0x9071
+#define GL_STANDARD_FONT_NAME_NV 0x9072
+#define GL_SYSTEM_FONT_NAME_NV 0x9073
+#define GL_FILE_NAME_NV 0x9074
+#define GL_PATH_STROKE_WIDTH_NV 0x9075
+#define GL_PATH_END_CAPS_NV 0x9076
+#define GL_PATH_INITIAL_END_CAP_NV 0x9077
+#define GL_PATH_TERMINAL_END_CAP_NV 0x9078
+#define GL_PATH_JOIN_STYLE_NV 0x9079
+#define GL_PATH_MITER_LIMIT_NV 0x907A
+#define GL_PATH_DASH_CAPS_NV 0x907B
+#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C
+#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D
+#define GL_PATH_DASH_OFFSET_NV 0x907E
+#define GL_PATH_CLIENT_LENGTH_NV 0x907F
+#define GL_PATH_FILL_MODE_NV 0x9080
+#define GL_PATH_FILL_MASK_NV 0x9081
+#define GL_PATH_FILL_COVER_MODE_NV 0x9082
+#define GL_PATH_STROKE_COVER_MODE_NV 0x9083
+#define GL_PATH_STROKE_MASK_NV 0x9084
+#define GL_COUNT_UP_NV 0x9088
+#define GL_COUNT_DOWN_NV 0x9089
+#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A
+#define GL_CONVEX_HULL_NV 0x908B
+#define GL_BOUNDING_BOX_NV 0x908D
+#define GL_TRANSLATE_X_NV 0x908E
+#define GL_TRANSLATE_Y_NV 0x908F
+#define GL_TRANSLATE_2D_NV 0x9090
+#define GL_TRANSLATE_3D_NV 0x9091
+#define GL_AFFINE_2D_NV 0x9092
+#define GL_AFFINE_3D_NV 0x9094
+#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096
+#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098
+#define GL_UTF8_NV 0x909A
+#define GL_UTF16_NV 0x909B
+#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C
+#define GL_PATH_COMMAND_COUNT_NV 0x909D
+#define GL_PATH_COORD_COUNT_NV 0x909E
+#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F
+#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0
+#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1
+#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2
+#define GL_SQUARE_NV 0x90A3
+#define GL_ROUND_NV 0x90A4
+#define GL_TRIANGULAR_NV 0x90A5
+#define GL_BEVEL_NV 0x90A6
+#define GL_MITER_REVERT_NV 0x90A7
+#define GL_MITER_TRUNCATE_NV 0x90A8
+#define GL_SKIP_MISSING_GLYPH_NV 0x90A9
+#define GL_USE_MISSING_GLYPH_NV 0x90AA
+#define GL_PATH_ERROR_POSITION_NV 0x90AB
+#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD
+#define GL_ADJACENT_PAIRS_NV 0x90AE
+#define GL_FIRST_TO_REST_NV 0x90AF
+#define GL_PATH_GEN_MODE_NV 0x90B0
+#define GL_PATH_GEN_COEFF_NV 0x90B1
+#define GL_PATH_GEN_COMPONENTS_NV 0x90B3
+#define GL_PATH_STENCIL_FUNC_NV 0x90B7
+#define GL_PATH_STENCIL_REF_NV 0x90B8
+#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9
+#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD
+#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE
+#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF
+#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4
+#define GL_MOVE_TO_RESETS_NV 0x90B5
+#define GL_MOVE_TO_CONTINUES_NV 0x90B6
+#define GL_CLOSE_PATH_NV 0x00
+#define GL_MOVE_TO_NV 0x02
+#define GL_RELATIVE_MOVE_TO_NV 0x03
+#define GL_LINE_TO_NV 0x04
+#define GL_RELATIVE_LINE_TO_NV 0x05
+#define GL_HORIZONTAL_LINE_TO_NV 0x06
+#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07
+#define GL_VERTICAL_LINE_TO_NV 0x08
+#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09
+#define GL_QUADRATIC_CURVE_TO_NV 0x0A
+#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B
+#define GL_CUBIC_CURVE_TO_NV 0x0C
+#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D
+#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E
+#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F
+#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10
+#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11
+#define GL_SMALL_CCW_ARC_TO_NV 0x12
+#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13
+#define GL_SMALL_CW_ARC_TO_NV 0x14
+#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15
+#define GL_LARGE_CCW_ARC_TO_NV 0x16
+#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17
+#define GL_LARGE_CW_ARC_TO_NV 0x18
+#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19
+#define GL_RESTART_PATH_NV 0xF0
+#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2
+#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4
+#define GL_RECT_NV 0xF6
+#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8
+#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA
+#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC
+#define GL_ARC_TO_NV 0xFE
+#define GL_RELATIVE_ARC_TO_NV 0xFF
+#define GL_BOLD_BIT_NV 0x01
+#define GL_ITALIC_BIT_NV 0x02
+#define GL_GLYPH_WIDTH_BIT_NV 0x01
+#define GL_GLYPH_HEIGHT_BIT_NV 0x02
+#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04
+#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08
+#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10
+#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20
+#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40
+#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80
+#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100
+#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000
+#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000
+#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000
+#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000
+#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000
+#define GL_FONT_ASCENDER_BIT_NV 0x00200000
+#define GL_FONT_DESCENDER_BIT_NV 0x00400000
+#define GL_FONT_HEIGHT_BIT_NV 0x00800000
+#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000
+#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000
+#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000
+#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000
+#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000
+#define GL_ROUNDED_RECT_NV 0xE8
+#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9
+#define GL_ROUNDED_RECT2_NV 0xEA
+#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB
+#define GL_ROUNDED_RECT4_NV 0xEC
+#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED
+#define GL_ROUNDED_RECT8_NV 0xEE
+#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF
+#define GL_RELATIVE_RECT_NV 0xF7
+#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368
+#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369
+#define GL_FONT_UNAVAILABLE_NV 0x936A
+#define GL_FONT_UNINTELLIGIBLE_NV 0x936B
+#define GL_CONIC_CURVE_TO_NV 0x1A
+#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B
+#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000
+#define GL_STANDARD_FONT_FORMAT_NV 0x936C
+#define GL_PATH_PROJECTION_NV 0x1701
+#define GL_PATH_MODELVIEW_NV 0x1700
+#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3
+#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6
+#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36
+#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3
+#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4
+#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7
+#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38
+#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4
+#define GL_FRAGMENT_INPUT_NV 0x936D
+typedef GLuint (GL_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range);
+typedef void (GL_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);
+typedef GLboolean (GL_APIENTRYP PFNGLISPATHNVPROC) (GLuint path);
+typedef void (GL_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);
+typedef void (GL_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords);
+typedef void (GL_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);
+typedef void (GL_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords);
+typedef void (GL_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString);
+typedef void (GL_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (GL_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (GL_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
+typedef void (GL_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);
+typedef void (GL_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
+typedef void (GL_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
+typedef void (GL_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);
+typedef void (GL_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
+typedef void (GL_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);
+typedef void (GL_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);
+typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);
+typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);
+typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+typedef void (GL_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func);
+typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);
+typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode);
+typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value);
+typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands);
+typedef void (GL_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords);
+typedef void (GL_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray);
+typedef void (GL_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
+typedef void (GL_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
+typedef void (GL_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
+typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);
+typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);
+typedef GLfloat (GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);
+typedef GLboolean (GL_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);
+typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode);
+typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);
+typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef GLenum (GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLuint GL_APIENTRY glGenPathsNV (GLsizei range);
+GL_APICALL void GL_APIENTRY glDeletePathsNV (GLuint path, GLsizei range);
+GL_APICALL GLboolean GL_APIENTRY glIsPathNV (GLuint path);
+GL_APICALL void GL_APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);
+GL_APICALL void GL_APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords);
+GL_APICALL void GL_APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);
+GL_APICALL void GL_APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords);
+GL_APICALL void GL_APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString);
+GL_APICALL void GL_APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GL_APICALL void GL_APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GL_APICALL void GL_APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
+GL_APICALL void GL_APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath);
+GL_APICALL void GL_APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
+GL_APICALL void GL_APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL void GL_APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value);
+GL_APICALL void GL_APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value);
+GL_APICALL void GL_APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
+GL_APICALL void GL_APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units);
+GL_APICALL void GL_APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL void GL_APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL void GL_APIENTRY glPathCoverDepthFuncNV (GLenum func);
+GL_APICALL void GL_APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode);
+GL_APICALL void GL_APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode);
+GL_APICALL void GL_APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL void GL_APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL void GL_APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value);
+GL_APICALL void GL_APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value);
+GL_APICALL void GL_APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands);
+GL_APICALL void GL_APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords);
+GL_APICALL void GL_APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray);
+GL_APICALL void GL_APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
+GL_APICALL void GL_APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
+GL_APICALL void GL_APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
+GL_APICALL GLboolean GL_APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y);
+GL_APICALL GLboolean GL_APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y);
+GL_APICALL GLfloat GL_APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments);
+GL_APICALL GLboolean GL_APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+GL_APICALL void GL_APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m);
+GL_APICALL void GL_APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m);
+GL_APICALL void GL_APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m);
+GL_APICALL void GL_APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m);
+GL_APICALL void GL_APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m);
+GL_APICALL void GL_APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m);
+GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);
+GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode);
+GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);
+GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GL_APICALL GLenum GL_APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GL_APICALL void GL_APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);
+GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);
+#endif
+#endif /* GL_NV_path_rendering */
+
+#ifndef GL_NV_path_rendering_shared_edge
+#define GL_NV_path_rendering_shared_edge 1
+#define GL_SHARED_EDGE_NV 0xC0
+#endif /* GL_NV_path_rendering_shared_edge */
+
+#ifndef GL_NV_polygon_mode
+#define GL_NV_polygon_mode 1
+#define GL_POLYGON_MODE_NV 0x0B40
+#define GL_POLYGON_OFFSET_POINT_NV 0x2A01
+#define GL_POLYGON_OFFSET_LINE_NV 0x2A02
+#define GL_POINT_NV 0x1B00
+#define GL_LINE_NV 0x1B01
+#define GL_FILL_NV 0x1B02
+typedef void (GL_APIENTRYP PFNGLPOLYGONMODENVPROC) (GLenum face, GLenum mode);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPolygonModeNV (GLenum face, GLenum mode);
+#endif
+#endif /* GL_NV_polygon_mode */
-/* GL_NV_read_buffer */
#ifndef GL_NV_read_buffer
#define GL_NV_read_buffer 1
+#define GL_READ_BUFFER_NV 0x0C02
+typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
#endif
-typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
-#endif
+#endif /* GL_NV_read_buffer */
-/* GL_NV_read_buffer_front */
#ifndef GL_NV_read_buffer_front
#define GL_NV_read_buffer_front 1
-#endif
+#endif /* GL_NV_read_buffer_front */
-/* GL_NV_read_depth */
#ifndef GL_NV_read_depth
#define GL_NV_read_depth 1
-#endif
+#endif /* GL_NV_read_depth */
-/* GL_NV_read_depth_stencil */
#ifndef GL_NV_read_depth_stencil
#define GL_NV_read_depth_stencil 1
-#endif
+#endif /* GL_NV_read_depth_stencil */
-/* GL_NV_read_stencil */
#ifndef GL_NV_read_stencil
#define GL_NV_read_stencil 1
-#endif
+#endif /* GL_NV_read_stencil */
+
+#ifndef GL_NV_sRGB_formats
+#define GL_NV_sRGB_formats 1
+#define GL_SLUMINANCE_NV 0x8C46
+#define GL_SLUMINANCE_ALPHA_NV 0x8C44
+#define GL_SRGB8_NV 0x8C41
+#define GL_SLUMINANCE8_NV 0x8C47
+#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F
+#define GL_ETC1_SRGB8_NV 0x88EE
+#endif /* GL_NV_sRGB_formats */
+
+#ifndef GL_NV_sample_locations
+#define GL_NV_sample_locations 1
+#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D
+#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E
+#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F
+#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340
+#define GL_SAMPLE_LOCATION_NV 0x8E50
+#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341
+#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342
+#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void);
+#endif
+#endif /* GL_NV_sample_locations */
+
+#ifndef GL_NV_sample_mask_override_coverage
+#define GL_NV_sample_mask_override_coverage 1
+#endif /* GL_NV_sample_mask_override_coverage */
+
+#ifndef GL_NV_shader_noperspective_interpolation
+#define GL_NV_shader_noperspective_interpolation 1
+#endif /* GL_NV_shader_noperspective_interpolation */
+
+#ifndef GL_NV_shadow_samplers_array
+#define GL_NV_shadow_samplers_array 1
+#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4
+#endif /* GL_NV_shadow_samplers_array */
+
+#ifndef GL_NV_shadow_samplers_cube
+#define GL_NV_shadow_samplers_cube 1
+#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5
+#endif /* GL_NV_shadow_samplers_cube */
+
+#ifndef GL_NV_texture_border_clamp
+#define GL_NV_texture_border_clamp 1
+#define GL_TEXTURE_BORDER_COLOR_NV 0x1004
+#define GL_CLAMP_TO_BORDER_NV 0x812D
+#endif /* GL_NV_texture_border_clamp */
-/* GL_NV_texture_compression_s3tc_update */
#ifndef GL_NV_texture_compression_s3tc_update
#define GL_NV_texture_compression_s3tc_update 1
-#endif
+#endif /* GL_NV_texture_compression_s3tc_update */
-/* GL_NV_texture_npot_2D_mipmap */
#ifndef GL_NV_texture_npot_2D_mipmap
#define GL_NV_texture_npot_2D_mipmap 1
+#endif /* GL_NV_texture_npot_2D_mipmap */
+
+#ifndef GL_NV_viewport_array
+#define GL_NV_viewport_array 1
+#define GL_MAX_VIEWPORTS_NV 0x825B
+#define GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C
+#define GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D
+#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F
+typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVNVPROC) (GLuint first, GLsizei count, const GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v);
+typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDNVPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVNVPROC) (GLuint index, const GLint *v);
+typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVNVPROC) (GLuint first, GLsizei count, const GLfloat *v);
+typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFNVPROC) (GLuint index, GLfloat n, GLfloat f);
+typedef void (GL_APIENTRYP PFNGLGETFLOATI_VNVPROC) (GLenum target, GLuint index, GLfloat *data);
+typedef void (GL_APIENTRYP PFNGLENABLEINVPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLDISABLEINVPROC) (GLenum target, GLuint index);
+typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDINVPROC) (GLenum target, GLuint index);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glViewportArrayvNV (GLuint first, GLsizei count, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glViewportIndexedfNV (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+GL_APICALL void GL_APIENTRY glViewportIndexedfvNV (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glScissorArrayvNV (GLuint first, GLsizei count, const GLint *v);
+GL_APICALL void GL_APIENTRY glScissorIndexedNV (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glScissorIndexedvNV (GLuint index, const GLint *v);
+GL_APICALL void GL_APIENTRY glDepthRangeArrayfvNV (GLuint first, GLsizei count, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glDepthRangeIndexedfNV (GLuint index, GLfloat n, GLfloat f);
+GL_APICALL void GL_APIENTRY glGetFloati_vNV (GLenum target, GLuint index, GLfloat *data);
+GL_APICALL void GL_APIENTRY glEnableiNV (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glDisableiNV (GLenum target, GLuint index);
+GL_APICALL GLboolean GL_APIENTRY glIsEnablediNV (GLenum target, GLuint index);
#endif
+#endif /* GL_NV_viewport_array */
-/*------------------------------------------------------------------------*
- * QCOM extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_NV_viewport_array2
+#define GL_NV_viewport_array2 1
+#endif /* GL_NV_viewport_array2 */
+
+#ifndef GL_OVR_multiview
+#define GL_OVR_multiview 1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632
+#define GL_MAX_VIEWS_OVR 0x9631
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews);
+#endif
+#endif /* GL_OVR_multiview */
+
+#ifndef GL_OVR_multiview2
+#define GL_OVR_multiview2 1
+#endif /* GL_OVR_multiview2 */
+
+#ifndef GL_OVR_multiview_multisampled_render_to_texture
+#define GL_OVR_multiview_multisampled_render_to_texture 1
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTextureMultisampleMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews);
+#endif
+#endif /* GL_OVR_multiview_multisampled_render_to_texture */
-/* GL_QCOM_alpha_test */
#ifndef GL_QCOM_alpha_test
#define GL_QCOM_alpha_test 1
+#define GL_ALPHA_TEST_QCOM 0x0BC0
+#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
+#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
#endif
-typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
-#endif
+#endif /* GL_QCOM_alpha_test */
-/* GL_QCOM_binning_control */
#ifndef GL_QCOM_binning_control
#define GL_QCOM_binning_control 1
-#endif
+#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0
+#define GL_CPU_OPTIMIZED_QCOM 0x8FB1
+#define GL_GPU_OPTIMIZED_QCOM 0x8FB2
+#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3
+#endif /* GL_QCOM_binning_control */
-/* GL_QCOM_driver_control */
#ifndef GL_QCOM_driver_control
#define GL_QCOM_driver_control 1
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
+typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
#endif
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
-typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-#endif
+#endif /* GL_QCOM_driver_control */
-/* GL_QCOM_extended_get */
#ifndef GL_QCOM_extended_get
#define GL_QCOM_extended_get 1
+#define GL_TEXTURE_WIDTH_QCOM 0x8BD2
+#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3
+#define GL_TEXTURE_DEPTH_QCOM 0x8BD4
+#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5
+#define GL_TEXTURE_FORMAT_QCOM 0x8BD6
+#define GL_TEXTURE_TYPE_QCOM 0x8BD7
+#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8
+#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9
+#define GL_TEXTURE_TARGET_QCOM 0x8BDA
+#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB
+#define GL_STATE_RESTORE 0x8BDC
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
@@ -1744,66 +2905,84 @@ GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GL
GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
-#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
+GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels);
+GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **params);
#endif
+#endif /* GL_QCOM_extended_get */
-/* GL_QCOM_extended_get2 */
#ifndef GL_QCOM_extended_get2
#define GL_QCOM_extended_get2 1
+typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
-typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
-#endif
+#endif /* GL_QCOM_extended_get2 */
-/* GL_QCOM_perfmon_global_mode */
#ifndef GL_QCOM_perfmon_global_mode
#define GL_QCOM_perfmon_global_mode 1
-#endif
+#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0
+#endif /* GL_QCOM_perfmon_global_mode */
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_QCOM_writeonly_rendering 1
-#endif
-
-/* GL_QCOM_tiled_rendering */
#ifndef GL_QCOM_tiled_rendering
#define GL_QCOM_tiled_rendering 1
+#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001
+#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002
+#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004
+#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008
+#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010
+#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020
+#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040
+#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080
+#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100
+#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200
+#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400
+#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800
+#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000
+#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000
+#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000
+#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000
+#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000
+#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000
+#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000
+#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000
+#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000
+#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000
+#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000
+#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000
+#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000
+#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000
+#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000
+#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000
+#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000
+#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000
+#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000
+#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000
+typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
#endif
-typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
-typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
-#endif
+#endif /* GL_QCOM_tiled_rendering */
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_QCOM_writeonly_rendering 1
+#define GL_WRITEONLY_RENDERING_QCOM 0x8823
+#endif /* GL_QCOM_writeonly_rendering */
-/* GL_VIV_shader_binary */
#ifndef GL_VIV_shader_binary
#define GL_VIV_shader_binary 1
-#endif
+#define GL_SHADER_BINARY_VIV 0x8FC4
+#endif /* GL_VIV_shader_binary */
#ifdef __cplusplus
}
#endif
-#endif /* __gl2ext_h_ */
+#endif
diff --git a/panda/src/glesgsg/glesgsg.h b/panda/src/glesgsg/glesgsg.h
index 40b4722b22..416e5737cb 100644
--- a/panda/src/glesgsg/glesgsg.h
+++ b/panda/src/glesgsg/glesgsg.h
@@ -73,6 +73,7 @@
#define GL_RENDERBUFFER_ALPHA_SIZE_EXT GL_RENDERBUFFER_ALPHA_SIZE_OES
#define GL_RENDERBUFFER_DEPTH_SIZE_EXT GL_RENDERBUFFER_DEPTH_SIZE_OES
#define GL_RENDERBUFFER_STENCIL_SIZE_EXT GL_RENDERBUFFER_STENCIL_SIZE_OES
+#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
#define GL_DRAW_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
#define GL_READ_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
@@ -119,6 +120,17 @@
#define GL_LUMINANCE8 GL_LUMINANCE8_EXT
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE8_ALPHA8_EXT
#define GL_MAX_VERTEX_UNITS_ARB GL_MAX_VERTEX_UNITS_OES
+#define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE
+
+// These aren't technically part of OpenGL ES 1.0, but some implementations
+// nonetheless implement it.
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
+#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
+#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
+#define GL_DEBUG_SEVERITY_HIGH 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
+#define GL_DEBUG_SEVERITY_LOW 0x9148
+#define GL_DEBUG_OUTPUT 0x92E0
#undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY
diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx
index b750233520..1a16d557c4 100644
--- a/panda/src/glstuff/glGraphicsBuffer_src.cxx
+++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx
@@ -252,7 +252,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {
// In case of multisample rendering, we don't need to issue the barrier
// until we call glBlitFramebuffer.
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (gl_enable_memory_barriers && _fbo_multisample == 0) {
CLP(GraphicsStateGuardian) *glgsg;
DCAST_INTO_R(glgsg, _gsg, false);
@@ -526,7 +526,6 @@ rebuild_bitplanes() {
}
glgsg->bind_fbo(_fbo[layer]);
-#ifndef OPENGLES
if (glgsg->_use_object_labels) {
// Assign a label for OpenGL to use when displaying debug messages.
if (num_fbos > 1) {
@@ -538,7 +537,6 @@ rebuild_bitplanes() {
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data());
}
}
-#endif
// For all slots, update the slot.
if (_use_depth_stencil) {
@@ -591,7 +589,7 @@ rebuild_bitplanes() {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
} else if (glgsg->_supports_empty_framebuffer) {
// Set the "default" width and height, which is required to have an FBO
// without any attachments.
@@ -751,12 +749,10 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
_fb_properties.setup_color_texture(tex);
}
-#ifndef OPENGLES
GLenum target = glgsg->get_texture_target(tex->get_texture_type());
if (target == GL_TEXTURE_CUBE_MAP) {
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
}
-#endif
if (attachpoint == GL_DEPTH_ATTACHMENT_EXT) {
GLCAT.debug() << "Binding texture " << *tex << " to depth attachment.\n";
@@ -815,7 +811,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
GLuint gl_format = GL_RGBA4;
switch (slot) {
case RTP_depth_stencil:
- gl_format = GL_DEPTH_STENCIL_OES;
+ gl_format = GL_DEPTH24_STENCIL8_OES;
break;
case RTP_depth:
if (_fb_properties.get_depth_bits() > 24 && glgsg->_supports_depth32) {
@@ -906,7 +902,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
}
} else {
if (_fb_properties.get_color_bits() > 16 * 3) {
- gl_format = GL_RGBA32F_ARB;
+ gl_format = GL_RGB32F_ARB;
} else if (_fb_properties.get_color_bits() > 8 * 3) {
gl_format = GL_RGB16_EXT;
} else {
@@ -924,11 +920,11 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
}
} else {
if (_fb_properties.get_color_bits() > 16 * 3) {
- gl_format = GL_RGB32F_ARB;
+ gl_format = GL_RGBA32F_ARB;
} else if (_fb_properties.get_color_bits() > 8 * 3) {
- gl_format = GL_RGB16_EXT;
+ gl_format = GL_RGBA16_EXT;
} else {
- gl_format = GL_RGB;
+ gl_format = GL_RGBA;
}
}
}
@@ -1191,9 +1187,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) {
glgsg->_glFramebufferTexture3D(GL_FRAMEBUFFER_EXT, attachpoint,
target, gtc->_index, 0, layer);
break;
-#endif
-#ifndef OPENGLES
- case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY:
glgsg->_glFramebufferTextureLayer(GL_FRAMEBUFFER_EXT, attachpoint,
gtc->_index, 0, layer);
break;
@@ -1729,7 +1723,7 @@ resolve_multisamples() {
PStatGPUTimer timer(glgsg, _resolve_multisample_pcollector);
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (gl_enable_memory_barriers) {
// Issue memory barriers as necessary to make sure that the texture memory
// is synchronized before we blit to it.
diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I
index a1fa34dd4a..221aff21b9 100644
--- a/panda/src/glstuff/glGraphicsStateGuardian_src.I
+++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I
@@ -189,6 +189,8 @@ INLINE bool CLP(GraphicsStateGuardian)::
is_at_least_gles_version(int major_version, int minor_version) const {
#ifndef OPENGLES
return false;
+#elif defined(OPENGLES_1)
+ return major_version == 1 && _gl_version_minor >= minor_version;
#else
if (_gl_version_major < major_version) {
return false;
diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx
index d308af9aa8..de53ee150f 100644
--- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx
+++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx
@@ -56,6 +56,7 @@
#include "depthWriteAttrib.h"
#include "fogAttrib.h"
#include "lightAttrib.h"
+#include "logicOpAttrib.h"
#include "materialAttrib.h"
#include "rescaleNormalAttrib.h"
#include "scissorAttrib.h"
@@ -96,8 +97,8 @@ static void APIENTRY
null_glPointParameterfv(GLenum, const GLfloat *) {
}
-#ifdef OPENGLES
-// OpenGL ES doesn't support this, period. Might as well macro it.
+#ifdef OPENGLES_1
+// OpenGL ES 1 doesn't support this, period. Might as well macro it.
#define _glDrawRangeElements(mode, start, end, count, type, indices) \
glDrawElements(mode, count, type, indices)
@@ -126,13 +127,25 @@ null_glActiveTexture(GLenum gl_texture_stage) {
nassertv(gl_texture_stage == GL_TEXTURE0);
}
+#ifdef OPENGLES_2
+#define _glBlendEquation glBlendEquation
+#define _glBlendEquationSeparate glBlendEquationSeparate
+#define _glBlendFuncSeparate glBlendFuncSeparate
+#define _glBlendColor glBlendColor
+#else
static void APIENTRY
null_glBlendEquation(GLenum) {
}
+static void APIENTRY
+null_glBlendFuncSeparate(GLenum src, GLenum dest, GLenum, GLenum) {
+ glBlendFunc(src, dest);
+}
+
static void APIENTRY
null_glBlendColor(GLclampf, GLclampf, GLclampf, GLclampf) {
}
+#endif
#ifndef OPENGLES_1
// We have a default shader that will be applied when there isn't any shader
@@ -185,7 +198,7 @@ static const string default_fshader =
" p3d_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering
" p3d_FragColor *= color;\n"
#else
- " gl_FragColor = texture2D(p3d_Texture0, texcoord).bgra;\n"
+ " gl_FragColor = texture2D(p3d_Texture0, texcoord);\n"
" gl_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering
" gl_FragColor *= color;\n"
#endif
@@ -403,7 +416,6 @@ CLP(GraphicsStateGuardian)::
* This is called by the GL if an error occurs, if gl_debug has been enabled
* (and the driver supports the GL_ARB_debug_output extension).
*/
-#ifndef OPENGLES_1
void CLP(GraphicsStateGuardian)::
debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) {
// Determine how to map the severity level.
@@ -444,7 +456,6 @@ debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei l
}
#endif
}
-#endif // OPENGLES_1
/**
* Resets all internal state as if the gsg were newly created.
@@ -475,6 +486,7 @@ reset() {
_inv_state_mask.clear_bit(TransparencyAttrib::get_class_slot());
_inv_state_mask.clear_bit(ColorWriteAttrib::get_class_slot());
_inv_state_mask.clear_bit(ColorBlendAttrib::get_class_slot());
+ _inv_state_mask.clear_bit(LogicOpAttrib::get_class_slot());
_inv_state_mask.clear_bit(TextureAttrib::get_class_slot());
_inv_state_mask.clear_bit(TexGenAttrib::get_class_slot());
_inv_state_mask.clear_bit(TexMatrixAttrib::get_class_slot());
@@ -496,9 +508,9 @@ reset() {
// Save the extensions tokens.
_extensions.clear();
- // In OpenGL 3.0 and later, glGetString(GL_EXTENSIONS) is deprecated.
-#ifndef OPENGLES
- if (is_at_least_gl_version(3, 0)) {
+ // In OpenGL (ES) 3.0 and later, glGetString(GL_EXTENSIONS) is deprecated.
+#ifndef OPENGLES_1
+ if (_gl_version_major >= 3) {
PFNGLGETSTRINGIPROC _glGetStringi =
(PFNGLGETSTRINGIPROC)get_extension_func("glGetStringi");
@@ -547,7 +559,6 @@ reset() {
// Initialize OpenGL debugging output first, if enabled and supported.
_supports_debug = false;
_use_object_labels = false;
-#ifndef OPENGLES_1
if (gl_debug) {
PFNGLDEBUGMESSAGECALLBACKPROC_P _glDebugMessageCallback;
PFNGLDEBUGMESSAGECONTROLPROC _glDebugMessageControl;
@@ -615,7 +626,6 @@ reset() {
GLCAT.debug() << "gl-debug disabled and unsupported.\n";
}
}
-#endif // OPENGLES_1
_supported_geom_rendering =
Geom::GR_indexed_point |
@@ -627,7 +637,11 @@ reset() {
_supports_point_parameters = false;
-#ifndef OPENGLES_2
+#ifdef OPENGLES_1
+ _glPointParameterfv = glPointParameterfv;
+#elif defined(OPENGLES)
+ // Other OpenGL ES versions don't support point parameters.
+#else
if (is_at_least_gl_version(1, 4)) {
_supports_point_parameters = true;
_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)
@@ -669,7 +683,16 @@ reset() {
_supported_geom_rendering |= Geom::GR_point_sprite;
}
-#ifndef OPENGLES
+#ifdef OPENGLES_1
+ // OpenGL ES 1.0 does not support primitive restart indices.
+
+#elif defined(OPENGLES)
+ if (gl_support_primitive_restart_index && is_at_least_gles_version(3, 0)) {
+ glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+ _supported_geom_rendering |= Geom::GR_strip_cut_index;
+ }
+
+#else
_explicit_primitive_restart = false;
_glPrimitiveRestartIndex = NULL;
@@ -680,7 +703,7 @@ reset() {
// possible index for a numeric type as strip cut index, which coincides
// with our convention. This saves us a call to glPrimitiveRestartIndex
// ... of course, though, the Gallium driver bugs out here. See also:
- // https:www.panda3d.orgforumsviewtopic.php?f=5&t=17512
+ // https://www.panda3d.org/forums/viewtopic.php?f=5&t=17512
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
_supported_geom_rendering |= Geom::GR_strip_cut_index;
@@ -707,9 +730,15 @@ reset() {
}
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
_glDrawRangeElements = null_glDrawRangeElements;
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 0)) {
+ _glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)
+ get_extension_func("glDrawRangeElements");
+ }
+#else
if (is_at_least_gl_version(1, 2)) {
_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)
get_extension_func("glDrawRangeElements");
@@ -718,17 +747,18 @@ reset() {
_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)
get_extension_func("glDrawRangeElementsEXT");
}
+#endif
if (_glDrawRangeElements == NULL) {
GLCAT.warning()
<< "glDrawRangeElements advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n";
_glDrawRangeElements = null_glDrawRangeElements;
}
-#endif
+#endif // !OPENGLES_1
_supports_3d_texture = false;
#ifndef OPENGLES_1
- if (is_at_least_gl_version(1, 2)) {
+ if (is_at_least_gl_version(1, 2) || is_at_least_gles_version(3, 0)) {
_supports_3d_texture = true;
_glTexImage3D = (PFNGLTEXIMAGE3DPROC_P)
@@ -738,6 +768,7 @@ reset() {
_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)
get_extension_func("glCopyTexSubImage3D");
+#ifndef OPENGLES
} else if (has_extension("GL_EXT_texture3D")) {
_supports_3d_texture = true;
@@ -751,7 +782,7 @@ reset() {
_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)
get_extension_func("glCopyTexSubImage3DEXT");
}
-
+#else
} else if (has_extension("GL_OES_texture_3D")) {
_supports_3d_texture = true;
@@ -761,8 +792,6 @@ reset() {
get_extension_func("glTexSubImage3DOES");
_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)
get_extension_func("glCopyTexSubImage3DOES");
-
-#ifdef OPENGLES_2
_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DOES)
get_extension_func("glFramebufferTexture3DOES");
#endif
@@ -779,8 +808,11 @@ reset() {
_supports_tex_storage = false;
-#ifndef OPENGLES
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 0)) {
+#else
if (is_at_least_gl_version(4, 2) || has_extension("GL_ARB_texture_storage")) {
+#endif
_supports_tex_storage = true;
_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)
@@ -789,10 +821,9 @@ reset() {
get_extension_func("glTexStorage2D");
_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)
get_extension_func("glTexStorage3D");
-
- } else
-#endif
- if (has_extension("GL_EXT_texture_storage")) { // GLES case
+ }
+#ifdef OPENGLES
+ else if (has_extension("GL_EXT_texture_storage")) {
_supports_tex_storage = true;
_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)
@@ -802,6 +833,7 @@ reset() {
_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)
get_extension_func("glTexStorage3DEXT");
}
+#endif
if (_supports_tex_storage) {
if (_glTexStorage1D == NULL || _glTexStorage2D == NULL || _glTexStorage3D == NULL) {
@@ -842,25 +874,27 @@ reset() {
#endif
_supports_2d_texture_array = false;
-#ifndef OPENGLES
- if (is_at_least_gl_version(3, 0)) {
+#ifndef OPENGLES_1
+ if (_gl_version_major >= 3) {
_supports_2d_texture_array = true;
_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)
get_extension_func("glFramebufferTextureLayer");
+#ifndef OPENGLES
} else if (has_extension("GL_EXT_texture_array")) {
_supports_2d_texture_array = true;
_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)
get_extension_func("glFramebufferTextureLayerEXT");
+#endif
}
if (_supports_2d_texture_array && _glFramebufferTextureLayer == NULL) {
GLCAT.warning()
<< "Texture arrays advertised as supported by OpenGL runtime, but could not get pointer to glFramebufferTextureLayer function.\n";
}
-#endif
+#endif // !OPENGLES_1
#ifdef OPENGLES_2
_supports_cube_map = true;
@@ -895,13 +929,13 @@ reset() {
}
#endif
- _supports_texture_srgb = false;
- if (is_at_least_gl_version(2, 1) || has_extension("GL_EXT_texture_sRGB")) {
- _supports_texture_srgb = true;
-
- } else if (has_extension("GL_EXT_sRGB")) { // GLES case.
- _supports_texture_srgb = true;
- }
+#ifdef OPENGLES
+ _supports_texture_srgb =
+ is_at_least_gles_version(3, 0) || has_extension("GL_EXT_sRGB");
+#else
+ _supports_texture_srgb =
+ is_at_least_gl_version(2, 1) || has_extension("GL_EXT_texture_sRGB");
+#endif
#ifdef OPENGLES
_supports_compressed_texture = true;
@@ -1035,23 +1069,30 @@ reset() {
#endif
}
-#ifdef OPENGLES_2
- _supports_bgr = false;
+#ifdef OPENGLES
+ // Note that these extensions only offer support for GL_BGRA, not GL_BGR.
+ _supports_bgr = has_extension("GL_EXT_texture_format_BGRA8888") ||
+ has_extension("GL_APPLE_texture_format_BGRA8888");
#else
+ // In regular OpenGL, we have both GL_BGRA and GL_BGR.
_supports_bgr =
is_at_least_gl_version(1, 2) || has_extension("GL_EXT_bgra");
#endif
#ifdef SUPPORT_FIXED_FUNCTION
+#ifdef OPENGLES_1
+ _supports_rescale_normal = true;
+#else
_supports_rescale_normal =
!core_profile && gl_support_rescale_normal &&
(is_at_least_gl_version(1, 2) || has_extension("GL_EXT_rescale_normal"));
+#endif
#ifndef OPENGLES
_use_separate_specular_color = gl_separate_specular_color &&
(is_at_least_gl_version(1, 2) || has_extension("GL_EXT_separate_specular_color"));
#endif
-#endif
+#endif // SUPPORT_FIXED_FUNCTION
#ifdef OPENGLES
_supports_packed_dabc = false;
@@ -1064,8 +1105,13 @@ reset() {
has_extension("GL_ARB_vertex_type_10f_11f_11f_rev");
#endif
+#ifdef OPENGLES
+ //TODO
+ _supports_multisample = false;
+#else
_supports_multisample =
has_extension("GL_ARB_multisample") || is_at_least_gl_version(1, 3);
+#endif
#ifdef OPENGLES_1
_supports_generate_mipmap = is_at_least_gles_version(1, 1);
@@ -1076,8 +1122,10 @@ reset() {
has_extension("GL_SGIS_generate_mipmap");
#endif
-#ifdef OPENGLES
- _supports_tex_non_pow2 =
+#ifdef OPENGLES_1
+ _supports_tex_non_pow2 = false;
+#elif defined(OPENGLES)
+ _supports_tex_non_pow2 = is_at_least_gles_version(3, 0) ||
has_extension("GL_OES_texture_npot");
#else
_supports_tex_non_pow2 = is_at_least_gl_version(2, 0) ||
@@ -1177,19 +1225,31 @@ reset() {
#endif
#endif // OPENGLES_2
-#ifdef OPENGLES
- if (has_extension("GL_ANGLE_depth_texture")) {
- // This extension provides both depth textures and depth-stencil support.
- _supports_depth_texture = true;
- _supports_depth_stencil = true;
-
- } else if (has_extension("GL_OES_depth_texture")) {
- _supports_depth_texture = true;
- _supports_depth_stencil = has_extension("GL_OES_packed_depth_stencil");
- }
+#ifdef OPENGLES_1
+ _supports_depth_texture = false;
+ _supports_depth_stencil = has_extension("GL_OES_packed_depth_stencil");
_supports_depth24 = has_extension("GL_OES_depth24");
_supports_depth32 = has_extension("GL_OES_depth32");
+#elif defined(OPENGLES)
+ if (is_at_least_gles_version(3, 0)) {
+ _supports_depth_texture = true;
+ _supports_depth_stencil = true;
+ _supports_depth24 = true;
+ _supports_depth32 = true;
+ } else {
+ if (has_extension("GL_ANGLE_depth_texture")) {
+ // This extension provides both depth textures and depth-stencil support.
+ _supports_depth_texture = true;
+ _supports_depth_stencil = true;
+
+ } else if (has_extension("GL_OES_depth_texture")) {
+ _supports_depth_texture = true;
+ _supports_depth_stencil = has_extension("GL_OES_packed_depth_stencil");
+ }
+ _supports_depth24 = has_extension("GL_OES_depth24");
+ _supports_depth32 = has_extension("GL_OES_depth32");
+ }
#else
_supports_depth_texture = (is_at_least_gl_version(1, 4) ||
has_extension("GL_ARB_depth_texture"));
@@ -1200,7 +1260,7 @@ reset() {
#ifdef OPENGLES_2
if (gl_support_shadow_filter && _supports_depth_texture &&
- has_extension("GL_EXT_shadow_samplers")) {
+ (is_at_least_gles_version(3, 0) || has_extension("GL_EXT_shadow_samplers"))) {
_supports_shadow_filter = true;
}
#else
@@ -1230,17 +1290,21 @@ reset() {
is_at_least_gles_version(1, 1) ||
has_extension("GL_ARB_texture_env_combine");
+#ifdef OPENGLES_1
+ _supports_texture_saved_result =
+ has_extension("GL_OES_texture_env_crossbar");
+#else
_supports_texture_saved_result =
is_at_least_gl_version(1, 4) ||
- has_extension("GL_ARB_texture_env_crossbar") ||
- has_extension("GL_OES_texture_env_crossbar");
+ has_extension("GL_ARB_texture_env_crossbar");
+#endif
_supports_texture_dot3 =
is_at_least_gl_version(1, 3) ||
is_at_least_gles_version(1, 1) ||
has_extension("GL_ARB_texture_env_dot3");
}
-#endif
+#endif // SUPPORT_FIXED_FUNCTION
#ifdef OPENGLES_2
_supports_buffers = true;
@@ -1305,7 +1369,19 @@ reset() {
}
#endif
-#ifndef OPENGLES
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 0)) {
+ _glMapBufferRange = (PFNGLMAPBUFFERRANGEEXTPROC)
+ get_extension_func("glMapBufferRange");
+
+ } else if (has_extension("GL_EXT_map_buffer_range")) {
+ _glMapBufferRange = (PFNGLMAPBUFFERRANGEEXTPROC)
+ get_extension_func("glMapBufferRangeEXT");
+
+ } else {
+ _glMapBufferRange = NULL;
+ }
+#else
// Check for various advanced buffer management features.
if (is_at_least_gl_version(3, 0) || has_extension("GL_ARB_map_buffer_range")) {
_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)
@@ -1332,7 +1408,11 @@ reset() {
_supports_vao = false;
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 0)) {
+#else
if (is_at_least_gl_version(3, 0) || has_extension("GL_ARB_vertex_array_object")) {
+#endif
_supports_vao = true;
_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)
@@ -1342,6 +1422,7 @@ reset() {
_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)
get_extension_func("glGenVertexArrays");
+#ifdef OPENGLES
} else if (has_extension("GL_OES_vertex_array_object")) {
_supports_vao = true;
@@ -1351,6 +1432,7 @@ reset() {
get_extension_func("glDeleteVertexArraysOES");
_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)
get_extension_func("glGenVertexArraysOES");
+#endif
}
if (_supports_vao) {
@@ -1474,8 +1556,12 @@ reset() {
#endif // HAVE_CG
_supports_compute_shaders = false;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 1)) {
+#else
if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_compute_shader")) {
+#endif
_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)
get_extension_func("glDispatchCompute");
@@ -1483,7 +1569,7 @@ reset() {
_supports_compute_shaders = true;
}
}
-#endif
+#endif // !OPENGLES_1
#ifndef OPENGLES
if (_supports_glsl) {
@@ -1633,26 +1719,39 @@ reset() {
_glVertexAttrib4fv = glVertexAttrib4fv;
_glVertexAttrib4dv = null_glVertexAttrib4dv;
_glVertexAttribPointer = glVertexAttribPointer;
- _glVertexAttribIPointer = NULL;
_glVertexAttribLPointer = NULL;
+
+ if (is_at_least_gles_version(3, 0)) {
+ _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)
+ get_extension_func("glVertexAttribIPointer");
+ } else {
+ _glVertexAttribIPointer = NULL;
+ }
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
_use_vertex_attrib_binding = false;
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 1)) {
+#else
if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_vertex_attrib_binding")) {
+#endif
_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)
get_extension_func("glBindVertexBuffer");
_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)
get_extension_func("glVertexAttribFormat");
_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)
get_extension_func("glVertexAttribIFormat");
- _glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)
- get_extension_func("glVertexAttribLFormat");
_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)
get_extension_func("glVertexAttribBinding");
_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)
get_extension_func("glVertexBindingDivisor");
+#ifndef OPENGLES
+ _glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)
+ get_extension_func("glVertexAttribLFormat");
+#endif
+
if (gl_fixed_vertex_attrib_locations) {
_use_vertex_attrib_binding = true;
}
@@ -1674,7 +1773,11 @@ reset() {
#ifndef OPENGLES
// Check for uniform buffers.
+#ifdef OPENGLES
if (is_at_least_gl_version(3, 1) || has_extension("GL_ARB_uniform_buffer_object")) {
+#else
+ if (is_at_least_gles_version(3, 0)) {
+#endif
_supports_uniform_buffers = true;
_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)
get_extension_func("glGetActiveUniformsiv");
@@ -1696,8 +1799,20 @@ reset() {
_supports_vertex_attrib_divisor = false;
_supports_geometry_instancing = false;
-#elif defined(OPENGLES_2)
- if (has_extension("GL_ANGLE_instanced_arrays")) {
+#elif defined(OPENGLES)
+ if (is_at_least_gles_version(3, 0)) {
+ // OpenGL ES 3 has all of this in the core.
+ _glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)
+ get_extension_func("glVertexAttribDivisor");
+ _glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)
+ get_extension_func("glDrawArraysInstanced");
+ _glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)
+ get_extension_func("glDrawElementsInstanced");
+
+ _supports_vertex_attrib_divisor = true;
+ _supports_geometry_instancing = true;
+
+ } else if (has_extension("GL_ANGLE_instanced_arrays")) {
// This extension has both things in one.
#ifdef __EMSCRIPTEN__
// Work around bug - it doesn't allow ANGLE suffix in getProcAddress.
@@ -1819,8 +1934,12 @@ reset() {
// Check if we support indirect draw.
_supports_indirect_draw = false;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 1)) {
+#else
if (is_at_least_gl_version(4, 0) || has_extension("GL_ARB_draw_indirect")) {
+#endif
_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)
get_extension_func("glDrawArraysIndirect");
_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)
@@ -1835,7 +1954,45 @@ reset() {
}
#endif
-#ifdef OPENGLES_2
+#ifdef OPENGLES_1
+ if (has_extension("GL_OES_framebuffer_object")) {
+ _supports_framebuffer_object = true;
+ _glIsRenderbuffer = (PFNGLISRENDERBUFFEROESPROC)
+ get_extension_func("glIsRenderbufferOES");
+ _glBindRenderbuffer = (PFNGLBINDRENDERBUFFEROESPROC)
+ get_extension_func("glBindRenderbufferOES");
+ _glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSOESPROC)
+ get_extension_func("glDeleteRenderbuffersOES");
+ _glGenRenderbuffers = (PFNGLGENRENDERBUFFERSOESPROC)
+ get_extension_func("glGenRenderbuffersOES");
+ _glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEOESPROC)
+ get_extension_func("glRenderbufferStorageOES");
+ _glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVOESPROC)
+ get_extension_func("glGetRenderbufferParameterivOES");
+ _glIsFramebuffer = (PFNGLISFRAMEBUFFEROESPROC)
+ get_extension_func("glIsFramebufferOES");
+ _glBindFramebuffer = (PFNGLBINDFRAMEBUFFEROESPROC)
+ get_extension_func("glBindFramebufferOES");
+ _glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSOESPROC)
+ get_extension_func("glDeleteFramebuffersOES");
+ _glGenFramebuffers = (PFNGLGENFRAMEBUFFERSOESPROC)
+ get_extension_func("glGenFramebuffersOES");
+ _glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC)
+ get_extension_func("glCheckFramebufferStatusOES");
+ _glFramebufferTexture1D = NULL;
+ _glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC)
+ get_extension_func("glFramebufferTexture2DOES");
+ _glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEROESPROC)
+ get_extension_func("glFramebufferRenderbufferOES");
+ _glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC)
+ get_extension_func("glGetFramebufferAttachmentParameterivOES");
+ _glGenerateMipmap = (PFNGLGENERATEMIPMAPOESPROC)
+ get_extension_func("glGenerateMipmapOES");
+ } else {
+ _supports_framebuffer_object = false;
+ _glGenerateMipmap = NULL;
+ }
+#elif defined(OPENGLES)
// In OpenGL ES 2.x, FBO's are supported in the core.
_supports_framebuffer_object = true;
_glIsRenderbuffer = glIsRenderbuffer;
@@ -1854,13 +2011,9 @@ reset() {
_glFramebufferRenderbuffer = glFramebufferRenderbuffer;
_glGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
_glGenerateMipmap = glGenerateMipmap;
+
#else
- // Make sure this is properly initialized.
- _glGenerateMipmap = NULL;
-
// TODO: add ARB3.0 version
-
- _supports_framebuffer_object = false;
if (has_extension("GL_EXT_framebuffer_object")) {
_supports_framebuffer_object = true;
_glIsRenderbuffer = (PFNGLISRENDERBUFFEREXTPROC)
@@ -1897,43 +2050,17 @@ reset() {
get_extension_func("glGetFramebufferAttachmentParameterivEXT");
_glGenerateMipmap = (PFNGLGENERATEMIPMAPEXTPROC)
get_extension_func("glGenerateMipmapEXT");
+
+ } else if (is_at_least_gl_version(3, 0)) {
+ // This case should go away when we support the ARB/3.0 version of FBOs.
+ _supports_framebuffer_object = false;
+ _glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)
+ get_extension_func("glGenerateMipmap");
+
+ } else {
+ _supports_framebuffer_object = false;
+ _glGenerateMipmap = NULL;
}
-#ifdef OPENGLES
- else if (has_extension("GL_OES_framebuffer_object")) {
- _supports_framebuffer_object = true;
- _glIsRenderbuffer = (PFNGLISRENDERBUFFEROESPROC)
- get_extension_func("glIsRenderbufferOES");
- _glBindRenderbuffer = (PFNGLBINDRENDERBUFFEROESPROC)
- get_extension_func("glBindRenderbufferOES");
- _glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSOESPROC)
- get_extension_func("glDeleteRenderbuffersOES");
- _glGenRenderbuffers = (PFNGLGENRENDERBUFFERSOESPROC)
- get_extension_func("glGenRenderbuffersOES");
- _glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEOESPROC)
- get_extension_func("glRenderbufferStorageOES");
- _glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVOESPROC)
- get_extension_func("glGetRenderbufferParameterivOES");
- _glIsFramebuffer = (PFNGLISFRAMEBUFFEROESPROC)
- get_extension_func("glIsFramebufferOES");
- _glBindFramebuffer = (PFNGLBINDFRAMEBUFFEROESPROC)
- get_extension_func("glBindFramebufferOES");
- _glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSOESPROC)
- get_extension_func("glDeleteFramebuffersOES");
- _glGenFramebuffers = (PFNGLGENFRAMEBUFFERSOESPROC)
- get_extension_func("glGenFramebuffersOES");
- _glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC)
- get_extension_func("glCheckFramebufferStatusOES");
- _glFramebufferTexture1D = NULL;
- _glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC)
- get_extension_func("glFramebufferTexture2DOES");
- _glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEROESPROC)
- get_extension_func("glFramebufferRenderbufferOES");
- _glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC)
- get_extension_func("glGetFramebufferAttachmentParameterivOES");
- _glGenerateMipmap = (PFNGLGENERATEMIPMAPOESPROC)
- get_extension_func("glGenerateMipmapOES");
- }
-#endif // OPENGLES
#endif
#ifndef OPENGLES
@@ -1945,21 +2072,38 @@ reset() {
}
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
+ // Do we support empty framebuffer objects?
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 1)) {
+#else
if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_framebuffer_no_attachments")) {
+#endif
_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)
get_extension_func("glFramebufferParameteri");
_supports_empty_framebuffer = true;
} else {
_supports_empty_framebuffer = false;
}
-#endif
+#endif // !OPENGLES_1
_supports_framebuffer_multisample = false;
- if (has_extension("GL_EXT_framebuffer_multisample")) {
+ if (is_at_least_gles_version(3, 0)) {
+ _supports_framebuffer_multisample = true;
+ _glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
+ get_extension_func("glRenderbufferStorageMultisample");
+
+#ifdef OPENGLES
+ } else if (has_extension("GL_APPLE_framebuffer_multisample")) {
+ _supports_framebuffer_multisample = true;
+ _glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC)
+ get_extension_func("glRenderbufferStorageMultisampleAPPLE");
+#else
+ } else if (has_extension("GL_EXT_framebuffer_multisample")) {
_supports_framebuffer_multisample = true;
_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
get_extension_func("glRenderbufferStorageMultisampleEXT");
+#endif
}
#ifndef OPENGLES
@@ -1973,7 +2117,13 @@ reset() {
#ifndef OPENGLES_1
_supports_framebuffer_blit = false;
- if (has_extension("GL_EXT_framebuffer_blit")) {
+
+ if (is_at_least_gles_version(3, 0)) {
+ _supports_framebuffer_blit = true;
+ _glBlitFramebuffer = (PFNGLBLITFRAMEBUFFEREXTPROC)
+ get_extension_func("glBlitFramebuffer");
+
+ } else if (has_extension("GL_EXT_framebuffer_blit")) {
_supports_framebuffer_blit = true;
_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFEREXTPROC)
get_extension_func("glBlitFramebufferEXT");
@@ -1985,7 +2135,11 @@ reset() {
_max_color_targets = 1;
#elif defined(OPENGLES_2)
- if (has_extension("GL_EXT_draw_buffers")) {
+ if (is_at_least_gles_version(3, 0)) {
+ _glDrawBuffers = (PFNGLDRAWBUFFERSPROC)
+ get_extension_func("glDrawBuffers");
+
+ } else if (has_extension("GL_EXT_draw_buffers")) {
_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)
get_extension_func("glDrawBuffersEXT");
@@ -2020,8 +2174,8 @@ reset() {
}
#endif // !OPENGLES_1
-#ifndef OPENGLES
- if (is_at_least_gl_version(3, 0)) {
+#ifndef OPENGLES_1
+ if (_gl_version_major >= 3) {
_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)
get_extension_func("glClearBufferfv");
_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)
@@ -2137,38 +2291,120 @@ reset() {
}
#endif
-#ifdef OPENGLES_2
- // In OpenGL ES 2.x, this is supported in the core.
- _glBlendEquation = glBlendEquation;
-#else
- _glBlendEquation = NULL;
- bool supports_blend_equation = false;
- if (is_at_least_gl_version(1, 2)) {
- supports_blend_equation = true;
- _glBlendEquation = (PFNGLBLENDEQUATIONPROC)
- get_extension_func("glBlendEquation");
- } else if (has_extension("GL_OES_blend_subtract")) {
- supports_blend_equation = true;
+#ifdef OPENGLES_1
+ // In OpenGL ES 1, blending is supported via extensions.
+ if (has_extension("GL_OES_blend_subtract")) {
_glBlendEquation = (PFNGLBLENDEQUATIONPROC)
get_extension_func("glBlendEquationOES");
+
+ if (_glBlendEquation == NULL) {
+ _glBlendEquation = null_glBlendEquation;
+ GLCAT.warning()
+ << "BlendEquationOES advertised as supported by OpenGL ES runtime, but "
+ "could not get pointer to extension function.\n";
+ }
+ } else {
+ _glBlendEquation = null_glBlendEquation;
+ }
+
+ if (has_extension("GL_OES_blend_equation_separate")) {
+ _glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEOESPROC)
+ get_extension_func("glBlendEquationSeparateOES");
+
+ if (_glBlendEquation == NULL) {
+ _supports_blend_equation_separate = false;
+ GLCAT.warning()
+ << "BlendEquationSeparateOES advertised as supported by OpenGL ES "
+ "runtime, but could not get pointer to extension function.\n";
+ } else {
+ _supports_blend_equation_separate = true;
+ }
+ } else {
+ _supports_blend_equation_separate = false;
+ _glBlendEquationSeparate = NULL;
+ }
+
+ if (has_extension("GL_OES_blend_func_separate")) {
+ _glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEOESPROC)
+ get_extension_func("glBlendFuncSeparateOES");
+
+ if (_glBlendFuncSeparate == NULL) {
+ _glBlendFuncSeparate = null_glBlendFuncSeparate;
+ GLCAT.warning()
+ << "BlendFuncSeparateOES advertised as supported by OpenGL ES runtime, but "
+ "could not get pointer to extension function.\n";
+ }
+ } else {
+ _glBlendFuncSeparate = null_glBlendFuncSeparate;
+ }
+
+#elif defined(OPENGLES)
+ // In OpenGL ES 2.x and above, this is supported in the core.
+ _supports_blend_equation_separate = false;
+
+#else
+ if (is_at_least_gl_version(1, 2)) {
+ _glBlendEquation = (PFNGLBLENDEQUATIONPROC)
+ get_extension_func("glBlendEquation");
+
} else if (has_extension("GL_EXT_blend_minmax")) {
- supports_blend_equation = true;
_glBlendEquation = (PFNGLBLENDEQUATIONPROC)
get_extension_func("glBlendEquationEXT");
+
+ } else {
+ _glBlendEquation = null_glBlendEquation;
}
- if (supports_blend_equation && _glBlendEquation == NULL) {
- GLCAT.warning()
- << "BlendEquation advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n";
- }
+
if (_glBlendEquation == NULL) {
_glBlendEquation = null_glBlendEquation;
+ GLCAT.warning()
+ << "BlendEquation advertised as supported by OpenGL runtime, but could "
+ "not get pointer to extension function.\n";
+ }
+
+ if (is_at_least_gl_version(2, 0)) {
+ _supports_blend_equation_separate = true;
+ _glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)
+ get_extension_func("glBlendEquationSeparate");
+
+ } else if (has_extension("GL_EXT_blend_equation_separate")) {
+ _supports_blend_equation_separate = true;
+ _glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)
+ get_extension_func("glBlendEquationSeparateEXT");
+
+ } else {
+ _supports_blend_equation_separate = false;
+ _glBlendEquationSeparate = NULL;
+ }
+
+ if (_supports_blend_equation_separate && _glBlendEquationSeparate == NULL) {
+ _supports_blend_equation_separate = false;
+ GLCAT.warning()
+ << "BlendEquationSeparate advertised as supported by OpenGL runtime, "
+ "but could not get pointer to extension function.\n";
+ }
+
+ if (is_at_least_gl_version(1, 4)) {
+ _glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)
+ get_extension_func("glBlendFuncSeparate");
+
+ } else if (has_extension("GL_EXT_blend_func_separate")) {
+ _glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEEXTPROC)
+ get_extension_func("glBlendFuncSeparateEXT");
+
+ } else {
+ _glBlendFuncSeparate = null_glBlendFuncSeparate;
+ }
+
+ if (_glBlendFuncSeparate == NULL) {
+ _glBlendFuncSeparate = null_glBlendFuncSeparate;
+ GLCAT.warning()
+ << "BlendFuncSeparate advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n";
}
#endif
-#ifdef OPENGLES_2
- // In OpenGL ES 2.x, this is supported in the core.
- _glBlendColor = glBlendColor;
-#else
+ // In OpenGL ES 2.x, this is supported in the core. In 1.x, not at all.
+#ifndef OPENGLES
_glBlendColor = NULL;
bool supports_blend_color = false;
if (is_at_least_gl_version(1, 2)) {
@@ -2189,6 +2425,15 @@ reset() {
}
#endif
+#ifdef OPENGLES_1
+ // OpenGL ES 1 doesn't support dual-source blending.
+#elif defined(OPENGLES)
+ _supports_dual_source_blending = has_extension("GL_EXT_blend_func_extended");
+#else
+ _supports_dual_source_blending =
+ is_at_least_gl_version(3, 3) || has_extension("GL_ARB_blend_func_extended");
+#endif
+
#ifdef OPENGLES
_edge_clamp = GL_CLAMP_TO_EDGE;
#else
@@ -2208,13 +2453,18 @@ reset() {
}
#endif
-#ifdef OPENGLES_2
+#ifdef OPENGLES_1
+ _mirror_repeat = GL_REPEAT;
+ if (has_extension("GL_OES_texture_mirrored_repeat")) {
+ _mirror_repeat = GL_MIRRORED_REPEAT;
+ }
+#elif defined(OPENGLES)
+ // OpenGL 2.x and above support this in the core.
_mirror_repeat = GL_MIRRORED_REPEAT;
#else
_mirror_repeat = GL_REPEAT;
- if (has_extension("GL_ARB_texture_mirrored_repeat") ||
- is_at_least_gl_version(1, 4) ||
- has_extension("GL_OES_texture_mirrored_repeat")) {
+ if (is_at_least_gl_version(1, 4) ||
+ has_extension("GL_ARB_texture_mirrored_repeat")) {
_mirror_repeat = GL_MIRRORED_REPEAT;
}
#endif
@@ -2230,7 +2480,10 @@ reset() {
}
#endif
-#ifndef OPENGLES
+#ifdef OPENGLES
+ _supports_texture_lod = is_at_least_gles_version(3, 0);
+ _supports_texture_lod_bias = false;
+#else
_supports_texture_lod = false;
_supports_texture_lod_bias = false;
@@ -2244,6 +2497,13 @@ reset() {
}
#endif
+#ifdef OPENGLES
+ _supports_texture_max_level = is_at_least_gles_version(3, 0) ||
+ has_extension("GL_APPLE_texture_max_level");
+#else
+ _supports_texture_max_level = is_at_least_gl_version(1, 2);
+#endif
+
if (_supports_multisample) {
GLint sample_buffers = 0;
glGetIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers);
@@ -2274,9 +2534,9 @@ reset() {
} else {
_max_3d_texture_dimension = 0;
}
-#ifndef OPENGLES
- if(_supports_2d_texture_array) {
- glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &max_2d_texture_array_layers);
+#ifndef OPENGLES_1
+ if (_supports_2d_texture_array) {
+ glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_2d_texture_array_layers);
_max_2d_texture_array_layers = max_2d_texture_array_layers;
}
#endif
@@ -2317,9 +2577,11 @@ reset() {
<< ", max 3d texture = " << _max_3d_texture_dimension
<< ", max 2d texture array = " << max_2d_texture_array_layers
<< ", max cube map = " << _max_cube_map_dimension << "\n";
+#ifndef OPENGLES
GLCAT.debug()
<< "max_elements_vertices = " << max_elements_vertices
<< ", max_elements_indices = " << max_elements_indices << "\n";
+#endif
if (_supports_buffers) {
if (vertex_buffers) {
GLCAT.debug()
@@ -2384,10 +2646,14 @@ reset() {
_supports_anisotropy = true;
}
- // Check availability of image readwrite functionality in shaders.
+ // Check availability of image read/write functionality in shaders.
_max_image_units = 0;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
+#ifdef OPENGLES
+ if (is_at_least_gl_version(3, 1)) {
+#else
if (is_at_least_gl_version(4, 2) || has_extension("GL_ARB_shader_image_load_store")) {
+#endif
_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)
get_extension_func("glBindImageTexture");
_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)
@@ -2395,6 +2661,7 @@ reset() {
glGetIntegerv(GL_MAX_IMAGE_UNITS, &_max_image_units);
+#ifndef OPENGLES
} else if (has_extension("GL_EXT_shader_image_load_store")) {
_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)
get_extension_func("glBindImageTextureEXT");
@@ -2402,17 +2669,23 @@ reset() {
get_extension_func("glMemoryBarrierEXT");
glGetIntegerv(GL_MAX_IMAGE_UNITS_EXT, &_max_image_units);
+#endif
} else {
_glBindImageTexture = NULL;
_glMemoryBarrier = NULL;
}
+#endif // !OPENGLES_1
_supports_sampler_objects = false;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (gl_support_sampler_objects &&
- ((is_at_least_gl_version(3, 3) || has_extension("GL_ARB_sampler_objects")))) {
+#ifdef OPENGLES
+ is_at_least_gles_version(3, 0)) {
+#else
+ (is_at_least_gl_version(3, 3) || has_extension("GL_ARB_sampler_objects"))) {
+#endif
_glGenSamplers = (PFNGLGENSAMPLERSPROC) get_extension_func("glGenSamplers");
_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) get_extension_func("glDeleteSamplers");
_glBindSampler = (PFNGLBINDSAMPLERPROC) get_extension_func("glBindSampler");
@@ -2431,7 +2704,7 @@ reset() {
_supports_sampler_objects = true;
}
}
-#endif // OPENGLES
+#endif // !OPENGLES_1
// Check availability of multi-bind functions.
_supports_multi_bind = false;
@@ -2459,9 +2732,14 @@ reset() {
<< "ARB_multi_bind advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n";
}
}
-#endif // OPENGLES
+#endif // !OPENGLES
+#ifndef OPENGLES_1
+#ifdef OPENGLES
+ if (is_at_least_gl_version(3, 0)) {
+#else
if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_internalformat_query2")) {
+#endif
_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)
get_extension_func("glGetInternalformativ");
@@ -2470,8 +2748,10 @@ reset() {
<< "ARB_internalformat_query2 advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n";
}
}
+#endif // !OPENGLES_1
_supports_bindless_texture = false;
+#ifndef OPENGLES
if (has_extension("GL_ARB_bindless_texture")) {
_glGetTextureHandle = (PFNGLGETTEXTUREHANDLEPROC)
get_extension_func("glGetTextureHandleARB");
@@ -2490,13 +2770,17 @@ reset() {
_supports_bindless_texture = true;
}
}
-#endif
+#endif // !OPENGLES
-#ifndef OPENGLES
+#ifndef OPENGLES_1
_supports_get_program_binary = false;
_program_binary_formats.clear();
+#ifdef OPENGLES
+ if (is_at_least_gles_version(3, 0)) {
+#else
if (is_at_least_gl_version(4, 1) || has_extension("GL_ARB_get_program_binary")) {
+#endif
_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)
get_extension_func("glGetProgramBinary");
_glProgramBinary = (PFNGLPROGRAMBINARYPROC)
@@ -2522,7 +2806,7 @@ reset() {
}
}
}
-#endif
+#endif // !OPENGLES_1
report_my_gl_errors();
@@ -2538,12 +2822,18 @@ reset() {
}
#endif
- _supports_stencil_wrap =
- has_extension("GL_EXT_stencil_wrap") || has_extension("GL_OES_stencil_wrap");
-
+#ifdef OPENGLES_1
+ _supports_stencil_wrap = has_extension("GL_OES_stencil_wrap");
+#elif defined(OPENGLES)
+ _supports_stencil_wrap = true;
+#else
+ _supports_stencil_wrap = is_at_least_gl_version(1, 4) ||
+ has_extension("GL_EXT_stencil_wrap");
+#endif
_supports_two_sided_stencil = false;
#ifndef OPENGLES
+ //TODO: support the two-sided stencil functions that ended up in core.
if (has_extension("GL_EXT_stencil_two_side")) {
_glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC)
get_extension_func("glActiveStencilFaceEXT");
@@ -2598,10 +2888,8 @@ reset() {
memset(_vertex_attrib_divisors, 0, sizeof(GLint) * 32);
#endif
-#ifndef OPENGLES
// Dither is on by default in GL; let's turn it off
glDisable(GL_DITHER);
-#endif // OPENGLES
_dithering_enabled = false;
#ifndef OPENGLES_1
@@ -2707,20 +2995,24 @@ reset() {
report_my_gl_errors();
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (GLCAT.is_debug()) {
- GLCAT.debug()
- << "Supported shader binary formats:\n";
- GLCAT.debug() << " ";
+ if (_supports_get_program_binary) {
+ GLCAT.debug()
+ << "Supported shader binary formats:\n";
+ GLCAT.debug() << " ";
- pset::const_iterator it;
- for (it = _program_binary_formats.begin();
- it != _program_binary_formats.end(); ++it) {
- char number[16];
- sprintf(number, "0x%04X", *it);
- GLCAT.debug(false) << " " << number << "";
+ pset::const_iterator it;
+ for (it = _program_binary_formats.begin();
+ it != _program_binary_formats.end(); ++it) {
+ char number[16];
+ sprintf(number, "0x%04X", *it);
+ GLCAT.debug(false) << " " << number << "";
+ }
+ GLCAT.debug(false) << "\n";
+ } else {
+ GLCAT.debug() << "No shader binary formats supported.\n";
}
- GLCAT.debug(false) << "\n";
}
#endif
@@ -2880,7 +3172,7 @@ clear(DrawableRegion *clearable) {
int mask = 0;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (_current_fbo != 0 && _glClearBufferfv != NULL) {
// We can use glClearBuffer to clear all the color attachments, which
// protects us from the overhead of having to call set_draw_buffer for
@@ -3172,7 +3464,7 @@ clear_before_callback() {
// Clear the bound sampler object, so that we do not inadvertently override
// the callback's desired sampler settings.
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (_supports_sampler_objects) {
_glBindSampler(0, 0);
@@ -3664,7 +3956,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
_use_sender = !vertex_arrays;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (_use_vertex_attrib_binding) {
const GeomVertexFormat *format = data_reader->get_format();
if (format != _current_vertex_format) {
@@ -3980,7 +4272,7 @@ disable_standard_vertex_arrays() {
}
#endif // SUPPORT_FIXED_FUNCTION
-#ifndef OPENGLES
+#ifndef OPENGLES_1
/**
* Updates the vertex format used by the shader. This is still an
* experimental feature.
@@ -4687,7 +4979,7 @@ end_draw_primitives() {
report_my_gl_errors();
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
/**
* Issues the given memory barriers, and clears the list of textures marked as
* incoherent for the given bits.
@@ -4732,7 +5024,7 @@ issue_memory_barrier(GLbitfield barriers) {
report_my_gl_errors();
}
-#endif // OPENGLES
+#endif // OPENGLES_1
/**
* Creates whatever structures the GSG requires to represent the texture
@@ -4874,7 +5166,7 @@ void CLP(GraphicsStateGuardian)::
release_texture(TextureContext *tc) {
CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc);
-#ifndef OPENGLES
+#ifndef OPENGLES_1
_textures_needing_fetch_barrier.erase(gtc);
_textures_needing_image_access_barrier.erase(gtc);
_textures_needing_update_barrier.erase(gtc);
@@ -4918,7 +5210,7 @@ extract_texture_data(Texture *tex) {
return success;
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
/**
* Creates whatever structures the GSG requires to represent the sampler state
* internally, and returns a newly-allocated SamplerContext object with this
@@ -4946,6 +5238,7 @@ prepare_sampler(const SamplerState &sampler) {
_glSamplerParameteri(index, GL_TEXTURE_WRAP_R,
get_texture_wrap_mode(sampler.get_wrap_w()));
+#ifndef OPENGLES
#ifdef STDFLOAT_DOUBLE
LVecBase4f fvalue = LCAST(float, sampler.get_border_color());
_glSamplerParameterfv(index, GL_TEXTURE_BORDER_COLOR, fvalue.get_data());
@@ -4953,6 +5246,7 @@ prepare_sampler(const SamplerState &sampler) {
_glSamplerParameterfv(index, GL_TEXTURE_BORDER_COLOR,
sampler.get_border_color().get_data());
#endif
+#endif // OPENGLES
SamplerState::FilterType minfilter = sampler.get_effective_minfilter();
SamplerState::FilterType magfilter = sampler.get_effective_magfilter();
@@ -4995,18 +5289,20 @@ prepare_sampler(const SamplerState &sampler) {
_glSamplerParameterf(index, GL_TEXTURE_MAX_LOD, sampler.get_max_lod());
}
+#ifndef OPENGLES
if (_supports_texture_lod_bias) {
_glSamplerParameterf(index, GL_TEXTURE_LOD_BIAS, sampler.get_lod_bias());
}
+#endif
gsc->enqueue_lru(&_prepared_objects->_sampler_object_lru);
report_my_gl_errors();
return gsc;
}
-#endif // !OPENGLES
+#endif // !OPENGLES_1
-#ifndef OPENGLES
+#ifndef OPENGLES_1
/**
* Frees the GL resources previously allocated for the sampler. This function
* should never be called directly; instead, call SamplerState::release().
@@ -5021,7 +5317,7 @@ release_sampler(SamplerContext *sc) {
delete gsc;
}
-#endif // !OPENGLES
+#endif // !OPENGLES_1
/**
* Creates a new retained-mode representation of the given geom, and returns a
@@ -5627,7 +5923,7 @@ issue_timer_query(int pstats_index) {
#endif
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
/**
* Dispatches a currently bound compute shader using the given work group
* counts.
@@ -5643,7 +5939,7 @@ dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) {
maybe_gl_finish();
}
-#endif // !OPENGLES
+#endif // !OPENGLES_1
/**
* Creates a new GeomMunger object to munge vertices appropriate to this GSG
@@ -5823,7 +6119,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z,
}
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (gtc->needs_barrier(GL_TEXTURE_UPDATE_BARRIER_BIT)) {
// Make sure that any incoherent writes to this texture have been synced.
issue_memory_barrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
@@ -5903,7 +6199,6 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z,
dr->get_region_pixels(xo, yo, w, h);
Texture::ComponentType component_type = tex->get_component_type();
- bool color_mode = false;
Texture::Format format = tex->get_format();
switch (format) {
@@ -5928,7 +6223,6 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z,
break;
default:
- color_mode = true;
if (_current_properties->get_srgb_color()) {
if (_current_properties->get_alpha_bits()) {
format = Texture::F_srgb_alpha;
@@ -5988,6 +6282,11 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z,
case GL_DEPTH_STENCIL:
GLCAT.spam(false) << "GL_DEPTH_STENCIL, ";
break;
+#ifndef OPENGLES_1
+ case GL_RG:
+ GLCAT.spam(false) << "GL_RG, ";
+ break;
+#endif
case GL_RGB:
GLCAT.spam(false) << "GL_RGB, ";
break;
@@ -6046,7 +6345,7 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z,
// We may have to reverse the byte ordering of the image if GL didn't do it
// for us.
- if (color_mode && !_supports_bgr) {
+ if (external_format == GL_RGBA || external_format == GL_RGB) {
PTA_uchar new_image;
const unsigned char *result =
fix_component_ordering(new_image, image_ptr, image_size,
@@ -6631,6 +6930,34 @@ do_issue_material() {
}
#endif // SUPPORT_FIXED_FUNCTION
+/**
+ * Issues the logic operation attribute to the GL.
+ */
+#if !defined(OPENGLES) || defined(OPENGLES_1)
+void CLP(GraphicsStateGuardian)::
+do_issue_logic_op() {
+ const LogicOpAttrib *target_logic_op;
+ _target_rs->get_attrib_def(target_logic_op);
+
+ if (target_logic_op->get_operation() != LogicOpAttrib::O_none) {
+ glEnable(GL_COLOR_LOGIC_OP);
+ glLogicOp(GL_CLEAR - 1 + (int)target_logic_op->get_operation());
+
+ if (GLCAT.is_spam()) {
+ GLCAT.spam() << "glEnable(GL_COLOR_LOGIC_OP)\n";
+ GLCAT.spam() << "glLogicOp(" << target_logic_op->get_operation() << ")\n";
+ }
+ } else {
+ glDisable(GL_COLOR_LOGIC_OP);
+ glLogicOp(GL_COPY);
+
+ if (GLCAT.is_spam()) {
+ GLCAT.spam() << "glDisable(GL_COLOR_LOGIC_OP)\n";
+ }
+ }
+}
+#endif
+
/**
*
*/
@@ -6677,6 +7004,7 @@ do_issue_blending() {
_target_rs->get_attrib_def(target_color_blend);
CPT(ColorBlendAttrib) color_blend = target_color_blend;
ColorBlendAttrib::Mode color_blend_mode = target_color_blend->get_mode();
+ ColorBlendAttrib::Mode alpha_blend_mode = target_color_blend->get_alpha_mode();
const TransparencyAttrib *target_transparency;
_target_rs->get_attrib_def(target_transparency);
@@ -6689,10 +7017,19 @@ do_issue_blending() {
enable_multisample_alpha_one(false);
enable_multisample_alpha_mask(false);
enable_blend(true);
- _glBlendEquation(get_blend_equation_type(color_blend_mode));
- glBlendFunc(get_blend_func(color_blend->get_operand_a()),
- get_blend_func(color_blend->get_operand_b()));
+ if (_supports_blend_equation_separate) {
+ _glBlendEquationSeparate(get_blend_equation_type(color_blend_mode),
+ get_blend_equation_type(alpha_blend_mode));
+ } else {
+ _glBlendEquation(get_blend_equation_type(color_blend_mode));
+ }
+ _glBlendFuncSeparate(get_blend_func(color_blend->get_operand_a()),
+ get_blend_func(color_blend->get_operand_b()),
+ get_blend_func(color_blend->get_alpha_operand_a()),
+ get_blend_func(color_blend->get_alpha_operand_b()));
+
+#ifndef OPENGLES_1
LColor c;
if (_color_blend_involves_color_scale) {
// Apply the current color scale to the blend mode.
@@ -6702,12 +7039,23 @@ do_issue_blending() {
}
_glBlendColor(c[0], c[1], c[2], c[3]);
+#endif
if (GLCAT.is_spam()) {
- GLCAT.spam() << "glBlendEquation(" << color_blend_mode << ")\n";
- GLCAT.spam() << "glBlendFunc(" << color_blend->get_operand_a()
- << color_blend->get_operand_b() << ")\n";
+ if (_supports_blend_equation_separate) {
+ GLCAT.spam() << "glBlendEquationSeparate(" << color_blend_mode << ", "
+ << alpha_blend_mode << ")\n";
+ } else {
+ GLCAT.spam() << "glBlendEquation(" << color_blend_mode << ")\n";
+ }
+ GLCAT.spam() << "glBlendFuncSeparate("
+ << color_blend->get_operand_a() << ", "
+ << color_blend->get_operand_b() << ", "
+ << color_blend->get_alpha_operand_a() << ", "
+ << color_blend->get_alpha_operand_b() << ")\n";
+#ifndef OPENGLES_1
GLCAT.spam() << "glBlendColor(" << c << ")\n";
+#endif
}
return;
}
@@ -7415,7 +7763,7 @@ do_get_extension_func(const char *) {
*/
void CLP(GraphicsStateGuardian)::
set_draw_buffer(int rbtype) {
-#ifndef OPENGLES // Draw buffers not supported by OpenGL ES.
+#ifndef OPENGLES // Draw buffers not supported by OpenGL ES. (TODO!)
if (_current_fbo) {
GLuint buffers[16];
int nbuffers = 0;
@@ -7509,7 +7857,7 @@ set_draw_buffer(int rbtype) {
*/
void CLP(GraphicsStateGuardian)::
set_read_buffer(int rbtype) {
-#ifndef OPENGLES // Draw buffers not supported by OpenGL ES.
+#ifndef OPENGLES // Draw buffers not supported by OpenGL ES. (TODO!)
if (rbtype & (RenderBuffer::T_depth | RenderBuffer::T_stencil)) {
// Special case: don't have to call ReadBuffer for these.
return;
@@ -7637,7 +7985,7 @@ get_numeric_type(Geom::NumericType numeric_type) {
#endif
case Geom::NT_packed_ufloat:
-#ifndef OPENGLES
+#ifndef OPENGLES_1
return GL_UNSIGNED_INT_10F_11F_11F_REV;
#else
break;
@@ -7673,7 +8021,7 @@ get_texture_target(Texture::TextureType texture_type) const {
return GL_NONE;
case Texture::TT_2d_texture_array:
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (_supports_2d_texture_array) {
return GL_TEXTURE_2D_ARRAY;
}
@@ -7872,7 +8220,7 @@ get_component_type(Texture::ComponentType component_type) {
case Texture::T_short:
return GL_SHORT;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case Texture::T_half_float:
return GL_HALF_FLOAT;
#endif
@@ -8107,10 +8455,12 @@ get_external_image_format(Texture *tex) const {
case Texture::F_r11_g11_b10:
case Texture::F_rgb9_e5:
#ifdef OPENGLES
+ // OpenGL ES never supports BGR, even if _supports_bgr is true.
return GL_RGB;
#else
return _supports_bgr ? GL_BGR : GL_RGB;
#endif
+
case Texture::F_rgba:
case Texture::F_rgbm:
case Texture::F_rgba4:
@@ -8121,11 +8471,7 @@ get_external_image_format(Texture *tex) const {
case Texture::F_rgba32:
case Texture::F_srgb_alpha:
case Texture::F_rgb10_a2:
-#ifdef OPENGLES_2
- return GL_RGBA;
-#else
return _supports_bgr ? GL_BGRA : GL_RGBA;
-#endif
case Texture::F_luminance:
case Texture::F_sluminance:
@@ -8143,7 +8489,7 @@ get_external_image_format(Texture *tex) const {
return GL_RG;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case Texture::F_r8i:
case Texture::F_r32i:
return GL_RED_INTEGER;
@@ -8746,7 +9092,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
return force_sized ? GL_RG8 : GL_RG;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case Texture::F_rg:
return force_sized ? GL_RG8 : GL_RG;
#endif
@@ -8771,7 +9117,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
return GL_R32I;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case Texture::F_r11_g11_b10:
return GL_R11F_G11F_B10F;
@@ -9077,6 +9423,13 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
case ColorBlendAttrib::O_one_minus_constant_alpha:
case ColorBlendAttrib::O_one_minus_alpha_scale:
break;
+
+ // No dual-source blending, either.
+ case ColorBlendAttrib::O_incoming1_color:
+ case ColorBlendAttrib::O_one_minus_incoming1_color:
+ case ColorBlendAttrib::O_incoming1_alpha:
+ case ColorBlendAttrib::O_one_minus_incoming1_alpha:
+ break;
#else
case ColorBlendAttrib::O_constant_color:
case ColorBlendAttrib::O_color_scale:
@@ -9093,6 +9446,18 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
case ColorBlendAttrib::O_one_minus_constant_alpha:
case ColorBlendAttrib::O_one_minus_alpha_scale:
return GL_ONE_MINUS_CONSTANT_ALPHA;
+
+ case ColorBlendAttrib::O_incoming1_color:
+ return GL_SRC1_COLOR;
+
+ case ColorBlendAttrib::O_one_minus_incoming1_color:
+ return GL_ONE_MINUS_SRC1_COLOR;
+
+ case ColorBlendAttrib::O_incoming1_alpha:
+ return GL_SRC1_ALPHA;
+
+ case ColorBlendAttrib::O_one_minus_incoming1_alpha:
+ return GL_ONE_MINUS_SRC1_ALPHA;
#endif
case ColorBlendAttrib::O_incoming_color_saturate:
@@ -9111,7 +9476,7 @@ GLenum CLP(GraphicsStateGuardian)::
get_usage(Geom::UsageHint usage_hint) {
switch (usage_hint) {
case Geom::UH_stream:
-#ifdef OPENGLES
+#ifdef OPENGLES_1
return GL_DYNAMIC_DRAW;
#else
return GL_STREAM_DRAW;
@@ -9146,6 +9511,7 @@ get_compressed_format_string(GLenum format) {
case 0x83F3: return "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT";
case 0x86B0: return "GL_COMPRESSED_RGB_FXT1_3DFX";
case 0x86B1: return "GL_COMPRESSED_RGBA_FXT1_3DFX";
+ case 0x88EE: return "GL_ETC1_SRGB8_NV";
case 0x8A54: return "GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT";
case 0x8A55: return "GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT";
case 0x8A56: return "GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT";
@@ -9176,6 +9542,7 @@ get_compressed_format_string(GLenum format) {
case 0x8C71: return "GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT";
case 0x8C72: return "GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT";
case 0x8C73: return "GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT";
+ case 0x8D64: return "GL_ETC1_RGB8_OES";
case 0x8DBB: return "GL_COMPRESSED_RED_RGTC1";
case 0x8DBC: return "GL_COMPRESSED_SIGNED_RED_RGTC1";
case 0x8DBD: return "GL_COMPRESSED_RG_RGTC2";
@@ -9289,7 +9656,7 @@ reissue_transforms() {
_active_texture_stage = -1;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
// Might also want to reissue the vertex format, for good measure.
_current_vertex_format.clear();
memset(_vertex_attrib_columns, 0, sizeof(const GeomVertexColumn *) * 32);
@@ -9660,6 +10027,16 @@ set_state_and_transform(const RenderState *target,
}
#endif
+#if !defined(OPENGLES) || defined(OPENGLES_1)
+ int logic_op_slot = LogicOpAttrib::get_class_slot();
+ if (_target_rs->get_attrib(logic_op_slot) != _state_rs->get_attrib(logic_op_slot) ||
+ !_state_mask.get_bit(logic_op_slot)) {
+ // PStatGPUTimer timer(this, _draw_set_state_logic_op_pcollector);
+ do_issue_logic_op();
+ _state_mask.set_bit(logic_op_slot);
+ }
+#endif
+
int transparency_slot = TransparencyAttrib::get_class_slot();
int color_write_slot = ColorWriteAttrib::get_class_slot();
int color_blend_slot = ColorBlendAttrib::get_class_slot();
@@ -9923,7 +10300,7 @@ update_standard_texture_bindings() {
// Unsupported texture mode.
continue;
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_CUBE_MAP_ARRAY) {
// Cannot be applied via the FFP.
continue;
@@ -10663,23 +11040,20 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) {
glTexParameteri(target, GL_TEXTURE_WRAP_S,
get_texture_wrap_mode(sampler.get_wrap_u()));
#ifndef OPENGLES
- if (target != GL_TEXTURE_1D) {
+ if (target != GL_TEXTURE_1D)
+#endif
+ {
glTexParameteri(target, GL_TEXTURE_WRAP_T,
get_texture_wrap_mode(sampler.get_wrap_v()));
}
-#endif
-#ifdef OPENGLES_2
- if (target == GL_TEXTURE_3D_OES) {
- glTexParameteri(target, GL_TEXTURE_WRAP_R_OES,
- get_texture_wrap_mode(sampler.get_wrap_w()));
- }
-#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (target == GL_TEXTURE_3D) {
glTexParameteri(target, GL_TEXTURE_WRAP_R,
get_texture_wrap_mode(sampler.get_wrap_w()));
}
+#endif
+#ifndef OPENGLES
LColor border_color = sampler.get_border_color();
call_glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, border_color);
#endif // OPENGLES
@@ -10742,12 +11116,14 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) {
}
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (_supports_texture_lod) {
glTexParameterf(target, GL_TEXTURE_MIN_LOD, sampler.get_min_lod());
glTexParameterf(target, GL_TEXTURE_MAX_LOD, sampler.get_max_lod());
}
+#endif
+#ifndef OPENGLES
if (_supports_texture_lod_bias) {
glTexParameterf(target, GL_TEXTURE_LOD_BIAS, sampler.get_lod_bias());
}
@@ -10803,7 +11179,7 @@ apply_texture(CLP(TextureContext) *gtc) {
*/
bool CLP(GraphicsStateGuardian)::
apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc) {
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (_supports_sampler_objects) {
// We support sampler objects. Prepare the sampler object and bind it to
// the indicated texture unit.
@@ -10821,7 +11197,7 @@ apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc
}
} else
-#endif // OPENGLES
+#endif // !OPENGLES_1
{
// We don't support sampler objects. We'll have to bind the texture and
// change the texture parameters if they don't match.
@@ -11159,14 +11535,12 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
}
}
-#ifndef OPENGLES // OpenGL ES doesn't have GL_TEXTURE_MAX_LEVEL.
- if (is_at_least_gl_version(1, 2)) {
+ if (_supports_texture_max_level) {
// By the time we get here, we have a pretty good prediction for the
// number of mipmaps we're going to have, so tell the GL that's all it's
// going to get.
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, num_levels - 1);
}
-#endif
#ifndef OPENGLES_2
if (gtc->_generate_mipmaps && _glGenerateMipmap == NULL) {
@@ -11425,7 +11799,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
}
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
if (needs_reload || num_ram_mipmap_levels > 0) {
// Make sure that any incoherent writes to this texture have been synced.
if (gtc->needs_barrier(GL_TEXTURE_UPDATE_BARRIER_BIT)) {
@@ -11528,7 +11902,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
}
nassertr(image_ptr >= orig_image_ptr && image_ptr + view_size <= orig_image_ptr + tex->get_ram_mipmap_image_size(n), false);
- if (!_supports_bgr && image_compression == Texture::CM_off) {
+ if (image_compression == Texture::CM_off) {
// If the GL doesn't claim to support BGR, we may have to reverse
// the component ordering of the image.
image_ptr = fix_component_ordering(bgr_image, image_ptr, view_size,
@@ -11573,7 +11947,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
break;
#endif // OPENGLES
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case GL_TEXTURE_2D_ARRAY:
case GL_TEXTURE_CUBE_MAP_ARRAY:
if (_supports_2d_texture_array) {
@@ -11589,7 +11963,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return false;
}
break;
-#endif // OPENGLES
+#endif // OPENGLES_1
#ifndef OPENGLES
case GL_TEXTURE_BUFFER:
@@ -11672,12 +12046,10 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
GLCAT.warning()
<< "No mipmap level " << n << " defined for " << tex->get_name()
<< "\n";
-#ifndef OPENGLES
- if (is_at_least_gl_version(1, 2)) {
+ if (_supports_texture_max_level) {
// Tell the GL we have no more mipmaps for it to use.
glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, n - mipmap_bias);
}
-#endif
break;
}
@@ -11702,7 +12074,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
}
nassertr(image_ptr >= orig_image_ptr && image_ptr + view_size <= orig_image_ptr + tex->get_ram_mipmap_image_size(n), false);
- if (!_supports_bgr && image_compression == Texture::CM_off) {
+ if (image_compression == Texture::CM_off) {
// If the GL doesn't claim to support BGR, we may have to reverse
// the component ordering of the image.
image_ptr = fix_component_ordering(bgr_image, image_ptr, view_size,
@@ -11731,13 +12103,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
break;
#endif // OPENGLES // OpenGL ES will fall through.
-#ifdef OPENGLES_2
- case GL_TEXTURE_3D_OES:
-#endif
-#ifndef OPENGLES
- case GL_TEXTURE_3D:
-#endif
#ifndef OPENGLES_1
+ case GL_TEXTURE_3D:
if (_supports_3d_texture) {
if (image_compression == Texture::CM_off) {
_glTexImage3D(page_target, n - mipmap_bias, internal_format,
@@ -11753,9 +12120,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return false;
}
break;
-#endif
+#endif // OPENGLES_1
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case GL_TEXTURE_2D_ARRAY:
case GL_TEXTURE_CUBE_MAP_ARRAY:
if (_supports_2d_texture_array) {
@@ -11773,7 +12140,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return false;
}
break;
-#endif // OPENGLES
+#endif // OPENGLES_1
#ifndef OPENGLES
case GL_TEXTURE_BUFFER:
@@ -11852,12 +12219,8 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
Texture *tex = gtc->get_texture();
nassertr(tex != (Texture *)NULL, false);
- int internal_format = GL_RGBA;
-#ifdef OPENGLES_2
- int external_format = GL_RGBA;
-#else
- int external_format = GL_BGRA;
-#endif
+ GLenum internal_format = GL_RGBA;
+ GLenum external_format = GL_BGRA;
const unsigned char *image_ptr = tex->get_simple_ram_image();
if (image_ptr == (const unsigned char *)NULL) {
@@ -11876,19 +12239,17 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
int width = tex->get_simple_x_size();
int height = tex->get_simple_y_size();
- int component_type = GL_UNSIGNED_BYTE;
+ GLenum component_type = GL_UNSIGNED_BYTE;
if (GLCAT.is_debug()) {
GLCAT.debug()
<< "loading simple image for " << tex->get_name() << "\n";
}
-#ifndef OPENGLES
// Turn off mipmaps for the simple texture.
- if (tex->uses_mipmaps() && is_at_least_gl_version(1, 2)) {
+ if (tex->uses_mipmaps() && _supports_texture_max_level) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
}
-#endif
#ifdef DO_PSTATS
_data_transferred_pcollector.add_level(image_size);
@@ -12056,7 +12417,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
return false;
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
// Make sure any incoherent writes to the texture have been synced.
if (gtc->needs_barrier(GL_TEXTURE_UPDATE_BARRIER_BIT)) {
issue_memory_barrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
@@ -12078,19 +12439,11 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
glGetTexParameteriv(target, GL_TEXTURE_WRAP_S, &wrap_u);
glGetTexParameteriv(target, GL_TEXTURE_WRAP_T, &wrap_v);
wrap_w = GL_REPEAT;
+#ifndef OPENGLES_1
if (_supports_3d_texture) {
-#ifdef OPENGLES_2
- glGetTexParameteriv(target, GL_TEXTURE_WRAP_R_OES, &wrap_w);
-#endif
-#ifndef OPENGLES
glGetTexParameteriv(target, GL_TEXTURE_WRAP_R, &wrap_w);
-#endif
}
- if (_supports_2d_texture_array) {
-#ifndef OPENGLES
- glGetTexParameteriv(target, GL_TEXTURE_WRAP_R, &wrap_w);
#endif
- }
glGetTexParameteriv(target, GL_TEXTURE_MIN_FILTER, &minfilter);
glGetTexParameteriv(target, GL_TEXTURE_MAG_FILTER, &magfilter);
@@ -12113,13 +12466,9 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
if (_supports_3d_texture && target == GL_TEXTURE_3D) {
glGetTexLevelParameteriv(page_target, 0, GL_TEXTURE_DEPTH, &depth);
- }
-#ifndef OPENGLES
- else if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_CUBE_MAP_ARRAY) {
+ } else if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_CUBE_MAP_ARRAY) {
glGetTexLevelParameteriv(page_target, 0, GL_TEXTURE_DEPTH, &depth);
- }
-#endif
- else if (target == GL_TEXTURE_CUBE_MAP) {
+ } else if (target == GL_TEXTURE_CUBE_MAP) {
depth = 6;
}
#endif
@@ -12328,7 +12677,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
break;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
case GL_R11F_G11F_B10F:
type = Texture::T_float;
format = Texture::F_r11_g11_b10;
@@ -12578,12 +12927,11 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
// Also get the mipmap levels.
GLint num_expected_levels = tex->get_expected_num_mipmap_levels();
GLint highest_level = num_expected_levels;
-#ifndef OPENGLES
- if (is_at_least_gl_version(1, 2)) {
+
+ if (_supports_texture_max_level) {
glGetTexParameteriv(target, GL_TEXTURE_MAX_LEVEL, &highest_level);
highest_level = min(highest_level, num_expected_levels);
}
-#endif
for (int n = 1; n <= highest_level; ++n) {
if (!extract_texture_image(image, page_size, tex, target, page_target,
type, compression, n)) {
diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h
index 9d73f69130..d06cf2de3f 100644
--- a/panda/src/glstuff/glGraphicsStateGuardian_src.h
+++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h
@@ -141,6 +141,8 @@ typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, G
typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
#ifndef OPENGLES_1
// GLSL shader functions
@@ -186,8 +188,26 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size
typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-#endif // OPENGLES_1
-#ifndef OPENGLES
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect);
+typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex);
+typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor);
+typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
+typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);
typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
@@ -195,17 +215,22 @@ typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pnam
typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
+typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+#endif // OPENGLES_1
+#ifndef OPENGLES
typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);
typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);
typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers);
-typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);
-typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
-typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
-typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary);
-typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEPROC) (GLuint texture);
typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEPROC) (GLuint texture, GLuint sampler);
typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTPROC) (GLuint64 handle);
@@ -245,9 +270,7 @@ public:
virtual int get_driver_shader_version_major();
virtual int get_driver_shader_version_minor();
-#ifndef OPENGLES_1
static void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam);
-#endif
virtual void reset();
@@ -281,7 +304,7 @@ public:
bool force);
virtual void end_draw_primitives();
-#ifndef OPENGLES
+#ifndef OPENGLES_1
void issue_memory_barrier(GLbitfield barrier);
#endif
@@ -290,7 +313,7 @@ public:
virtual void release_texture(TextureContext *tc);
virtual bool extract_texture_data(Texture *tex);
-#ifndef OPENGLES
+#ifndef OPENGLES_1
virtual SamplerContext *prepare_sampler(const SamplerState &sampler);
virtual void release_sampler(SamplerContext *sc);
#endif
@@ -329,7 +352,7 @@ public:
virtual PT(TimerQueryContext) issue_timer_query(int pstats_index);
-#ifndef OPENGLES
+#ifndef OPENGLES_1
virtual void dispatch_compute(int size_x, int size_y, int size_z);
#endif
@@ -405,6 +428,9 @@ protected:
void do_issue_material();
#endif
void do_issue_texture();
+#if !defined(OPENGLES) || defined(OPENGLES_1)
+ void do_issue_logic_op();
+#endif
void do_issue_blending();
#ifdef SUPPORT_FIXED_FUNCTION
void do_issue_tex_gen();
@@ -533,7 +559,7 @@ protected:
void disable_standard_texture_bindings();
void update_standard_texture_bindings();
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
void update_shader_vertex_format(const GeomVertexFormat *format);
#endif
@@ -657,7 +683,7 @@ protected:
GLuint _current_ibuffer_index;
GLuint _current_fbo;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
pvector _current_vertex_buffers;
bool _use_vertex_attrib_binding;
CPT(GeomVertexFormat) _current_vertex_format;
@@ -701,7 +727,7 @@ public:
PFNGLSECONDARYCOLORPOINTERPROC _glSecondaryColorPointer;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
PFNGLDRAWRANGEELEMENTSPROC _glDrawRangeElements;
#endif
@@ -777,8 +803,15 @@ public:
#ifndef OPENGLES
PFNGLMAPBUFFERPROC _glMapBuffer;
PFNGLUNMAPBUFFERPROC _glUnmapBuffer;
- PFNGLMAPBUFFERRANGEPROC _glMapBufferRange;
+#endif
+#ifdef OPENGLES
+ PFNGLMAPBUFFERRANGEEXTPROC _glMapBufferRange;
+#else
+ PFNGLMAPBUFFERRANGEPROC _glMapBufferRange;
+#endif
+
+#ifndef OPENGLES_1
bool _supports_uniform_buffers;
PFNGLBINDBUFFERBASEPROC _glBindBufferBase;
@@ -786,8 +819,16 @@ public:
PFNGLBUFFERSTORAGEPROC _glBufferStorage;
#endif
+ bool _supports_blend_equation_separate;
+#ifndef OPENGLES_2
+ // OpenGL ES 2+ has these in the core.
PFNGLBLENDEQUATIONPROC _glBlendEquation;
+ PFNGLBLENDEQUATIONSEPARATEPROC _glBlendEquationSeparate;
+ PFNGLBLENDFUNCSEPARATEPROC _glBlendFuncSeparate;
+#endif
+#ifndef OPENGLES
PFNGLBLENDCOLORPROC _glBlendColor;
+#endif
bool _supports_vao;
GLuint _current_vao_index;
@@ -795,7 +836,7 @@ public:
PFNGLDELETEVERTEXARRAYSPROC _glDeleteVertexArrays;
PFNGLGENVERTEXARRAYSPROC _glGenVertexArrays;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
PFNGLDRAWARRAYSINDIRECTPROC _glDrawArraysIndirect;
PFNGLDRAWELEMENTSINDIRECTPROC _glDrawElementsIndirect;
#endif
@@ -830,7 +871,7 @@ public:
PFNGLGENERATETEXTUREMIPMAPPROC _glGenerateTextureMipmap;
#endif
-#ifndef OPENGLES
+#ifndef OPENGLES_1
bool _supports_empty_framebuffer;
PFNGLFRAMEBUFFERPARAMETERIPROC _glFramebufferParameteri;
#endif
@@ -846,7 +887,7 @@ public:
PFNGLBLITFRAMEBUFFEREXTPROC _glBlitFramebuffer;
PFNGLDRAWBUFFERSPROC _glDrawBuffers;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
PFNGLCLEARBUFFERFVPROC _glClearBufferfv;
PFNGLCLEARBUFFERIVPROC _glClearBufferiv;
PFNGLCLEARBUFFERFIPROC _glClearBufferfi;
@@ -917,10 +958,7 @@ public:
PFNGLVERTEXATTRIBDIVISORPROC _glVertexAttribDivisor;
PFNGLDRAWARRAYSINSTANCEDPROC _glDrawArraysInstanced;
PFNGLDRAWELEMENTSINSTANCEDPROC _glDrawElementsInstanced;
-#endif // !OPENGLES_1
-#ifndef OPENGLES
PFNGLBINDVERTEXBUFFERPROC _glBindVertexBuffer;
- PFNGLBINDVERTEXBUFFERSPROC _glBindVertexBuffers;
PFNGLVERTEXATTRIBFORMATPROC _glVertexAttribFormat;
PFNGLVERTEXATTRIBIFORMATPROC _glVertexAttribIFormat;
PFNGLVERTEXATTRIBLFORMATPROC _glVertexAttribLFormat;
@@ -937,16 +975,19 @@ public:
PFNGLSAMPLERPARAMETERFPROC _glSamplerParameterf;
PFNGLSAMPLERPARAMETERFVPROC _glSamplerParameterfv;
PFNGLPROGRAMPARAMETERIPROC _glProgramParameteri;
- PFNGLPATCHPARAMETERIPROC _glPatchParameteri;
- PFNGLBINDTEXTURESPROC _glBindTextures;
- PFNGLBINDSAMPLERSPROC _glBindSamplers;
- PFNGLBINDIMAGETEXTUREPROC _glBindImageTexture;
- PFNGLBINDIMAGETEXTURESPROC _glBindImageTextures;
PFNGLDISPATCHCOMPUTEPROC _glDispatchCompute;
PFNGLMEMORYBARRIERPROC _glMemoryBarrier;
PFNGLGETPROGRAMBINARYPROC _glGetProgramBinary;
PFNGLPROGRAMBINARYPROC _glProgramBinary;
PFNGLGETINTERNALFORMATIVPROC _glGetInternalformativ;
+ PFNGLBINDIMAGETEXTUREPROC _glBindImageTexture;
+#endif // !OPENGLES_1
+#ifndef OPENGLES
+ PFNGLBINDVERTEXBUFFERSPROC _glBindVertexBuffers;
+ PFNGLPATCHPARAMETERIPROC _glPatchParameteri;
+ PFNGLBINDTEXTURESPROC _glBindTextures;
+ PFNGLBINDSAMPLERSPROC _glBindSamplers;
+ PFNGLBINDIMAGETEXTURESPROC _glBindImageTextures;
PFNGLVIEWPORTARRAYVPROC _glViewportArrayv;
PFNGLSCISSORARRAYVPROC _glScissorArrayv;
PFNGLDEPTHRANGEARRAYVPROC _glDepthRangeArrayv;
@@ -965,10 +1006,9 @@ public:
GLenum _mirror_edge_clamp;
GLenum _mirror_border_clamp;
-#ifndef OPENGLES
bool _supports_texture_lod;
bool _supports_texture_lod_bias;
-#endif
+ bool _supports_texture_max_level;
#ifndef OPENGLES_1
GLsizei _instance_count;
@@ -979,7 +1019,7 @@ public:
DeletedNames _deleted_display_lists;
DeletedNames _deleted_queries;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
// Stores textures for which memory bariers should be issued.
typedef pset TextureSet;
TextureSet _textures_needing_fetch_barrier;
diff --git a/panda/src/glstuff/glSamplerContext_src.cxx b/panda/src/glstuff/glSamplerContext_src.cxx
index fa5f4984ae..486ebb0cc5 100644
--- a/panda/src/glstuff/glSamplerContext_src.cxx
+++ b/panda/src/glstuff/glSamplerContext_src.cxx
@@ -13,7 +13,7 @@
#include "pnotify.h"
-#ifndef OPENGLES
+#ifndef OPENGLES_1
TypeHandle CLP(SamplerContext)::_type_handle;
@@ -68,4 +68,4 @@ reset_data() {
// the sampler later. glGenSamplers(1, &_index);
}
-#endif // OPENGLES
+#endif // OPENGLES_1
diff --git a/panda/src/glstuff/glSamplerContext_src.h b/panda/src/glstuff/glSamplerContext_src.h
index 369ab49ab6..2a07bdd4a1 100644
--- a/panda/src/glstuff/glSamplerContext_src.h
+++ b/panda/src/glstuff/glSamplerContext_src.h
@@ -11,7 +11,7 @@
* @date 2014-12-11
*/
-#ifndef OPENGLES
+#ifndef OPENGLES_1
#include "pandabase.h"
#include "samplerContext.h"
@@ -56,4 +56,4 @@ private:
static TypeHandle _type_handle;
};
-#endif // OPENGLES
+#endif // OPENGLES_1
diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx
index c2f7edaa48..46c8da2d3b 100644
--- a/panda/src/glstuff/glShaderContext_src.cxx
+++ b/panda/src/glstuff/glShaderContext_src.cxx
@@ -300,7 +300,6 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
name_buflen = max(64, name_buflen);
name_buffer = (char *)alloca(name_buflen);
-#ifndef OPENGLES
// Get the used uniform blocks.
if (_glgsg->_supports_uniform_buffers) {
GLint block_count = 0, block_maxlength = 0;
@@ -324,7 +323,6 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
reflect_uniform_block(i, block_name_cstr, name_buffer, name_buflen);
}
}
-#endif // !OPENGLES
// Bind the program, so that we can call glUniform1i for the textures.
_glgsg->_glUseProgram(_glsl_program);
@@ -402,11 +400,9 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) {
param_type == GL_INT_VEC2 ||
param_type == GL_INT_VEC3 ||
param_type == GL_INT_VEC4 ||
-#ifndef OPENGLES
param_type == GL_UNSIGNED_INT_VEC2 ||
param_type == GL_UNSIGNED_INT_VEC3 ||
param_type == GL_UNSIGNED_INT_VEC4 ||
-#endif
param_type == GL_UNSIGNED_INT);
// Check if it has a p3d_ prefix - if so, assign special meaning.
@@ -505,7 +501,6 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) {
_shader->_var_spec.push_back(bind);
}
-#ifndef OPENGLES
/**
* Analyzes the uniform block and stores its format.
*/
@@ -583,6 +578,7 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
numeric_type = GeomEnums::NT_float32;
break;
+#ifndef OPENGLES
case GL_DOUBLE:
case GL_DOUBLE_VEC2:
case GL_DOUBLE_VEC3:
@@ -592,6 +588,7 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
case GL_DOUBLE_MAT4:
numeric_type = GeomEnums::NT_float64;
break;
+#endif
default:
GLCAT.info() << "Ignoring uniform '" << name_buffer
@@ -604,7 +601,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
case GL_BOOL_VEC2:
case GL_UNSIGNED_INT_VEC2:
case GL_FLOAT_VEC2:
+#ifndef OPENGLES
case GL_DOUBLE_VEC2:
+#endif
num_components = 2;
break;
@@ -612,7 +611,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
case GL_BOOL_VEC3:
case GL_UNSIGNED_INT_VEC3:
case GL_FLOAT_VEC3:
+#ifndef OPENGLES
case GL_DOUBLE_VEC3:
+#endif
num_components = 3;
break;
@@ -620,12 +621,16 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
case GL_BOOL_VEC4:
case GL_UNSIGNED_INT_VEC4:
case GL_FLOAT_VEC4:
+#ifndef OPENGLES
case GL_DOUBLE_VEC4:
+#endif
num_components = 4;
break;
case GL_FLOAT_MAT3:
+#ifndef OPENGLES
case GL_DOUBLE_MAT3:
+#endif
num_components = 3;
contents = GeomEnums::C_matrix;
nassertd(param_size <= 1 || astrides[ui] == mstrides[ui] * 3) continue;
@@ -633,7 +638,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
break;
case GL_FLOAT_MAT4:
+#ifndef OPENGLES
case GL_DOUBLE_MAT4:
+#endif
num_components = 4;
contents = GeomEnums::C_matrix;
nassertd(param_size <= 1 || astrides[ui] == mstrides[ui] * 4) continue;
@@ -655,7 +662,6 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
// _uniform_blocks.push_back(block);
}
-#endif // !OPENGLES
/**
* Analyzes a single uniform variable and considers how it should be handled
@@ -671,23 +677,24 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
_glgsg->_glGetActiveUniform(_glsl_program, i, name_buflen, NULL, ¶m_size, ¶m_type, name_buffer);
GLint p = _glgsg->_glGetUniformLocation(_glsl_program, name_buffer);
+ if (GLCAT.is_debug()) {
+ GLCAT.debug()
+ << "Active uniform " << name_buffer << " with size " << param_size
+ << " and type 0x" << hex << param_type << dec
+ << " is bound to location " << p << "\n";
+ }
// Some NVidia drivers (361.43 for example) (incorrectly) include "internal"
// uniforms in the list starting with "_main_" (for example,
// "_main_0_gp5fp[0]") we need to skip those, because we don't know anything
// about them
if (strncmp(name_buffer, "_main_", 6) == 0) {
- GLCAT.warning() << "Ignoring uniform " << name_buffer << " which may be generated by buggy Nvidia driver.\n";
+ if (GLCAT.is_debug()) {
+ GLCAT.debug() << "Ignoring uniform " << name_buffer << " which may be generated by buggy Nvidia driver.\n";
+ }
return;
}
- if (GLCAT.is_debug()) {
- GLCAT.debug()
- << "Active uniform " << name_buffer << " with size " << param_size
- << " and type 0x" << hex << param_type << dec
- << " is bound to location " << p << "\n";
- }
-
if (p < 0) {
// Special meaning, or it's in a uniform block. Let it go.
return;
@@ -1099,9 +1106,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
string member_name(name_buffer);
if (member_name == "shadowMap") {
switch (param_type) {
-#ifndef OPENGLES
case GL_SAMPLER_CUBE_SHADOW:
-#endif // !OPENGLES
case GL_SAMPLER_2D:
case GL_SAMPLER_2D_SHADOW:
case GL_SAMPLER_CUBE:
@@ -1279,26 +1284,26 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
if (param_size == 1) {
// A single uniform (not an array, or an array of size 1).
switch (param_type) {
-#ifndef OPENGLES
- case GL_INT_SAMPLER_1D:
case GL_INT_SAMPLER_2D:
case GL_INT_SAMPLER_3D:
case GL_INT_SAMPLER_2D_ARRAY:
case GL_INT_SAMPLER_CUBE:
- case GL_INT_SAMPLER_BUFFER:
- case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_1D:
case GL_UNSIGNED_INT_SAMPLER_2D:
case GL_UNSIGNED_INT_SAMPLER_3D:
case GL_UNSIGNED_INT_SAMPLER_CUBE:
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
- case GL_UNSIGNED_INT_SAMPLER_BUFFER:
- case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
- case GL_SAMPLER_1D_SHADOW:
- case GL_SAMPLER_1D:
case GL_SAMPLER_CUBE_SHADOW:
case GL_SAMPLER_2D_ARRAY:
case GL_SAMPLER_2D_ARRAY_SHADOW:
+#ifndef OPENGLES
+ case GL_INT_SAMPLER_1D:
+ case GL_INT_SAMPLER_BUFFER:
+ case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
+ case GL_UNSIGNED_INT_SAMPLER_1D:
+ case GL_UNSIGNED_INT_SAMPLER_BUFFER:
+ case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
+ case GL_SAMPLER_1D:
+ case GL_SAMPLER_1D_SHADOW:
case GL_SAMPLER_BUFFER:
case GL_SAMPLER_CUBE_MAP_ARRAY:
case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
@@ -1320,14 +1325,12 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
return;
}
case GL_FLOAT_MAT2:
-#ifndef OPENGLES
case GL_FLOAT_MAT2x3:
case GL_FLOAT_MAT2x4:
case GL_FLOAT_MAT3x2:
case GL_FLOAT_MAT3x4:
case GL_FLOAT_MAT4x2:
case GL_FLOAT_MAT4x3:
-#endif
GLCAT.warning() << "GLSL shader requested an unsupported matrix type\n";
return;
case GL_FLOAT_MAT3: {
@@ -1461,28 +1464,29 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
_shader->_ptr_spec.push_back(bind);
return;
}
-#ifndef OPENGLES
- case GL_IMAGE_1D:
case GL_IMAGE_2D:
case GL_IMAGE_3D:
case GL_IMAGE_CUBE:
case GL_IMAGE_2D_ARRAY:
- case GL_IMAGE_CUBE_MAP_ARRAY:
- case GL_IMAGE_BUFFER:
- case GL_INT_IMAGE_1D:
case GL_INT_IMAGE_2D:
case GL_INT_IMAGE_3D:
case GL_INT_IMAGE_CUBE:
case GL_INT_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_CUBE_MAP_ARRAY:
- case GL_INT_IMAGE_BUFFER:
- case GL_UNSIGNED_INT_IMAGE_1D:
case GL_UNSIGNED_INT_IMAGE_2D:
case GL_UNSIGNED_INT_IMAGE_3D:
case GL_UNSIGNED_INT_IMAGE_CUBE:
case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
+#ifndef OPENGLES
+ case GL_IMAGE_1D:
+ case GL_IMAGE_CUBE_MAP_ARRAY:
+ case GL_IMAGE_BUFFER:
+ case GL_INT_IMAGE_1D:
+ case GL_INT_IMAGE_CUBE_MAP_ARRAY:
+ case GL_INT_IMAGE_BUFFER:
+ case GL_UNSIGNED_INT_IMAGE_1D:
case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY:
case GL_UNSIGNED_INT_IMAGE_BUFFER:
+#endif
// This won't really change at runtime, so we might as well bind once
// and then forget about it.
_glgsg->_glUniform1i(p, _glsl_img_inputs.size());
@@ -1494,7 +1498,6 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
_glsl_img_inputs.push_back(input);
}
return;
-#endif
default:
GLCAT.warning() << "Ignoring unrecognized GLSL parameter type!\n";
}
@@ -1502,14 +1505,12 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
// A uniform array.
switch (param_type) {
case GL_FLOAT_MAT2:
-#ifndef OPENGLES
case GL_FLOAT_MAT2x3:
case GL_FLOAT_MAT2x4:
case GL_FLOAT_MAT3x2:
case GL_FLOAT_MAT3x4:
case GL_FLOAT_MAT4x2:
case GL_FLOAT_MAT4x3:
-#endif
GLCAT.warning() << "GLSL shader requested an unrecognized matrix array type\n";
return;
case GL_BOOL:
@@ -1597,10 +1598,10 @@ get_sampler_texture_type(int &out, GLenum param_type) {
case GL_SAMPLER_1D:
out = Texture::TT_1d_texture;
return true;
+#endif
case GL_INT_SAMPLER_2D:
case GL_UNSIGNED_INT_SAMPLER_2D:
-#endif
case GL_SAMPLER_2D:
out = Texture::TT_2d_texture;
return true;
@@ -1614,10 +1615,8 @@ get_sampler_texture_type(int &out, GLenum param_type) {
}
return true;
-#ifndef OPENGLES
case GL_INT_SAMPLER_3D:
case GL_UNSIGNED_INT_SAMPLER_3D:
-#endif
case GL_SAMPLER_3D:
out = Texture::TT_3d_texture;
if (_glgsg->_supports_3d_texture) {
@@ -1628,7 +1627,6 @@ get_sampler_texture_type(int &out, GLenum param_type) {
return false;
}
-#ifndef OPENGLES
case GL_SAMPLER_CUBE_SHADOW:
if (!_glgsg->_supports_shadow_filter) {
GLCAT.error()
@@ -1638,7 +1636,6 @@ get_sampler_texture_type(int &out, GLenum param_type) {
// Fall through
case GL_INT_SAMPLER_CUBE:
case GL_UNSIGNED_INT_SAMPLER_CUBE:
-#endif
case GL_SAMPLER_CUBE:
out = Texture::TT_cube_map;
if (!_glgsg->_supports_cube_map) {
@@ -1648,7 +1645,6 @@ get_sampler_texture_type(int &out, GLenum param_type) {
}
return true;
-#ifndef OPENGLES
case GL_SAMPLER_2D_ARRAY_SHADOW:
if (!_glgsg->_supports_shadow_filter) {
GLCAT.error()
@@ -1668,6 +1664,7 @@ get_sampler_texture_type(int &out, GLenum param_type) {
return false;
}
+#ifndef OPENGLES
case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
if (!_glgsg->_supports_shadow_filter) {
GLCAT.error()
@@ -1699,7 +1696,7 @@ get_sampler_texture_type(int &out, GLenum param_type) {
<< "GLSL shader uses buffer texture, which is unsupported by the driver.\n";
return false;
}
-#endif
+#endif // !OPENGLES
default:
GLCAT.error()
@@ -2129,7 +2126,6 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
const GeomVertexArrayDataHandle *array_reader;
-#ifndef OPENGLES
if (_glgsg->_use_vertex_attrib_binding) {
// Use experimental new separated formatbinding state.
const GeomVertexDataPipelineReader *data_reader = _glgsg->_data_reader;
@@ -2185,9 +2181,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
}
_glgsg->_enabled_vertex_attrib_arrays = enabled_attribs;
- } else
-#endif
- {
+ } else {
Geom::NumericType numeric_type;
int start, stride, num_values;
size_t nvarying = _shader->_var_spec.size();
@@ -2230,13 +2224,10 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
for (int i = 0; i < num_elements; ++i) {
_glgsg->enable_vertex_attrib_array(p);
-#ifndef OPENGLES
if (bind._integer) {
_glgsg->_glVertexAttribIPointer(p, num_values, _glgsg->get_numeric_type(numeric_type),
stride, client_pointer);
- } else
-#endif
- if (numeric_type == GeomEnums::NT_packed_dabc) {
+ } else if (numeric_type == GeomEnums::NT_packed_dabc) {
// GL_BGRA is a special accepted value available since OpenGL 3.2.
// It requires us to pass GL_TRUE for normalized.
_glgsg->_glVertexAttribPointer(p, GL_BGRA, GL_UNSIGNED_BYTE,
@@ -2340,9 +2331,7 @@ disable_shader_texture_bindings() {
break;
case Texture::TT_2d_texture_array:
-#ifndef OPENGLES
- glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, 0);
-#endif
+ glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
break;
case Texture::TT_cube_map:
@@ -2357,15 +2346,16 @@ disable_shader_texture_bindings() {
}
}
-#ifndef OPENGLES
// Now unbind all the image units. Not sure if we *have* to do this.
int num_image_units = min(_glsl_img_inputs.size(), (size_t)_glgsg->_max_image_units);
if (num_image_units > 0) {
+#ifndef OPENGLES
if (_glgsg->_supports_multi_bind) {
_glgsg->_glBindImageTextures(0, num_image_units, NULL);
-
- } else {
+ } else
+#endif
+ {
for (int i = 0; i < num_image_units; ++i) {
_glgsg->_glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R8);
}
@@ -2382,7 +2372,6 @@ disable_shader_texture_bindings() {
}
}
}
-#endif
_glgsg->report_my_gl_errors();
}
@@ -2402,7 +2391,6 @@ update_shader_texture_bindings(ShaderContext *prev) {
return;
}
-#ifndef OPENGLES
GLbitfield barriers = 0;
// First bind all the 'image units'; a bit of an esoteric OpenGL feature
@@ -2500,7 +2488,6 @@ update_shader_texture_bindings(ShaderContext *prev) {
}
}
}
-#endif
size_t num_textures = _shader->_tex_spec.size();
GLuint *textures;
@@ -2781,12 +2768,12 @@ glsl_compile_shader(Shader::ShaderType type) {
handle = _glgsg->_glCreateShader(GL_TESS_EVALUATION_SHADER);
}
break;
+#endif
case Shader::ST_compute:
if (_glgsg->get_supports_compute_shaders()) {
handle = _glgsg->_glCreateShader(GL_COMPUTE_SHADER);
}
break;
-#endif
default:
break;
}
@@ -2844,7 +2831,6 @@ glsl_compile_and_link() {
_glgsg->_glObjectLabel(GL_PROGRAM, _glsl_program, name.size(), name.data());
}
-#ifndef OPENGLES
// Do we have a compiled program? Try to load that.
unsigned int format;
string binary;
@@ -2868,7 +2854,6 @@ glsl_compile_and_link() {
<< _shader->get_filename() << "\n";
}
}
-#endif
bool valid = true;
@@ -2933,7 +2918,6 @@ glsl_compile_and_link() {
// If we requested to retrieve the shader, we should indicate that before
// linking.
-#ifndef OPENGLES
bool retrieve_binary = false;
if (_glgsg->_supports_get_program_binary) {
retrieve_binary = _shader->get_cache_compiled_shader();
@@ -2946,7 +2930,6 @@ glsl_compile_and_link() {
_glgsg->_glProgramParameteri(_glsl_program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
}
-#endif
if (GLCAT.is_debug()) {
GLCAT.debug()
@@ -2967,7 +2950,6 @@ glsl_compile_and_link() {
// Report any warnings.
glsl_report_program_errors(_glsl_program, false);
-#ifndef OPENGLES
if (retrieve_binary) {
GLint length = 0;
_glgsg->_glGetProgramiv(_glsl_program, GL_PROGRAM_BINARY_LENGTH, &length);
@@ -2998,7 +2980,6 @@ glsl_compile_and_link() {
}
#endif // NDEBUG
}
-#endif // OPENGLES
_glgsg->report_my_gl_errors();
return true;
diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h
index 4209ec66fb..13f90fcecc 100644
--- a/panda/src/glstuff/glShaderContext_src.h
+++ b/panda/src/glstuff/glShaderContext_src.h
@@ -35,10 +35,8 @@ public:
ALLOC_DELETED_CHAIN(CLP(ShaderContext));
void reflect_attribute(int i, char *name_buf, GLsizei name_buflen);
-#ifndef OPENGLES
void reflect_uniform_block(int i, const char *block_name,
char *name_buffer, GLsizei name_buflen);
-#endif
void reflect_uniform(int i, char *name_buffer, GLsizei name_buflen);
bool get_sampler_texture_type(int &out, GLenum param_type);
diff --git a/panda/src/glstuff/glTextureContext_src.cxx b/panda/src/glstuff/glTextureContext_src.cxx
index 8639b898a2..a5b97dd2f7 100644
--- a/panda/src/glstuff/glTextureContext_src.cxx
+++ b/panda/src/glstuff/glTextureContext_src.cxx
@@ -82,7 +82,7 @@ reset_data() {
_has_storage = false;
_immutable = false;
-#ifndef OPENGLES
+#ifndef OPENGLES_1
// Mark the texture as coherent.
if (gl_enable_memory_barriers) {
_glgsg->_textures_needing_fetch_barrier.erase(this);
@@ -131,7 +131,7 @@ get_handle() {
#endif
}
-#ifndef OPENGLES
+#ifndef OPENGLES_1
/**
*
*/
@@ -176,4 +176,4 @@ mark_incoherent(bool wrote) {
_glgsg->_textures_needing_framebuffer_barrier.insert(this);
}
-#endif // OPENGLES
+#endif // !OPENGLES_1
diff --git a/panda/src/glstuff/glTextureContext_src.h b/panda/src/glstuff/glTextureContext_src.h
index 8a36882f26..123f2d207d 100644
--- a/panda/src/glstuff/glTextureContext_src.h
+++ b/panda/src/glstuff/glTextureContext_src.h
@@ -36,7 +36,7 @@ public:
void make_handle_resident();
GLuint64 get_handle();
-#ifdef OPENGLES
+#ifdef OPENGLES_1
static CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; };
#else
bool needs_barrier(GLbitfield barrier);
diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx
index 2905d54d7d..4b7c396577 100644
--- a/panda/src/gobj/shader.cxx
+++ b/panda/src/gobj/shader.cxx
@@ -2362,15 +2362,14 @@ r_preprocess_source(ostream &out, const Filename &fn,
bool had_include = false;
int lineno = 0;
while (getline(*source, line)) {
- // We always forward the actual line - the GLSL compiler will silently
- // ignore #pragma lines anyway.
++lineno;
- out << line << "\n";
// Check if this line contains a #pragma.
char pragma[64];
if (line.size() < 8 ||
sscanf(line.c_str(), " # pragma %63s", pragma) != 1) {
+ // Just pass the line through unmodified.
+ out << line << "\n";
// One exception: check for an #endif after an include. We have to
// restore the line number in case the include happened under an #if
@@ -2435,8 +2434,11 @@ r_preprocess_source(ostream &out, const Filename &fn,
} else if (strcmp(pragma, "optionNV") == 0) {
// This is processed by NVIDIA drivers. Don't touch it.
+ out << line << "\n";
} else {
+ // Forward it, the driver will ignore it if it doesn't know it.
+ out << line << "\n";
shader_cat.warning()
<< "Ignoring unknown pragma directive \"" << pragma << "\" at line "
<< lineno << " of file " << fn << ":\n " << line << "\n";
diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I
index 534b7aad00..25244367a8 100644
--- a/panda/src/gobj/texture.I
+++ b/panda/src/gobj/texture.I
@@ -2033,9 +2033,9 @@ set_component_type(Texture::ComponentType component_type) {
* ram image needs to be replaced.
*/
INLINE void Texture::
-set_loaded_from_image() {
+set_loaded_from_image(bool flag) {
CDWriter cdata(_cycler, false);
- cdata->_loaded_from_image = true;
+ cdata->_loaded_from_image = flag;
}
/**
@@ -2054,9 +2054,9 @@ get_loaded_from_image() const {
* when a Texture is loaded.
*/
INLINE void Texture::
-set_loaded_from_txo() {
+set_loaded_from_txo(bool flag) {
CDWriter cdata(_cycler, false);
- cdata->_loaded_from_txo = true;
+ cdata->_loaded_from_txo = flag;
}
/**
diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h
index 15f465ac4d..e1226579b2 100644
--- a/panda/src/gobj/texture.h
+++ b/panda/src/gobj/texture.h
@@ -300,70 +300,115 @@ PUBLISHED:
INLINE bool has_filename() const;
INLINE const Filename &get_filename() const;
+ INLINE void set_filename(const Filename &filename);
+ INLINE void clear_filename();
+ MAKE_PROPERTY2(filename, has_filename, get_filename, set_filename, clear_filename);
+
INLINE bool has_alpha_filename() const;
INLINE const Filename &get_alpha_filename() const;
- MAKE_PROPERTY2(filename, has_filename, get_filename);
- MAKE_PROPERTY2(alpha_filename, has_alpha_filename, get_alpha_filename);
+ INLINE void set_alpha_filename(const Filename &alpha_filename);
+ INLINE void clear_alpha_filename();
+ MAKE_PROPERTY2(alpha_filename, has_alpha_filename, get_alpha_filename, set_alpha_filename, clear_alpha_filename);
INLINE bool has_fullpath() const;
INLINE const Filename &get_fullpath() const;
+ INLINE void set_fullpath(const Filename &fullpath);
+ INLINE void clear_fullpath();
+ MAKE_PROPERTY2(fullpath, has_fullpath, get_fullpath, set_fullpath, clear_fullpath);
+
INLINE bool has_alpha_fullpath() const;
INLINE const Filename &get_alpha_fullpath() const;
- MAKE_PROPERTY2(fullpath, has_fullpath, get_fullpath);
- MAKE_PROPERTY2(alpha_fullpath, has_alpha_fullpath, get_alpha_fullpath);
+ INLINE void set_alpha_fullpath(const Filename &alpha_fullpath);
+ INLINE void clear_alpha_fullpath();
+ MAKE_PROPERTY2(alpha_fullpath, has_alpha_fullpath, get_alpha_fullpath, set_alpha_fullpath, clear_alpha_fullpath);
INLINE int get_x_size() const;
+ INLINE void set_x_size(int x_size);
+ MAKE_PROPERTY(x_size, get_x_size, set_x_size);
+
INLINE int get_y_size() const;
+ INLINE void set_y_size(int y_size);
+ MAKE_PROPERTY(y_size, get_y_size, set_y_size);
+
INLINE int get_z_size() const;
+ INLINE void set_z_size(int z_size);
+ MAKE_PROPERTY(z_size, get_z_size, set_z_size);
+
INLINE int get_num_views() const;
+ INLINE void set_num_views(int num_views);
+ MAKE_PROPERTY(num_views, get_num_views, set_num_views);
+
INLINE int get_num_pages() const;
INLINE int get_num_components() const;
INLINE int get_component_width() const;
INLINE TextureType get_texture_type() const;
- INLINE Format get_format() const;
- INLINE ComponentType get_component_type() const;
INLINE GeomEnums::UsageHint get_usage_hint() const;
- MAKE_PROPERTY(num_views, get_num_views);
+
MAKE_PROPERTY(num_pages, get_num_pages);
MAKE_PROPERTY(num_components, get_num_components);
MAKE_PROPERTY(component_width, get_component_width);
MAKE_PROPERTY(texture_type, get_texture_type);
- MAKE_PROPERTY(format, get_format);
- MAKE_PROPERTY(component_type, get_component_type);
MAKE_PROPERTY(usage_hint, get_usage_hint);
+ INLINE Format get_format() const;
+ INLINE void set_format(Format format);
+ MAKE_PROPERTY(format, get_format, set_format);
+
+ INLINE ComponentType get_component_type() const;
+ INLINE void set_component_type(ComponentType component_type);
+ MAKE_PROPERTY(component_type, get_component_type, set_component_type);
+
+ INLINE SamplerState::WrapMode get_wrap_u() const;
INLINE void set_wrap_u(WrapMode wrap);
+ MAKE_PROPERTY(wrap_u, get_wrap_u, set_wrap_u);
+
+ INLINE SamplerState::WrapMode get_wrap_v() const;
INLINE void set_wrap_v(WrapMode wrap);
+ MAKE_PROPERTY(wrap_v, get_wrap_v, set_wrap_v);
+
+ INLINE SamplerState::WrapMode get_wrap_w() const;
INLINE void set_wrap_w(WrapMode wrap);
+ MAKE_PROPERTY(wrap_w, get_wrap_w, set_wrap_w);
+
+ INLINE SamplerState::FilterType get_minfilter() const;
+ INLINE SamplerState::FilterType get_effective_minfilter() const;
INLINE void set_minfilter(FilterType filter);
+ MAKE_PROPERTY(minfilter, get_minfilter, set_minfilter);
+ MAKE_PROPERTY(effective_minfilter, get_effective_minfilter);
+
+ INLINE SamplerState::FilterType get_magfilter() const;
+ INLINE SamplerState::FilterType get_effective_magfilter() const;
INLINE void set_magfilter(FilterType filter);
+ MAKE_PROPERTY(magfilter, get_magfilter, set_magfilter);
+ MAKE_PROPERTY(effective_magfilter, get_effective_magfilter);
+
+ INLINE int get_anisotropic_degree() const;
+ INLINE int get_effective_anisotropic_degree() const;
INLINE void set_anisotropic_degree(int anisotropic_degree);
+ MAKE_PROPERTY(anisotropic_degree, get_anisotropic_degree, set_anisotropic_degree);
+ MAKE_PROPERTY(effective_anisotropic_degree, get_effective_anisotropic_degree);
+
+ INLINE LColor get_border_color() const;
INLINE void set_border_color(const LColor &color);
+ MAKE_PROPERTY(border_color, get_border_color, set_border_color);
+
+ INLINE bool has_compression() const;
+ INLINE CompressionMode get_compression() const;
INLINE void set_compression(CompressionMode compression);
+ MAKE_PROPERTY(compression, get_compression, set_compression); // Could maybe use has_compression here, too
+
+ INLINE bool get_render_to_texture() const;
INLINE void set_render_to_texture(bool render_to_texture);
+ MAKE_PROPERTY(render_to_texture, get_render_to_texture, set_render_to_texture);
INLINE const SamplerState &get_default_sampler() const;
INLINE void set_default_sampler(const SamplerState &sampler);
- INLINE SamplerState::WrapMode get_wrap_u() const;
- INLINE SamplerState::WrapMode get_wrap_v() const;
- INLINE SamplerState::WrapMode get_wrap_w() const;
- INLINE SamplerState::FilterType get_minfilter() const;
- INLINE SamplerState::FilterType get_magfilter() const;
- INLINE SamplerState::FilterType get_effective_minfilter() const;
- INLINE SamplerState::FilterType get_effective_magfilter() const;
- INLINE int get_anisotropic_degree() const;
- INLINE int get_effective_anisotropic_degree() const;
- INLINE LColor get_border_color() const;
- INLINE CompressionMode get_compression() const;
- INLINE bool has_compression() const;
- INLINE bool get_render_to_texture() const;
- INLINE bool uses_mipmaps() const;
MAKE_PROPERTY(default_sampler, get_default_sampler, set_default_sampler);
- MAKE_PROPERTY(compression, get_compression, set_compression);
+ INLINE bool uses_mipmaps() const;
- INLINE void set_quality_level(QualityLevel quality_level);
INLINE QualityLevel get_quality_level() const;
INLINE QualityLevel get_effective_quality_level() const;
+ INLINE void set_quality_level(QualityLevel quality_level);
MAKE_PROPERTY(quality_level, get_quality_level, set_quality_level);
MAKE_PROPERTY(effective_quality_level, get_effective_quality_level);
@@ -372,6 +417,7 @@ PUBLISHED:
INLINE int get_expected_mipmap_y_size(int n) const;
INLINE int get_expected_mipmap_z_size(int n) const;
INLINE int get_expected_mipmap_num_pages(int n) const;
+ MAKE_PROPERTY(expected_num_mipmap_levels, get_expected_num_mipmap_levels);
INLINE bool has_ram_image() const;
INLINE bool has_uncompressed_ram_image() const;
@@ -381,6 +427,12 @@ PUBLISHED:
INLINE size_t get_ram_page_size() const;
INLINE size_t get_expected_ram_image_size() const;
INLINE size_t get_expected_ram_page_size() const;
+ MAKE_PROPERTY(ram_image_size, get_ram_image_size);
+ MAKE_PROPERTY(ram_view_size, get_ram_view_size);
+ MAKE_PROPERTY(ram_page_size, get_ram_page_size);
+ MAKE_PROPERTY(expected_ram_image_size, get_expected_ram_image_size);
+ MAKE_PROPERTY(expected_ram_page_size, get_expected_ram_page_size);
+
INLINE CPTA_uchar get_ram_image();
INLINE CompressionMode get_ram_image_compression() const;
INLINE CPTA_uchar get_uncompressed_ram_image();
@@ -395,6 +447,10 @@ PUBLISHED:
virtual bool get_keep_ram_image() const;
virtual bool is_cacheable() const;
+ MAKE_PROPERTY(ram_image_compression, get_ram_image_compression);
+ MAKE_PROPERTY(keep_ram_image, get_keep_ram_image, set_keep_ram_image);
+ MAKE_PROPERTY(cacheable, is_cacheable);
+
INLINE bool compress_ram_image(CompressionMode compression = CM_on,
QualityLevel quality_level = QL_default,
GraphicsStateGuardianBase *gsg = NULL);
@@ -421,6 +477,9 @@ PUBLISHED:
INLINE void clear_ram_mipmap_images();
INLINE void generate_ram_mipmap_images();
+ MAKE_PROPERTY(num_ram_mipmap_images, get_num_ram_mipmap_images);
+ MAKE_PROPERTY(num_loadable_ram_mipmap_images, get_num_loadable_ram_mipmap_images);
+
INLINE int get_simple_x_size() const;
INLINE int get_simple_y_size() const;
INLINE bool has_simple_ram_image() const;
@@ -432,6 +491,10 @@ PUBLISHED:
void generate_simple_ram_image();
INLINE void clear_simple_ram_image();
+ MAKE_PROPERTY(simple_x_size, get_simple_x_size);
+ MAKE_PROPERTY(simple_y_size, get_simple_y_size);
+ MAKE_PROPERTY2(simple_ram_image, has_simple_ram_image, get_simple_ram_image);
+
PT(TexturePeeker) peek();
INLINE UpdateSeq get_properties_modified() const;
@@ -441,9 +504,9 @@ PUBLISHED:
MAKE_PROPERTY(image_modified, get_image_modified);
MAKE_PROPERTY(simple_image_modified, get_simple_image_modified);
- INLINE void set_auto_texture_scale(AutoTextureScale scale);
- INLINE AutoTextureScale get_auto_texture_scale() const;
INLINE bool has_auto_texture_scale() const;
+ INLINE AutoTextureScale get_auto_texture_scale() const;
+ INLINE void set_auto_texture_scale(AutoTextureScale scale);
MAKE_PROPERTY(auto_texture_scale, get_auto_texture_scale,
set_auto_texture_scale);
@@ -470,22 +533,6 @@ PUBLISHED:
INLINE static bool has_textures_power_2();
PUBLISHED:
- // These are published, but in general, you shouldn't be mucking with these
- // values; they are set automatically when a texture is loaded.
- INLINE void set_filename(const Filename &filename);
- INLINE void clear_filename();
- INLINE void set_alpha_filename(const Filename &alpha_filename);
- INLINE void clear_alpha_filename();
-
- INLINE void set_fullpath(const Filename &fullpath);
- INLINE void clear_fullpath();
- INLINE void set_alpha_fullpath(const Filename &alpha_fullpath);
- INLINE void clear_alpha_fullpath();
-
- INLINE void set_x_size(int x_size);
- INLINE void set_y_size(int y_size);
- INLINE void set_z_size(int z_size);
- INLINE void set_num_views(int num_views);
INLINE int get_pad_x_size() const;
INLINE int get_pad_y_size() const;
@@ -499,21 +546,29 @@ PUBLISHED:
INLINE int get_orig_file_y_size() const;
INLINE int get_orig_file_z_size() const;
+ MAKE_PROPERTY(orig_file_x_size, get_orig_file_x_size);
+ MAKE_PROPERTY(orig_file_y_size, get_orig_file_y_size);
+ MAKE_PROPERTY(orig_file_z_size, get_orig_file_z_size);
+
void set_orig_file_size(int x, int y, int z = 1);
- INLINE void set_format(Format format);
- INLINE void set_component_type(ComponentType component_type);
- INLINE void set_loaded_from_image();
+ INLINE void set_loaded_from_image(bool flag = true);
INLINE bool get_loaded_from_image() const;
+ MAKE_PROPERTY(loaded_from_image, get_loaded_from_image, set_loaded_from_image);
- INLINE void set_loaded_from_txo();
+ INLINE void set_loaded_from_txo(bool flag = true);
INLINE bool get_loaded_from_txo() const;
+ MAKE_PROPERTY(loaded_from_txo, get_loaded_from_txo, set_loaded_from_txo);
INLINE bool get_match_framebuffer_format() const;
INLINE void set_match_framebuffer_format(bool flag);
+ MAKE_PROPERTY(match_framebuffer_format, get_match_framebuffer_format,
+ set_match_framebuffer_format);
INLINE bool get_post_load_store_cache() const;
INLINE void set_post_load_store_cache(bool flag);
+ MAKE_PROPERTY(post_load_store_cache, get_post_load_store_cache,
+ set_post_load_store_cache);
TextureContext *prepare_now(int view,
PreparedGraphicsObjects *prepared_objects,
diff --git a/panda/src/grutil/config_grutil.cxx b/panda/src/grutil/config_grutil.cxx
index ea8aa7174d..5564a3719d 100644
--- a/panda/src/grutil/config_grutil.cxx
+++ b/panda/src/grutil/config_grutil.cxx
@@ -23,6 +23,7 @@
#include "nodeVertexTransform.h"
#include "rigidBodyCombiner.h"
#include "pipeOcclusionCullTraverser.h"
+#include "shaderTerrainMesh.h"
#include "dconfig.h"
@@ -123,6 +124,7 @@ init_libgrutil() {
RigidBodyCombiner::init_type();
PipeOcclusionCullTraverser::init_type();
SceneGraphAnalyzerMeter::init_type();
+ ShaderTerrainMesh::init_type();
#ifdef HAVE_AUDIO
MovieTexture::init_type();
diff --git a/panda/src/grutil/p3grutil_composite1.cxx b/panda/src/grutil/p3grutil_composite1.cxx
index c02bb0c421..85d1c61e50 100644
--- a/panda/src/grutil/p3grutil_composite1.cxx
+++ b/panda/src/grutil/p3grutil_composite1.cxx
@@ -1,6 +1,7 @@
#include "cardMaker.cxx"
#include "heightfieldTesselator.cxx"
#include "geoMipTerrain.cxx"
+#include "shaderTerrainMesh.cxx"
#include "config_grutil.cxx"
#include "lineSegs.cxx"
#include "fisheyeMaker.cxx"
diff --git a/panda/src/grutil/shaderTerrainMesh.I b/panda/src/grutil/shaderTerrainMesh.I
new file mode 100644
index 0000000000..1f6e90f03c
--- /dev/null
+++ b/panda/src/grutil/shaderTerrainMesh.I
@@ -0,0 +1,191 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file shaderTerrainMesh.I
+ * @author tobspr
+ * @date 2016-02-16
+ */
+
+/**
+ * @brief Sets the path to the heightfield
+ * @details This sets the path to the terrain heightfield. It should be 16bit
+ * single channel, and have a power-of-two resolution greater than 32.
+ * Common sizes are 2048x2048 or 4096x4096.
+ *
+ * @param filename Path to the heightfield
+ */
+INLINE void ShaderTerrainMesh::set_heightfield_filename(const Filename& filename) {
+ _heightfield_source = filename;
+}
+
+/**
+ * @brief Returns the heightfield path
+ * @details This returns the path of the terrain heightfield, previously set with
+ * set_heightfield()
+ *
+ * @return Path to the heightfield
+ */
+INLINE const Filename& ShaderTerrainMesh::get_heightfield_filename() const {
+ return _heightfield_source;
+}
+
+/**
+ * @brief Sets the chunk size
+ * @details This sets the chunk size of the terrain. A chunk is basically the
+ * smallest unit in LOD. If the chunk size is too small, the terrain will
+ * perform bad, since there will be way too many chunks. If the chunk size
+ * is too big, you will not get proper LOD, and might also get bad performance.
+ *
+ * For terrains of the size 4096x4096 or 8192x8192, a chunk size of 32 seems
+ * to produce good results. For smaller resolutions, you should try out a
+ * size of 16 or even 8 for very small terrains.
+ *
+ * The amount of chunks generated for the last level equals to
+ * (heightfield_size / chunk_size) ** 2. The chunk size has to be a power
+ * of two.
+ *
+ * @param chunk_size Size of the chunks, has to be a power of two
+ */
+INLINE void ShaderTerrainMesh::set_chunk_size(size_t chunk_size) {
+ _chunk_size = chunk_size;
+}
+
+/**
+ * @brief Returns the chunk size
+ * @details This returns the chunk size, previously set with set_chunk_size()
+ * @return Chunk size
+ */
+INLINE size_t ShaderTerrainMesh::get_chunk_size() const {
+ return _chunk_size;
+}
+
+/**
+ * @brief Sets whether to generate patches
+ * @details If this option is set to true, GeomPatches will be used instead of
+ * GeomTriangles. This is required when the terrain is used with tesselation
+ * shaders, since patches are required for tesselation, whereas triangles
+ * are required for regular rendering.
+ *
+ * If this option is set to true while not using a tesselation shader, the
+ * terrain will not get rendered, or even produce errors. The same applies
+ * when this is option is not set, but the terrain is used with tesselation
+ * shaders.
+ *
+ * @param generate_patches [description]
+ */
+INLINE void ShaderTerrainMesh::set_generate_patches(bool generate_patches) {
+ _generate_patches = generate_patches;
+}
+
+/**
+ * @brief Returns whether to generate patches
+ * @details This returns whether patches are generated, previously set with
+ * set_generate_patches()
+ *
+ * @return Whether to generate patches
+ */
+INLINE bool ShaderTerrainMesh::get_generate_patches() const {
+ return _generate_patches;
+}
+
+
+/**
+ * @brief Sets the desired triangle width
+ * @details This sets the desired width a triangle should have in pixels.
+ * A value of 10.0 for example will make the terrain tesselate everything
+ * in a way that each triangle edge roughly is 10 pixels wide.
+ * Of course this will not always accurately match, however you can use this
+ * setting to control the LOD algorithm of the terrain.
+ *
+ * @param target_triangle_width Desired triangle width in pixels
+ */
+INLINE void ShaderTerrainMesh::set_target_triangle_width(PN_stdfloat target_triangle_width) {
+ _target_triangle_width = target_triangle_width;
+}
+
+/**
+ * @brief Returns the target triangle width
+ * @details This returns the target triangle width, previously set with
+ * ShaderTerrainMesh::set_target_triangle_width()
+ *
+ * @return Target triangle width
+ */
+INLINE PN_stdfloat ShaderTerrainMesh::get_target_triangle_width() const {
+ return _target_triangle_width;
+}
+
+
+/**
+ * @brief Sets whether to enable terrain updates
+ * @details This flag controls whether the terrain should be updated. If this value
+ * is set to false, no updating of the terrain will happen. This can be useful
+ * to debug the culling algorithm used by the terrain.
+ *
+ * @param update_enabled Whether to update the terrain
+ */
+INLINE void ShaderTerrainMesh::set_update_enabled(bool update_enabled) {
+ _update_enabled = update_enabled;
+}
+
+/**
+ * @brief Returns whether the terrain is getting updated
+ * @details This returns whether the terrain is getting updates, previously set with
+ * set_update_enabled()
+ *
+ * @return Whether to update the terrain
+ */
+INLINE bool ShaderTerrainMesh::get_update_enabled() const {
+ return _update_enabled;
+}
+
+/**
+ * @brief Returns a handle to the heightfield texture
+ * @details This returns a handle to the internally used heightfield texture. This
+ * can be used to set the heightfield as a shader input.
+ *
+ * @return Handle to the heightfield texture
+ */
+INLINE Texture* ShaderTerrainMesh::get_heightfield_tex() const {
+ return _heightfield_tex;
+}
+
+/**
+ * @brief Clears all children
+ * @details This clears all children on the chunk and sets them to NULL. This will
+ * effectively free all memory consumed by this chunk and its children.
+ */
+INLINE void ShaderTerrainMesh::Chunk::clear_children() {
+ for (size_t i = 0; i < 4; ++i) {
+ delete children[i];
+ children[i] = NULL;
+ }
+}
+
+/**
+ * @brief Chunk constructor
+ * @details This constructs a new chunk, and sets all children to NULL.
+ */
+INLINE ShaderTerrainMesh::Chunk::Chunk() {
+ for (size_t i = 0; i < 4; ++i)
+ children[i] = NULL;
+}
+
+/**
+ * @brief Chunk destructor
+ * @details This destructs the chunk, freeing all used resources
+ */
+INLINE ShaderTerrainMesh::Chunk::~Chunk() {
+ clear_children();
+}
+
+/**
+ * @see ShaderTerrainMesh::uv_to_world(LTexCoord)
+ */
+INLINE LPoint3 ShaderTerrainMesh::uv_to_world(PN_stdfloat u, PN_stdfloat v) const {
+ return uv_to_world(LTexCoord(u, v));
+}
diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx
new file mode 100644
index 0000000000..9523b093bf
--- /dev/null
+++ b/panda/src/grutil/shaderTerrainMesh.cxx
@@ -0,0 +1,715 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file shaderTerrainMesh.cxx
+ * @author tobspr
+ * @date 2016-02-16
+ */
+
+
+#include "shaderTerrainMesh.h"
+#include "geom.h"
+#include "geomVertexFormat.h"
+#include "geomVertexData.h"
+#include "geomVertexWriter.h"
+#include "geomNode.h"
+#include "geomTriangles.h"
+#include "geomPatches.h"
+#include "omniBoundingVolume.h"
+#include "cullableObject.h"
+#include "cullTraverser.h"
+#include "cullHandler.h"
+#include "cullTraverserData.h"
+#include "clockObject.h"
+#include "shaderAttrib.h"
+#include "renderAttrib.h"
+#include "shaderInput.h"
+#include "boundingBox.h"
+#include "samplerState.h"
+#include "config_grutil.h"
+#include "typeHandle.h"
+
+ConfigVariableBool stm_use_hexagonal_layout
+("stm-use-hexagonal-layout", true,
+ PRC_DESC("Set this to true to use a hexagonal vertex layout. This approximates "
+ "the heightfield in a better way, however the CLOD transitions might be "
+ "visible due to the vertices not matching exactly."));
+
+ConfigVariableInt stm_max_chunk_count
+("stm-max-chunk-count", 2048,
+ PRC_DESC("Controls the maximum amount of chunks the Terrain can display. If you use "
+ "a high LOD, you might have to increment this value. The lower this value is "
+ "the less data has to be transferred to the GPU."));
+
+ConfigVariableInt stm_max_views
+("stm-max-views", 8,
+ PRC_DESC("Controls the maximum amount of different views the Terrain can be rendered "
+ "with. Each camera rendering the terrain corresponds to a view. Lowering this "
+ "value will reduce the data that has to be transferred to the GPU."));
+
+PStatCollector ShaderTerrainMesh::_basic_collector("Cull:ShaderTerrainMesh:Setup");
+PStatCollector ShaderTerrainMesh::_lod_collector("Cull:ShaderTerrainMesh:CollectLOD");
+
+NotifyCategoryDef(shader_terrain, "");
+
+TypeHandle ShaderTerrainMesh::_type_handle;
+
+/**
+ * @brief Helper function to check for a power of two
+ * @details This method checks for a power of two by using bitmasks
+ *
+ * @param x Number to check
+ * @return true if x is a power of two, false otherwise
+ */
+int check_power_of_two(size_t x)
+{
+ return ((x != 0) && ((x & (~x + 1)) == x));
+}
+
+/**
+ * @brief Constructs a new Terrain Mesh
+ * @details This constructs a new terrain mesh. By default, no transform is set
+ * on the mesh, causing it to range over the unit box from (0, 0, 0) to
+ * (1, 1, 1). Usually you want to set a custom transform with NodePath::set_scale()
+ */
+ShaderTerrainMesh::ShaderTerrainMesh() :
+ PandaNode("ShaderTerrainMesh"),
+ _size(0),
+ _chunk_size(32),
+ _heightfield_source(""),
+ _generate_patches(false),
+ _data_texture(NULL),
+ _chunk_geom(NULL),
+ _current_view_index(0),
+ _last_frame_count(-1),
+ _target_triangle_width(10.0f),
+ _update_enabled(true),
+ _heightfield_tex(NULL)
+{
+ set_final(true);
+ set_bounds(new OmniBoundingVolume());
+}
+
+/**
+ * @brief Generates the terrain mesh
+ * @details This generates the terrain mesh, initializing all chunks of the
+ * internal used quadtree. At this point, a heightfield and a chunk size should
+ * have been set, otherwise an error is thrown.
+ *
+ * If anything goes wrong, like a missing heightfield, then an error is printed
+ * and false is returned.
+ *
+ * @return true if the terrain was initialized, false if an error occured
+ */
+bool ShaderTerrainMesh::generate() {
+ if (!do_load_heightfield())
+ return false;
+
+ if (_chunk_size < 8 || !check_power_of_two(_chunk_size)) {
+ shader_terrain_cat.error() << "Invalid chunk size! Has to be >= 8 and a power of two!" << endl;
+ return false;
+ }
+
+ if (_chunk_size > _size / 4) {
+ shader_terrain_cat.error() << "Chunk size too close or greater than the actual terrain size!" << endl;
+ return false;
+ }
+
+ do_create_chunks();
+ do_compute_bounds(&_base_chunk);
+ do_create_chunk_geom();
+ do_init_data_texture();
+ do_convert_heightfield();
+
+ return true;
+}
+
+/**
+ * @brief Converts the internal used PNMImage to a Texture
+ * @details This converts the internal used PNMImage to a texture object. The
+ * reason for this is, that we need the PNMimage for computing the chunk
+ * bounds, but don't need it afterwards. However, since we have it in ram,
+ * we can just put its contents into a Texture object, which enables the
+ * user to call get_heightfield() instead of manually loading the texture
+ * from disk again to set it as shader input (Panda does not cache PNMImages)
+ */
+void ShaderTerrainMesh::do_convert_heightfield() {
+ _heightfield_tex = new Texture();
+ _heightfield_tex->load(_heightfield);
+ _heightfield_tex->set_keep_ram_image(true);
+
+ if (_heightfield.get_maxval() != 65535) {
+ shader_terrain_cat.warning() << "Using non 16-bit heightfield!" << endl;
+ } else {
+ _heightfield_tex->set_format(Texture::F_r16);
+ }
+ _heightfield_tex->set_minfilter(SamplerState::FT_linear);
+ _heightfield_tex->set_magfilter(SamplerState::FT_linear);
+ _heightfield.clear();
+}
+
+/**
+ * @brief Intermal method to load the heightfield
+ * @details This method loads the heightfield from the heightfield path,
+ * and performs some basic checks, including a check for a power of two,
+ * and same width and height.
+ *
+ * @return true if the heightfield was loaded and meets the requirements
+ */
+bool ShaderTerrainMesh::do_load_heightfield() {
+
+ if(!_heightfield.read(_heightfield_source)) {
+ shader_terrain_cat.error() << "Could not load heightfield from " << _heightfield_source << endl;
+ return false;
+ }
+
+ if (_heightfield.get_x_size() != _heightfield.get_y_size()) {
+ shader_terrain_cat.error() << "Only square heightfields are supported!";
+ return false;
+ }
+
+ _size = _heightfield.get_x_size();
+
+ if (_size < 32 || !check_power_of_two(_size)) {
+ shader_terrain_cat.error() << "Invalid heightfield! Needs to be >= 32 and a power of two (was: "
+ << _size << ")!" << endl;
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief Internal method to init the terrain data texture
+ * @details This method creates the data texture, used to store all chunk data.
+ * The data texture is set as a shader input later on, and stores the position
+ * and scale of each chunk. Every row in the data texture denotes a view on
+ * the terrain.
+ */
+void ShaderTerrainMesh::do_init_data_texture() {
+ _data_texture = new Texture("TerrainDataTexture");
+ _data_texture->setup_2d_texture(stm_max_chunk_count, stm_max_views, Texture::T_float, Texture::F_rgba32);
+ _data_texture->set_clear_color(LVector4(0));
+ _data_texture->clear_image();
+}
+
+/**
+ * @brief Internal method to init the quadtree
+ * @details This method creates the base chunk and then inits all chunks recursively
+ * by using ShaderTerrainMesh::do_init_chunk().
+ */
+void ShaderTerrainMesh::do_create_chunks() {
+
+ // Release any previously stored children
+ _base_chunk.clear_children();
+
+ // Create the base chunk
+ _base_chunk.depth = 0;
+ _base_chunk.x = 0;
+ _base_chunk.y = 0;
+ _base_chunk.size = _size;
+ _base_chunk.edges.set(0, 0, 0, 0);
+ _base_chunk.avg_height = 0.5;
+ _base_chunk.min_height = 0.0;
+ _base_chunk.max_height = 1.0;
+ _base_chunk.last_clod = 0.0;
+ do_init_chunk(&_base_chunk);
+}
+
+/**
+ * @brief Internal method to recursively init the quadtree
+ * @details This method inits the quadtree. Starting from a given node, it
+ * first examines if that node should be subdivided.
+ *
+ * If the node should be subdivided, four children are created and this method
+ * is called on the children again. If the node is a leaf, all children are
+ * set to NULL and nothing else happens.
+ *
+ * The chunk parameter may not be zero or undefined behaviour occurs.
+ *
+ * @param chunk The parent chunk
+ */
+void ShaderTerrainMesh::do_init_chunk(Chunk* chunk) {
+ if (chunk->size > _chunk_size) {
+
+ // Compute children chunk size
+ size_t child_chunk_size = chunk->size / 2;
+
+ // Subdivide chunk into 4 children
+ for (size_t y = 0; y < 2; ++y) {
+ for (size_t x = 0; x < 2; ++x) {
+ Chunk* child = new Chunk();
+ child->size = child_chunk_size;
+ child->depth = chunk->depth + 1;
+ child->x = chunk->x + x * child_chunk_size;
+ child->y = chunk->y + y * child_chunk_size;
+ do_init_chunk(child);
+ chunk->children[x + 2*y] = child;
+ }
+ }
+ } else {
+ // Final chunk, initialize all children to zero
+ for (size_t i = 0; i < 4; ++i) {
+ chunk->children[i] = NULL;
+ }
+ }
+}
+
+/**
+ * @brief Recursively computes the bounds for a given chunk
+ * @details This method takes a parent chunk, and computes the bounds recursively,
+ * depending on whether the chunk is a leaf or a node.
+ *
+ * If the chunk is a leaf, then the average, min and max values for that chunk
+ * are computed by iterating over the heightfield region of that chunk.
+ *
+ * If the chunk is a node, this method is called recursively on all children
+ * first, and after that, the average, min and max values for that chunk
+ * are computed by merging those values of the children.
+ *
+ * If chunk is NULL, undefined behaviour occurs.
+ *
+ * @param chunk The parent chunk
+ */
+void ShaderTerrainMesh::do_compute_bounds(Chunk* chunk) {
+
+ // Final chunk (Leaf)
+ if (chunk->size == _chunk_size) {
+
+ // Get a pointer to the PNMImage data, this is faster than using get_xel()
+ // for all pixels, since get_xel() also includes bounds checks and so on.
+ xel* data = _heightfield.get_array();
+
+ // Pixel getter function. Note that we have to flip the Y-component, since
+ // panda itself also flips it
+ // auto get_xel = [&](size_t x, size_t y){ return data[x + (_size - 1 - y) * _size].b / (PN_stdfloat)PGM_MAXMAXVAL; };
+ #define get_xel(x, y) (data[(x) + (_size - 1 - (y)) * _size].b / (PN_stdfloat)PGM_MAXMAXVAL)
+
+ // Iterate over all pixels
+ PN_stdfloat avg_height = 0.0, min_height = 1.0, max_height = 0.0;
+ for (size_t x = 0; x < _chunk_size; ++x) {
+ for (size_t y = 0; y < _chunk_size; ++y) {
+
+ // Access data directly, to improve performance
+ PN_stdfloat height = get_xel(chunk->x + x, chunk->y + y);
+ avg_height += height;
+ min_height = min(min_height, height);
+ max_height = max(max_height, height);
+ }
+ }
+
+ // Normalize average height
+ avg_height /= _chunk_size * _chunk_size;
+
+ // Store values
+ chunk->min_height = min_height;
+ chunk->max_height = max_height;
+ chunk->avg_height = avg_height;
+
+ // Get edges in the order (0, 0) (1, 0) (0, 1) (1, 1)
+ for (size_t y = 0; y < 2; ++y) {
+ for (size_t x = 0; x < 2; ++x) {
+ chunk->edges.set_cell(x + 2 * y, get_xel(
+ chunk->x + x * (_chunk_size - 1),
+ chunk->y + y * (_chunk_size - 1)
+ ));
+ }
+ }
+
+ #undef get_xel
+
+ } else {
+
+ // Reset heights
+ chunk->avg_height = 0.0;
+ chunk->min_height = 1.0;
+ chunk->max_height = 0.0;
+
+ // Perform bounds computation for every children and merge the children values
+ for (size_t i = 0; i < 4; ++i) {
+ do_compute_bounds(chunk->children[i]);
+ chunk->avg_height += chunk->children[i]->avg_height / 4.0;
+ chunk->min_height = min(chunk->min_height, chunk->children[i]->min_height);
+ chunk->max_height = max(chunk->max_height, chunk->children[i]->max_height);
+ }
+
+ // Also take the edge points from the children
+ chunk->edges.set_x(chunk->children[0]->edges.get_x());
+ chunk->edges.set_y(chunk->children[1]->edges.get_y());
+ chunk->edges.set_z(chunk->children[2]->edges.get_z());
+ chunk->edges.set_w(chunk->children[3]->edges.get_w());
+ }
+}
+
+/**
+ * @brief Internal method to create the chunk geom
+ * @details This method generates the internal used base chunk. The base chunk geom
+ * is used to render the actual terrain, and will get instanced for every chunk.
+ *
+ * The chunk has a size of (size+3) * (size+3), since additional triangles are
+ * inserted at the borders to prevent holes between chunks of a different LOD.
+ *
+ * If the generate patches option is set, patches will be generated instead
+ * of triangles, which allows the terrain to use a tesselation shader.
+ */
+void ShaderTerrainMesh::do_create_chunk_geom() {
+
+ // Convert chunk size to an integer, because we operate on integers and get
+ // signed/unsigned mismatches otherwise
+ int size = (int)_chunk_size;
+
+ // Create vertex data
+ PT(GeomVertexData) gvd = new GeomVertexData("vertices", GeomVertexFormat::get_v3(), Geom::UH_static);
+ gvd->reserve_num_rows( (size + 3) * (size + 3) );
+ GeomVertexWriter vertex_writer(gvd, "vertex");
+
+ // Create primitive
+ PT(GeomPrimitive) triangles = NULL;
+ if (_generate_patches) {
+ triangles = new GeomPatches(3, Geom::UH_static);
+ } else {
+ triangles = new GeomTriangles(Geom::UH_static);
+ }
+
+ // Insert chunk vertices
+ for (int y = -1; y <= size + 1; ++y) {
+ for (int x = -1; x <= size + 1; ++x) {
+ LVector3 vtx_pos(x / (PN_stdfloat)size, y / (PN_stdfloat)size, 0.0f);
+ // Stitched vertices at the cornders
+ if (x == -1 || y == -1 || x == size + 1 || y == size + 1) {
+ vtx_pos.set_z(-1.0f / (PN_stdfloat)size);
+ vtx_pos.set_x(max(0.0f, min(1.0f, vtx_pos.get_x())));
+ vtx_pos.set_y(max(0.0f, min(1.0f, vtx_pos.get_y())));
+ }
+ vertex_writer.add_data3f(vtx_pos);
+ }
+ }
+
+ // Its important to use int and not size_t here, since we do store negative values
+ // auto get_point_index = [&size](int x, int y){ return (x + 1) + (size + 3) * (y + 1); };
+ #define get_point_index(x, y) (((x) + 1) + (size + 3) * ((y) + 1))
+
+ // Create triangles
+ for (int y = -1; y <= size; ++y) {
+ for (int x = -1; x <= size; ++x) {
+ // Get point indices of the quad vertices
+ int tl = get_point_index(x, y);
+ int tr = get_point_index(x + 1, y);
+ int bl = get_point_index(x, y + 1);
+ int br = get_point_index(x + 1, y + 1);
+
+ // Vary triangle scheme on each uneven quad
+ if (stm_use_hexagonal_layout && (x + y) % 2 == 0 ) {
+ triangles->add_vertices(tl, tr, br);
+ triangles->add_vertices(tl, br, bl);
+ } else {
+ triangles->add_vertices(tl, tr, bl);
+ triangles->add_vertices(bl, tr, br);
+ }
+ }
+ }
+
+ #undef get_point_index
+
+ // Construct geom
+ PT(Geom) geom = new Geom(gvd);
+ geom->add_primitive(triangles);
+
+ // Do not set any bounds, we do culling ourself
+ geom->clear_bounds();
+ geom->set_bounds(new OmniBoundingVolume());
+ _chunk_geom = geom;
+}
+
+/**
+ * @copydoc PandaNode::is_renderable()
+ */
+bool ShaderTerrainMesh::is_renderable() const {
+ return true;
+}
+
+/**
+ * @copydoc PandaNode::is_renderable()
+ */
+bool ShaderTerrainMesh::safe_to_flatten() const {
+ return false;
+}
+
+/**
+ * @copydoc PandaNode::safe_to_combine()
+ */
+bool ShaderTerrainMesh::safe_to_combine() const {
+ return false;
+}
+
+/**
+ * @copydoc PandaNode::add_for_draw()
+ */
+void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &data) {
+
+ // Make sure the terrain was properly initialized, and the geom was created
+ // successfully
+ nassertv(_data_texture != NULL);
+ nassertv(_chunk_geom != NULL);
+
+ _basic_collector.start();
+
+ // Get current frame count
+ int frame_count = ClockObject::get_global_clock()->get_frame_count();
+
+ if (_last_frame_count != frame_count) {
+ // Frame count changed, this means we are at the beginning of a new frame.
+ // In this case, update the frame count and reset the view index.
+ _last_frame_count = frame_count;
+ _current_view_index = 0;
+ }
+
+ // Get transform and render state for this render pass
+ CPT(TransformState) modelview_transform = data.get_internal_transform(trav);
+ CPT(RenderState) state = data._state->compose(get_state());
+
+ // Store a handle to the scene setup
+ const SceneSetup* scene = trav->get_scene();
+
+ // Get the MVP matrix, this is required for the LOD
+ const Lens* current_lens = scene->get_lens();
+ const LMatrix4& projection_mat = current_lens->get_projection_mat();
+
+ // Get the current lens bounds
+ PT(BoundingVolume) cam_bounds = scene->get_cull_bounds();
+
+ // Transform the camera bounds with the main camera transform
+ DCAST(GeometricBoundingVolume, cam_bounds)->xform(scene->get_camera_transform()->get_mat());
+
+ TraversalData traversal_data;
+ traversal_data.cam_bounds = cam_bounds;
+ traversal_data.model_mat = get_transform()->get_mat();
+ traversal_data.mvp_mat = modelview_transform->get_mat() * projection_mat;
+ traversal_data.emitted_chunks = 0;
+ traversal_data.storage_ptr = (ChunkDataEntry*)_data_texture->modify_ram_image().p();
+ traversal_data.screen_size.set(scene->get_viewport_width(), scene->get_viewport_height());
+
+ // Move write pointer so it points to the beginning of the current view
+ traversal_data.storage_ptr += _data_texture->get_x_size() * _current_view_index;
+
+ if (_update_enabled) {
+ // Traverse recursively
+ _lod_collector.start();
+ do_traverse(&_base_chunk, &traversal_data);
+ _lod_collector.stop();
+ } else {
+ // Do a rough guess of the emitted chunks, we don't know the actual count
+ // (we would have to store it). This is only for debugging anyways, so
+ // its not important we get an accurate count here.
+ traversal_data.emitted_chunks = _data_texture->get_x_size();
+ }
+
+ // Set shader inputs
+ CPT(RenderAttrib) current_shader_attrib = state->get_attrib_def(ShaderAttrib::get_class_slot());
+
+ // Make sure the user didn't forget to set a shader
+ if (!DCAST(ShaderAttrib, current_shader_attrib)->has_shader()) {
+ shader_terrain_cat.warning() << "No shader set on the terrain! You need to set the appropriate shader!" << endl;
+ }
+
+ // Should never happen
+ nassertv(current_shader_attrib != NULL);
+
+ current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input(
+ new ShaderInput("ShaderTerrainMesh.terrain_size", LVecBase2i(_size)) );
+ current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input(
+ new ShaderInput("ShaderTerrainMesh.chunk_size", LVecBase2i(_chunk_size)));
+ current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input(
+ new ShaderInput("ShaderTerrainMesh.view_index", LVecBase2i(_current_view_index)));
+ current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input(
+ new ShaderInput("ShaderTerrainMesh.data_texture", _data_texture));
+ current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input(
+ new ShaderInput("ShaderTerrainMesh.heightfield", _heightfield_tex));
+ current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_instance_count(
+ traversal_data.emitted_chunks);
+
+ state = state->set_attrib(current_shader_attrib, 10000);
+
+ // Emit chunk
+ CullableObject *object = new CullableObject(_chunk_geom, state, modelview_transform);
+ trav->get_cull_handler()->record_object(object, trav);
+
+ // After rendering, increment the view index
+ ++_current_view_index;
+
+ if (_current_view_index > stm_max_views) {
+ shader_terrain_cat.error() << "More views than supported! Increase the stm-max-views config variable!" << endl;
+ }
+
+ _basic_collector.stop();
+}
+
+/**
+ * @brief Traverses the quadtree
+ * @details This method traverses the given chunk, deciding whether it should
+ * be rendered or subdivided.
+ *
+ * In case the chunk is decided to be subdivided, this method is called on
+ * all children.
+ *
+ * In case the chunk is decided to be rendered, ShaderTerrainMesh::do_emit_chunk() is
+ * called. Otherwise nothing happens, and the chunk does not get rendered.
+ *
+ * @param chunk Chunk to traverse
+ * @param data Traversal data
+ */
+void ShaderTerrainMesh::do_traverse(Chunk* chunk, TraversalData* data, bool fully_visible) {
+
+ // Don't check bounds if we are fully visible
+ if (!fully_visible) {
+
+ // Construct chunk bounding volume
+ PN_stdfloat scale = 1.0 / (PN_stdfloat)_size;
+ LPoint3 bb_min(chunk->x * scale, chunk->y * scale, chunk->min_height);
+ LPoint3 bb_max((chunk->x + chunk->size) * scale, (chunk->y + chunk->size) * scale, chunk->max_height);
+
+ BoundingBox bbox = BoundingBox(bb_min, bb_max);
+ DCAST(GeometricBoundingVolume, &bbox)->xform(data->model_mat);
+ int intersection = data->cam_bounds->contains(&bbox);
+
+ if (intersection == BoundingVolume::IF_no_intersection) {
+ // No intersection with frustum
+ return;
+ }
+
+ // If the bounds are fully visible, there is no reason to perform culling
+ // on the children, so we set this flag to prevent any bounding computation
+ // on the child nodes.
+ fully_visible = (intersection & BoundingVolume::IF_all) != 0;
+ }
+
+ // Check if the chunk should be subdivided. In case the chunk is a leaf node,
+ // the chunk will never get subdivided.
+ // NOTE: We still always perform the LOD check. This is for the reason that
+ // the lod check also computes the CLOD factor, which is useful.
+ if (do_check_lod_matches(chunk, data) || chunk->size == _chunk_size) {
+ do_emit_chunk(chunk, data);
+ } else {
+ // Traverse children
+ for (size_t i = 0; i < 4; ++i) {
+ do_traverse(chunk->children[i], data, fully_visible);
+ }
+ }
+}
+
+/**
+ * @brief Checks whether a chunk should get subdivided
+ * @details This method checks whether a chunk fits on screen, or should be
+ * subdivided in order to provide bigger detail.
+ *
+ * In case this method returns true, the chunk lod is fine, and the chunk
+ * can be rendered. If the method returns false, the chunk should be subdivided.
+ *
+ * @param chunk Chunk to check
+ * @param data Traversal data
+ *
+ * @return true if the chunk is sufficient, false if the chunk should be subdivided
+ */
+bool ShaderTerrainMesh::do_check_lod_matches(Chunk* chunk, TraversalData* data) {
+
+ // Project all points to world space
+ LVector2 projected_points[4];
+ for (size_t y = 0; y < 2; ++y) {
+ for (size_t x = 0; x < 2; ++x) {
+
+ // Compute point in model space (0,0,0 to 1,1,1)
+ LVector3 edge_pos = LVector3(
+ (PN_stdfloat)(chunk->x + x * (chunk->size - 1)) / (PN_stdfloat)_size,
+ (PN_stdfloat)(chunk->y + y * (chunk->size - 1)) / (PN_stdfloat)_size,
+ chunk->edges.get_cell(x + 2 * y)
+ );
+ LVector4 projected = data->mvp_mat.xform(LVector4(edge_pos, 1.0));
+ if (projected.get_w() == 0.0) {
+ projected.set(0.0, 0.0, -1.0, 1.0f);
+ }
+ projected *= 1.0 / projected.get_w();
+ projected_points[x + 2 * y].set(
+ projected.get_x() * data->screen_size.get_x(),
+ projected.get_y() * data->screen_size.get_y());
+ }
+ }
+
+ // Compute the length of the edges in screen space
+ PN_stdfloat edge_top = (projected_points[1] - projected_points[3]).length_squared();
+ PN_stdfloat edge_right = (projected_points[0] - projected_points[2]).length_squared();
+ PN_stdfloat edge_bottom = (projected_points[2] - projected_points[3]).length_squared();
+ PN_stdfloat edge_left = (projected_points[0] - projected_points[1]).length_squared();
+
+ // CLOD factor
+ PN_stdfloat max_edge = max(edge_top, max(edge_right, max(edge_bottom, edge_left)));
+
+ // Micro-Optimization: We use length_squared() instead of length() to compute the
+ // maximum edge length. This reduces it to one csqrt instead of four.
+ max_edge = csqrt(max_edge);
+
+ PN_stdfloat tesselation_factor = (max_edge / _target_triangle_width) / (PN_stdfloat)_chunk_size;
+ PN_stdfloat clod_factor = max(0.0, min(1.0, 2.0 - tesselation_factor));
+
+ // Store the clod factor
+ chunk->last_clod = clod_factor;
+
+ return tesselation_factor <= 2.0;
+}
+
+/**
+ * @brief Internal method to spawn a chunk
+ * @details This method is used to spawn a chunk in case the traversal decided
+ * that the chunk gets rendered. It writes the chunks data to the texture, and
+ * increments the write pointer
+ *
+ * @param chunk Chunk to spawn
+ * @param data Traversal data
+ */
+void ShaderTerrainMesh::do_emit_chunk(Chunk* chunk, TraversalData* data) {
+ if (data->emitted_chunks >= _data_texture->get_x_size()) {
+
+ // Only print warning once
+ if (data->emitted_chunks == _data_texture->get_x_size()) {
+ shader_terrain_cat.error() << "Too many chunks in the terrain! Consider lowering the desired LOD, or increase the stm-max-chunk-count variable." << endl;
+ data->emitted_chunks++;
+ }
+ return;
+ }
+
+ ChunkDataEntry& data_entry = *data->storage_ptr;
+ data_entry.x = chunk->x;
+ data_entry.y = chunk->y;
+ data_entry.size = chunk->size / _chunk_size;
+ data_entry.clod = chunk->last_clod;
+
+ data->emitted_chunks ++;
+ data->storage_ptr ++;
+}
+
+/**
+ * @brief Transforms a texture coordinate to world space
+ * @details This transforms a texture coordinatefrom uv-space (0 to 1) to world
+ * space. This takes the terrains transform into account, and also samples the
+ * heightmap. This method should be called after generate().
+ *
+ * @param coord Coordinate in uv-space from 0, 0 to 1, 1
+ * @return World-Space point
+ */
+LPoint3 ShaderTerrainMesh::uv_to_world(const LTexCoord& coord) const {
+ nassertr(_heightfield_tex != NULL, LPoint3(0));
+ PT(TexturePeeker) peeker = _heightfield_tex->peek();
+ nassertr(peeker != NULL, LPoint3(0));
+
+ LColor result;
+ if (!peeker->lookup_bilinear(result, coord.get_x(), coord.get_y())) {
+ shader_terrain_cat.error() << "UV out of range, cant transform to world!" << endl;
+ return LPoint3(0);
+ }
+ LPoint3 unit_point(coord.get_x(), coord.get_y(), result.get_x());
+ return get_transform()->get_mat().xform_point_general(unit_point);
+}
diff --git a/panda/src/grutil/shaderTerrainMesh.h b/panda/src/grutil/shaderTerrainMesh.h
new file mode 100644
index 0000000000..f66caacf76
--- /dev/null
+++ b/panda/src/grutil/shaderTerrainMesh.h
@@ -0,0 +1,205 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file shaderTerrainMesh.h
+ * @author tobspr
+ * @date 2016-02-16
+ */
+
+#ifndef SHADER_TERRAIN_MESH_H
+#define SHADER_TERRAIN_MESH_H
+
+#include "pandabase.h"
+#include "luse.h"
+#include "pnmImage.h"
+#include "geom.h"
+#include "pandaNode.h"
+#include "texture.h"
+#include "texturePeeker.h"
+#include "configVariableBool.h"
+#include "configVariableInt.h"
+#include "pStatCollector.h"
+#include "filename.h"
+#include
+
+extern ConfigVariableBool stm_use_hexagonal_layout;
+extern ConfigVariableInt stm_max_chunk_count;
+extern ConfigVariableInt stm_max_views;
+
+
+NotifyCategoryDecl(shader_terrain, EXPCL_PANDA_GRUTIL, EXPTP_PANDA_GRUTIL);
+
+
+/**
+ * @brief Terrain Renderer class utilizing the GPU
+ * @details This class provides functionality to render heightfields of large
+ * sizes utilizing the GPU. Internally a quadtree is used to generate the LODs.
+ * The final terrain is then rendered using instancing on the GPU. This makes
+ * it possible to use very large heightfields (8192+) with very reasonable
+ * performance. The terrain provides options to control the LOD using a
+ * target triangle width, see ShaderTerrainMesh::set_target_triangle_width().
+ *
+ * Because the Terrain is rendered entirely on the GPU, it needs a special
+ * vertex shader. There is a default vertex shader available, which you can
+ * use in your own shaders. IMPORTANT: If you don't set an appropriate shader
+ * on the terrain, nothing will be visible.
+ */
+class EXPCL_PANDA_GRUTIL ShaderTerrainMesh : public PandaNode {
+
+PUBLISHED:
+
+ ShaderTerrainMesh();
+
+ INLINE void set_heightfield_filename(const Filename& filename);
+ INLINE const Filename& get_heightfield_filename() const;
+ MAKE_PROPERTY(heightfield_filename, get_heightfield_filename, set_heightfield_filename);
+
+ INLINE void set_chunk_size(size_t chunk_size);
+ INLINE size_t get_chunk_size() const;
+ MAKE_PROPERTY(chunk_size, get_chunk_size, set_chunk_size);
+
+ INLINE void set_generate_patches(bool generate_patches);
+ INLINE bool get_generate_patches() const;
+ MAKE_PROPERTY(generate_patches, get_generate_patches, set_generate_patches);
+
+ INLINE void set_update_enabled(bool update_enabled);
+ INLINE bool get_update_enabled() const;
+ MAKE_PROPERTY(update_enabled, get_update_enabled, set_update_enabled);
+
+ INLINE void set_target_triangle_width(PN_stdfloat target_triangle_width);
+ INLINE PN_stdfloat get_target_triangle_width() const;
+ MAKE_PROPERTY(target_triangle_width, get_target_triangle_width, set_target_triangle_width);
+
+ INLINE Texture* get_heightfield_tex() const;
+ MAKE_PROPERTY(heightfield_tex, get_heightfield_tex);
+
+ LPoint3 uv_to_world(const LTexCoord& coord) const;
+ INLINE LPoint3 uv_to_world(PN_stdfloat u, PN_stdfloat v) const;
+
+ bool generate();
+
+public:
+
+ // Methods derived from PandaNode
+ virtual bool is_renderable() const;
+ virtual bool safe_to_flatten() const;
+ virtual bool safe_to_combine() const;
+ virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data);
+
+private:
+
+ // Chunk data
+ struct Chunk {
+ // Depth, starting at 0
+ size_t depth;
+
+ // Chunk position in heightfield space
+ size_t x, y;
+
+ // Chunk size in heightfield space
+ size_t size;
+
+ // Children, in the order (0, 0) (1, 0) (0, 1) (1, 1)
+ Chunk* children[4];
+
+ // Chunk heights, used for culling
+ PN_stdfloat avg_height, min_height, max_height;
+
+ // Edge heights, used for lod computation, in the same order as the children
+ LVector4 edges;
+
+ // Last CLOD factor, stored while computing LOD, used for seamless transitions between lods
+ PN_stdfloat last_clod;
+
+ INLINE void clear_children();
+ INLINE Chunk();
+ INLINE ~Chunk();
+ };
+
+
+ // Single entry in the data block
+ struct ChunkDataEntry {
+ // float x, y, size, clod;
+
+ // Panda uses BGRA, the above layout shows how its actually in texture memory,
+ // the layout below makes it work with BGRA.
+ PN_float32 size, y, x, clod;
+ };
+
+ // Data used while traversing all chunks
+ struct TraversalData {
+ // Global MVP used for LOD
+ LMatrix4 mvp_mat;
+
+ // Local model matrix used for culling
+ LMatrix4 model_mat;
+
+ // Camera bounds in world space
+ BoundingVolume* cam_bounds;
+
+ // Amount of emitted chunks so far
+ int emitted_chunks;
+
+ // Screen resolution, used for LOD
+ LVector2i screen_size;
+
+ // Pointer to the texture memory, where each chunk is written to
+ ChunkDataEntry* storage_ptr;
+ };
+
+ bool do_load_heightfield();
+ void do_convert_heightfield();
+ void do_init_data_texture();
+ void do_create_chunks();
+ void do_init_chunk(Chunk* chunk);
+ void do_compute_bounds(Chunk* chunk);
+ void do_create_chunk_geom();
+ void do_traverse(Chunk* chunk, TraversalData* data, bool fully_visible = false);
+ void do_emit_chunk(Chunk* chunk, TraversalData* data);
+ bool do_check_lod_matches(Chunk* chunk, TraversalData* data);
+
+ Chunk _base_chunk;
+ Filename _heightfield_source;
+ size_t _size;
+ size_t _chunk_size;
+ bool _generate_patches;
+ PNMImage _heightfield;
+ PT(Texture) _heightfield_tex;
+ PT(Geom) _chunk_geom;
+ PT(Texture) _data_texture;
+ size_t _current_view_index;
+ int _last_frame_count;
+ PN_stdfloat _target_triangle_width;
+ bool _update_enabled;
+
+ // PStats stuff
+ static PStatCollector _lod_collector;
+ static PStatCollector _basic_collector;
+
+
+// Type handle stuff
+public:
+ static TypeHandle get_class_type() {
+ return _type_handle;
+ }
+ static void init_type() {
+ PandaNode::init_type();
+ register_type(_type_handle, "ShaderTerrainMesh", PandaNode::get_class_type());
+ }
+ virtual TypeHandle get_type() const {
+ return get_class_type();
+ }
+ virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+ static TypeHandle _type_handle;
+};
+
+#include "shaderTerrainMesh.I"
+
+#endif // SHADER_TERRAIN_MESH_H
diff --git a/panda/src/linmath/lvecBase2_src.h b/panda/src/linmath/lvecBase2_src.h
index e4c1c8a905..0167855c65 100644
--- a/panda/src/linmath/lvecBase2_src.h
+++ b/panda/src/linmath/lvecBase2_src.h
@@ -33,9 +33,13 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LVecBase2)() DEFAULT_CTOR;
INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE fill_value);
INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y);
-
ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase2));
+#ifdef CPPPARSER
+ FLOATNAME(LVecBase2) &operator = (const FLOATNAME(LVecBase2) ©) = default;
+ FLOATNAME(LVecBase2) &operator = (FLOATTYPE fill_value) = default;
+#endif
+
INLINE_LINMATH static const FLOATNAME(LVecBase2) &zero();
INLINE_LINMATH static const FLOATNAME(LVecBase2) &unit_x();
INLINE_LINMATH static const FLOATNAME(LVecBase2) &unit_y();
diff --git a/panda/src/linmath/lvecBase3_src.h b/panda/src/linmath/lvecBase3_src.h
index c1879231b1..fdc39c7819 100644
--- a/panda/src/linmath/lvecBase3_src.h
+++ b/panda/src/linmath/lvecBase3_src.h
@@ -36,6 +36,11 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z);
ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase3));
+#ifdef CPPPARSER
+ FLOATNAME(LVecBase3) &operator = (const FLOATNAME(LVecBase3) ©) = default;
+ FLOATNAME(LVecBase3) &operator = (FLOATTYPE fill_value) = default;
+#endif
+
INLINE_LINMATH static const FLOATNAME(LVecBase3) &zero();
INLINE_LINMATH static const FLOATNAME(LVecBase3) &unit_x();
INLINE_LINMATH static const FLOATNAME(LVecBase3) &unit_y();
diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h
index 21afc8b182..1d4a16e961 100644
--- a/panda/src/linmath/lvecBase4_src.h
+++ b/panda/src/linmath/lvecBase4_src.h
@@ -45,6 +45,11 @@ PUBLISHED:
INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(LVector3) &vector);
ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase4));
+#ifdef CPPPARSER
+ FLOATNAME(LVecBase4) &operator = (const FLOATNAME(LVecBase4) ©) = default;
+ FLOATNAME(LVecBase4) &operator = (FLOATTYPE fill_value) = default;
+#endif
+
INLINE_LINMATH static const FLOATNAME(LVecBase4) &zero();
INLINE_LINMATH static const FLOATNAME(LVecBase4) &unit_x();
INLINE_LINMATH static const FLOATNAME(LVecBase4) &unit_y();
diff --git a/panda/src/pgraph/alphaTestAttrib.h b/panda/src/pgraph/alphaTestAttrib.h
index 8d620e66e7..5c38727347 100644
--- a/panda/src/pgraph/alphaTestAttrib.h
+++ b/panda/src/pgraph/alphaTestAttrib.h
@@ -36,6 +36,10 @@ PUBLISHED:
INLINE PN_stdfloat get_reference_alpha() const;
INLINE PandaCompareFunc get_mode() const;
+PUBLISHED:
+ MAKE_PROPERTY(reference_alpha, get_reference_alpha);
+ MAKE_PROPERTY(mode, get_mode);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/antialiasAttrib.h b/panda/src/pgraph/antialiasAttrib.h
index 146561407d..30a72bb535 100644
--- a/panda/src/pgraph/antialiasAttrib.h
+++ b/panda/src/pgraph/antialiasAttrib.h
@@ -52,6 +52,11 @@ PUBLISHED:
INLINE unsigned short get_mode_type() const;
INLINE unsigned short get_mode_quality() const;
+PUBLISHED:
+ MAKE_PROPERTY(mode, get_mode);
+ MAKE_PROPERTY(mode_type, get_mode_type);
+ MAKE_PROPERTY(mode_quality, get_mode_quality);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/audioVolumeAttrib.h b/panda/src/pgraph/audioVolumeAttrib.h
index 29ccf23563..3b2120462f 100644
--- a/panda/src/pgraph/audioVolumeAttrib.h
+++ b/panda/src/pgraph/audioVolumeAttrib.h
@@ -40,6 +40,9 @@ PUBLISHED:
INLINE PN_stdfloat get_volume() const;
CPT(RenderAttrib) set_volume(PN_stdfloat volume) const;
+PUBLISHED:
+ MAKE_PROPERTY2(volume, has_volume, get_volume);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/auxBitplaneAttrib.h b/panda/src/pgraph/auxBitplaneAttrib.h
index 75ac6aee01..4c5866c49c 100644
--- a/panda/src/pgraph/auxBitplaneAttrib.h
+++ b/panda/src/pgraph/auxBitplaneAttrib.h
@@ -63,6 +63,9 @@ PUBLISHED:
INLINE int get_outputs() const;
+PUBLISHED:
+ MAKE_PROPERTY(outputs, get_outputs);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx
index 575b5236ed..d15e9a2bf3 100644
--- a/panda/src/pgraph/camera.cxx
+++ b/panda/src/pgraph/camera.cxx
@@ -272,8 +272,10 @@ write_datagram(BamWriter *manager, Datagram &dg) {
dg.add_bool(_active);
dg.add_uint32(_camera_mask.get_word());
- manager->write_pointer(dg, _initial_state);
- dg.add_stdfloat(_lod_scale);
+ if (manager->get_file_minor_ver() >= 41) {
+ manager->write_pointer(dg, _initial_state);
+ dg.add_stdfloat(_lod_scale);
+ }
}
////////////////////////////////////////////////////////////////////
@@ -286,7 +288,10 @@ write_datagram(BamWriter *manager, Datagram &dg) {
int Camera::
complete_pointers(TypedWritable **p_list, BamReader *manager) {
int pi = LensNode::complete_pointers(p_list, manager);
- _initial_state = DCAST(RenderState, p_list[pi++]);
+
+ if (manager->get_file_minor_ver() >= 41) {
+ _initial_state = DCAST(RenderState, p_list[pi++]);
+ }
return pi;
}
diff --git a/panda/src/pgraph/colorAttrib.h b/panda/src/pgraph/colorAttrib.h
index e2f38f46ed..54b57b8abb 100644
--- a/panda/src/pgraph/colorAttrib.h
+++ b/panda/src/pgraph/colorAttrib.h
@@ -42,6 +42,10 @@ PUBLISHED:
INLINE Type get_color_type() const;
INLINE const LColor &get_color() const;
+PUBLISHED:
+ MAKE_PROPERTY(color_type, get_color_type);
+ MAKE_PROPERTY(color, get_color);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/colorBlendAttrib.I b/panda/src/pgraph/colorBlendAttrib.I
index fa2aca94ff..1df1f9eb6c 100644
--- a/panda/src/pgraph/colorBlendAttrib.I
+++ b/panda/src/pgraph/colorBlendAttrib.I
@@ -19,6 +19,9 @@ ColorBlendAttrib() :
_mode(M_none),
_a(O_one),
_b(O_one),
+ _alpha_mode(M_none),
+ _alpha_a(O_one),
+ _alpha_b(O_one),
_color(LColor::zero()),
_involves_constant_color(false),
_involves_color_scale(false)
@@ -31,18 +34,29 @@ ColorBlendAttrib() :
INLINE ColorBlendAttrib::
ColorBlendAttrib(ColorBlendAttrib::Mode mode,
ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b,
+ ColorBlendAttrib::Mode alpha_mode,
+ ColorBlendAttrib::Operand alpha_a, ColorBlendAttrib::Operand alpha_b,
const LColor &color) :
_mode(mode),
_a(a),
_b(b),
+ _alpha_mode(alpha_mode),
+ _alpha_a(alpha_a),
+ _alpha_b(alpha_b),
_color(color),
- _involves_constant_color(involves_constant_color(a) || involves_constant_color(b)),
- _involves_color_scale(involves_color_scale(a) || involves_color_scale(b))
+ _involves_constant_color(involves_constant_color(a) ||
+ involves_constant_color(b) ||
+ involves_constant_color(alpha_a) ||
+ involves_constant_color(alpha_b)),
+ _involves_color_scale(involves_color_scale(a) ||
+ involves_color_scale(b) ||
+ involves_color_scale(alpha_a) ||
+ involves_color_scale(alpha_b))
{
}
/**
- * Returns the colorBlend mode.
+ * Returns the blending mode for the RGB channels.
*/
INLINE ColorBlendAttrib::Mode ColorBlendAttrib::
get_mode() const {
@@ -50,7 +64,7 @@ get_mode() const {
}
/**
- * Returns the multiplier for the first component.
+ * Returns the RGB multiplier for the first component.
*/
INLINE ColorBlendAttrib::Operand ColorBlendAttrib::
get_operand_a() const {
@@ -58,13 +72,37 @@ get_operand_a() const {
}
/**
- * Returns the multiplier for the second component.
+ * Returns the RGB multiplier for the second component.
*/
INLINE ColorBlendAttrib::Operand ColorBlendAttrib::
get_operand_b() const {
return _b;
}
+/**
+ * Returns the blending mode for the alpha channel.
+ */
+INLINE ColorBlendAttrib::Mode ColorBlendAttrib::
+get_alpha_mode() const {
+ return _alpha_mode;
+}
+
+/**
+ * Returns the alpha multiplier for the first component.
+ */
+INLINE ColorBlendAttrib::Operand ColorBlendAttrib::
+get_alpha_operand_a() const {
+ return _alpha_a;
+}
+
+/**
+ * Returns the alpha multiplier for the second component.
+ */
+INLINE ColorBlendAttrib::Operand ColorBlendAttrib::
+get_alpha_operand_b() const {
+ return _alpha_b;
+}
+
/**
* Returns the constant color associated with the attrib.
*/
@@ -114,14 +152,5 @@ involves_constant_color(ColorBlendAttrib::Operand operand) {
*/
INLINE bool ColorBlendAttrib::
involves_color_scale(ColorBlendAttrib::Operand operand) {
- switch (operand) {
- case O_color_scale:
- case O_one_minus_color_scale:
- case O_alpha_scale:
- case O_one_minus_alpha_scale:
- return true;
-
- default:
- return false;
- }
+ return (operand >= O_color_scale);
}
diff --git a/panda/src/pgraph/colorBlendAttrib.cxx b/panda/src/pgraph/colorBlendAttrib.cxx
index ef5d934976..92fe98ab79 100644
--- a/panda/src/pgraph/colorBlendAttrib.cxx
+++ b/panda/src/pgraph/colorBlendAttrib.cxx
@@ -39,19 +39,38 @@ make_off() {
CPT(RenderAttrib) ColorBlendAttrib::
make(ColorBlendAttrib::Mode mode) {
ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, O_one, O_one,
+ mode, O_one, O_one,
LColor::zero());
return return_new(attrib);
}
/**
* Constructs a new ColorBlendAttrib object that enables special-effect
- * blending. This supercedes transparency.
+ * blending. This supercedes transparency. The given mode and operands are
+ * used for both the RGB and alpha channels.
*/
CPT(RenderAttrib) ColorBlendAttrib::
make(ColorBlendAttrib::Mode mode,
ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b,
const LColor &color) {
- ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, a, b, color);
+ ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, a, b, mode, a, b, color);
+ return return_new(attrib);
+}
+
+/**
+ * Constructs a new ColorBlendAttrib object that enables special-effect
+ * blending. This supercedes transparency. This form is used to specify
+ * separate blending parameters for the RGB and alpha channels.
+ */
+CPT(RenderAttrib) ColorBlendAttrib::
+make(ColorBlendAttrib::Mode mode,
+ ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b,
+ ColorBlendAttrib::Mode alpha_mode,
+ ColorBlendAttrib::Operand alpha_a, ColorBlendAttrib::Operand alpha_b,
+ const LColor &color) {
+ ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, a, b,
+ alpha_mode, alpha_a, alpha_b,
+ color);
return return_new(attrib);
}
@@ -156,6 +175,13 @@ write_datagram(BamWriter *manager, Datagram &dg) {
dg.add_uint8(_mode);
dg.add_uint8(_a);
dg.add_uint8(_b);
+
+ if (manager->get_file_minor_ver() >= 42) {
+ dg.add_uint8(_alpha_mode);
+ dg.add_uint8(_alpha_a);
+ dg.add_uint8(_alpha_b);
+ }
+
_color.write_datagram(dg);
}
@@ -187,10 +213,34 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_mode = (Mode)scan.get_uint8();
_a = (Operand)scan.get_uint8();
_b = (Operand)scan.get_uint8();
+
+ if (manager->get_file_minor_ver() >= 42) {
+ _alpha_mode = (Mode)scan.get_uint8();
+ _alpha_a = (Operand)scan.get_uint8();
+ _alpha_b = (Operand)scan.get_uint8();
+ } else {
+ // Before bam 6.42, these were shifted by four.
+ if (_a >= O_incoming1_color) {
+ _a = (Operand)(_a + 4);
+ }
+ if (_b >= O_incoming1_color) {
+ _b = (Operand)(_b + 4);
+ }
+
+ // And there was only one set of blend constants for both RGB and alpha.
+ _alpha_mode = _mode;
+ _alpha_a = _a;
+ _alpha_b = _b;
+ }
+
_color.read_datagram(scan);
- _involves_constant_color = involves_constant_color(_a) || involves_constant_color(_b);
- _involves_color_scale = involves_color_scale(_a) || involves_color_scale(_b);
+ _involves_constant_color =
+ involves_constant_color(_a) || involves_constant_color(_alpha_a) ||
+ involves_constant_color(_b) || involves_constant_color(_alpha_b);
+ _involves_color_scale =
+ involves_color_scale(_a) || involves_color_scale(_alpha_a) ||
+ involves_color_scale(_b) || involves_color_scale(_alpha_b);
}
/**
@@ -234,7 +284,7 @@ operator << (ostream &out, ColorBlendAttrib::Operand operand) {
return out << "one";
case ColorBlendAttrib::O_incoming_color:
- return out << "incomfing_color";
+ return out << "incoming_color";
case ColorBlendAttrib::O_one_minus_incoming_color:
return out << "one_minus_incoming_color";
@@ -283,6 +333,18 @@ operator << (ostream &out, ColorBlendAttrib::Operand operand) {
case ColorBlendAttrib::O_one_minus_alpha_scale:
return out << "one_minus_alpha_scale";
+
+ case ColorBlendAttrib::O_incoming1_color:
+ return out << "incoming1_color";
+
+ case ColorBlendAttrib::O_one_minus_incoming1_color:
+ return out << "one_minus_incoming1_color";
+
+ case ColorBlendAttrib::O_incoming1_alpha:
+ return out << "incoming1_alpha";
+
+ case ColorBlendAttrib::O_one_minus_incoming1_alpha:
+ return out << "one_minus_incoming1_alpha";
}
return out << "**invalid ColorBlendAttrib::Operand(" << (int)operand << ")**";
diff --git a/panda/src/pgraph/colorBlendAttrib.h b/panda/src/pgraph/colorBlendAttrib.h
index 3e836fdb45..6d66747218 100644
--- a/panda/src/pgraph/colorBlendAttrib.h
+++ b/panda/src/pgraph/colorBlendAttrib.h
@@ -52,11 +52,20 @@ PUBLISHED:
O_one_minus_constant_alpha,
O_incoming_color_saturate, // valid only for operand a
- // If you set either of the operands to any of the below, the blend color
- // is taken from the current ColorScaleAttrib. This also inhibits the
- // normal behavior of the ColorScaleAttrib; it no longer directly scales
- // the vertex colors, on the assumption that you will instead take care of
- // the scale here, in the blend mode.
+ // The following are used for dual-source blending, where the fragment
+ // shader outputs a second color that will be used for blending.
+ O_incoming1_color,
+ O_one_minus_incoming1_color,
+ O_incoming1_alpha,
+ O_one_minus_incoming1_alpha,
+
+ // If you set any of the operands to any of the below, the blend color is
+ // taken from the current ColorScaleAttrib. This also inhibits the normal
+ // behavior of the ColorScaleAttrib; it no longer directly scales the
+ // vertex colors, on the assumption that you will instead take care of the
+ // scale here, in the blend mode.
+ //
+ // These modes are being considered for deprecation.
O_color_scale,
O_one_minus_color_scale,
O_alpha_scale,
@@ -66,6 +75,7 @@ PUBLISHED:
private:
INLINE ColorBlendAttrib();
INLINE ColorBlendAttrib(Mode mode, Operand a, Operand b,
+ Mode alpha_mode, Operand alpha_a, Operand alpha_b,
const LColor &color);
PUBLISHED:
@@ -73,11 +83,19 @@ PUBLISHED:
static CPT(RenderAttrib) make(Mode mode);
static CPT(RenderAttrib) make(Mode mode, Operand a, Operand b,
const LColor &color = LColor::zero());
+ static CPT(RenderAttrib) make(Mode rgb_mode, Operand rgb_a, Operand rgb_b,
+ Mode alpha_mode, Operand alpha_a, Operand alpha_b,
+ const LColor &color = LColor::zero());
static CPT(RenderAttrib) make_default();
INLINE Mode get_mode() const;
INLINE Operand get_operand_a() const;
INLINE Operand get_operand_b() const;
+
+ INLINE Mode get_alpha_mode() const;
+ INLINE Operand get_alpha_operand_a() const;
+ INLINE Operand get_alpha_operand_b() const;
+
INLINE LColor get_color() const;
INLINE bool involves_constant_color() const;
@@ -86,6 +104,17 @@ PUBLISHED:
INLINE static bool involves_constant_color(Operand operand);
INLINE static bool involves_color_scale(Operand operand);
+PUBLISHED:
+ MAKE_PROPERTY(rgb_mode, get_mode);
+ MAKE_PROPERTY(rgb_operand_a, get_operand_a);
+ MAKE_PROPERTY(rgb_operand_b, get_operand_b);
+
+ MAKE_PROPERTY(alpha_mode, get_alpha_mode);
+ MAKE_PROPERTY(alpha_operand_a, get_alpha_operand_a);
+ MAKE_PROPERTY(alpha_operand_b, get_alpha_operand_b);
+
+ MAKE_PROPERTY(color, get_color);
+
public:
virtual void output(ostream &out) const;
@@ -97,6 +126,8 @@ protected:
private:
Mode _mode;
Operand _a, _b;
+ Mode _alpha_mode;
+ Operand _alpha_a, _alpha_b;
LColor _color;
bool _involves_constant_color;
bool _involves_color_scale;
diff --git a/panda/src/pgraph/colorScaleAttrib.h b/panda/src/pgraph/colorScaleAttrib.h
index 060b2721a1..aa3ace8738 100644
--- a/panda/src/pgraph/colorScaleAttrib.h
+++ b/panda/src/pgraph/colorScaleAttrib.h
@@ -43,6 +43,9 @@ PUBLISHED:
INLINE const LVecBase4 &get_scale() const;
CPT(RenderAttrib) set_scale(const LVecBase4 &scale) const;
+PUBLISHED:
+ MAKE_PROPERTY2(scale, has_scale, get_scale);
+
public:
virtual bool lower_attrib_can_override() const;
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/colorWriteAttrib.h b/panda/src/pgraph/colorWriteAttrib.h
index 76d9d5c1db..b7dcb7eb37 100644
--- a/panda/src/pgraph/colorWriteAttrib.h
+++ b/panda/src/pgraph/colorWriteAttrib.h
@@ -48,6 +48,9 @@ PUBLISHED:
INLINE unsigned int get_channels() const;
+PUBLISHED:
+ MAKE_PROPERTY(channels, get_channels);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx
index d5427a659f..10b9fb04d3 100644
--- a/panda/src/pgraph/config_pgraph.cxx
+++ b/panda/src/pgraph/config_pgraph.cxx
@@ -50,6 +50,7 @@
#include "loaderFileType.h"
#include "loaderFileTypeBam.h"
#include "loaderFileTypeRegistry.h"
+#include "logicOpAttrib.h"
#include "materialAttrib.h"
#include "modelFlattenRequest.h"
#include "modelLoadRequest.h"
@@ -419,6 +420,7 @@ init_libpgraph() {
Loader::init_type();
LoaderFileType::init_type();
LoaderFileTypeBam::init_type();
+ LogicOpAttrib::init_type();
MaterialAttrib::init_type();
ModelFlattenRequest::init_type();
ModelLoadRequest::init_type();
@@ -483,6 +485,7 @@ init_libpgraph() {
LensNode::register_with_read_factory();
LightAttrib::register_with_read_factory();
LightRampAttrib::register_with_read_factory();
+ LogicOpAttrib::register_with_read_factory();
MaterialAttrib::register_with_read_factory();
ModelNode::register_with_read_factory();
ModelRoot::register_with_read_factory();
diff --git a/panda/src/pgraph/cullBinAttrib.h b/panda/src/pgraph/cullBinAttrib.h
index c61fd2ebfc..f17a9876c6 100644
--- a/panda/src/pgraph/cullBinAttrib.h
+++ b/panda/src/pgraph/cullBinAttrib.h
@@ -35,6 +35,10 @@ PUBLISHED:
INLINE const string &get_bin_name() const;
INLINE int get_draw_order() const;
+PUBLISHED:
+ MAKE_PROPERTY(bin_name, get_bin_name);
+ MAKE_PROPERTY(draw_order, get_draw_order);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/cullFaceAttrib.h b/panda/src/pgraph/cullFaceAttrib.h
index 1dc2d8147e..5f6589a52a 100644
--- a/panda/src/pgraph/cullFaceAttrib.h
+++ b/panda/src/pgraph/cullFaceAttrib.h
@@ -44,6 +44,11 @@ PUBLISHED:
INLINE bool get_reverse() const;
Mode get_effective_mode() const;
+PUBLISHED:
+ MAKE_PROPERTY(mode, get_actual_mode);
+ MAKE_PROPERTY(reverse, get_reverse);
+ MAKE_PROPERTY(effective_mode, get_effective_mode);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/depthOffsetAttrib.h b/panda/src/pgraph/depthOffsetAttrib.h
index fe617fa56a..0976e2025a 100644
--- a/panda/src/pgraph/depthOffsetAttrib.h
+++ b/panda/src/pgraph/depthOffsetAttrib.h
@@ -60,6 +60,11 @@ PUBLISHED:
INLINE PN_stdfloat get_min_value() const;
INLINE PN_stdfloat get_max_value() const;
+PUBLISHED:
+ MAKE_PROPERTY(offset, get_offset);
+ MAKE_PROPERTY(min_value, get_min_value);
+ MAKE_PROPERTY(max_value, get_max_value);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/depthTestAttrib.h b/panda/src/pgraph/depthTestAttrib.h
index 66eb9fb135..6380a197d9 100644
--- a/panda/src/pgraph/depthTestAttrib.h
+++ b/panda/src/pgraph/depthTestAttrib.h
@@ -33,6 +33,9 @@ PUBLISHED:
INLINE PandaCompareFunc get_mode() const;
+PUBLISHED:
+ MAKE_PROPERTY(mode, get_mode);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/depthWriteAttrib.h b/panda/src/pgraph/depthWriteAttrib.h
index 7efdf4a70f..9cd96b40f9 100644
--- a/panda/src/pgraph/depthWriteAttrib.h
+++ b/panda/src/pgraph/depthWriteAttrib.h
@@ -39,6 +39,9 @@ PUBLISHED:
INLINE Mode get_mode() const;
+PUBLISHED:
+ MAKE_PROPERTY(mode, get_mode);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/fogAttrib.h b/panda/src/pgraph/fogAttrib.h
index 1762fb09ee..28a84600e0 100644
--- a/panda/src/pgraph/fogAttrib.h
+++ b/panda/src/pgraph/fogAttrib.h
@@ -34,6 +34,9 @@ PUBLISHED:
INLINE bool is_off() const;
INLINE Fog *get_fog() const;
+PUBLISHED:
+ MAKE_PROPERTY(fog, get_fog);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/lightRampAttrib.h b/panda/src/pgraph/lightRampAttrib.h
index 08c3a1ea84..b1ac147376 100644
--- a/panda/src/pgraph/lightRampAttrib.h
+++ b/panda/src/pgraph/lightRampAttrib.h
@@ -52,6 +52,9 @@ PUBLISHED:
INLINE PN_stdfloat get_level(int n) const;
INLINE PN_stdfloat get_threshold(int n) const;
+PUBLISHED:
+ MAKE_PROPERTY(mode, get_mode);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/logicOpAttrib.I b/panda/src/pgraph/logicOpAttrib.I
new file mode 100644
index 0000000000..189769a3e6
--- /dev/null
+++ b/panda/src/pgraph/logicOpAttrib.I
@@ -0,0 +1,29 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file logicOpAttrib.I
+ * @author rdb
+ * @date 2016-03-24
+ */
+
+/**
+ * Use LogicOpAttrib::make() to construct a new LogicOpAttrib object.
+ */
+INLINE LogicOpAttrib::
+LogicOpAttrib(LogicOpAttrib::Operation op) :
+ _op(op)
+{
+}
+
+/**
+ * Returns the logic operation specified by this attribute.
+ */
+INLINE LogicOpAttrib::Operation LogicOpAttrib::
+get_operation() const {
+ return _op;
+}
diff --git a/panda/src/pgraph/logicOpAttrib.cxx b/panda/src/pgraph/logicOpAttrib.cxx
new file mode 100644
index 0000000000..b632bb1b45
--- /dev/null
+++ b/panda/src/pgraph/logicOpAttrib.cxx
@@ -0,0 +1,205 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file logicOpAttrib.I
+ * @author rdb
+ * @date 2016-03-24
+ */
+
+#include "logicOpAttrib.h"
+#include "graphicsStateGuardianBase.h"
+#include "dcast.h"
+#include "bamReader.h"
+#include "bamWriter.h"
+#include "datagram.h"
+#include "datagramIterator.h"
+
+TypeHandle LogicOpAttrib::_type_handle;
+int LogicOpAttrib::_attrib_slot;
+
+/**
+ * Constructs a new LogicOpAttrib object that disables special-effect
+ * blending, allowing normal transparency to be used instead.
+ */
+CPT(RenderAttrib) LogicOpAttrib::
+make_off() {
+ return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot);
+}
+
+/**
+ * Constructs a new LogicOpAttrib object with the given logic operation.
+ */
+CPT(RenderAttrib) LogicOpAttrib::
+make(LogicOpAttrib::Operation op) {
+ LogicOpAttrib *attrib = new LogicOpAttrib(op);
+ return return_new(attrib);
+}
+
+/**
+ * Returns a RenderAttrib that corresponds to whatever the standard default
+ * properties for render attributes of this type ought to be.
+ */
+CPT(RenderAttrib) LogicOpAttrib::
+make_default() {
+ return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot);
+}
+
+/**
+ *
+ */
+void LogicOpAttrib::
+output(ostream &out) const {
+ out << get_type() << ":" << get_operation();
+}
+
+/**
+ * Intended to be overridden by derived LogicOpAttrib types to return a
+ * unique number indicating whether this LogicOpAttrib is equivalent to the
+ * other one.
+ *
+ * This should return 0 if the two LogicOpAttrib objects are equivalent, a
+ * number less than zero if this one should be sorted before the other one,
+ * and a number greater than zero otherwise.
+ *
+ * This will only be called with two LogicOpAttrib objects whose get_type()
+ * functions return the same.
+ */
+int LogicOpAttrib::
+compare_to_impl(const RenderAttrib *other) const {
+ const LogicOpAttrib *la = (const LogicOpAttrib *)other;
+ return (int)_op - (int)la->_op;
+}
+
+/**
+ * Intended to be overridden by derived RenderAttrib types to return a unique
+ * hash for these particular properties. RenderAttribs that compare the same
+ * with compare_to_impl(), above, should return the same hash; RenderAttribs
+ * that compare differently should return a different hash.
+ */
+size_t LogicOpAttrib::
+get_hash_impl() const {
+ size_t hash = 0;
+ hash = int_hash::add_hash(hash, (int)_op);
+ return hash;
+}
+
+/**
+ *
+ */
+CPT(RenderAttrib) LogicOpAttrib::
+get_auto_shader_attrib_impl(const RenderState *state) const {
+ return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot);
+}
+
+/**
+ * Tells the BamReader how to create objects of type LogicOpAttrib.
+ */
+void LogicOpAttrib::
+register_with_read_factory() {
+ BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
+}
+
+/**
+ * Writes the contents of this object to the datagram for shipping out to a
+ * Bam file.
+ */
+void LogicOpAttrib::
+write_datagram(BamWriter *manager, Datagram &dg) {
+ RenderAttrib::write_datagram(manager, dg);
+
+ dg.add_uint8(_op);
+}
+
+/**
+ * This function is called by the BamReader's factory when a new object of
+ * type LogicOpAttrib is encountered in the Bam file. It should create the
+ * LogicOpAttrib and extract its information from the file.
+ */
+TypedWritable *LogicOpAttrib::
+make_from_bam(const FactoryParams ¶ms) {
+ LogicOpAttrib *attrib = new LogicOpAttrib(O_none);
+ DatagramIterator scan;
+ BamReader *manager;
+
+ parse_params(params, scan, manager);
+ attrib->fillin(scan, manager);
+
+ return attrib;
+}
+
+/**
+ * This internal function is called by make_from_bam to read in all of the
+ * relevant data from the BamFile for the new LogicOpAttrib.
+ */
+void LogicOpAttrib::
+fillin(DatagramIterator &scan, BamReader *manager) {
+ RenderAttrib::fillin(scan, manager);
+
+ _op = (Operation)scan.get_uint8();
+}
+
+/**
+ *
+ */
+ostream &
+operator << (ostream &out, LogicOpAttrib::Operation op) {
+ switch (op) {
+ case LogicOpAttrib::O_none:
+ return out << "none";
+
+ case LogicOpAttrib::O_clear:
+ return out << "clear";
+
+ case LogicOpAttrib::O_and:
+ return out << "and";
+
+ case LogicOpAttrib::O_and_reverse:
+ return out << "and_reverse";
+
+ case LogicOpAttrib::O_copy:
+ return out << "copy";
+
+ case LogicOpAttrib::O_and_inverted:
+ return out << "and_inverted";
+
+ case LogicOpAttrib::O_noop:
+ return out << "noop";
+
+ case LogicOpAttrib::O_xor:
+ return out << "xor";
+
+ case LogicOpAttrib::O_or:
+ return out << "or";
+
+ case LogicOpAttrib::O_nor:
+ return out << "nor";
+
+ case LogicOpAttrib::O_equivalent:
+ return out << "equivalent";
+
+ case LogicOpAttrib::O_invert:
+ return out << "invert";
+
+ case LogicOpAttrib::O_or_reverse:
+ return out << "or_reverse";
+
+ case LogicOpAttrib::O_copy_inverted:
+ return out << "copy_inverted";
+
+ case LogicOpAttrib::O_or_inverted:
+ return out << "or_inverted";
+
+ case LogicOpAttrib::O_nand:
+ return out << "nand";
+
+ case LogicOpAttrib::O_set:
+ return out << "set";
+ }
+
+ return out << "**invalid LogicOpAttrib::Operation(" << (int)op << ")**";
+}
diff --git a/panda/src/pgraph/logicOpAttrib.h b/panda/src/pgraph/logicOpAttrib.h
new file mode 100644
index 0000000000..988836f8d1
--- /dev/null
+++ b/panda/src/pgraph/logicOpAttrib.h
@@ -0,0 +1,112 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file logicOpAttrib.I
+ * @author rdb
+ * @date 2016-03-24
+ */
+
+#ifndef LOGICOPATTRIB_H
+#define LOGICOPATTRIB_H
+
+#include "pandabase.h"
+#include "luse.h"
+#include "renderAttrib.h"
+
+class FactoryParams;
+
+/**
+ * If enabled, specifies that a custom logical operation be performed instead
+ * of any color blending. Setting it to a value other than M_none will cause
+ * color blending to be disabled and the given logic operation to be performed.
+ */
+class EXPCL_PANDA_PGRAPH LogicOpAttrib : public RenderAttrib {
+PUBLISHED:
+ enum Operation {
+ O_none, // LogicOp disabled, regular blending occurs.
+ O_clear, // Clears framebuffer value.
+ O_and,
+ O_and_reverse,
+ O_copy, // Writes the incoming color to the framebuffer.
+ O_and_inverted,
+ O_noop, // Leaves the framebuffer value unaltered.
+ O_xor,
+ O_or,
+ O_nor,
+ O_equivalent,
+ O_invert,
+ O_or_reverse,
+ O_copy_inverted,
+ O_or_inverted,
+ O_nand,
+ O_set, // Sets all the bits in the framebuffer to 1.
+ };
+
+private:
+ INLINE LogicOpAttrib(Operation op);
+
+PUBLISHED:
+ static CPT(RenderAttrib) make_off();
+ static CPT(RenderAttrib) make(Operation op);
+ static CPT(RenderAttrib) make_default();
+
+ INLINE Operation get_operation() const;
+ MAKE_PROPERTY(operation, get_operation);
+
+public:
+ virtual void output(ostream &out) const;
+
+protected:
+ virtual int compare_to_impl(const RenderAttrib *other) const;
+ virtual size_t get_hash_impl() const;
+ virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
+
+private:
+ Operation _op;
+
+PUBLISHED:
+ static int get_class_slot() {
+ return _attrib_slot;
+ }
+ virtual int get_slot() const {
+ return get_class_slot();
+ }
+
+public:
+ static void register_with_read_factory();
+ virtual void write_datagram(BamWriter *manager, Datagram &dg);
+
+protected:
+ static TypedWritable *make_from_bam(const FactoryParams ¶ms);
+ void fillin(DatagramIterator &scan, BamReader *manager);
+
+public:
+ static TypeHandle get_class_type() {
+ return _type_handle;
+ }
+ static void init_type() {
+ RenderAttrib::init_type();
+ register_type(_type_handle, "LogicOpAttrib",
+ RenderAttrib::get_class_type());
+ _attrib_slot = register_slot(_type_handle, 100, new LogicOpAttrib(O_none));
+ }
+ virtual TypeHandle get_type() const {
+ return get_class_type();
+ }
+ virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+ static TypeHandle _type_handle;
+ static int _attrib_slot;
+};
+
+EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, LogicOpAttrib::Operation op);
+
+#include "logicOpAttrib.I"
+
+#endif
diff --git a/panda/src/pgraph/materialAttrib.h b/panda/src/pgraph/materialAttrib.h
index 729e9ac345..f984b699b3 100644
--- a/panda/src/pgraph/materialAttrib.h
+++ b/panda/src/pgraph/materialAttrib.h
@@ -36,6 +36,9 @@ PUBLISHED:
INLINE bool is_off() const;
INLINE Material *get_material() const;
+PUBLISHED:
+ MAKE_PROPERTY(material, get_material);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx
index c6bfff127c..de0cf7c4fb 100644
--- a/panda/src/pgraph/nodePath.cxx
+++ b/panda/src/pgraph/nodePath.cxx
@@ -4832,6 +4832,62 @@ get_transparency() const {
return TransparencyAttrib::M_none;
}
+/**
+ * Specifically sets or disables a logical operation on this particular node.
+ * If no other nodes override, this will cause geometry to be rendered without
+ * color blending but instead using the given logical operator.
+ */
+void NodePath::
+set_logic_op(LogicOpAttrib::Operation op, int priority) {
+ nassertv_always(!is_empty());
+
+ node()->set_attrib(LogicOpAttrib::make(op), priority);
+}
+
+/**
+ * Completely removes any logical operation that may have been set on this
+ * node via set_logic_op(). The geometry at this level and below will
+ * subsequently be rendered using standard color blending.
+ */
+void NodePath::
+clear_logic_op() {
+ nassertv_always(!is_empty());
+ node()->clear_attrib(LogicOpAttrib::get_class_slot());
+}
+
+/**
+ * Returns true if a logical operation has been explicitly set on this
+ * particular node via set_logic_op(). If this returns true, then
+ * get_logic_op() may be called to determine whether a logical operation has
+ * been explicitly disabled for this node or set to particular operation.
+ */
+bool NodePath::
+has_logic_op() const {
+ nassertr_always(!is_empty(), false);
+ return node()->has_attrib(LogicOpAttrib::get_class_slot());
+}
+
+/**
+ * Returns the logical operation that has been specifically set on this node
+ * via set_logic_op(), or O_none if standard color blending has been
+ * specifically set, or if nothing has been specifically set. See also
+ * has_logic_op(). This does not necessarily imply that the geometry will
+ * or will not be rendered with the given logical operation, as there may be
+ * other nodes that override.
+ */
+LogicOpAttrib::Operation NodePath::
+get_logic_op() const {
+ nassertr_always(!is_empty(), LogicOpAttrib::O_none);
+ const RenderAttrib *attrib =
+ node()->get_attrib(LogicOpAttrib::get_class_slot());
+ if (attrib != (const RenderAttrib *)NULL) {
+ const LogicOpAttrib *ta = DCAST(LogicOpAttrib, attrib);
+ return ta->get_operation();
+ }
+
+ return LogicOpAttrib::O_none;
+}
+
/**
* Specifies the antialiasing type that should be applied at this node and
* below. See AntialiasAttrib.
diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h
index 729bcf37f3..4f39aa28bb 100644
--- a/panda/src/pgraph/nodePath.h
+++ b/panda/src/pgraph/nodePath.h
@@ -26,6 +26,7 @@
#include "transformState.h"
#include "renderModeAttrib.h"
#include "transparencyAttrib.h"
+#include "logicOpAttrib.h"
#include "nodePathComponent.h"
#include "pointerTo.h"
#include "referenceCount.h"
@@ -62,57 +63,83 @@ class SamplerState;
class Shader;
class ShaderInput;
-/*
- * A NodePath is the fundamental unit of high-level interaction with the scene
- * graph. It encapsulates the complete path down to a node from some other
- * node, usually the root of the scene graph. This is used to resolve
- * ambiguities associated with instancing. NodePath also contains a number of
- * handy high-level methods for common scene-graph manipulations, such as
- * reparenting, and common state changes, such as repositioning. There are
- * also a number of NodePath methods for finding nodes deep within the tree by
- * name or by type. These take a path string, which at its simplest consists
- * of a series of node names separated by slashes, like a directory pathname.
- * Each component of the path string may optionally consist of one of the
- * following special names, instead of a node name: * -- matches
- * exactly one node, with any name. ** -- matches any sequence of
- * zero or more nodes. +typename -- matches any node that is or derives from
- * the given type. -typename -- matches any node that is the given type
- * exactly. =tag -- matches any node that has the indicated tag.
- * =tag=value -- matches any node whose tag matches the indicated value.
- * Furthermore, a node name may itself contain standard filename globbing
- * characters, like *, ?, and [a-z], that will be accepted as a partial match.
- * (In fact, the '*' special name may be seen as just a special case of this.)
- * The globbing characters may not be used with the typename matches or with
- * tag matches, but they may be used to match a tag's value in the =tag=value
- * syntax. The special characters "@@", appearing at the beginning of a node
- * name, indicate a stashed node. Normally, stashed nodes are not returned by
- * a find (but see the special flags, below), but a stashed node may be found
- * if it is explicitly named with its leading @@ characters. By extension,
- * "@@*" may be used to identify any stashed node. Examples: "roomgraph" will
- * look for a node named "graph", which is a child of an unnamed node, which
- * is a child of a node named "room", which is a child of the starting path.
- * "**red*" will look for any node anywhere in the tree (below the starting
- * path) with a name that begins with "red". "**+PartBundleNode**head" will
- * look for a node named "head", somewhere below a PartBundleNode anywhere in
- * the tree. The search is always potentially ambiguous, even if the special
- * wildcard operators are not used, because there may be multiple nodes in the
- * tree with the same name. In general, in the case of an ambiguity, the
- * shortest path is preferred; when a method (such as extend_by) must choose
- * only only one of several possible paths, it will choose the shortest
- * available; on the other hand, when a method (such as find_all_matches) is
- * to return all of the matching paths, it will sort them so that the shortest
- * paths appear first in the output. Special flags. The entire string may
- * optionally be followed by the ";" character, followed by one or more of the
- * following special control flags, with no intervening spaces or punctuation:
- * -h Do not return hidden nodes. +h Do return hidden nodes. -s Do
- * not return stashed nodes unless explicitly referenced with @@. +s Return
- * stashed nodes even without any explicit @@ characters. -i Node name
- * comparisons are not case insensitive: case must match exactly. +i Node
- * name comparisons are case insensitive: case is not important. This affects
- * matches against the node name only; node type and tag strings are always
- * case sensitive. The default flags are +h-s-i.
- */
-
+//
+// A NodePath is the fundamental unit of high-level interaction with the scene
+// graph. It encapsulates the complete path down to a node from some other
+// node, usually the root of the scene graph. This is used to resolve
+// ambiguities associated with instancing.
+//
+// NodePath also contains a number of handy high-level methods for common
+// scene-graph manipulations, such as reparenting, and common state changes,
+// such as repositioning.
+//
+// There are also a number of NodePath methods for finding nodes deep within
+// the tree by name or by type. These take a path string, which at its
+// simplest consists of a series of node names separated by slashes, like a
+// directory pathname.
+//
+// Each component of the path string may optionally consist of one of the
+// following special names, instead of a node name:
+//
+// * -- matches exactly one node, with any name.
+// ** -- matches any sequence of zero or more nodes.
+// +typename -- matches any node that is or derives from the given type.
+// -typename -- matches any node that is the given type exactly.
+// =tag -- matches any node that has the indicated tag.
+// =tag=value -- matches any node whose tag matches the indicated value.
+//
+// Furthermore, a node name may itself contain standard filename globbing
+// characters, like *, ?, and [a-z], that will be accepted as a partial match.
+// (In fact, the '*' special name may be seen as just a special case of this.)
+// The globbing characters may not be used with the typename matches or with
+// tag matches, but they may be used to match a tag's value in the =tag=value
+// syntax.
+//
+// The special characters "@@", appearing at the beginning of a node name,
+// indicate a stashed node. Normally, stashed nodes are not returned by a
+// find (but see the special flags, below), but a stashed node may be found if
+// it is explicitly named with its leading @@ characters. By extension, "@@*"
+// may be used to identify any stashed node.
+//
+// Examples:
+//
+// "room//graph" will look for a node named "graph", which is a child of an
+// unnamed node, which is a child of a node named "room", which is a child of
+// the starting path.
+//
+// "**/red*" will look for any node anywhere in the tree (below the starting
+// path) with a name that begins with "red".
+//
+// "**/+PartBundleNode/**/head" will look for a node named "head", somewhere
+// below a PartBundleNode anywhere in the tree.
+//
+//
+// The search is always potentially ambiguous, even if the special wildcard
+// operators are not used, because there may be multiple nodes in the tree
+// with the same name. In general, in the case of an ambiguity, the shortest
+// path is preferred; when a method (such as extend_by) must choose only only
+// one of several possible paths, it will choose the shortest available; on
+// the other hand, when a method (such as find_all_matches) is to return all
+// of the matching paths, it will sort them so that the shortest paths appear
+// first in the output.
+//
+//
+// Special flags. The entire string may optionally be followed by the ";"
+// character, followed by one or more of the following special control flags,
+// with no intervening spaces or punctuation:
+//
+// -h Do not return hidden nodes.
+// +h Do return hidden nodes.
+// -s Do not return stashed nodes unless explicitly referenced with @@.
+// +s Return stashed nodes even without any explicit @@ characters.
+// -i Node name comparisons are not case insensitive: case must match
+// exactly.
+// +i Node name comparisons are case insensitive: case is not important.
+// This affects matches against the node name only; node type and tag
+// strings are always case sensitive.
+//
+// The default flags are +h-s-i.
+//
/**
* NodePath is the fundamental system for disambiguating instances, and also
@@ -786,6 +813,11 @@ PUBLISHED:
bool has_transparency() const;
TransparencyAttrib::Mode get_transparency() const;
+ void set_logic_op(LogicOpAttrib::Operation op, int priority = 0);
+ void clear_logic_op();
+ bool has_logic_op() const;
+ LogicOpAttrib::Operation get_logic_op() const;
+
void set_antialias(unsigned short mode, int priority = 0);
void clear_antialias();
bool has_antialias() const;
diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx
index c13ec6326d..656802b8f0 100644
--- a/panda/src/pgraph/nodePath_ext.cxx
+++ b/panda/src/pgraph/nodePath_ext.cxx
@@ -156,7 +156,11 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const {
}
}
+#if PY_MAJOR_VERSION >= 3
+ PyObject *result = Py_BuildValue("(O(y#))", func, bam_stream.data(), (Py_ssize_t) bam_stream.size());
+#else
PyObject *result = Py_BuildValue("(O(s#))", func, bam_stream.data(), (Py_ssize_t) bam_stream.size());
+#endif
Py_DECREF(func);
Py_DECREF(this_class);
return result;
diff --git a/panda/src/pgraph/p3pgraph_composite3.cxx b/panda/src/pgraph/p3pgraph_composite3.cxx
index 5b88a55d2f..18be4cb35e 100644
--- a/panda/src/pgraph/p3pgraph_composite3.cxx
+++ b/panda/src/pgraph/p3pgraph_composite3.cxx
@@ -7,6 +7,7 @@
#include "loaderFileType.cxx"
#include "loaderFileTypeBam.cxx"
#include "loaderFileTypeRegistry.cxx"
+#include "logicOpAttrib.cxx"
#include "materialAttrib.cxx"
#include "materialCollection.cxx"
#include "modelFlattenRequest.cxx"
diff --git a/panda/src/pgraph/renderAttribRegistry.h b/panda/src/pgraph/renderAttribRegistry.h
index 9858192332..59194fd278 100644
--- a/panda/src/pgraph/renderAttribRegistry.h
+++ b/panda/src/pgraph/renderAttribRegistry.h
@@ -47,7 +47,7 @@ public:
// Raise this number whenever we add a new attrib. This used to be
// determined at runtime, but it's better to have it as a constexpr.
- static const int _max_slots = 29;
+ static const int _max_slots = 32;
int register_slot(TypeHandle type_handle, int sort,
RenderAttrib *default_attrib);
diff --git a/panda/src/pgraph/renderModeAttrib.h b/panda/src/pgraph/renderModeAttrib.h
index 0306de9737..631789dd60 100644
--- a/panda/src/pgraph/renderModeAttrib.h
+++ b/panda/src/pgraph/renderModeAttrib.h
@@ -63,9 +63,14 @@ PUBLISHED:
INLINE PN_stdfloat get_thickness() const;
INLINE bool get_perspective() const;
INLINE const LColor &get_wireframe_color() const;
-
INLINE int get_geom_rendering(int geom_rendering) const;
+PUBLISHED:
+ MAKE_PROPERTY(mode, get_mode);
+ MAKE_PROPERTY(thickness, get_thickness);
+ MAKE_PROPERTY(perspective, get_perspective);
+ MAKE_PROPERTY(wireframe_color, get_wireframe_color);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/rescaleNormalAttrib.h b/panda/src/pgraph/rescaleNormalAttrib.h
index 3017c9a879..d76d51e6de 100644
--- a/panda/src/pgraph/rescaleNormalAttrib.h
+++ b/panda/src/pgraph/rescaleNormalAttrib.h
@@ -49,6 +49,7 @@ PUBLISHED:
INLINE static CPT(RenderAttrib) make_default();
INLINE Mode get_mode() const;
+ MAKE_PROPERTY(mode, get_mode);
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/scissorAttrib.h b/panda/src/pgraph/scissorAttrib.h
index 941d704a7c..48a4b87a7c 100644
--- a/panda/src/pgraph/scissorAttrib.h
+++ b/panda/src/pgraph/scissorAttrib.h
@@ -47,6 +47,9 @@ PUBLISHED:
INLINE const LVecBase4 &get_frame() const;
+PUBLISHED:
+ MAKE_PROPERTY(frame, get_frame);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/shadeModelAttrib.h b/panda/src/pgraph/shadeModelAttrib.h
index c9550bccac..067555207a 100644
--- a/panda/src/pgraph/shadeModelAttrib.h
+++ b/panda/src/pgraph/shadeModelAttrib.h
@@ -39,6 +39,7 @@ PUBLISHED:
static CPT(RenderAttrib) make_default();
INLINE Mode get_mode() const;
+ MAKE_PROPERTY(mode, get_mode);
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h
index 9159d52e18..08676286f5 100644
--- a/panda/src/pgraph/shaderAttrib.h
+++ b/panda/src/pgraph/shaderAttrib.h
@@ -114,6 +114,10 @@ PUBLISHED:
static void register_with_read_factory();
+PUBLISHED:
+ MAKE_PROPERTY(shader, get_shader);
+ MAKE_PROPERTY(instance_count, get_instance_count);
+
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraph/transparencyAttrib.h b/panda/src/pgraph/transparencyAttrib.h
index 2baf3710a1..ebd7f4f157 100644
--- a/panda/src/pgraph/transparencyAttrib.h
+++ b/panda/src/pgraph/transparencyAttrib.h
@@ -51,6 +51,7 @@ PUBLISHED:
static CPT(RenderAttrib) make_default();
INLINE Mode get_mode() const;
+ MAKE_PROPERTY(mode, get_mode);
public:
virtual void output(ostream &out) const;
diff --git a/panda/src/pgraphnodes/lightLensNode.I b/panda/src/pgraphnodes/lightLensNode.I
index 8cf9ea7eb6..ddb2808e86 100644
--- a/panda/src/pgraphnodes/lightLensNode.I
+++ b/panda/src/pgraphnodes/lightLensNode.I
@@ -42,12 +42,11 @@ set_shadow_caster(bool caster) {
*/
INLINE void LightLensNode::
set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int buffer_sort) {
- if ((_shadow_caster && !caster) || buffer_xsize != _sb_xsize || buffer_ysize != _sb_ysize) {
+ if ((_shadow_caster && !caster) || buffer_xsize != _sb_size[0] || buffer_ysize != _sb_size[1]) {
clear_shadow_buffers();
}
_shadow_caster = caster;
- _sb_xsize = buffer_xsize;
- _sb_ysize = buffer_ysize;
+ _sb_size.set(buffer_xsize, buffer_ysize);
if (buffer_sort != _sb_sort) {
ShadowBuffers::iterator it;
@@ -59,6 +58,25 @@ set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int buffer_so
set_active(caster);
}
+/**
+ * Returns the size of the shadow buffer to be created for this light source.
+ */
+INLINE LVecBase2i LightLensNode::
+get_shadow_buffer_size() const {
+ return _sb_size;
+}
+
+/**
+ * Sets the size of the shadow buffer to be created for this light source.
+ */
+INLINE void LightLensNode::
+set_shadow_buffer_size(const LVecBase2i &size) {
+ if (size != _sb_size) {
+ clear_shadow_buffers();
+ }
+ _sb_size = size;
+}
+
/**
* Returns the buffer that has been constructed for a given GSG, or NULL if no
* such buffer has (yet) been constructed. This should be used for debugging
diff --git a/panda/src/pgraphnodes/lightLensNode.cxx b/panda/src/pgraphnodes/lightLensNode.cxx
index ba1e93acac..bc3e134116 100644
--- a/panda/src/pgraphnodes/lightLensNode.cxx
+++ b/panda/src/pgraphnodes/lightLensNode.cxx
@@ -31,8 +31,7 @@ LightLensNode(const string &name, Lens *lens) :
{
set_active(false);
_shadow_caster = false;
- _sb_xsize = 512;
- _sb_ysize = 512;
+ _sb_size.set(512, 512);
_sb_sort = -10;
// set_initial_state(RenderState::make(ShaderAttrib::make_off(), 1000));
// Backface culling helps eliminating artifacts.
@@ -57,8 +56,7 @@ LightLensNode(const LightLensNode ©) :
Light(copy),
Camera(copy),
_shadow_caster(copy._shadow_caster),
- _sb_xsize(copy._sb_xsize),
- _sb_ysize(copy._sb_ysize),
+ _sb_size(copy._sb_size),
_sb_sort(-10)
{
}
@@ -126,8 +124,8 @@ write_datagram(BamWriter *manager, Datagram &dg) {
Light::write_datagram(manager, dg);
dg.add_bool(_shadow_caster);
- dg.add_int32(_sb_xsize);
- dg.add_int32(_sb_ysize);
+ dg.add_int32(_sb_size[0]);
+ dg.add_int32(_sb_size[1]);
dg.add_int32(_sb_sort);
}
diff --git a/panda/src/pgraphnodes/lightLensNode.h b/panda/src/pgraphnodes/lightLensNode.h
index 205a58b660..d4e0c7385d 100644
--- a/panda/src/pgraphnodes/lightLensNode.h
+++ b/panda/src/pgraphnodes/lightLensNode.h
@@ -38,14 +38,22 @@ PUBLISHED:
INLINE void set_shadow_caster(bool caster);
INLINE void set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int sort = -10);
+ INLINE LVecBase2i get_shadow_buffer_size() const;
+ INLINE void set_shadow_buffer_size(const LVecBase2i &size);
+
INLINE GraphicsOutputBase *get_shadow_buffer(GraphicsStateGuardianBase *gsg);
+PUBLISHED:
+ MAKE_PROPERTY(shadow_caster, is_shadow_caster);
+ MAKE_PROPERTY(shadow_buffer_size, get_shadow_buffer_size, set_shadow_buffer_size);
+
protected:
LightLensNode(const LightLensNode ©);
void clear_shadow_buffers();
+ LVecBase2i _sb_size;
bool _shadow_caster;
- int _sb_xsize, _sb_ysize, _sb_sort;
+ int _sb_sort;
// This is really a map of GSG -> GraphicsOutput.
typedef pmap ShadowBuffers;
diff --git a/panda/src/physx/physxClothDesc.cxx b/panda/src/physx/physxClothDesc.cxx
index cfe9fdf53b..3c1ffce57d 100644
--- a/panda/src/physx/physxClothDesc.cxx
+++ b/panda/src/physx/physxClothDesc.cxx
@@ -281,11 +281,11 @@ get_solver_iterations() const {
return _desc.solverIterations;
}
-/*
/**
* Used by PhysScene to query the sizes of arrays to allocate for the user
* buffers in PhysxClothNode.
*/
+/*
void PhysxClothDesc::
get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) {
diff --git a/panda/src/physx/physxSoftBody.cxx b/panda/src/physx/physxSoftBody.cxx
index 0fb78a6770..268a229502 100644
--- a/panda/src/physx/physxSoftBody.cxx
+++ b/panda/src/physx/physxSoftBody.cxx
@@ -535,16 +535,10 @@ get_hard_stretch_limitation_factor() const {
#endif // NX_SDK_VERSION_NUMBER > 281
-
-
-
-
-
-
-/*
/**
* Attaches a cloth vertex to a position in world space.
*/
+/*
void PhysxSoftBody::
attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) {
@@ -553,6 +547,7 @@ attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) {
_ptr->attachVertexToGlobalPosition(vertexId, PhysxManager::point3_to_nxVec3(pos));
}
+*/
/**
* Attaches the cloth to a shape. All cloth points currently inside the shape
@@ -561,6 +556,7 @@ attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) {
* This method only works with primitive and convex shapes. Since the inside
* of a general triangle mesh is not clearly defined.
*/
+/*
void PhysxSoftBody::
attach_to_shape(PhysxShape *shape) {
@@ -570,6 +566,7 @@ attach_to_shape(PhysxShape *shape) {
NxU32 attachmentFlags = 0; // --TODO--
_ptr->attachToShape(shape->ptr(), attachmentFlags);
}
+*/
/**
* Attaches the cloth to all shapes, currently colliding.
@@ -577,6 +574,7 @@ attach_to_shape(PhysxShape *shape) {
* This method only works with primitive and convex shapes. Since the inside
* of a general triangle mesh is not clearly defined.
*/
+/*
void PhysxSoftBody::
attach_to_colliding_shapes() {
@@ -585,6 +583,7 @@ attach_to_colliding_shapes() {
NxU32 attachmentFlags = 0; // --TODO--
_ptr->attachToCollidingShapes(attachmentFlags);
}
+*/
/**
* Detaches the cloth from a shape it has been attached to before.
@@ -592,6 +591,7 @@ attach_to_colliding_shapes() {
* If the cloth has not been attached to the shape before, the call has no
* effect.
*/
+/*
void PhysxSoftBody::
detach_from_shape(PhysxShape *shape) {
@@ -600,20 +600,24 @@ detach_from_shape(PhysxShape *shape) {
_ptr->detachFromShape(shape->ptr());
}
+*/
/**
* Frees a previously attached cloth point.
*/
+/*
void PhysxSoftBody::
free_vertex(unsigned int vertexId) {
nassertv(_error_type == ET_ok);
_ptr->freeVertex(vertexId);
}
+*/
/**
* Attaches a cloth vertex to a local position within a shape.
*/
+/*
void PhysxSoftBody::
attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos) {
@@ -626,10 +630,12 @@ attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const
PhysxManager::point3_to_nxVec3(localPos),
attachmentFlags);
}
+*/
/**
* Return the attachment status of the given vertex.
*/
+/*
PhysxEnums::PhysxVertexAttachmentStatus PhysxSoftBody::
get_vertex_attachment_status(unsigned int vertexId) const {
@@ -638,12 +644,14 @@ get_vertex_attachment_status(unsigned int vertexId) const {
return (PhysxVertexAttachmentStatus) _ptr->getVertexAttachmentStatus(vertexId);
}
+*/
/**
* Returns the pointer to an attached shape pointer of the given vertex. If
* the vertex is not attached or attached to a global position, NULL is
* returned.
*/
+/*
PhysxShape *PhysxSoftBody::
get_vertex_attachment_shape(unsigned int vertexId) const {
@@ -655,12 +663,14 @@ get_vertex_attachment_shape(unsigned int vertexId) const {
return shape;
}
+*/
/**
* Returns the attachment position of the given vertex. If the vertex is
* attached to shape, the position local to the shape's pose is returned. If
* the vertex is not attached, the return value is undefined.
*/
+/*
LPoint3f PhysxSoftBody::
get_vertex_attachment_pos(unsigned int vertexId) const {
@@ -670,11 +680,13 @@ get_vertex_attachment_pos(unsigned int vertexId) const {
return PhysxManager::nxVec3_to_point3(_ptr->getVertexAttachmentPosition(vertexId));
}
+*/
/**
* Sets an external acceleration which affects all non attached particles of
* the cloth.
*/
+/*
void PhysxSoftBody::
set_external_acceleration(LVector3f const &acceleration) {
@@ -683,10 +695,12 @@ set_external_acceleration(LVector3f const &acceleration) {
_ptr->setExternalAcceleration(PhysxManager::vec3_to_nxVec3(acceleration));
}
+*/
/**
* Sets an acceleration acting normal to the cloth surface at each vertex.
*/
+/*
void PhysxSoftBody::
set_wind_acceleration(LVector3f const &acceleration) {
@@ -695,33 +709,39 @@ set_wind_acceleration(LVector3f const &acceleration) {
_ptr->setWindAcceleration(PhysxManager::vec3_to_nxVec3(acceleration));
}
+*/
/**
* Retrieves the external acceleration which affects all non attached
* particles of the cloth.
*/
+/*
LVector3f PhysxSoftBody::
get_external_acceleration() const {
nassertr(_error_type == ET_ok, LVector3f::zero());
return PhysxManager::nxVec3_to_vec3(_ptr->getExternalAcceleration());
}
+*/
/**
* Retrieves the acceleration acting normal to the cloth surface at each
* vertex
*/
+/*
LVector3f PhysxSoftBody::
get_wind_acceleration() const {
nassertr(_error_type == ET_ok, LVector3f::zero());
return PhysxManager::nxVec3_to_vec3(_ptr->getWindAcceleration());
}
+*/
/**
* Applies a force (or impulse) defined in the global coordinate frame, to a
* particular vertex of the cloth.
*/
+/*
void PhysxSoftBody::
add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) {
@@ -730,11 +750,13 @@ add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) {
vertexId,
(NxForceMode) mode);
}
+*/
/**
* Applies a radial force (or impulse) at a particular position. All vertices
* within radius will be affected with a quadratic drop-off.
*/
+/*
void PhysxSoftBody::
add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceMode mode) {
@@ -744,11 +766,13 @@ add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceM
radius,
(NxForceMode) mode);
}
+*/
/**
* Applies a directed force (or impulse) at a particular position. All
* vertices within radius will be affected with a quadratic drop-off.
*/
+/*
void PhysxSoftBody::
add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, PhysxForceMode mode) {
diff --git a/panda/src/physx/physxSoftBodyDesc.cxx b/panda/src/physx/physxSoftBodyDesc.cxx
index 8e1016b14c..2f3aada839 100644
--- a/panda/src/physx/physxSoftBodyDesc.cxx
+++ b/panda/src/physx/physxSoftBodyDesc.cxx
@@ -317,11 +317,11 @@ get_solver_iterations() const {
return _desc.solverIterations;
}
-/*
/**
* Used by PhysScene to query the sizes of arrays to allocate for the user
* buffers in PhysxSoftBodyNode.
*/
+/*
void PhysxSoftBodyDesc::
get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) {
diff --git a/panda/src/physx/physxVehicle.cxx b/panda/src/physx/physxVehicle.cxx
index 39314bff32..c4aa1a57fc 100644
--- a/panda/src/physx/physxVehicle.cxx
+++ b/panda/src/physx/physxVehicle.cxx
@@ -57,10 +57,10 @@ update_vehicle(float dt) {
// TODO !!!
}
-/*
/**
* Returns the actor for this vehicle.
*/
+/*
PhysxActor *PhysxVehicle::
get_actor() const {
@@ -69,20 +69,22 @@ get_actor() const {
}
*/
-/*
/**
* Returns the number of wheels on this vehicle.
*/
+/*
unsigned int PhysxVehicle::
get_num_wheels() const {
nassertr(_error_type == ET_ok, 0);
return _wheels.size();
}
+*/
/**
* Returns the n-th wheel of this vehicle.
*/
+/*
PhysxWheel *PhysxVehicle::
get_wheel(unsigned int idx) const {
diff --git a/panda/src/physx/physxVehicle.h b/panda/src/physx/physxVehicle.h
index 62f86a9de0..78b358e667 100644
--- a/panda/src/physx/physxVehicle.h
+++ b/panda/src/physx/physxVehicle.h
@@ -34,10 +34,11 @@ PUBLISHED:
INLINE PhysxVehicle();
INLINE ~PhysxVehicle();
- // PhysxActor *get_actor() const;
+ //PhysxActor *get_actor() const;
- // unsigned int get_num_wheels() const; PhysxWheel *get_wheel(unsigned int
- // idx) const; MAKE_SEQ(get_wheels, get_num_wheels, get_wheel);
+ //unsigned int get_num_wheels() const;
+ //PhysxWheel *get_wheel(unsigned int idx) const;
+ //MAKE_SEQ(get_wheels, get_num_wheels, get_wheel);
INLINE void ls() const;
INLINE void ls(ostream &out, int indent_level=0) const;
diff --git a/panda/src/physx/physxVehicleDesc.cxx b/panda/src/physx/physxVehicleDesc.cxx
index e74d031e58..0a114773cd 100644
--- a/panda/src/physx/physxVehicleDesc.cxx
+++ b/panda/src/physx/physxVehicleDesc.cxx
@@ -13,10 +13,10 @@
#include "physxVehicleDesc.h"
-/*
/**
*
*/
+/*
void PhysxVehicleDesc::
add_wheel(PhysxWheelDesc *wheelDesc) {
diff --git a/panda/src/physx/physxWheel.cxx b/panda/src/physx/physxWheel.cxx
index 897c4b54cf..d8c3663532 100644
--- a/panda/src/physx/physxWheel.cxx
+++ b/panda/src/physx/physxWheel.cxx
@@ -17,10 +17,10 @@
TypeHandle PhysxWheel::_type_handle;
-/*
/**
*
*/
+/*
PhysxWheelShape *PhysxWheel::
get_wheel_shape() const {
@@ -28,7 +28,6 @@ get_wheel_shape() const {
}
*/
-/*
/**
* Attaches a node path to this wheel. The node path's transform will be
* updated automatically.
@@ -36,6 +35,7 @@ get_wheel_shape() const {
* Note: any non-uniform scale or shear set on the NodePath's transform will
* be overwritten at the time of the first update.
*/
+/*
void PhysxWheel::
attach_node_path(const NodePath &np) {
@@ -43,22 +43,26 @@ attach_node_path(const NodePath &np) {
nassertv_always(!np.is_empty());
_np = NodePath(np);
}
+*/
/**
* Detaches a previously assigned NodePath from this wheel. The NodePath's
* transform will no longer be updated.
*/
+/*
void PhysxWheel::
detach_node_path() {
nassertv(_error_type == ET_ok);
_np = NodePath();
}
+*/
/**
* Retrieves a previously attached NodePath. An empty NodePath will be
* returned if no NodePath has been attached to this wheel.
*/
+/*
NodePath PhysxWheel::
get_node_path() const {
diff --git a/panda/src/physx/physxWheel.h b/panda/src/physx/physxWheel.h
index 25bc92e241..84aa5a3acd 100644
--- a/panda/src/physx/physxWheel.h
+++ b/panda/src/physx/physxWheel.h
@@ -32,17 +32,16 @@ PUBLISHED:
INLINE PhysxWheel();
INLINE ~PhysxWheel();
- // PhysxActor *get_touched_actor() const; PhysxWheelShape *get_wheel_shape()
- // const;
+ //PhysxActor *get_touched_actor() const;
+ //PhysxWheelShape *get_wheel_shape() const;
- // void attach_node_path(const NodePath &np); void detach_node_path();
- // NodePath get_node_path() const;
+ //void attach_node_path(const NodePath &np);
+ //void detach_node_path();
+ //NodePath get_node_path() const;
INLINE void ls() const;
INLINE void ls(ostream &out, int indent_level=0) const;
-public:
-
private:
PT(PhysxWheelShape) _wheelShape;
NodePath _np;
diff --git a/panda/src/physx/physxWheelDesc.cxx b/panda/src/physx/physxWheelDesc.cxx
index 6eac9897ba..20c71c173a 100644
--- a/panda/src/physx/physxWheelDesc.cxx
+++ b/panda/src/physx/physxWheelDesc.cxx
@@ -13,10 +13,10 @@
#include "physxWheelDesc.h"
-/*
/**
*
*/
+/*
void PhysxWheelDesc::
set_wheel_radius(float wheelRadius) {
diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx
index b62d45519f..bcd555f003 100644
--- a/panda/src/pipeline/pipeline.cxx
+++ b/panda/src/pipeline/pipeline.cxx
@@ -24,22 +24,23 @@ Pipeline *Pipeline::_render_pipeline = (Pipeline *)NULL;
*/
Pipeline::
Pipeline(const string &name, int num_stages) :
- Namable(name)
+ Namable(name),
#ifdef THREADED_PIPELINE
- , _lock("Pipeline")
+ _num_stages(num_stages),
+ _lock("Pipeline")
+#else
+ _num_stages(1)
#endif
{
#ifdef THREADED_PIPELINE
-
-/*
- * We maintain all of the cyclers in the world on one of two linked lists.
- * Cyclers that are "clean", which is to say, they have the same value across
- * all pipeline stages, are stored on the _clean list. Cyclers that are
- * "dirty", which have different values across some pipeline stages, are
- * stored instead on the _dirty list. Cyclers can move themselves from clean
- * to dirty by calling add_dirty_cycler(), and cyclers get moved from dirty to
- * clean during cycle().
- */
+ // We maintain all of the cyclers in the world on one of two linked
+ // lists. Cyclers that are "clean", which is to say, they have the
+ // same value across all pipeline stages, are stored on the _clean
+ // list. Cyclers that are "dirty", which have different values
+ // across some pipeline stages, are stored instead on the _dirty
+ // list. Cyclers can move themselves from clean to dirty by calling
+ // add_dirty_cycler(), and cyclers get moved from dirty to clean
+ // during cycle().
// To visit each cycler once requires traversing both lists.
_clean.make_head();
@@ -53,9 +54,15 @@ Pipeline(const string &name, int num_stages) :
// This flag is true only during the call to cycle().
_cycling = false;
+#else
+ if (num_stages != 1) {
+ pipeline_cat.warning()
+ << "Requested " << num_stages
+ << " pipeline stages but multithreaded render pipelines not enabled in build.\n";
+ }
#endif // THREADED_PIPELINE
- set_num_stages(num_stages);
+ nassertv(num_stages >= 1);
}
/**
diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx
index 17a9c5ff58..5e0f52f5a6 100644
--- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx
+++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx
@@ -319,7 +319,7 @@ write_data(xel *array, xelval *) {
row_pointer[0] = row;
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
- delete row;
+ delete[] row;
/* Step 6: Finish compression */
diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h
index 4251751135..2755f0f25d 100644
--- a/panda/src/putil/bam.h
+++ b/panda/src/putil/bam.h
@@ -32,7 +32,7 @@ static const unsigned short _bam_major_ver = 6;
// Bumped to major version 6 on 2006-02-11 to factor out PandaNode::CData.
static const unsigned short _bam_first_minor_ver = 14;
-static const unsigned short _bam_minor_ver = 41;
+static const unsigned short _bam_minor_ver = 42;
// Bumped to minor version 14 on 2007-12-19 to change default ColorAttrib.
// Bumped to minor version 15 on 2008-04-09 to add TextureAttrib::_implicit_sort.
// Bumped to minor version 16 on 2008-05-13 to add Texture::_quality_level.
@@ -61,5 +61,6 @@ static const unsigned short _bam_minor_ver = 41;
// Bumped to minor version 39 on 2016-01-09 to change lights and materials.
// Bumped to minor version 40 on 2016-01-11 to make NodePaths writable.
// Bumped to minor version 41 on 2016-03-02 to change LensNode, Lens, and Camera.
+// Bumped to minor version 42 on 2016-04-08 to expand ColorBlendAttrib.
#endif
diff --git a/panda/src/putil/bamReader.I b/panda/src/putil/bamReader.I
index 19f1a37a9d..ece2676956 100644
--- a/panda/src/putil/bamReader.I
+++ b/panda/src/putil/bamReader.I
@@ -159,6 +159,17 @@ get_file_pos() {
return _source->get_file_pos();
}
+/**
+ * Registers a factory function that is called when an object of the given
+ * type is encountered within the .bam stream.
+ *
+ * @param user_data an optional pointer to be passed along to the function.
+ */
+void BamReader::
+register_factory(TypeHandle handle, WritableFactory::CreateFunc *func, void *user_data) {
+ get_factory()->register_factory(handle, func, user_data);
+}
+
/**
* Returns the global WritableFactory for generating TypedWritable objects
*/
diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h
index 885fddaffb..4785a4d4fc 100644
--- a/panda/src/putil/bamReader.h
+++ b/panda/src/putil/bamReader.h
@@ -148,11 +148,14 @@ PUBLISHED:
INLINE int get_current_major_ver() const;
INLINE int get_current_minor_ver() const;
+ EXTENSION(PyObject *get_file_version() const);
+
PUBLISHED:
MAKE_PROPERTY(source, get_source, set_source);
MAKE_PROPERTY(filename, get_filename);
MAKE_PROPERTY(loader_options, get_loader_options, set_loader_options);
+ MAKE_PROPERTY(file_version, get_file_version);
MAKE_PROPERTY(file_endian, get_file_endian);
MAKE_PROPERTY(file_stdfloat_double, get_file_stdfloat_double);
@@ -194,7 +197,13 @@ public:
INLINE streampos get_file_pos();
public:
+ INLINE static void register_factory(TypeHandle type, WritableFactory::CreateFunc *func,
+ void *user_data = NULL);
INLINE static WritableFactory *get_factory();
+
+PUBLISHED:
+ EXTENSION(static void register_factory(TypeHandle handle, PyObject *func));
+
private:
INLINE static void create_factory();
diff --git a/panda/src/putil/bamReader_ext.cxx b/panda/src/putil/bamReader_ext.cxx
new file mode 100644
index 0000000000..4a490f90d9
--- /dev/null
+++ b/panda/src/putil/bamReader_ext.cxx
@@ -0,0 +1,123 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file bamReader_ext.cxx
+ * @author rdb
+ * @date 2016-04-09
+ */
+
+#include "bamReader_ext.h"
+#include "config_util.h"
+
+#ifdef HAVE_PYTHON
+
+#ifndef CPPPARSER
+extern Dtool_PyTypedObject Dtool_BamReader;
+extern Dtool_PyTypedObject Dtool_DatagramIterator;
+extern Dtool_PyTypedObject Dtool_TypedWritable;
+#endif // CPPPARSER
+
+/**
+ * Factory function that calls the registered Python function.
+ */
+static TypedWritable *factory_callback(const FactoryParams ¶ms){
+ PyObject *func = (PyObject *)params.get_user_data();
+ nassertr(func != NULL, NULL);
+
+#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
+ // Use PyGILState to protect this asynchronous call.
+ PyGILState_STATE gstate;
+ gstate = PyGILState_Ensure();
+#endif
+
+ // Extract the parameters we will pass to the Python function.
+ DatagramIterator scan;
+ BamReader *manager;
+ parse_params(params, scan, manager);
+
+ PyObject *py_scan = DTool_CreatePyInstance(&scan, Dtool_DatagramIterator, false, false);
+ PyObject *py_manager = DTool_CreatePyInstance(manager, Dtool_BamReader, false, false);
+ PyObject *args = PyTuple_Pack(2, py_scan, py_manager);
+
+ // Now call the Python function.
+ Thread *current_thread = Thread::get_current_thread();
+ PyObject *result = current_thread->call_python_func(func, args);
+ Py_DECREF(args);
+ Py_DECREF(py_scan);
+ Py_DECREF(py_manager);
+
+ if (result == (PyObject *)NULL) {
+ util_cat.error()
+ << "Exception occurred in Python factory function\n";
+
+ } else if (result == Py_None) {
+ util_cat.error()
+ << "Python factory function returned None\n";
+ Py_DECREF(result);
+ result = NULL;
+ }
+
+#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
+ PyGILState_Release(gstate);
+#endif
+
+ // Unwrap the returned TypedWritable object.
+ if (result == (PyObject *)NULL) {
+ return (TypedWritable *)NULL;
+ } else {
+ void *object = NULL;
+ Dtool_Call_ExtractThisPointer(result, Dtool_TypedWritable, &object);
+
+ TypedWritable *ptr = (TypedWritable *)object;
+ ReferenceCount *ref_count = ptr->as_reference_count();
+ if (ref_count != NULL) {
+ // If the Python pointer is the last reference to it, make sure that the
+ // object isn't destroyed. We do this by calling unref(), which
+ // decreases the reference count without destroying the object.
+ if (result->ob_refcnt <= 1) {
+ ref_count->unref();
+
+ // Tell the Python wrapper object that it shouldn't try to delete the
+ // object when it is destroyed.
+ ((Dtool_PyInstDef *)result)->_memory_rules = false;
+ }
+ Py_DECREF(result);
+ }
+
+ return (TypedWritable *)object;
+ }
+}
+
+/**
+ * Returns the version number of the Bam file currently being read.
+ */
+PyObject *Extension::
+get_file_version() const {
+ return Py_BuildValue("(ii)", _this->get_file_major_ver(),
+ _this->get_file_minor_ver());
+}
+
+/**
+ * Registers a Python function as factory function for the given type. This
+ * should be a function (or class object) that takes a DatagramIterator and a
+ * BamReader as arguments, and should return a TypedWritable object.
+ */
+void Extension::
+register_factory(TypeHandle handle, PyObject *func) {
+ nassertv(func != NULL);
+
+ if (!PyCallable_Check(func)) {
+ Dtool_Raise_TypeError("second argument to register_factory must be callable");
+ return;
+ }
+
+ Py_INCREF(func);
+ BamReader::get_factory()->register_factory(handle, &factory_callback, (void *)func);
+}
+
+#endif
diff --git a/panda/src/putil/bamReader_ext.h b/panda/src/putil/bamReader_ext.h
new file mode 100644
index 0000000000..d7905c617f
--- /dev/null
+++ b/panda/src/putil/bamReader_ext.h
@@ -0,0 +1,39 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University. All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license. You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file bamReader_ext.h
+ * @author rdb
+ * @date 2016-04-09
+ */
+
+#ifndef BAMREADER_EXT_H
+#define BAMREADER_EXT_H
+
+#include "dtoolbase.h"
+
+#ifdef HAVE_PYTHON
+
+#include "extension.h"
+#include "bamReader.h"
+#include "py_panda.h"
+
+/**
+ * This class defines the extension methods for BamReader, which are called
+ * instead of any C++ methods with the same prototype.
+ */
+template<>
+class Extension : public ExtensionBase {
+public:
+ PyObject *get_file_version() const;
+
+ static void register_factory(TypeHandle handle, PyObject *func);
+};
+
+#endif // HAVE_PYTHON
+
+#endif // BAMREADER_EXT_H
diff --git a/panda/src/putil/factory.I b/panda/src/putil/factory.I
index 37da03c686..57d3fadff5 100644
--- a/panda/src/putil/factory.I
+++ b/panda/src/putil/factory.I
@@ -70,6 +70,6 @@ make_instance_more_general(const string &type_name,
*/
template
INLINE void Factory::
-register_factory(TypeHandle handle, CreateFunc *func) {
- FactoryBase::register_factory(handle, (BaseCreateFunc *)func);
+register_factory(TypeHandle handle, CreateFunc *func, void *user_data) {
+ FactoryBase::register_factory(handle, (BaseCreateFunc *)func, user_data);
}
diff --git a/panda/src/putil/factory.h b/panda/src/putil/factory.h
index f45f1ffce3..4520153911 100644
--- a/panda/src/putil/factory.h
+++ b/panda/src/putil/factory.h
@@ -49,7 +49,8 @@ public:
make_instance_more_general(const string &type_name,
const FactoryParams ¶ms = FactoryParams());
- INLINE void register_factory(TypeHandle handle, CreateFunc *func);
+ INLINE void register_factory(TypeHandle handle, CreateFunc *func,
+ void *user_data = NULL);
};
#include "factory.I"
diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx
index 935ad7bb33..52704e92cd 100644
--- a/panda/src/putil/factoryBase.cxx
+++ b/panda/src/putil/factoryBase.cxx
@@ -128,12 +128,18 @@ find_registered_type(TypeHandle handle) {
/**
* Registers a new kind of thing the Factory will be able to create.
+ *
+ * @param user_data an optional pointer to be passed along to the function.
*/
void FactoryBase::
-register_factory(TypeHandle handle, BaseCreateFunc *func) {
+register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) {
nassertv(handle != TypeHandle::none());
nassertv(func != (BaseCreateFunc *)NULL);
- _creators[handle] = func;
+
+ Creator creator;
+ creator._func = func;
+ creator._user_data = user_data;
+ _creators[handle] = creator;
}
/**
@@ -234,15 +240,16 @@ operator = (const FactoryBase &) {
* not be created.
*/
TypedObject *FactoryBase::
-make_instance_exact(TypeHandle handle, const FactoryParams ¶ms) {
+make_instance_exact(TypeHandle handle, FactoryParams params) {
Creators::const_iterator ci = _creators.find(handle);
if (ci == _creators.end()) {
return NULL;
}
- BaseCreateFunc *func = (BaseCreateFunc *)((*ci).second);
- nassertr(func != (BaseCreateFunc *)NULL, NULL);
- return (*func)(params);
+ Creator creator = (*ci).second;
+ nassertr(creator._func != (BaseCreateFunc *)NULL, NULL);
+ params._user_data = creator._user_data;
+ return (*creator._func)(params);
}
/**
@@ -251,7 +258,7 @@ make_instance_exact(TypeHandle handle, const FactoryParams ¶ms) {
* instance could not be created.
*/
TypedObject *FactoryBase::
-make_instance_more_specific(TypeHandle handle, const FactoryParams ¶ms) {
+make_instance_more_specific(TypeHandle handle, FactoryParams params) {
// First, walk through the established preferred list. Maybe one of these
// qualifies.
@@ -272,9 +279,10 @@ make_instance_more_specific(TypeHandle handle, const FactoryParams ¶ms) {
for (ci = _creators.begin(); ci != _creators.end(); ++ci) {
TypeHandle ctype = (*ci).first;
if (ctype.is_derived_from(handle)) {
- BaseCreateFunc *func = (BaseCreateFunc *)((*ci).second);
- nassertr(func != (BaseCreateFunc *)NULL, NULL);
- TypedObject *object = (*func)(params);
+ Creator creator = (*ci).second;
+ nassertr(creator._func != (BaseCreateFunc *)NULL, NULL);
+ params._user_data = creator._user_data;
+ TypedObject *object = (*creator._func)(params);
if (object != (TypedObject *)NULL) {
return object;
}
diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h
index 13ea0c8eaa..6fcfc2f54f 100644
--- a/panda/src/putil/factoryBase.h
+++ b/panda/src/putil/factoryBase.h
@@ -56,7 +56,7 @@ public:
TypeHandle find_registered_type(TypeHandle handle);
- void register_factory(TypeHandle handle, BaseCreateFunc *func);
+ void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = NULL);
int get_num_types() const;
TypeHandle get_type(int n) const;
@@ -74,22 +74,18 @@ private:
void operator = (const FactoryBase ©);
// internal utility functions
- TypedObject *make_instance_exact(TypeHandle handle,
- const FactoryParams ¶ms);
+ TypedObject *make_instance_exact(TypeHandle handle, FactoryParams params);
TypedObject *make_instance_more_specific(TypeHandle handle,
- const FactoryParams ¶ms);
+ FactoryParams params);
private:
// internal mechanics and bookkeeping
+ struct Creator {
+ BaseCreateFunc *_func;
+ void *_user_data;
+ };
-#if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(__ICL) //__ICL is Intel C++
- // Visual C++ seems to have a problem with building a map based on
- // BaseCreateFunc. We'll have to typecast it on the way out.
- typedef pmap Creators;
-#else
- typedef pmap Creators;
-#endif
-
+ typedef pmap Creators;
Creators _creators;
typedef pvector Preferred;
diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I
index 3183ae718e..0c6fdd09e7 100644
--- a/panda/src/putil/factoryParams.I
+++ b/panda/src/putil/factoryParams.I
@@ -13,6 +13,54 @@
#include "pnotify.h"
+/**
+ *
+ */
+INLINE FactoryParams::
+FactoryParams() : _user_data(NULL) {
+}
+
+/**
+ *
+ */
+INLINE FactoryParams::
+FactoryParams(const FactoryParams ©) :
+ _params(copy._params),
+ _user_data(copy._user_data) {}
+
+/**
+ *
+ */
+INLINE FactoryParams::
+~FactoryParams() {
+}
+
+#ifdef USE_MOVE_SEMANTICS
+/**
+ *
+ */
+INLINE FactoryParams::
+FactoryParams(FactoryParams &&from) NOEXCEPT :
+ _params(move(from._params)),
+ _user_data(from._user_data) {}
+
+/**
+ *
+ */
+INLINE void FactoryParams::
+operator = (FactoryParams &&from) NOEXCEPT {
+ _params = move(from._params);
+ _user_data = from._user_data;
+}
+#endif
+
+/**
+ * Returns the custom pointer that was associated with the factory function.
+ */
+INLINE void *FactoryParams::
+get_user_data() const {
+ return _user_data;
+}
/**
* A handy convenience template function that extracts a parameter of the
diff --git a/panda/src/putil/factoryParams.cxx b/panda/src/putil/factoryParams.cxx
index 47e41ebcf3..6224f8b94e 100644
--- a/panda/src/putil/factoryParams.cxx
+++ b/panda/src/putil/factoryParams.cxx
@@ -13,20 +13,6 @@
#include "factoryParams.h"
-/**
- *
- */
-FactoryParams::
-FactoryParams() {
-}
-
-/**
- *
- */
-FactoryParams::
-~FactoryParams() {
-}
-
/**
*
*/
diff --git a/panda/src/putil/factoryParams.h b/panda/src/putil/factoryParams.h
index 428399dd85..5c45a6e2ee 100644
--- a/panda/src/putil/factoryParams.h
+++ b/panda/src/putil/factoryParams.h
@@ -35,8 +35,14 @@
*/
class EXPCL_PANDA_PUTIL FactoryParams {
public:
- FactoryParams();
- ~FactoryParams();
+ INLINE FactoryParams();
+ INLINE FactoryParams(const FactoryParams ©);
+ INLINE ~FactoryParams();
+
+#ifdef USE_MOVE_SEMANTICS
+ INLINE FactoryParams(FactoryParams &&from) NOEXCEPT;
+ INLINE void operator = (FactoryParams &&from) NOEXCEPT;
+#endif
void add_param(FactoryParam *param);
void clear();
@@ -46,10 +52,15 @@ public:
FactoryParam *get_param_of_type(TypeHandle type) const;
+ INLINE void *get_user_data() const;
+
private:
typedef pvector< PT(TypedReferenceCount) > Params;
Params _params;
+ void *_user_data;
+
+ friend class FactoryBase;
};
template
diff --git a/panda/src/putil/p3putil_ext_composite.cxx b/panda/src/putil/p3putil_ext_composite.cxx
new file mode 100644
index 0000000000..4bedeea559
--- /dev/null
+++ b/panda/src/putil/p3putil_ext_composite.cxx
@@ -0,0 +1,3 @@
+#include "bamReader_ext.cxx"
+#include "pythonCallbackObject.cxx"
+#include "typedWritable_ext.cxx"
diff --git a/panda/src/putil/typedWritable.h b/panda/src/putil/typedWritable.h
index 20d7a7cb67..8278efba95 100644
--- a/panda/src/putil/typedWritable.h
+++ b/panda/src/putil/typedWritable.h
@@ -47,7 +47,10 @@ public:
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager);
virtual bool require_fully_complete() const;
+PUBLISHED:
virtual void fillin(DatagramIterator &scan, BamReader *manager);
+
+public:
virtual void finalize(BamReader *manager);
virtual ReferenceCount *as_reference_count();
diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx
index afa7f986c8..224686ed3e 100644
--- a/panda/src/putil/typedWritable_ext.cxx
+++ b/panda/src/putil/typedWritable_ext.cxx
@@ -110,7 +110,11 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const {
}
}
+#if PY_MAJOR_VERSION >= 3
+ PyObject *result = Py_BuildValue("(O(Oy#))", func, this_class, bam_stream.data(), (Py_ssize_t) bam_stream.size());
+#else
PyObject *result = Py_BuildValue("(O(Os#))", func, this_class, bam_stream.data(), (Py_ssize_t) bam_stream.size());
+#endif
Py_DECREF(func);
Py_DECREF(this_class);
return result;
@@ -212,10 +216,18 @@ py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *thi
PyObject *result;
if (py_reader != NULL){
+#if PY_MAJOR_VERSION >= 3
+ result = PyObject_CallFunction(func, (char *)"(y#O)", data.data(), (Py_ssize_t) data.size(), py_reader);
+#else
result = PyObject_CallFunction(func, (char *)"(s#O)", data.data(), (Py_ssize_t) data.size(), py_reader);
+#endif
Py_DECREF(py_reader);
} else {
+#if PY_MAJOR_VERSION >= 3
+ result = PyObject_CallFunction(func, (char *)"(y#)", data.data(), (Py_ssize_t) data.size());
+#else
result = PyObject_CallFunction(func, (char *)"(s#)", data.data(), (Py_ssize_t) data.size());
+#endif
}
if (result == NULL) {
diff --git a/samples/music-box/main.py b/samples/music-box/main.py
index 774168f782..dd8ecf0299 100755
--- a/samples/music-box/main.py
+++ b/samples/music-box/main.py
@@ -41,7 +41,7 @@ class MusicBox(DirectObject):
# Loading sounds is done in a similar way to loading other things
# Loading the main music box song
- self.musicBoxSound = base.loadMusic('music/musicbox.ogg')
+ self.musicBoxSound = loader.loadMusic('music/musicbox.ogg')
self.musicBoxSound.setVolume(.5) # Volume is a percentage from 0 to 1
# 0 means loop forever, 1 (default) means
# play once. 2 or higher means play that many times
@@ -69,7 +69,7 @@ class MusicBox(DirectObject):
# Loading the open/close effect
# loadSFX and loadMusic are identical. They are often used for organization
#(loadMusic is used for background music, loadSfx is used for other effects)
- self.lidSfx = base.loadSfx('music/openclose.ogg')
+ self.lidSfx = loader.loadSfx('music/openclose.ogg')
# The open/close file has both effects in it. Fortunatly we can use intervals
# to easily define parts of a sound file to play
self.lidOpenSfx = SoundInterval(self.lidSfx, duration=2, startTime=0)
diff --git a/samples/shader-terrain/heightfield.png b/samples/shader-terrain/heightfield.png
new file mode 100644
index 0000000000..2d72c0445f
Binary files /dev/null and b/samples/shader-terrain/heightfield.png differ
diff --git a/samples/shader-terrain/main.py b/samples/shader-terrain/main.py
new file mode 100644
index 0000000000..10f926fb2f
--- /dev/null
+++ b/samples/shader-terrain/main.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+# Author: tobspr
+#
+# Last Updated: 2016-02-13
+#
+# This tutorial provides an example of using the ShaderTerrainMesh class
+
+import os, sys, math, random
+
+from direct.showbase.ShowBase import ShowBase
+from panda3d.core import ShaderTerrainMesh, Shader, load_prc_file_data
+from panda3d.core import SamplerState
+
+class ShaderTerrainDemo(ShowBase):
+ def __init__(self):
+
+ # Load some configuration variables, its important for this to happen
+ # before the ShowBase is initialized
+ load_prc_file_data("", """
+ textures-power-2 none
+ window-title Panda3D Shader Terrain Demo
+ """)
+
+ # Initialize the showbase
+ ShowBase.__init__(self)
+
+ # Increase camera FOV aswell as the far plane
+ self.camLens.set_fov(90)
+ self.camLens.set_near_far(0.1, 50000)
+
+ # Construct the terrain
+ self.terrain_node = ShaderTerrainMesh()
+
+ # Set a heightfield, the heightfield should be a 16-bit png and
+ # have a quadratic size of a power of two.
+ self.terrain_node.heightfield_filename = "heightfield.png"
+
+ # Set the target triangle width. For a value of 10.0 for example,
+ # the terrain will attempt to make every triangle 10 pixels wide on screen.
+ self.terrain_node.target_triangle_width = 10.0
+
+ # Generate the terrain
+ self.terrain_node.generate()
+
+ # Attach the terrain to the main scene and set its scale
+ self.terrain = self.render.attach_new_node(self.terrain_node)
+ self.terrain.set_scale(1024, 1024, 100)
+ self.terrain.set_pos(-512, -512, -70.0)
+
+ # Set a shader on the terrain. The ShaderTerrainMesh only works with
+ # an applied shader. You can use the shaders used here in your own shaders
+ terrain_shader = Shader.load(Shader.SL_GLSL, "terrain.vert.glsl", "terrain.frag.glsl")
+ self.terrain.set_shader(terrain_shader)
+ self.terrain.set_shader_input("camera", self.camera)
+
+ # Set some texture on the terrain
+ grass_tex = self.loader.loadTexture("textures/grass.png")
+ grass_tex.set_minfilter(SamplerState.FT_linear_mipmap_linear)
+ grass_tex.set_anisotropic_degree(16)
+ self.terrain.set_texture(grass_tex)
+
+ # Load some skybox - you can safely ignore this code
+ skybox = self.loader.loadModel("models/skybox.bam")
+ skybox.reparent_to(self.render)
+ skybox.set_scale(20000)
+
+ skybox_texture = self.loader.loadTexture("textures/skybox.jpg")
+ skybox_texture.set_minfilter(SamplerState.FT_linear)
+ skybox_texture.set_magfilter(SamplerState.FT_linear)
+ skybox_texture.set_wrap_u(SamplerState.WM_repeat)
+ skybox_texture.set_wrap_v(SamplerState.WM_mirror)
+ skybox_texture.set_anisotropic_degree(16)
+ skybox.set_texture(skybox_texture)
+
+ skybox_shader = Shader.load(Shader.SL_GLSL, "skybox.vert.glsl", "skybox.frag.glsl")
+ skybox.set_shader(skybox_shader)
+
+demo = ShaderTerrainDemo()
+demo.run()
diff --git a/samples/shader-terrain/models/skybox.bam b/samples/shader-terrain/models/skybox.bam
new file mode 100644
index 0000000000..d39bf69577
Binary files /dev/null and b/samples/shader-terrain/models/skybox.bam differ
diff --git a/samples/shader-terrain/skybox.frag.glsl b/samples/shader-terrain/skybox.frag.glsl
new file mode 100644
index 0000000000..1703cfd425
--- /dev/null
+++ b/samples/shader-terrain/skybox.frag.glsl
@@ -0,0 +1,21 @@
+#version 150
+
+in vec3 skybox_pos;
+out vec4 color;
+
+uniform sampler2D p3d_Texture0;
+
+void main() {
+
+ vec3 view_dir = normalize(skybox_pos);
+ vec2 skybox_uv;
+
+ // Convert spherical coordinates
+ const float pi = 3.14159265359;
+ skybox_uv.x = (atan(view_dir.y, view_dir.x) + (0.5 * pi)) / (2 * pi);
+ skybox_uv.y = clamp(view_dir.z * 0.72 + 0.35, 0.0, 1.0);
+
+ vec3 skybox_color = textureLod(p3d_Texture0, skybox_uv, 0).xyz;
+
+ color = vec4(skybox_color, 1);
+}
diff --git a/samples/shader-terrain/skybox.vert.glsl b/samples/shader-terrain/skybox.vert.glsl
new file mode 100644
index 0000000000..464d9d2a94
--- /dev/null
+++ b/samples/shader-terrain/skybox.vert.glsl
@@ -0,0 +1,13 @@
+#version 150
+
+// This is just a simple vertex shader transforming the skybox
+
+in vec4 p3d_Vertex;
+uniform mat4 p3d_ModelViewProjectionMatrix;
+
+out vec3 skybox_pos;
+
+void main() {
+ skybox_pos = p3d_Vertex.xyz;
+ gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
+}
diff --git a/samples/shader-terrain/terrain.frag.glsl b/samples/shader-terrain/terrain.frag.glsl
new file mode 100644
index 0000000000..0f447842c3
--- /dev/null
+++ b/samples/shader-terrain/terrain.frag.glsl
@@ -0,0 +1,56 @@
+#version 150
+
+// This is the terrain fragment shader. There is a lot of code in here
+// which is not necessary to render the terrain, but included for convenience -
+// Like generating normals from the heightmap or a simple fog effect.
+
+// Most of the time you want to adjust this shader to get your terrain the look
+// you want. The vertex shader most likely will stay the same.
+
+in vec2 terrain_uv;
+in vec3 vtx_pos;
+out vec4 color;
+
+uniform struct {
+ sampler2D data_texture;
+ sampler2D heightfield;
+ int view_index;
+ int terrain_size;
+ int chunk_size;
+} ShaderTerrainMesh;
+
+uniform sampler2D p3d_Texture0;
+uniform vec3 wspos_camera;
+
+// Compute normal from the heightmap, this assumes the terrain is facing z-up
+vec3 get_terrain_normal() {
+ const float terrain_height = 50.0;
+ vec3 pixel_size = vec3(1.0, -1.0, 0) / textureSize(ShaderTerrainMesh.heightfield, 0).xxx;
+ float u0 = texture(ShaderTerrainMesh.heightfield, terrain_uv + pixel_size.yz).x * terrain_height;
+ float u1 = texture(ShaderTerrainMesh.heightfield, terrain_uv + pixel_size.xz).x * terrain_height;
+ float v0 = texture(ShaderTerrainMesh.heightfield, terrain_uv + pixel_size.zy).x * terrain_height;
+ float v1 = texture(ShaderTerrainMesh.heightfield, terrain_uv + pixel_size.zx).x * terrain_height;
+ vec3 tangent = normalize(vec3(1.0, 0, u1 - u0));
+ vec3 binormal = normalize(vec3(0, 1.0, v1 - v0));
+ return normalize(cross(tangent, binormal));
+}
+
+
+
+void main() {
+ vec3 diffuse = texture(p3d_Texture0, terrain_uv * 16.0).xyz;
+ vec3 normal = get_terrain_normal();
+
+ // Add some fake lighting - you usually want to use your own lighting code here
+ vec3 fake_sun = normalize(vec3(0.7, 0.2, 0.6));
+ vec3 shading = max(0.0, dot(normal, fake_sun)) * diffuse;
+ shading += vec3(0.07, 0.07, 0.1);
+
+
+ // Fake fog
+ float dist = distance(vtx_pos, wspos_camera);
+ float fog_factor = smoothstep(0, 1, dist / 1000.0);
+ shading = mix(shading, vec3(0.7, 0.7, 0.8), fog_factor);
+
+ color = vec4(shading, 1.0);
+}
diff --git a/samples/shader-terrain/terrain.vert.glsl b/samples/shader-terrain/terrain.vert.glsl
new file mode 100644
index 0000000000..d693451c89
--- /dev/null
+++ b/samples/shader-terrain/terrain.vert.glsl
@@ -0,0 +1,56 @@
+#version 150
+
+// This is the default terrain vertex shader. Most of the time you can just copy
+// this and reuse it, and just modify the fragment shader.
+
+in vec4 p3d_Vertex;
+uniform mat4 p3d_ModelViewProjectionMatrix;
+uniform mat4 p3d_ModelMatrix;
+
+uniform struct {
+ sampler2D data_texture;
+ sampler2D heightfield;
+ int view_index;
+ int terrain_size;
+ int chunk_size;
+} ShaderTerrainMesh;
+
+out vec2 terrain_uv;
+out vec3 vtx_pos;
+
+void main() {
+
+ // Terrain data has the layout:
+ // x: x-pos, y: y-pos, z: size, w: clod
+ vec4 terrain_data = texelFetch(ShaderTerrainMesh.data_texture,
+ ivec2(gl_InstanceID, ShaderTerrainMesh.view_index), 0);
+
+ // Get initial chunk position in the (0, 0, 0), (1, 1, 0) range
+ vec3 chunk_position = p3d_Vertex.xyz;
+
+ // CLOD implementation
+ float clod_factor = smoothstep(0, 1, terrain_data.w);
+ chunk_position.xy -= clod_factor * fract(chunk_position.xy * ShaderTerrainMesh.chunk_size / 2.0)
+ * 2.0 / ShaderTerrainMesh.chunk_size;
+
+ // Scale the chunk
+ chunk_position *= terrain_data.z * float(ShaderTerrainMesh.chunk_size)
+ / float(ShaderTerrainMesh.terrain_size);
+ chunk_position.z *= ShaderTerrainMesh.chunk_size;
+
+ // Offset the chunk, it is important that this happens after the scale
+ chunk_position.xy += terrain_data.xy / float(ShaderTerrainMesh.terrain_size);
+
+ // Compute the terrain UV coordinates
+ terrain_uv = chunk_position.xy;
+
+ // Sample the heightfield and offset the terrain - we do not need to multiply
+ // the height with anything since the terrain transform is included in the
+ // model view projection matrix.
+ chunk_position.z += texture(ShaderTerrainMesh.heightfield, terrain_uv).x;
+ gl_Position = p3d_ModelViewProjectionMatrix * vec4(chunk_position, 1);
+
+ // Output the vertex world space position - in this case we use this to render
+ // the fog.
+ vtx_pos = (p3d_ModelMatrix * vec4(chunk_position, 1)).xyz;
+}
diff --git a/samples/shader-terrain/textures/LICENSE.txt b/samples/shader-terrain/textures/LICENSE.txt
new file mode 100644
index 0000000000..e59b601333
--- /dev/null
+++ b/samples/shader-terrain/textures/LICENSE.txt
@@ -0,0 +1,5 @@
+Grass texture from (cc by 3.0)
+http://opengameart.org/content/grass-texture
+
+Skybox by rdb
+http://rdb.name/PANO_20140818_112419.jpg
diff --git a/samples/shader-terrain/textures/grass.png b/samples/shader-terrain/textures/grass.png
new file mode 100644
index 0000000000..79e09bb135
Binary files /dev/null and b/samples/shader-terrain/textures/grass.png differ
diff --git a/samples/shader-terrain/textures/skybox.jpg b/samples/shader-terrain/textures/skybox.jpg
new file mode 100644
index 0000000000..1092bc6aae
Binary files /dev/null and b/samples/shader-terrain/textures/skybox.jpg differ