2014-12-10 15:52:37 +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 ebiten
|
|
|
|
|
|
|
|
import (
|
2014-12-14 10:34:47 +01:00
|
|
|
"github.com/go-gl/gl"
|
2014-12-10 15:52:37 +01:00
|
|
|
"image"
|
|
|
|
)
|
|
|
|
|
2014-12-14 14:05:44 +01:00
|
|
|
// IsKeyPressed returns a boolean indicating whether key is pressed.
|
2014-12-14 09:28:19 +01:00
|
|
|
func IsKeyPressed(key Key) bool {
|
2014-12-14 10:57:29 +01:00
|
|
|
return currentUI.input.isKeyPressed(key)
|
2014-12-14 09:28:19 +01:00
|
|
|
}
|
|
|
|
|
2014-12-14 14:05:44 +01:00
|
|
|
// CursorPosition returns a position of a mouse cursor.
|
2014-12-14 09:28:19 +01:00
|
|
|
func CursorPosition() (x, y int) {
|
2014-12-14 10:57:29 +01:00
|
|
|
return currentUI.input.cursorPosition()
|
2014-12-14 09:28:19 +01:00
|
|
|
}
|
|
|
|
|
2014-12-14 14:05:44 +01:00
|
|
|
// IsMouseButtonPressed returns a boolean indicating whether mouseButton is pressed.
|
2014-12-14 09:28:19 +01:00
|
|
|
func IsMouseButtonPressed(mouseButton MouseButton) bool {
|
2014-12-14 10:57:29 +01:00
|
|
|
return currentUI.input.isMouseButtonPressed(mouseButton)
|
2014-12-14 10:34:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func glFilter(f Filter) int {
|
|
|
|
switch f {
|
|
|
|
case FilterNearest:
|
|
|
|
return gl.NEAREST
|
|
|
|
case FilterLinear:
|
|
|
|
return gl.LINEAR
|
|
|
|
default:
|
|
|
|
panic("not reached")
|
|
|
|
}
|
2014-12-14 09:28:19 +01:00
|
|
|
}
|
|
|
|
|
2014-12-14 14:05:44 +01:00
|
|
|
// NewRenderTargetID returns a new RenderTargetID.
|
2014-12-14 09:28:19 +01:00
|
|
|
func NewRenderTargetID(width, height int, filter Filter) (RenderTargetID, error) {
|
2014-12-14 10:57:29 +01:00
|
|
|
return currentUI.newRenderTargetID(width, height, glFilter(filter))
|
2014-12-14 09:28:19 +01:00
|
|
|
}
|
|
|
|
|
2014-12-14 14:05:44 +01:00
|
|
|
// NewTextureID returns a new TextureID.
|
2014-12-14 09:28:19 +01:00
|
|
|
func NewTextureID(img image.Image, filter Filter) (TextureID, error) {
|
2014-12-14 10:57:29 +01:00
|
|
|
return currentUI.newTextureID(img, glFilter(filter))
|
2014-12-10 15:52:37 +01:00
|
|
|
}
|