Zero-overhead 2D rendering library for JOGL using Kotlin

Overview

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

You might also like...
A small game using Fleks Entity Component System.

Dinoleon TBD Credits Arks: Dino Sprites Szadi art: Platformer Fantasy Free Package craftpix.net: Jungle Cartoon GUI Soup of Justice Font cooltext.com

🎮 A Minesweeper like puzzle game, built using Jetpack Compose, for Android.
🎮 A Minesweeper like puzzle game, built using Jetpack Compose, for Android.

Minesweeper w/ Jetpack Compose This is a Minesweeper-like puzzle game, built using Jetpack Compose, for Android. The objective of this game is to clea

A non-linear problem solver using automatic differentiation and penalty methods.

HelixOptimizer Join the discord and contribute! https://discord.gg/kqe74EER A non-linear problem solver using automatic differentiation and penalty me

Legacy 1.x version of PlayN library.

PlayN is a cross-platform Java game development library written in Java that targets HTML5 browsers (via GWT), desktop JVMs, Android and iOS devices.

Game made with Korge (Kotlin Multiplatform game engine)

MolesAttack Kotlin Multiplatform Game Play Html/js: https://feliperce.github.io/MolesAttack-Distribution/ Jar: https://feliperce.github.io/MolesAttack

Sample source code for Android Pride Rainbow Bounding Box written in Kotlin and OpenGL 🏳️‍🌈

Sample Code for Animated Rainbow Bounding Box in OpenGL A sample app showing how to draw a rainbow bounding box on Android with OpenGL and Kotlin. Blo

 Android Kotlin: Matching Kitties: A Game Inspired by Cats
Android Kotlin: Matching Kitties: A Game Inspired by Cats

Android Kotlin: Matching Kitties: A Game Inspired by Cats A kotlin based Android memory game Screenshots | | | | | | | | | Viewing the App You can clo

Android Tetris + kotlin + jetpack compose
Android Tetris + kotlin + jetpack compose

Android Tetris + kotlin + jetpack compose

simple game implements with kotlin and jetpack.(covered by unit test)
simple game implements with kotlin and jetpack.(covered by unit test)

Simple Spy Game: Source Code 🚨 Published version 🚨 This repository contains a detailed game app that implements simple game using Koin, Room, Corout

Comments
  • Update for modern kotlin

    Update for modern kotlin

    Using version 1.0.1 I am getting this error:

    Class 'org.anglur.joglext.jogl2d.GLGraphics2D' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler

    opened by bryaan 1
Owner
Jonathan
Electron conductor
Jonathan
Wordle game clone written in Kotlin & using Compose UI Toolkit.

Wordle Compose Wordle game clone written in Kotlin & using Compose UI Toolkit. Screenshots Compose for Desktop Main screens Playing Victory End of gam

Olivier Patry 37 Nov 3, 2022
A simple game that was developed using Kotlin

TruthOrDare About the App: A simple Android game that reminds you of your childhood . How to use? 1 - Clone or download the Project to your machine. 2

Leandro Santos 1 Jan 15, 2022
🐦 A flappy bird clone using Compose Web and radio button

?? Compose Bird A flappy bird clone using Compose Web and radio buttons

theapache64 36 Dec 31, 2022
Our maze game is an 2d-animation game developed using android studio.

Our maze game is an 2d-animation game developed using android studio. The game consists of a ball and a board with a hole in the center of it. We are using accelerometer as controller to guide ball towards the hole. T

Suraj Devgan 6 Nov 29, 2022
Basic template to create a game using minigdx

MiniGDX Game Template Create your first game using miniGDX by clicking the "Use this Template" button above. The game will be configured for: the JVM

MiniGDX 22 Dec 16, 2022
Switch Snake implemented using Compose Desktop. Inspired by this tweet

?? switch-snake Switch Snake implemented using Compose Desktop. Inspired by this tweet ✨ Demo ??️ Play Demo in Full Quality ?? Run ./gradlew run ✍️ A

theapache64 128 Dec 24, 2022
A simple Snake game implemented using Compose for Desktop

A simple Snake game implemented using Compose for Desktop

Arkadii Ivanov 58 Dec 27, 2022
Tic Tac Toe game using Test Driven Development

Tic Tac Toe About this Kata This short and simple Kata should be performed using Test Driven Development (TDD). Rules The rules are described below :

null 0 Oct 11, 2021
A Sudoku Application using Graph Data Structure(Directed Colored Graph).

Project Overview Graph Sudoku is an application which was created with three goals in mind: Teach myself Jetpack Compose Teach myself Graph Datastruct

null 3 Aug 10, 2022
Fifteen is a puzzle game created using Jetpack Compose for Android.

Fifteen / Jetpack Compose Fifteen is a puzzle game created using Jetpack Compose for Android. The goal of the game is to arrange the knuckles in ascen

Timur 2 Jan 17, 2022