Project

General

Profile

« Previous | Next » 

Revision 9fb802ce

Added by Leszek Koltunski 4 days ago

  • ID 9fb802ce73a78a688d935f7ed3c036149777d61d
  • Parent 35268ac9

simplifications

View differences:

src/main/java/org/distorted/library/main/DistortedFramebuffer.kt
60 60
                    GLES.glTexParameteri(GLES.GL_TEXTURE_2D, GLES.GL_TEXTURE_WRAP_T, GLES.GL_REPEAT)
61 61
                    GLES.glTexParameterf(GLES.GL_TEXTURE_2D, GLES.GL_TEXTURE_MIN_FILTER, GLES.GL_NEAREST.toFloat())
62 62
                    GLES.glTexParameterf(GLES.GL_TEXTURE_2D, GLES.GL_TEXTURE_MAG_FILTER, GLES.GL_LINEAR.toFloat())
63
                    GLES.glTexImage2D(GLES.GL_TEXTURE_2D, 0, GLES.GL_RGBA, mRealWidth, mRealHeight, 0, GLES.GL_RGBA, GLES.GL_UNSIGNED_BYTE, null)
63
                    GLES.glTexImage2D(GLES.GL_TEXTURE_2D, 0, GLES.GL_RGBA, mRealWidth, mRealHeight, 0, GLES.GL_RGBA, GLES.GL_UNSIGNED_BYTE)
64 64
                }
65 65

  
66 66
                GLES.glFramebufferTexture2D(GLES.GL_FRAMEBUFFER, GLES.GL_COLOR_ATTACHMENT0, GLES.GL_TEXTURE_2D, mColorH!![i*mNumColors], 0)
......
88 88

  
89 89
                if (mDepthStencil==DEPTH_NO_STENCIL)
90 90
                {
91
                    GLES.glTexImage2D(GLES.GL_TEXTURE_2D, 0, GLES.GL_DEPTH_COMPONENT, mRealWidth, mRealHeight, 0, GLES.GL_DEPTH_COMPONENT, GLES.GL_UNSIGNED_INT, null)
91
                    GLES.glTexImage2D(GLES.GL_TEXTURE_2D, 0, GLES.GL_DEPTH_COMPONENT, mRealWidth, mRealHeight, 0, GLES.GL_DEPTH_COMPONENT, GLES.GL_UNSIGNED_INT)
92 92
                }
93 93
                else if (mDepthStencil==BOTH_DEPTH_STENCIL)
94 94
                {
95
                    GLES.glTexImage2D(GLES.GL_TEXTURE_2D, 0, GLES.GL_DEPTH24_STENCIL8, mRealWidth, mRealHeight, 0, GLES.GL_DEPTH_STENCIL, GLES.GL_UNSIGNED_INT_24_8, null)
95
                    GLES.glTexImage2D(GLES.GL_TEXTURE_2D, 0, GLES.GL_DEPTH24_STENCIL8, mRealWidth, mRealHeight, 0, GLES.GL_DEPTH_STENCIL, GLES.GL_UNSIGNED_INT_24_8)
96 96
                }
97 97
            }
98 98
            GLES.glBindTexture(GLES.GL_TEXTURE_2D, 0)
src/main/java/org/distorted/library/platform/GLES.kt
293 293
   {
294 294
        GLES31.glTexParameterf(target, pname, param)
295 295
   }
296
   fun glTexImage2D(target: Int, level: Int, internalformat: Int, width: Int, height: Int, border: Int, format: Int, type: Int, pixels: NativeBuffer?)
296
   fun glTexImage2D(target: Int, level: Int, internalformat: Int, width: Int, height: Int, border: Int, format: Int, type: Int)
297 297
   {
298
        GLES31.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels?.bb)
298
        GLES31.glTexImage2D(target, level, internalformat, width, height, border, format, type, null)
299 299
   }
300 300
   fun glDisable(cap: Int)
301 301
   {
src/main/java/org/distorted/library/platform/NativeBitmap.kt
55 55
        bitmap = bmp
56 56
    }
57 57

  
58
    fun getW(): Int = if( bitmap==null ) 0 else bitmap!!.width
59
    fun getH(): Int = if( bitmap==null ) 0 else bitmap!!.height
58
    fun getW(): Int = bitmap?.width  ?: 0
59
    fun getH(): Int = bitmap?.height ?: 0
60 60

  
61 61
    fun flip()
62 62
    {
......
72 72

  
73 73
    fun createARGB(w: Int, h: Int, argb: Int)
74 74
    {
75
        bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
76
        canvas = Canvas(bitmap!!)
75 77
        paint = paint ?: Paint()
76 78
        paint!!.color = argb
77 79
        paint!!.style = Paint.Style.FILL
78
        bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
79
        canvas = Canvas(bitmap!!)
80 80
        canvas!!.drawRect(0f, 0f, w.toFloat(), h.toFloat(), paint!!)
81 81
    }
82 82

  
src/main/java/org/distorted/library/platform/NativeBuffer.kt
29 29

  
30 30
class NativeBuffer()
31 31
{
32
    var bb: ByteBuffer?  = null
33 32
    var ib: IntBuffer?   = null
34 33
    var fb: FloatBuffer? = null
35 34

  
36 35
    constructor(b: IntArray): this()
37 36
    {
38 37
        ib = ByteBuffer.allocateDirect(4*b.size).order(ByteOrder.nativeOrder()).asIntBuffer()
39
        ib!!.put(b).position(0)
38
        update(b)
40 39
    }
41 40

  
42 41
    constructor(b: FloatArray) : this()
43 42
    {
44 43
        fb = ByteBuffer.allocateDirect(4*b.size).order(ByteOrder.nativeOrder()).asFloatBuffer()
45
        fb!!.put(b).position(0)
44
        update(b)
46 45
    }
47 46

  
48
    fun update(b: FloatArray?)
49
    {
50
        fb?.put(b)?.position(0)
51
    }
47
    fun update(b: FloatArray?) = fb?.put(b)?.position(0)
48
    fun update(b: IntArray?)   = ib?.put(b)?.position(0)
52 49

  
53
    fun update(b: IntArray?)
54
    {
55
        ib?.put(b)?.position(0)
56
    }
57 50
}

Also available in: Unified diff