Skip to content

Commit

Permalink
Javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJohnny committed Oct 25, 2023
1 parent d47f13a commit 36e4f06
Show file tree
Hide file tree
Showing 27 changed files with 148 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Adaptation for <code>java.desktop<code/>with swing and awt.
* {@code java-desktop@pjgl} <br><br>
* PJGL adaptation that uses {@code java.desktop} module. That means: {@link java.awt} and {@link javax.swing}.
*/
package com.panjohnny.pjgl.adapt.desktop;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWKeyCallbackI;

/**
* Keyboard implementation using GLFW.
*
* @author PanJohnny
*/
@Adaptation("lwjgl@pjgl")
public class GLFWKeyboard implements KeyboardAdapter, GLFWKeyCallbackI {
private final boolean[] keys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import com.panjohnny.pjgl.adapt.Adaptation;

/**
* Provides constants shared across this adaptation.
* @author PanJohnny
*/
@SuppressWarnings("unused")
@Adaptation("lwjgl@pjgl")
public class LWJGLConstants {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import static org.lwjgl.glfw.GLFW.*;

/**
* An initializer for quickly starting your project with LWJGL adaptation
* An initializer for quickly starting your project with LWJGL adaptation.
* @author PanJohnny
*/
@Adaptation("lwjgl@pjgl")
public class LWJGLInitializer implements PJGLInitializer {
Expand Down
30 changes: 29 additions & 1 deletion src/main/java/com/panjohnny/pjgl/adapt/lwjgl/OpenGLRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.panjohnny.pjgl.api.PJGL;
import com.panjohnny.pjgl.api.PJGLEvents;
import com.panjohnny.pjgl.api.asset.Sprite;
import com.panjohnny.pjgl.api.asset.atlas.AtlasRegion;
import com.panjohnny.pjgl.api.asset.SpriteRegistry;
import com.panjohnny.pjgl.api.asset.atlas.AtlasRegion;
import com.panjohnny.pjgl.api.camera.OrthographicCamera2D;
import com.panjohnny.pjgl.api.object.GameObject;
import com.panjohnny.pjgl.api.object.components.Position;
Expand Down Expand Up @@ -34,7 +34,21 @@
import static org.lwjgl.opengl.GL11C.glEnable;

/**
* <h1>Rendering with OpenGL</h1>
* <h2>Default states</h2>
* <ul>
* <li>{@code GL_TEXTURE_2D}</li>
* <li>{@code GL_TRIANGLES}</li>
* <li>{@code GL_BLEND}</li>
* </ul>
* <aside>The blend function used is {@code GL_ONE_MINUS_SRC_ALPHA}.</aside>
* <h2>Rendering</h2>
* <p>Uses orthographic view to render objects. Supports rendering {@link com.panjohnny.pjgl.api.asset.atlas.TextureAtlas} and {@link Sprite} of type Integer.</p>
* <aside>Provides minimal functionality to {@link G2DRenderer} as: on first render it attempts to draw the result of render function, the result is saved as an temporary file and the render is never repeated.</aside>
*
* @apiNote This renderer is really simple and I advise you to check the source code. If you are not happy with the result and capabilities create your own.
* @author PanJohnny
* @see OpenGLOrthographicCamera
*/
@Adaptation("lwjgl@pjgl")
public class OpenGLRenderer implements RendererAdapter {
Expand Down Expand Up @@ -191,6 +205,20 @@ public OrthographicCamera2D getCamera() {
return cam;
}

/**
* Provides the functionality as a orthographic camera. Uses the following functions:
* <pre>
* {@code
* glMatrixMode(GL_PROJECTION);
* glLoadIdentity();
* glViewport(0, 0, windowWidth, windowHeight);
* glOrtho(0.0f, windowWidth, windowHeight, 0.0f, 0.0f, 1.0f);
* glTranslated(transformX, transformY, 0);
* glScaled(scaleX, scaleY, 0);
* }
* </pre>
* @author PanJohnny
*/
public static class OpenGLOrthographicCamera extends OrthographicCamera2D {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* {@code lwjgl@pjgl} <br><br>
* PJGL adaptation that uses {@link org.lwjgl}.
*
* @see com.panjohnny.pjgl.adapt.lwjgl.OpenGLRenderer
*/
package com.panjohnny.pjgl.adapt.lwjgl;
7 changes: 7 additions & 0 deletions src/main/java/com/panjohnny/pjgl/adapt/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Contains default adaptations. The {@link com.panjohnny.pjgl.adapt.Adaptation} annotation is so to be present on every adaptation class.
*
* @see com.panjohnny.pjgl.adapt.lwjgl.LWJGLInitializer
* @see com.panjohnny.pjgl.adapt.desktop.JDInitializer
*/
package com.panjohnny.pjgl.adapt;
8 changes: 8 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/asset/Animation.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
import java.util.List;
import java.util.function.BiConsumer;

/**
* Create animations!
*
* @see Animation#loadFromJson(String, BiConsumer)
* @see AnimationBuilder
*
* @author PanJohnny
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public class Animation {
private final String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* <h2>Texture Sprites</h2>
* <p>These sprites contain integer representing OpenGL texture.</p>
* <p>Register them with {@link #registerTextureSprite(String, String)}. This method supports loading from filesystem.</p>
* @author PanJohnny
*/
@SuppressWarnings("unused")
public final class SpriteRegistry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.panjohnny.pjgl.api.asset.Sprite;

/**
* @author PanJohnny
*/
public class AtlasRegion extends Sprite<Integer> {
private final float offsetX;
private final float offsetY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import com.panjohnny.pjgl.api.asset.Sprite;

/**
* Texture atlases are used to optimize rendering.
*
* @apiNote Only for LWJGL
* @author PanJohnny
*/
public class TextureAtlas extends Sprite<Integer> {
private final int width, height;
public TextureAtlas(String id, Integer image, int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Use texture atlas to optimize rendering.
*
* @see com.panjohnny.pjgl.api.asset.atlas.TextureAtlas
*/
package com.panjohnny.pjgl.api.asset.atlas;
7 changes: 7 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/asset/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Asset handling and animations.
*
* @see com.panjohnny.pjgl.api.asset.SpriteRegistry
* @see com.panjohnny.pjgl.api.asset.atlas
*/
package com.panjohnny.pjgl.api.asset;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/**
* Simple orthographic camera implementation. Override {@link #apply(Object)} to apply effects.
*
* @since v0.3.7-alpha
* @since 0.3.7-alpha
* @author PanJohnny
*/
@SuppressWarnings("unused")
public abstract class OrthographicCamera2D {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/camera/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Camera<s>(s)</s> to be implemented by an adaptation.
*/
package com.panjohnny.pjgl.api.camera;
6 changes: 6 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/event/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* PJGL uses event based system to communicate.
*
* @see com.panjohnny.pjgl.api.event.PJGLEvent
*/
package com.panjohnny.pjgl.api.event;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Component that handles animations. Requires SpriteRenderer to be present on the owner.
*
* @author PanJohnny
*/
@SuppressWarnings("unused")
public class Animator extends Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Components that you can add to objects to make them better and stronger!
*/
package com.panjohnny.pjgl.api.object.components;
4 changes: 4 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/object/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Objects and stuff, what can I say?
*/
package com.panjohnny.pjgl.api.object;
6 changes: 6 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Classes to be used as an API to interact with PJGL.
*
* @see com.panjohnny.pjgl.api.PJGL
*/
package com.panjohnny.pjgl.api;
4 changes: 4 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
* Utility to resolve the hardest question of java programmer. To resource, or to file? Obviously it depends on the use case, but I need to write some silly stuff somewhere eh.
* @author PanJohnny
*/
public final class FileUtil {
public static InputStream resolveFileOrResource(String path) throws FileNotFoundException{
// attempt to load resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import java.io.*;
import java.util.Base64;

/**
* I heard there was java serialization, so here I am... Maybe networking someday?
*
* @author PanJohnny
*/
@SuppressWarnings("unused")
public final class SerializationUtil {
/**
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/panjohnny/pjgl/api/util/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import javax.sound.sampled.*;

/**
* Class for playing music
* Class for playing music, well umm not OpenAL tho... Coming soon?
* <aside>This class uses {@link javax.sound.sampled}.</aside>
*
* @author PanJohnny
*/
@SuppressWarnings("unused")
public class Track {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/panjohnny/pjgl/api/util/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* (Hopefully) useful utilities.
*/
package com.panjohnny.pjgl.api.util;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Elsa, do you want to build an adapter?
*/
package com.panjohnny.pjgl.core.adapters;
6 changes: 6 additions & 0 deletions src/main/java/com/panjohnny/pjgl/core/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* The libraries core.
*
* @see com.panjohnny.pjgl.core.EngineOptions
*/
package com.panjohnny.pjgl.core;
6 changes: 6 additions & 0 deletions src/main/java/com/panjohnny/pjgl/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Contains all of PJGL.
*
* @see com.panjohnny.pjgl.api.PJGL PJGL to get started
*/
package com.panjohnny.pjgl;

0 comments on commit 36e4f06

Please sign in to comment.