All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.huskerdev.grapl.gl.platforms.macos.NSGLContext.kt Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package com.huskerdev.grapl.gl.platforms.macos

import com.huskerdev.grapl.core.window.impl.MacWindowPeer
import com.huskerdev.grapl.gl.GLProfile

class NSGLContext(
    val nsglHandle: Long,
    cgl: CGLContext
): CGLContext(cgl.handle, cgl.majorVersion, cgl.minorVersion) {

    companion object {
        @JvmStatic private external fun nAttachToWindow(windowPtr: Long, contextPtr: Long): Long
        @JvmStatic private external fun nFlushBuffer(nsgl: Long)
        @JvmStatic private external fun nReleaseContext(nsgl: Long)

        @JvmStatic private external fun nSetSwapInterval(nsgl: Long, swapInterval: Int)

        fun createAttached(peer: MacWindowPeer, profile: GLProfile, shareWith: Long, majorVersion: Int, minorVersion: Int) =
            create(profile, shareWith, majorVersion, minorVersion).run {
                NSGLContext(nAttachToWindow(peer.handle, this.handle), this)
            }

    }

    override fun delete() =
        nReleaseContext(nsglHandle)

    fun flushBuffer() =
        nFlushBuffer(nsglHandle)

    fun setSwapInterval(swapInterval: Int) =
        nSetSwapInterval(nsglHandle, swapInterval)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy