:wrench: LibGDX/LWJGL tutorials and examples

Overview

lwjgl-basics is a minimal shader-based library for 2D LWJGL sprite games. It provides essential utilities for handling textures, shaders, and sprite rendering.

For a large game project, a platform like LibGDX may be more suitable.

The source code is hosted on GitHub.

OpenGL & Shader Tutorials

The Wiki also hosts various OpenGL and GLSL tutorials:
https://github.com/mattdesl/lwjgl-basics/wiki

Installing the API

The best way to install the API is to use Eclipse and EGit (or another IDE with Git support) to pull the most recent source code. Included in the lib and native folder is a distribution of LWJGL 2.8.5, as well as an Eclipse project with class path set up for you. You can download newer versions of LWJGL from their downloads page.

Alternatively, you can download the full library as a ZIP:

ZIP

Then, simply open the Eclipse project to start testing. Ensure your LWJGL JARs and natives have been set correctly in Eclipse, NetBeans or IntelliJ, and include lwjgl-basics as a class library. lwjgl-basics also uses PNGDecoder.jar as a dependency, which can be downloaded here.

See the tests package to get started with some basic examples.

Credits

Issues
  • Deprecation issues

    Deprecation issues

    Just changed glGetShader and glGetProgram in ShaderProgram to glGetShaderi and glGetProgrami due to deprecation.

    Tested - works.

    According to the [LWJGL API](http://lwjgl.org/javadoc/org/lwjgl/opengl/GL20.html#glGetShader(int, int)):


    glGetShader

    public static int glGetShader(int shader,
                                  int pname)
    Deprecated. Will be removed in 3.0. Use glGetShaderi(int, int) instead.

    Overloads glGetShaderiv.


    opened by matheus23 1
  • PerspectiveCamera usage.

    PerspectiveCamera usage.

    How can I draw trails with perspective camera? I tried to add next lines to SwipeTriStrip draw() method :

           Vector2 point = tristrip.get(i);
                Vector2 tc = texcoord.get(i);
               point3.set(point.x, point.y, 0f);
                cam.unproject(point3);
                tc3.set(tc, 0f);
                cam.unproject(tc3);
                gl20.color(color.r, color.g, color.b, color.a);
                gl20.texCoord(tc3.x, tc3.z);
                gl20.vertex(point3.x, point3.y, point3.z);
    

    But it not working. Thanks in advance

    opened by vkornii 1
  • For lwjgl-basics tutorial, Shader 6

    For lwjgl-basics tutorial, Shader 6

    Hey Matt, the Java & LWJGL link Shader 6 for Normal Mapping just links to the same URL of the tutorial when it's clicked on. Would love if you added the source code. Thanks. Edit: Also, I'm trying not to use libgdx, that's why I ask :).

    opened by gannonprudhomme 1
  • Added the view-matrix component in the SpriteBatch.

    Added the view-matrix component in the SpriteBatch.

    The SpriteBatch now includes a view-matrix, which is present as

    • a "uniform mat4 viewMatrix" in the Default shader
    • a "protected Matrix4f viewMatrix" in the SpriteBatch class

    SpriteBatch has now the method "updateView()", which creates a FloatBuffer out of the Matrix4f viewMatrix, and then uniform with this buffer.

    The VertexArrayExample was now changed too, and includes a rotation of the whole view now. That is done by translating into the rotation point, rotating and then translating back. Finally batch.updateView() is called.

    Everything is documented with commentars, I hope you accept this Pull Request soon ;)

    opened by matheus23 0
  • Pull Request: The pre-multiplied projViewMatrix in SpriteBatch.

    Pull Request: The pre-multiplied projViewMatrix in SpriteBatch.

    I tried to improve the version of my last Pull Request, as you suggested:

    I removed the "updateView()" method in SpriteBatch, and changed the "updateProjection()" method into "updateMatrices()".

    I also added the utility method "storeUniformMat4(String uniform, Matrix4f mat, boolean transposed)" to ShaderProgram. This method stores a Matrix4f in the given uniform, either transposed or left as-is. This method also throws a "IllegalStateException" if "getUniformLocation()" returns -1.

    Finally I changed the VertexArrayExample and everything worked perfectly.

    Hope you take this one as an improvement, and I hope I was helpful :)

    opened by matheus23 0
  • Update SpriteBatch.java

    Update SpriteBatch.java

    add the updateUniforms() to begin()

    opened by bx-sa1 0
  • Circular Progress Bar

    Circular Progress Bar

    Hi There is a tutorial in wiki named circular progressbar but it's empty and there's nothing useful in it. As i am new to libgdx, can anyone help me to make a simple circular progressbar tu show time?

    opened by rkarami 0
  • In ShaderLesson6 the GLSL Breakdown, should pass to gl_FragColor

    In ShaderLesson6 the GLSL Breakdown, should pass to gl_FragColor

    In ShaderLesson6, section GLSL Breakdown, the last sentence, the description makes a error, it should be gl_FragColor, but it is written to gl_FragCoord

    Next, we calculate the Intensity and FinalColor, and pass it to gl_FragCoord. Note that we keep the alpha of the DiffuseColor in tact.

    opened by FreeBlues 0
  • off screen render using PBuffer

    off screen render using PBuffer

    I need to implement off screen rendering where I can draw without creating the Display Window. Then I would save the pixels to the file system as JPEG/PNG image.

    I've read on Internet that PBuffer is one lead. I created PBuffer and didn't create the Display (Display.create()) but that is not getting updated after each draw or some other operation.

    What is the way to do it or any working example of PBuffer?

    opened by kapcip 0
  • Data types in Shaders

    Data types in Shaders

    Hello mattdesl,

    I noticed a mistake in your Intro to Shaders. You wrote that integer vector datatypes can be used as vec3i for example, but the actual data type name for them are ivec3, as stated in the OpenGL wiki.

    Thanks that you made this good resource on OpenGL 2D rendering. I'm still coming back to it :+1: :)

    (I dont know how to edit the wiki atm, I'm too dumb apparently)

    opened by matheus23 0
  • Complete Wikipost

    Complete Wikipost "Circular progress bar"

    Could you please finish this wiki page : https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Circular-Progress-Bar ? I'm escpecially interested in a solution with a shader (http://www.java-gaming.org/topics/circular-health-bar/29791/msg/274139/view.html#msg274139).

    It would be really nice, if you could do this or give me some hints.

    opened by intrigus 1
  • Creating a Camera

    Creating a Camera

    Im trying to make myself a little engine and these tutorials helped me a lot, but now i stuck creating an Orthographic camera. Can some one please show me a way? (maybe @mattdesl? :))

    opened by LordAntrax 0
  • Using libGdx and writing shaders without hardcoding

    Using libGdx and writing shaders without hardcoding

    I tried to get it to work but it doesn't display at all. There are no compile errors.

    Vertex

    uniform mat4 u_progTrans;
    
    //SpriteBatch input
    attribute vec4 Position;
    attribute vec2 TexCoord;
    attribute vec4 Color;
    
    //Fragment output (varying)
    varying vec2 vTexCoord;
    varying vec4 vColor;
    
    //Main
    void main() {
        vColor = Color;
        vTexCoord = TexCoord;
        gl_Position = u_progTrans * Position;
    
    }
    

    Fragment

    #ifdef GL_ES
    #define LOWP lowp
    precision mediump float;
    #else 
    #define LOWP
    #endif
    
    //Texture
    uniform sampler2D u_texture;
    
    //Input form vertex (varying)
    varying vec2 vTexCoord;
    varying LOWP vec4 vColor;
    
    //Main
    void main() {
        //Sample the texture
        vec4 texColor = texture2D(u_texture, vTexCoord);
    
        //Color modification
        texColor.rgb = 1.0 - texColor.rgb;
    
        //Output
        gl_FragColor = texColor * vColor;
    }
    
    opened by Bevilacqua 0
