Make Clp2 internal

This commit is contained in:
Hajime Hoshi 2013-06-23 02:42:13 +09:00
parent 420187b45b
commit e0b36010f7
3 changed files with 10 additions and 7 deletions

View File

@ -0,0 +1,3 @@
package opengl
var Clp2 = clp2

View File

@ -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()

View File

@ -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")