2014-12-31 10:23:18 +01:00
|
|
|
// Copyright 2014 Hajime Hoshi
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package opengl
|
|
|
|
|
2017-12-03 11:21:59 +01:00
|
|
|
type (
|
|
|
|
Filter int
|
|
|
|
ShaderType int
|
|
|
|
BufferType int
|
|
|
|
BufferUsage int
|
|
|
|
Mode int
|
|
|
|
operation int
|
|
|
|
)
|
2014-12-31 13:55:40 +01:00
|
|
|
|
2016-02-29 18:16:32 +01:00
|
|
|
type CompositeMode int
|
2016-02-28 16:25:16 +01:00
|
|
|
|
|
|
|
const (
|
2016-02-29 18:16:32 +01:00
|
|
|
CompositeModeSourceOver CompositeMode = iota // This value must be 0 (= initial value)
|
|
|
|
CompositeModeClear
|
|
|
|
CompositeModeCopy
|
|
|
|
CompositeModeDestination
|
|
|
|
CompositeModeDestinationOver
|
|
|
|
CompositeModeSourceIn
|
|
|
|
CompositeModeDestinationIn
|
|
|
|
CompositeModeSourceOut
|
|
|
|
CompositeModeDestinationOut
|
|
|
|
CompositeModeSourceAtop
|
|
|
|
CompositeModeDestinationAtop
|
|
|
|
CompositeModeXor
|
|
|
|
CompositeModeLighter
|
|
|
|
CompositeModeUnknown
|
2016-02-28 16:25:16 +01:00
|
|
|
)
|
|
|
|
|
2016-07-03 11:11:37 +02:00
|
|
|
func operations(mode CompositeMode) (src operation, dst operation) {
|
2016-02-28 16:25:16 +01:00
|
|
|
switch mode {
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeSourceOver:
|
2016-07-03 11:11:37 +02:00
|
|
|
return one, oneMinusSrcAlpha
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeClear:
|
2016-07-03 11:11:37 +02:00
|
|
|
return zero, zero
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeCopy:
|
2016-07-03 11:11:37 +02:00
|
|
|
return one, zero
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeDestination:
|
2016-07-03 11:11:37 +02:00
|
|
|
return zero, one
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeDestinationOver:
|
2016-07-03 11:11:37 +02:00
|
|
|
return oneMinusDstAlpha, one
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeSourceIn:
|
2016-07-03 11:11:37 +02:00
|
|
|
return dstAlpha, zero
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeDestinationIn:
|
2016-07-03 11:11:37 +02:00
|
|
|
return zero, srcAlpha
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeSourceOut:
|
2016-07-03 11:11:37 +02:00
|
|
|
return oneMinusDstAlpha, zero
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeDestinationOut:
|
2016-07-03 11:11:37 +02:00
|
|
|
return zero, oneMinusSrcAlpha
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeSourceAtop:
|
2016-07-03 11:11:37 +02:00
|
|
|
return dstAlpha, oneMinusSrcAlpha
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeDestinationAtop:
|
2016-07-03 11:11:37 +02:00
|
|
|
return oneMinusDstAlpha, srcAlpha
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeXor:
|
2016-07-03 11:11:37 +02:00
|
|
|
return oneMinusDstAlpha, oneMinusSrcAlpha
|
2016-02-29 18:16:32 +01:00
|
|
|
case CompositeModeLighter:
|
2016-07-03 11:11:37 +02:00
|
|
|
return one, one
|
2016-02-28 16:25:16 +01:00
|
|
|
default:
|
2017-12-03 11:21:59 +01:00
|
|
|
panic("not reached")
|
2016-02-28 16:25:16 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-22 09:52:58 +02:00
|
|
|
|
|
|
|
type DataType int
|
|
|
|
|
|
|
|
func (d DataType) SizeInBytes() int {
|
|
|
|
switch d {
|
|
|
|
case Short:
|
|
|
|
return 2
|
|
|
|
case Float:
|
|
|
|
return 4
|
|
|
|
default:
|
2017-12-03 11:21:59 +01:00
|
|
|
panic("not reached")
|
2016-10-22 09:52:58 +02:00
|
|
|
}
|
|
|
|
}
|