ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - jonatino/JOGL2D: Zero-overhead 2D rendering library for JOGL using Kotlin
Zero-overhead 2D rendering library for JOGL using Kotlin - jonatino/JOGL2D
Visit Site

GitHub - jonatino/JOGL2D: Zero-overhead 2D rendering library for JOGL using Kotlin

GitHub - jonatino/JOGL2D: Zero-overhead 2D rendering library for JOGL using Kotlin

JOGL2D

Zero-overhead 2D rendering library for JOGL

Build Status license

This library is licensed under Apache License 2.0.

JOGL2D is an open source Kotlin library that provides easy 2D graphics rendering capabilities to JOGL without adding any overhead whatsoever (memory/CPU). JOGL2D is a lightweight, resource friendly, stripped down version of brandonborkholder's glg2d.

How Can I Use JOGL2D?

Simply add JOGL2D to your JOGL application using your favourite dependancy management systems.

Gradle

compile 'org.anglur:joglext:1.0.3'

Maven

<dependency>
  <groupId>org.anglur</groupId>
  <artifactId>joglext</artifactId>
  <version>1.0.3</version>
</dependency>

Once added, it is very easy to implement. Start off by making a GLEventListener

object CharlatanoOverlay : GLEventListener {
    
    private val WINDOW_WIDTH = 500
    private val WINDOW_HEIGHT = 500
    private val FPS = 60
    
    val window = GLWindow.create(GLCapabilities(null))
    
    init {
        GLProfile.initSingleton()
    }
    
    fun open(width: Int = WINDOW_WIDTH, height: Int = WINDOW_HEIGHT, x: Int = 100, y: Int = 1000) {
        val animator = FPSAnimator(window, FPS, true)
        
        window.addWindowListener(object : WindowAdapter() {
            override fun windowDestroyNotify(e: WindowEvent) {
                thread {
                    if (animator.isStarted)
                        animator.stop()
                    exitProcess(0)
                }.start()
            }
        })
        
        window.addGLEventListener(this)
        window.setSize(width, height)
        window.setPosition(x, y)
        window.title = "Hello world"
        window.isVisible = true
        animator.start()
    }
    
    val g = GLGraphics2D() //Create GL2D wrapper
    
    override fun display(gLDrawable: GLAutoDrawable) {
        val gl2 = gLDrawable.gl.gL2
        
        gl2.glClear(GL.GL_COLOR_BUFFER_BIT)
        
        g.prePaint(gLDrawable.context) //Updated wrapper to latest glContext
        
        g.color = Color.RED
        g.drawRect(0, 0, 200, 200)
        g.color = Color.YELLOW
        g.drawLine(0, 0, 100, 100)
        g.color = Color.CYAN
        g.drawString("OpenGL 2D Made Easy! :D", 100, 100)
    }
    
    override fun init(glDrawable: GLAutoDrawable) {
    }
    
    override fun reshape(gLDrawable: GLAutoDrawable, x: Int, y: Int, width: Int, height: Int) {
        val gl = gLDrawable.gl.gL2
        gl.glViewport(0, 0, width, height)
    }
    
    override fun dispose(gLDrawable: GLAutoDrawable) {
        g.glDispose()
    }
}

Screenshots

Alt text

Huge credits again to @brandonborkholder for open sourcing his G2D library here: https://github.com/brandonborkholder/glg2d

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory