update consts

This commit is contained in:
Arnold 2019-06-06 10:02:12 +08:00
parent c616fdce85
commit 58269d2ce2
No known key found for this signature in database
GPG Key ID: 2008D1CC4BD1AE60
7 changed files with 32 additions and 54 deletions

View File

@ -235,7 +235,7 @@ local function Issue631()
--bf.src = GL_SRC_ALPHA
--bf.dst = GL_ONE_MINUS_SRC_ALPHA
fog:setBlendFunc(cc.blendFunc(gl.SRC_ALPHA , gl.ONE_MINUS_SRC_ALPHA))
fog:setBlendFunc(cc.blendFunc(ccb.BlendFactor.SRC_ALPHA , ccb.BlendFactor.ONE_MINUS_SRC_ALPHA))
layer2:addChild(fog, 1)
ret:addChild(layer2BaseGrid, 1)
layer2BaseGrid:addChild(layer2)

View File

@ -407,11 +407,11 @@ local function LayerTestBlend()
local dst = 0
if blend then
src = gl.SRC_ALPHA
dst = gl.ONE_MINUS_SRC_ALPHA
src = ccb.BlendFactor.SRC_ALPHA
dst = ccb.BlendFactor.ONE_MINUS_SRC_ALPHA
else
src = gl.ONE_MINUS_DST_COLOR
dst = gl.ZERO
src = ccb.BlendFactor.ONE_MINUS_DST_COLOR
dst = ccb.BlendFactor.ZERO
end
layer:setBlendFunc(cc.blendFunc(src, dst))
@ -626,7 +626,7 @@ local function LayerExtendedBlendOpacityTest()
layer3:setEndColor(cc.c3b(255, 0, 255))
layer3:setStartOpacity(255)
layer3:setEndOpacity(255)
layer3:setBlendFunc(cc.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA))
layer3:setBlendFunc(cc.blendFunc(ccb.BlendFactor.SRC_ALPHA, ccb.BlendFactor.ONE_MINUS_SRC_ALPHA))
ret:addChild(layer3)
return ret
end

View File

@ -603,7 +603,7 @@ local function NodeOpaqueTest()
for i = 0, 49 do
local background = cc.Sprite:create("Images/background1.png")
background:setBlendFunc(cc.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA))
background:setBlendFunc(cc.blendFunc(ccb.BlendFactor.ONE, ccb.BlendFactor.ONE_MINUS_SRC_ALPHA))
background:setAnchorPoint(cc.p(0, 0))
layer:addChild(background)
end
@ -621,7 +621,7 @@ local function NodeNonOpaqueTest()
for i = 0, 49 do
background = cc.Sprite:create("Images/background1.jpg")
background:setBlendFunc(cc.blendFunc(gl.ONE, gl.ZERO))
background:setBlendFunc(cc.blendFunc(ccb.BlendFactor.ONE, ccb.BlendFactor.ZERO))
background:setAnchorPoint(cc.p(0, 0))
layer:addChild(background)
end

View File

@ -1542,7 +1542,7 @@ local function PremultipliedAlphaTest()
emitter = cc.ParticleSystemQuad:create("Particles/BoilingFoam.plist")
emitter:retain()
emitter:setBlendFunc(cc.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA))
emitter:setBlendFunc(cc.blendFunc(ccb.BlendFactor.ONE, ccb.BlendFactor.ONE_MINUS_SRC_ALPHA))
--assert(emitter:getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless")

View File

@ -342,7 +342,7 @@ function Scene3DTest:create3DWorld()
"Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")
--set texture parameters
local tRepeatParams = { magFilter = ccb.SamplerFilter.LINEAR , minFilter = ccb.SamplerFilter.LINEAR , wrapS = ccb.SamplerAddressMode.MIRRORED_REPEAT , wrapT = ccb.SamplerAddressMode.MIRRORED_REPEAT }
local tRepeatParams = { magFilter = ccb.SamplerFilter.LINEAR , minFilter = ccb.SamplerFilter.LINEAR , sAddressMode = ccb.SamplerAddressMode.MIRRORED_REPEAT , tAddressMode = ccb.SamplerAddressMode.MIRRORED_REPEAT }
self._textureCube:setTexParameters(tRepeatParams)
--pass the texture sampler to our custom shader

View File

