Compare commits
No commits in common. "978614be36402128eab3520d32f5a21baf14faaf" and "44f5325f4e8b34d0a69f126a61f9ad8351a1155c" have entirely different histories.
978614be36
...
44f5325f4e
|
@ -1,18 +1,13 @@
|
|||
package com.danitheskunk.skunkworks;
|
||||
|
||||
import com.danitheskunk.skunkworks.gfx.Color;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Data {
|
||||
static final String[] vectorSeperators = new String[]{"x", ",", " "};
|
||||
private final LinkedHashMap<String, LinkedHashMap<String, String>> data;
|
||||
private Runnable callback;
|
||||
private String currentCategory;
|
||||
private final LinkedHashMap<String, LinkedHashMap<String, String>> data;
|
||||
|
||||
public Data(ByteBuffer data) {
|
||||
this.data = new LinkedHashMap<>();
|
||||
|
@ -22,57 +17,7 @@ public class Data {
|
|||
}
|
||||
|
||||
public String get(String category, String key) {
|
||||
var val = data.get(category).get(key);
|
||||
return val == null ? "" : val;
|
||||
}
|
||||
|
||||
public List<String> getCategories() {
|
||||
return new ArrayList<>(data.keySet());
|
||||
}
|
||||
|
||||
public Color getColor(String category, String key) {
|
||||
var str = get(category, key);
|
||||
if(str.equals("")) {
|
||||
return Color.WHITE;
|
||||
}
|
||||
if(str.startsWith("#") && (str.length() == 7 || str.length() == 9)) {
|
||||
var r = Integer.parseInt(str.substring(1, 3), 16);
|
||||
var g = Integer.parseInt(str.substring(3, 5), 16);
|
||||
var b = Integer.parseInt(str.substring(5, 7), 16);
|
||||
var a = str.length() == 9 ? Integer.parseInt(
|
||||
str.substring(7, 9),
|
||||
16
|
||||
) : 255;
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
for(var seperator : vectorSeperators) {
|
||||
if(str.contains(seperator)) {
|
||||
var posStr = str.split(seperator);
|
||||
return new Color(Integer.parseInt(posStr[0].strip()),
|
||||
Integer.parseInt(posStr[1].strip()),
|
||||
Integer.parseInt(posStr[2].strip())
|
||||
);
|
||||
}
|
||||
}
|
||||
return Color.WHITE;
|
||||
|
||||
}
|
||||
|
||||
public Vec2i getVec2i(String category, String key) {
|
||||
var str = get(category, key);
|
||||
if(str.equals("")) {
|
||||
return Vec2i.ZERO;
|
||||
}
|
||||
for(var seperator : vectorSeperators) {
|
||||
if(str.contains(seperator)) {
|
||||
var posStr = str.split(seperator);
|
||||
return new Vec2i(Integer.parseInt(posStr[0].strip()),
|
||||
Integer.parseInt(posStr[1].strip())
|
||||
);
|
||||
}
|
||||
}
|
||||
return Vec2i.ZERO;
|
||||
return data.get(category).get(key);
|
||||
}
|
||||
|
||||
public void onReload(Runnable callback) {
|
||||
|
|
|
@ -1,56 +1,16 @@
|
|||
package com.danitheskunk.skunkworks.audio;
|
||||
|
||||
/**
|
||||
* An audio sample
|
||||
* <p>
|
||||
* Either mono or stereo. Samplerate unaware.
|
||||
*/
|
||||
//todo: samplerate stuffs?
|
||||
public interface ISample {
|
||||
/**
|
||||
* Returns the length
|
||||
*
|
||||
* @return the length in samples
|
||||
*/
|
||||
int getLength();
|
||||
|
||||
/**
|
||||
* Returns the sample of left channel at position
|
||||
*
|
||||
* @param pos position in samples
|
||||
* @return the sample value from -1.0 to 1.0 (+ headroom if clipping)
|
||||
*/
|
||||
double getSampleLeft(int pos);
|
||||
|
||||
/**
|
||||
* Returns the sample of right channel at position
|
||||
*
|
||||
* @param pos position in samples
|
||||
* @return the sample value from -1.0 to 1.0 (+ headroom if clipping)
|
||||
*/
|
||||
double getSampleRight(int pos);
|
||||
|
||||
/**
|
||||
* Returns if the sample is in stereo
|
||||
*
|
||||
* @return true if the sample is stereo, false if mono
|
||||
*/
|
||||
boolean isStereo();
|
||||
|
||||
/**
|
||||
* Set a sample value for left and right channel
|
||||
*
|
||||
* @param pos position in samples
|
||||
* @param left sample value of left channel -32768 to 32768
|
||||
* @param right sample value of right channel -32768 to 32768
|
||||
*/
|
||||
void setSamplei(int pos, short left, short right);
|
||||
|
||||
/**
|
||||
* Set a sample value for left or mono channel
|
||||
*
|
||||
* @param pos position in samples
|
||||
* @param left sample value of left(or mono) channel -32768 to 32768
|
||||
*/
|
||||
void setSamplei(int pos, short left);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ public class Window extends BaseWindow {
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
//glDepthFunc(GL_GREATER);
|
||||
|
||||
glfwSetWindowSizeCallback(window, this::windowSizeCallback);
|
||||
glfwSetMouseButtonCallback(window, this::mouseButtonCallback);
|
||||
|
@ -348,7 +349,6 @@ public class Window extends BaseWindow {
|
|||
textureAtlas.update();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.0f);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
//glBegin(GL_TRIANGLES);
|
||||
return renderContext;
|
||||
}
|
||||
|
@ -360,9 +360,8 @@ public class Window extends BaseWindow {
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
glViewport(0, 0, size.getX(), size.getY());
|
||||
textureAtlas.update();
|
||||
glClearColor(0.f, 0.f, 0.f, 1.0f);
|
||||
glClearColor(0.f, 1.f, 0.f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDepthFunc(GL_LESS);
|
||||
//glBegin(GL_TRIANGLES);
|
||||
glUniformMatrix4fv(program3D.getUniformLocation("projection"),
|
||||
true,
|
||||
|
|
Loading…
Reference in New Issue