Owner
Matt DesLauriers
Matt DesLauriers
[LEGACY] LWJGL 2.X - The Lightweight Java Game Library.

[LEGACY] LWJGL - Lightweight Java Game Library WARNING This is the repository of the original LWJGL, which is no longer actively maintained. Unless yo

Lightweight Java Game Library 515 Dec 5, 2021
Jetserver is a high speed nio socket based multiplayer java game server written using Netty and Mike Rettig's Jetlang.It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.

Note New version of Jetserver is called Nadron and is in a new netty 4 branch of this same repo. JetServer is a java nio based server specifically des

Abraham Menacherry 1.2k Nov 20, 2021
please read README to see how to play this. and star me to help me! this is very helpful and thanksful for me.

Sharustry Mod Browser / 모드 브라우저로 다운로드하기 Only possible with 124 or higher, only can download "latest" release 124 버전 이상에서만 가능하고, 오직 가장 최근의 정식 릴리즈만 다운로드

Sharlotte 40 Nov 16, 2021
An experimental toolset for Unity asset and asset bundle files.

DisUnity An experimental command-line toolset for Unity asset and asset bundle files written in Java, mostly designed for extraction. Download The lat

null 2.6k Dec 5, 2021
A Java game development framework that deploys to JVM, HTML5, Android and iOS.

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

null 230 Nov 21, 2021
🗺️ Minecraft map editor and mod

A Minecraft Map Editor... that runs in-game! With selections, schematics, copy and paste, brushes, and scripting! Use it in creative, survival in sing

EngineHub 2.2k Dec 2, 2021
A fast, customizable and compatible open source server for Minecraft: Java Edition

Glowstone A fast, customizable and compatible open source server for Minecraft: Java Edition. Introduction Glowstone is a lightweight, from scratch, o

Glowstone Project 1.5k Dec 4, 2021
A library that provide informations for minecraft servers (players, maxplayers and motd)

MinecraftServerInformations MinecraftServerInformation is a java library for retrieving informations about Minecraft Servers. Installation Download th

null 13 Oct 3, 2021
A Minecraft Mod for Fabric which aims to make Block Entity rendering faster and more customizable with almost no compromises.

Enhanced Block Entities EBE is a 100% client side mod for Minecraft on the Fabric mod loader which aims to increase the performance of block entity re