@ -1192,28 +1192,6 @@ function Sprite3DCubeMapTest:addNewSpriteWithCoords(pos)
self:addChild(camera)
self:setCameraMask(2)
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
if targetPlatform == cc.PLATFORM_OS_ANDROID or targetPlatform == cc.PLATFORM_OS_WINRT or targetPlatform == cc.PLATFORM_OS_WP8 then
self._backToForegroundListener = cc.EventListenerCustom:create("event_renderer_recreated", function (eventCustom)
local state = self._teapot:getGLProgramState()
local glProgram = state:getGLProgram()
glProgramreset()
glProgram:initWithFilenames("Sprite3DTest/cube_map.vert", "Sprite3DTest/cube_map.frag")
glProgram:link()
glProgram:updateUniforms()
self._textureCube:reloadTexture()
local tRepeatParams = { magFilter=gl.NEAREST , minFilter=gl.NEAREST , wrapS=gl.MIRRORED_REPEAT , wrapT=gl.MIRRORED_REPEAT }
self._textureCube:setTexParameters(tRepeatParams)
state:setUniformTexture("u_cubeTex", self._textureCube)
self._skyBox:reload()
self._skyBox:setTexture(self._textureCube)
end)
cc.Director:getInstance():getEventDispatcher():addEventListenerWithFixedPriority(self._backToForegroundListener, -1)
end
end
----------------------------------------

View File

