"supported rgb files?"

pull/12/head
hYdos 2020-02-26 17:04:52 +10:00
parent d8eb6d4df5
commit 4c6b1253ff
5 changed files with 31 additions and 10 deletions

View File

@ -3,15 +3,14 @@ package com.github.halotroop.litecraft;
import java.util.Random; import java.util.Random;
import com.github.halotroop.litecraft.screens.TitleScreen; import com.github.halotroop.litecraft.screens.TitleScreen;
import com.github.halotroop.litecraft.world.*; import com.github.halotroop.litecraft.world.World;
import com.github.hydos.ginger.engine.api.*; import com.github.hydos.ginger.engine.api.*;
import com.github.hydos.ginger.engine.api.game.*; import com.github.hydos.ginger.engine.api.game.*;
import com.github.hydos.ginger.engine.cameras.Camera; import com.github.hydos.ginger.engine.cameras.*;
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.elements.objects.*; import com.github.hydos.ginger.engine.elements.objects.*;
import com.github.hydos.ginger.engine.font.*; import com.github.hydos.ginger.engine.font.FontType;
import com.github.hydos.ginger.engine.io.Window; import com.github.hydos.ginger.engine.io.Window;
import com.github.hydos.ginger.engine.math.vectors.*; import com.github.hydos.ginger.engine.math.vectors.Vector3f;
import com.github.hydos.ginger.engine.obj.ModelLoader; import com.github.hydos.ginger.engine.obj.ModelLoader;
import com.github.hydos.ginger.engine.obj.shapes.StaticCube; import com.github.hydos.ginger.engine.obj.shapes.StaticCube;
import com.github.hydos.ginger.engine.render.MasterRenderer; import com.github.hydos.ginger.engine.render.MasterRenderer;
@ -42,7 +41,10 @@ public class Litecraft extends Game
TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/stonebrick.png"); TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/stonebrick.png");
StaticCube.scaleCube(1); StaticCube.scaleCube(1);
Player player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f)); Player player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f));
Camera camera = new Camera(new Vector3f(0, 0.1f, 0), player);
Camera camera = new FirstPersonCamera(player);
player.isVisible = false;
ginger3D = new Ginger(); ginger3D = new Ginger();
data = new GameData(player, camera, 30); data = new GameData(player, camera, 30);
data.handleGuis = false; data.handleGuis = false;

View File

@ -43,8 +43,9 @@ public class TitleScreen extends Screen
playButton.update(); playButton.update();
if (playButton.isClicked()) if (playButton.isClicked())
{ {
buildText.remove();
Window.lockMouse(); Window.lockMouse();
playButton.hide(elements); playButton.hide(Litecraft.getInstance().data.guis);
Litecraft.getInstance().onPlayButtonClick();//TODO: add world gui so it takes u to world creation place Litecraft.getInstance().onPlayButtonClick();//TODO: add world gui so it takes u to world creation place
//TODO: also add a texture to be rendered behind the gui as an option //TODO: also add a texture to be rendered behind the gui as an option
} }

View File

@ -0,0 +1,5 @@
package com.github.hydos.ginger.engine.render.texture;
public enum ColorDepth {
R,RG,RGB,RGBA
}

View File

@ -6,6 +6,7 @@ import static org.lwjgl.system.MemoryStack.stackPush;
import java.io.IOException; import java.io.IOException;
import java.nio.*; import java.nio.*;
import org.lwjgl.stb.STBImage;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
import com.github.hydos.ginger.engine.render.tools.IOUtil; import com.github.hydos.ginger.engine.render.tools.IOUtil;
@ -34,19 +35,22 @@ public class Image
img = stbi_load_from_memory(imageBuffer, w, h, comp, 0); img = stbi_load_from_memory(imageBuffer, w, h, comp, 0);
if (img == null) if (img == null)
{ throw new RuntimeException("Failed to load image: " + stbi_failure_reason()); } { throw new RuntimeException("Failed to load image: " + stbi_failure_reason()); }
return new Image(w.get(0), h.get(0), img); return new Image(w.get(0), h.get(0), img, comp);
} }
} }
private ByteBuffer image; private ByteBuffer image;
private int width, height; private int width, height;
private IntBuffer comp;
Image(int width, int heigh, ByteBuffer image) Image(int width, int heigh, ByteBuffer image, IntBuffer comp)
{ {
this.image = image; this.image = image;
this.height = heigh; this.height = heigh;
this.width = width; this.width = width;
this.comp = comp;
} }
public Image(String imagePath) public Image(String imagePath)
@ -77,6 +81,7 @@ public class Image
this.image = img; this.image = img;
this.width = w.get(0); this.width = w.get(0);
this.height = h.get(0); this.height = h.get(0);
this.comp = comp;
} }
} }
@ -87,4 +92,8 @@ public class Image
public int getWidth() public int getWidth()
{ return width; } { return width; }
public IntBuffer getComp() {
return comp;
}
} }

View File

@ -125,7 +125,11 @@ public class Loader
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10241, 9729.0f); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10241, 9729.0f);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10240, 9729.0f); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10240, 9729.0f);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, texture.getWidth(), texture.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, texture.getImage()); if(texture.getComp().get() == 3) {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, texture.getWidth(), texture.getHeight(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, texture.getImage());
}else {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, texture.getWidth(), texture.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, texture.getImage());
}
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
if (Window.glContext.GL_EXT_texture_filter_anisotropic) if (Window.glContext.GL_EXT_texture_filter_anisotropic)