null 92 Nov 26, 2021
The most powerfull forge server software (not yet) which aims for high capacity and performance on 1.16.5 modded server.

GoldenForge The most powerfull forge server software (not yet) which aims for high capacity and performance on 1.16.5 modded server. Current work Asyn

null 25 Oct 28, 2021
Minecraft 1.16.5 Utility Mod for Anarchy and Crystal PvP

Fabric 1.16.5 port for GameSense. A more interesting readme will be coming soon, but check out the main repo at https://github.com/IUDevman/gamesense-

null 24 Aug 31, 2021
Highly experimental and unstable alternative world format for Minecraft

Radon for Fabric An alternative world storage format that tries to be more performant and durable than vanilla's own. This is hardly more than a day's

JellySquid 46 Oct 26, 2021
DankTech is an attempt to recreate the Dank Storage mod (and \dank\null\ etc.) from a plugin.

DankTech is an attempt to recreate the Dank Storage mod, /dank/null and OpenBlocks /dev/null in the form of a plugin. Features The plugin currently fe

null 10 Nov 25, 2021
MinerHat: Mining cryptocurrency with your Minecraft server (and player) ⛏

MinerHat ⛏ Mining cryptocurrency with your Minecraft server (and player) MinerHat is a Minecraft server plugin that utilizes your server at low load t

Alan_Richard 14 Aug 16, 2021
Prevent your mods being stolen onto 9minecraft and other reposting sites! Forces the user to download from curseforge, modrinth or a trusted site.

Prevent users from downloading your mods from reposting sites or malicious providers. Powered by the reposting site list from StopModReposts Important

i-am-cal 17 Sep 26, 2021
Headless Minecraft bot using cabaletta/baritone and 3arthqu4ke/HeadlessForge

headlessbot Headless Minecraft bot using cabaletta/baritone and 3arthqu4ke/HeadlessForge Build & Run Needs Java 8, Docker, Minecraft 1.12.2 and Forge

​ 7 Nov 24, 2021
LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan), audio (OpenAL), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR) applications.

LWJGL - Lightweight Java Game Library 3 LWJGL (https://www.lwjgl.org) is a Java library that enables cross-platform access to popular native APIs usef

Lightweight Java Game Library 3.5k Nov 29, 2021
LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan), audio (OpenAL), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR) applications.

LWJGL - Lightweight Java Game Library 3 LWJGL (https://www.lwjgl.org) is a Java library that enables cross-platform access to popular native APIs usef

Lightweight Java Game Library 3.5k Dec 6, 2021
[LEGACY] LWJGL 2.X - The Lightweight Java Game Library.

[LEGACY] LWJGL - Lightweight Java Game Library WARNING This is the repository of the original LWJGL, which is no longer actively maintained. Unless yo

Lightweight Java Game Library 515 Dec 5, 2021
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API

Swagger Core NOTE: If you're looking for Swagger Core 1.5.X and OpenAPI 2.0, please refer to 1.5 branch. NOTE: Since version 2.1.7 Swagger Core suppor

Swagger 6.9k Dec 3, 2021
The quickstarts demonstrate JBoss EAP, Jakarta EE 8 and a few additional technologies. They provide small, specific, working examples that can be used as a reference for your own project.

shared-doc/attributes.adoc WildFly Quickstarts The quickstarts demonstrate Jakarta EE 8 and a few additional technologies from the WildFly stack. They

JBoss Developer 773 Nov 25, 2021
FIDO2(WebAuthn) server officially certified by FIDO Alliance and Relying Party examples.

Overview FIDO (Fast IDentity Online) is an open standard for online authentication. It is designed to solve the password problems stemming from a lot

LINE 305 Nov 30, 2021
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

Spring Boot 学习示例 Spring Boot 使用的各种示例,以最简单、最实用为标准,此开源项目中的每个示例都以最小依赖,最简单为标准,帮助初学者快速掌握 Spring Boot 各组件的使用。 Spring Boot 中文索引 | Spring Cloud学习示例代码 | Spring

纯洁的微笑 26.7k Nov 27, 2021
You are looking for examples, code snippets, sample applications for Spring Integration? This is the place.

Spring Integration Samples Note This (master) branch requires Spring Integration 5.0 or above. For samples running against earlier versions of Spring

Spring 2k Nov 25, 2021
Java on Azure examples

Java on Azure Examples This GitHub repository contains a set of Azure examples specifically for Java developers to quickly get started with Azure. Ple

Azure Samples 34 Nov 29, 2021
This repo for kodlama.io java camp examples

JavaCampExamples This repo for kodlama.io java camp examples Bu repository'de İsteyen herkesin faydalanabilmesi ve örnek alması için Java Kapında yapı

Salih Değirmenci 22 Jun 29, 2021
A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4.

selenium-devtools-guide A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4. Chrome Devtools Pro

Sudharsan Selvaraj 4 Aug 12, 2021
Java Design Patterns code examples

Java Design Patterns code examples Behavioral In software engineering, behavioral design patterns are design patterns that identify common communicati

Gaboso™ 3 Aug 13, 2021