Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/generaloss/jpize-core
OpenGL Graphics Library
https://github.com/generaloss/jpize-core
graphics-library opengl
Last synced: 21 days ago
JSON representation
OpenGL Graphics Library
- Host: GitHub
- URL: https://github.com/generaloss/jpize-core
- Owner: generaloss
- License: agpl-3.0
- Created: 2024-09-19T15:14:33.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-10-30T20:06:06.000Z (21 days ago)
- Last Synced: 2024-10-30T20:34:36.413Z (21 days ago)
- Topics: graphics-library, opengl
- Language: Java
- Homepage:
- Size: 12.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Core Module](https://github.com/generaloss/jpize-core)
![jpize](logo.svg)---
## Getting Started
### Maven
```xmlio.github.generaloss
jpize-core
24.10.3```
### Gradle (Kotlin)
```kotlin
repositories {
mavenCentral()
}dependencies {
implementation("io.github.generaloss:jpize-core:24.10.3")
}
```---
## Examples
#### 1. Application
``` java
public class MyApp extends JpizeApplication {public static void main(String[] args) {
// create window context
Jpize.create(1280, 720, "Window Title")
.icon("/icon.png")
.build().setApp(new MyApp());
// run created contexts
Jpize.run();
}
public MyApp() { } // constructor calls before init()
@Override
public void init() { } // init() calls after Jpize.run();
@Override
public void update() { } // update loop
@Override
public void render() { } // render loop
@Override
public void resize(int width, int height) { } // calls when window resizes
@Override
public void dispose() { } // exit app
}
```#### 2. 2D Graphics:
``` java
TextureBatch batch = new TextureBatch(); // canvas for textures
Texture2D texture = new Texture2D("/texture.png");Gl.clearColorBuffer();
batch.setup();// rotate, shear and scale for subsequent textures
batch.rotate(angle);
batch.shear(angle_x, angle_y);
batch.scale(scale);
// draw texture
batch.draw(texture, x, y, width, height);
// draw rectangle
batch.drawRect(x, y, width, height, color);
batch.drawRect(x, y, width, height, r, g, b, a);
batch.drawRect(x, y, width, height, r, g, b);
batch.drawRect(x, y, width, height, alpha);batch.render();
```#### 3. Fonts:
``` java
// load
Font font = FontLoader.loadDefault();
Font font = FontLoader.loadFnt(path_or_resource, linearFilter);
Font font = FontLoader.loadTrueType(path_or_resource, size, charset, linearFilter);// options
font.options().scale = 1.5F;
font.options().rotation = 45;
font.options().italic = true;
font.options().invLineWrap = true;// bounds
float width = font.getTextWidth(line);
float height = font.getTextHeight(text);
Vec2f bounds = font.getBounds(text);// render
font.drawText(text, x, y);
font.drawText(batch, text, x, y);
Iterable iterable = font.iterable(text);
```#### 4. Input:
``` java
// mouse position
Jpize.getX()
Jpize.getY()// scroll
Jpize.input().getScroll()// mouse buttons
MouseBtn.LEFT.down()
MouseBtn.RIGHT.pressed()
MouseBtn.MIDDLE.up()// keys
Key.ENTER.pressed()
Key.ESCAPE.down()
Key.SPACE.up()// window
Jpize.getWidth()
Jpize.getHeight()// FPS & Delta Time
Jpize.getFPS()
Jpize.getDT()
```---
## Used libs:
* *[LWJGL3](https://github.com/LWJGL/lwjgl3)* (GLFW, OpenGL, STB)
* *[Jpize-Utils](https://github.com/generaloss/jpize-utils)*---
## Bugs and Feedback
For bugs, questions and discussions please use the [GitHub Issues](https://github.com/generaloss/jpize-engine/issues).