mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Make Clp2 internal
This commit is contained in:
parent
420187b45b
commit
e0b36010f7
3
graphics/opengl/export_test.go
Normal file
3
graphics/opengl/export_test.go
Normal file
@ -0,0 +1,3 @@
|
||||
package opengl
|
||||
|
||||
var Clp2 = clp2
|
@ -67,8 +67,8 @@ func (context *GraphicsContext) Fill(clr color.Color) {
|
||||
func (context *GraphicsContext) DrawRect(rect graphics.Rect, clr color.Color) {
|
||||
width := float32(context.currentOffscreenWidth)
|
||||
height := float32(context.currentOffscreenHeight)
|
||||
textureWidth := float32(Clp2(uint64(width)))
|
||||
textureHeight := float32(Clp2(uint64(height)))
|
||||
textureWidth := float32(clp2(uint64(width)))
|
||||
textureHeight := float32(clp2(uint64(height)))
|
||||
|
||||
// Normalize the coord between -1.0 and 1.0.
|
||||
x1 := float32(rect.X)/textureWidth*2.0 - 1.0
|
||||
@ -196,8 +196,8 @@ func (context *GraphicsContext) SetOffscreen(textureID graphics.TextureID) {
|
||||
func (context *GraphicsContext) setOffscreenFramebuffer(framebuffer C.GLuint,
|
||||
textureWidth, textureHeight int) {
|
||||
if framebuffer == context.mainFramebuffer {
|
||||
textureWidth = int(Clp2(uint64(context.screenWidth * context.screenScale)))
|
||||
textureHeight = int(Clp2(uint64(context.screenHeight * context.screenScale)))
|
||||
textureWidth = int(clp2(uint64(context.screenWidth * context.screenScale)))
|
||||
textureHeight = int(clp2(uint64(context.screenHeight * context.screenScale)))
|
||||
}
|
||||
|
||||
C.glFlush()
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Clp2(x uint64) uint64 {
|
||||
func clp2(x uint64) uint64 {
|
||||
x -= 1
|
||||
x |= (x >> 1)
|
||||
x |= (x >> 2)
|
||||
@ -29,8 +29,8 @@ type Texture struct {
|
||||
}
|
||||
|
||||
func createTexture(width, height int, pixels []uint8) *Texture {
|
||||
textureWidth := int(Clp2(uint64(width)))
|
||||
textureHeight := int(Clp2(uint64(height)))
|
||||
textureWidth := int(clp2(uint64(width)))
|
||||
textureHeight := int(clp2(uint64(height)))
|
||||
if pixels != nil {
|
||||
if width != textureWidth {
|
||||
panic("sorry, but width should be power of 2")
|
||||
|
Loading…
Reference in New Issue
Block a user