initial commit
This commit is contained in:
98
source/secondapplet.pde
Normal file
98
source/secondapplet.pde
Normal file
@@ -0,0 +1,98 @@
|
||||
import java.awt.Frame;
|
||||
SecondApplet sa;
|
||||
String[] args = {"TwoFrameTest"};
|
||||
|
||||
int pixelCount;
|
||||
String appTitle;
|
||||
boolean appActive;
|
||||
public class SecondApplet extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
//int w;
|
||||
//int h;
|
||||
//int w_old;
|
||||
//for(int i = 0; i < texture_pi.length; i++){
|
||||
// int w_ = texture_pi[i].width;
|
||||
// if (texture_pi[i]
|
||||
// int w_old =
|
||||
//}
|
||||
int w = textureWidth;
|
||||
int h = textureWidth;
|
||||
//println(w);
|
||||
pixelCount = w*h;
|
||||
render = createImage(w, h, ARGB);
|
||||
surface.setResizable(true);
|
||||
surface.setSize(w, h);
|
||||
surface.setTitle(appTitle);
|
||||
appActive = true;
|
||||
if (readPhase_i == 3) loadMRAO(false, false, false);
|
||||
else loadNewTex();
|
||||
}
|
||||
public void draw() {
|
||||
image(render, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
public void kill() {
|
||||
surface.setVisible(false);
|
||||
}
|
||||
|
||||
public void surfaceTitleSA(String title_) {
|
||||
String title = title_;
|
||||
surface.setTitle(title);
|
||||
}
|
||||
|
||||
boolean[] flipRGB = {false, false, false};
|
||||
|
||||
public void loadNewTex() {
|
||||
render = texture_pi[readPhase_i].get();
|
||||
}
|
||||
|
||||
public void loadMRAO(boolean r_b_, boolean b_b_, boolean g_b_) {
|
||||
if (r_b_) {
|
||||
if (!flipRGB[0]) {
|
||||
flipRGB[0] = true;
|
||||
} else {
|
||||
flipRGB[0] = false;
|
||||
}
|
||||
}
|
||||
if (b_b_) {
|
||||
if (!flipRGB[1]) {
|
||||
flipRGB[1] = true;
|
||||
} else {
|
||||
flipRGB[1] = false;
|
||||
}
|
||||
}
|
||||
if (g_b_) {
|
||||
|
||||
if (!flipRGB[2]) {
|
||||
flipRGB[2] = true;
|
||||
} else {
|
||||
flipRGB[2] = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < texture_pi.length; i++) {
|
||||
if (texture_pi[i] == null) {
|
||||
texture_pi[i] = createImage(textureWidth, textureHeight, ARGB);
|
||||
}
|
||||
}
|
||||
texture_pi[0].loadPixels();
|
||||
texture_pi[1].loadPixels();
|
||||
texture_pi[2].loadPixels();
|
||||
render.loadPixels();
|
||||
|
||||
for (int i = 0; i < pixelCount; i++) {
|
||||
float r = red(texture_pi[0].pixels[i]);
|
||||
float g = green(texture_pi[1].pixels[i]);
|
||||
float b = blue(texture_pi[2].pixels[i]);
|
||||
if (flipRGB[0]) r = 255-r;
|
||||
if (flipRGB[1]) g = 255-g;
|
||||
if (flipRGB[2]) b = 255-b;
|
||||
render.pixels[i] = color(r, g, b);
|
||||
}
|
||||
render.updatePixels();
|
||||
texture_pi[0].updatePixels();
|
||||
texture_pi[1].updatePixels();
|
||||
texture_pi[2].updatePixels();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user