Skip to content

Commit

Permalink
Erase with right clic
Browse files Browse the repository at this point in the history
Former-commit-id: a5afb49
  • Loading branch information
Aurelien Mora committed Aug 3, 2018
1 parent a7e08bc commit 23dc84b
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.lwjgl.glfw.GLFWMouseButtonCallback;
import org.sheepy.vulkan.VulkanApplication;
import org.sheepy.vulkan.device.LogicalDevice;
import org.sheepy.vulkan.sand.board.EMaterial;
import org.sheepy.vulkan.sand.board.EShape;
import org.sheepy.vulkan.sand.compute.BoardImage;
import org.sheepy.vulkan.sand.graphics.SandUIDescriptor;
Expand Down Expand Up @@ -36,6 +37,8 @@ public class SandApplication extends VulkanApplication

private boolean firstDrawLeft = false;
private boolean drawEnabledLeft = false;
private boolean firstDrawRight = false;
private boolean drawEnabledRight = false;
private SandUIDescriptor uiDescriptor;

private BoardImage image;
Expand Down Expand Up @@ -77,6 +80,18 @@ public void invoke(long window, int button, int action, int mods)
break;
case GLFW_MOUSE_BUTTON_RIGHT:
io.getMouseDown()[1] = action == GLFW_PRESS;
if (io.getWantCaptureMouse() == false && action == GLFW_PRESS)
{
if (drawEnabledRight == false)
{
firstDrawRight = true;
}
drawEnabledRight = true;
}
else
{
drawEnabledRight = false;
}
break;
case GLFW_MOUSE_BUTTON_MIDDLE:
io.getMouseDown()[2] = action == GLFW_PRESS;
Expand Down Expand Up @@ -153,6 +168,11 @@ public void drawFrame()
firstDrawLeft = false;
}

// Right draw: erase.
if (drawEnabledRight)
{
draw(cursorPosition, EMaterial.Void, firstDrawRight);
firstDrawRight = false;
}

boardPool.execute();
Expand Down

0 comments on commit 23dc84b

Please sign in to comment.