@ -92,7 +92,7 @@ local function TextureMipMap()
local texture0 = cc.Director:getInstance():getTextureCache():addImage(
"Images/grossini_dance_atlas.png")
texture0:generateMipmap()
texture0:setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE)
texture0:setTexParameters(ccb.SamplerFilter.LINEAR_MIPMAP_LINEAR, ccb.SamplerFilter.LINEAR, ccb.SamplerAddressMode.CLAMP_TO_EDGE, ccb.SamplerAddressMode.CLAMP_TO_EDGE)
local texture1 = cc.Director:getInstance():getTextureCache():addImage(
"Images/grossini_dance_atlas_nomipmap.png")
@ -131,12 +131,12 @@ local function TexturePVRMipMap()
local s = cc.Director:getInstance():getWinSize()
local imgMipMap = cc.Sprite:create("Images/logo-mipmap.pvr")
if imgMipMap ~= nil then
if imgMipMap ~= nil and imgMipMap:getTexture() ~= nil then
imgMipMap:setPosition(cc.p( s.width/2.0-100, s.height/2.0))
ret:addChild(imgMipMap)
-- support mipmap filtering
imgMipMap:getTexture():setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE)
imgMipMap:getTexture():setTexParameters(ccb.SamplerFilter.LINEAR_MIPMAP_LINEAR, ccb.SamplerFilter.LINEAR, ccb.SamplerAddressMode.CLAMP_TO_EDGE, ccb.SamplerAddressMode.CLAMP_TO_EDGE)
end
local img = cc.Sprite:create("Images/logo-nomipmap.pvr")
@ -173,7 +173,7 @@ local function TexturePVRMipMap2()
ret:addChild(imgMipMap)
-- support mipmap filtering
imgMipMap:getTexture():setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE)
imgMipMap:getTexture():setTexParameters(ccb.SamplerFilter.LINEAR_MIPMAP_LINEAR, ccb.SamplerFilter.LINEAR, ccb.SamplerAddressMode.CLAMP_TO_EDGE, ccb.SamplerAddressMode.CLAMP_TO_EDGE)
local img = cc.Sprite:create("Images/test_image.png")
img:setPosition(cc.p( s.width/2.0+100, s.height/2.0))
@ -779,9 +779,9 @@ local function TextureAlias()
local s = cc.Director:getInstance():getWinSize()
--
-- Sprite 1: gl.LINEAR
-- Sprite 1: ccb.SamplerFilter.LINEAR
--
-- Default filter is gl.LINEAR
-- Default filter is ccb.SamplerFilter.LINEAR
local sprite = cc.Sprite:create("Images/grossinis_sister1.png")
sprite:setPosition(cc.p( s.width/3.0, s.height/2.0))
@ -927,21 +927,21 @@ local function TextureBlend()
local cloud = cc.Sprite:create("Images/test_blend.png")
ret:addChild(cloud, i+1, 100+i)
cloud:setPosition(cc.p(50+25*i, 80))
cloud:setBlendFunc(cc.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA))
cloud:setBlendFunc(cc.blendFunc(ccb.BlendFactor.ONE, ccb.BlendFactor.ONE_MINUS_SRC_ALPHA))
-- CENTER sprites have also alpha pre-multiplied
-- they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
cloud = cc.Sprite:create("Images/test_blend.png")
ret:addChild(cloud, i+1, 200+i)
cloud:setPosition(cc.p(50+25*i, 160))
cloud:setBlendFunc(cc.blendFunc(gl.ONE_MINUS_DST_COLOR , gl.ZERO))
cloud:setBlendFunc(cc.blendFunc(ccb.BlendFactor.ONE_MINUS_DST_COLOR , ccb.BlendFactor.ZERO))
-- UPPER sprites are using custom blending function
-- You can set any blend function to your sprites
cloud = cc.Sprite:create("Images/test_blend.png")
ret:addChild(cloud, i+1, 200+i)
cloud:setPosition(cc.p(50+25*i, 320-80))
cloud:setBlendFunc(cc.blendFunc(gl.SRC_ALPHA, gl.ONE)) -- additive blending
cloud:setBlendFunc(cc.blendFunc(ccb.BlendFactor.SRC_ALPHA, ccb.BlendFactor.ONE)) -- additive blending
end
return ret
end
@ -1033,7 +1033,7 @@ local function TextureGlClamp()
local sprite = cc.Sprite:create("Images/pattern1.png", cc.rect(0,0,512,256))
ret:addChild(sprite, -1, kTagSprite1)
sprite:setPosition(cc.p(size.width/2,size.height/2))
sprite:getTexture():setTexParameters(gl.LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE)
sprite:getTexture():setTexParameters(ccb.SamplerFilter.LINEAR, ccb.SamplerFilter.LINEAR, ccb.SamplerAddressMode.CLAMP_TO_EDGE, ccb.SamplerAddressMode.CLAMP_TO_EDGE)
local rotate = cc.RotateBy:create(4, 360)
sprite:runAction(rotate)
@ -1058,7 +1058,7 @@ end
--
--------------------------------------------------------------------
local function TextureGlRepeat()
local ret = createTestLayer("Texture gl.REPEAT")
local ret = createTestLayer("Texture ccb.SamplerFilter.REPEAT")
local size = cc.Director:getInstance():getWinSize()
@ -1067,7 +1067,7 @@ local function TextureGlRepeat()
local sprite = cc.Sprite:create("Images/pattern1.png", cc.rect(0, 0, 4096, 4096))
ret:addChild(sprite, -1, kTagSprite1)
sprite:setPosition(cc.p(size.width/2,size.height/2))
sprite:getTexture():setTexParameters(gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT)
sprite:getTexture():setTexParameters(ccb.SamplerFilter.LINEAR, ccb.SamplerFilter.LINEAR, ccb.SamplerAddressMode.REPEAT, ccb.SamplerAddressMode.REPEAT)
local rotate = cc.RotateBy:create(4, 360)
sprite:runAction(rotate)
@ -1198,11 +1198,11 @@ local function TextureDrawAtPoint()
m_pTex1:retain()
m_pTex2F:retain()
local glNode = gl.glNodeCreate()
glNode:setContentSize(cc.size(256, 256))
glNode:setAnchorPoint(cc.p(0, 0))
glNode:registerScriptDrawHandler(draw)
ret:addChild(glNode)
--local glNode = gl.glNodeCreate()
--glNode:setContentSize(cc.size(256, 256))
--glNode:setAnchorPoint(cc.p(0, 0))
--glNode:registerScriptDrawHandler(draw)
--ret:addChild(glNode)
local function onNodeEvent(event)
if event == "exit" then
@ -1244,11 +1244,11 @@ local function TextureDrawInRect()
m_pTex1:retain()
m_pTex2F:retain()
local glNode = gl.glNodeCreate()
glNode:setContentSize(cc.size(256, 256))
glNode:setAnchorPoint(cc.p(0, 0))
glNode:registerScriptDrawHandler(draw)
ret:addChild(glNode)
--local glNode = gl.glNodeCreate()
--glNode:setContentSize(cc.size(256, 256))
--glNode:setAnchorPoint(cc.p(0, 0))
--glNode:registerScriptDrawHandler(draw)
--ret:addChild(glNode)
local function onNodeEvent(event)
if event == "exit" then