forked from SpaiR/imgui-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rendering implementation for LWJGL
- Loading branch information
Showing
59 changed files
with
6,728 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
|
||
[*.{groovy,java}] | ||
indent_size = 4 | ||
max_line_length = 160 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group 'imgui' | ||
version '1.0' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
allprojects { | ||
group 'imgui-java' | ||
version property('version') | ||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id 'groovy' | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
ext { | ||
jnigenVersion = '1.9.10' | ||
} | ||
|
||
dependencies { | ||
implementation gradleApi() | ||
implementation localGroovy() | ||
|
||
implementation "com.badlogicgames.gdx:gdx-jnigen:$jnigenVersion" | ||
} |
43 changes: 43 additions & 0 deletions
43
buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package imgui.generate | ||
|
||
import com.badlogic.gdx.jnigen.* | ||
import groovy.transform.CompileStatic | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.CopySpec | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
@CompileStatic | ||
class GenerateLibs extends DefaultTask { | ||
String description = 'Generates native libraries using classes under ":imgui-binding" and Dear-ImGui itself from "imgui" submodule.' | ||
|
||
private final String sourceDir = project.file('src/main/java') | ||
private final String classpath = project.file('build/classes/java/main') | ||
private final String jniDir = project.buildDir.path + '/jni' | ||
private final String tmpFolder = project.buildDir.path + '/tmp' | ||
private final String libsFolder = 'libsNative' | ||
|
||
@TaskAction | ||
void generate() { | ||
// Generate h/cpp files for JNI | ||
new NativeCodeGenerator().generate(sourceDir, classpath, jniDir) | ||
|
||
// Copy ImGui h/cpp files | ||
project.copy { CopySpec spec -> | ||
spec.from(project.rootProject.file('imgui')) { CopySpec it -> it.include('*.h', '*.cpp') } | ||
spec.from(project.file('src/main/native')) | ||
spec.into(jniDir) | ||
} | ||
|
||
// Generate platform dependant ant configs and header files | ||
def buildConfig = new BuildConfig('imgui-java', tmpFolder, libsFolder, jniDir) | ||
def win64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, true) | ||
new AntScriptGenerator().generate(buildConfig, win64) | ||
|
||
// Generate native libraries | ||
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile') | ||
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives') | ||
|
||
// Ant creates this folder in the root of the project. Since it will be empty we delete it | ||
project.rootProject.file(libsFolder).deleteDir() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version=0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import imgui.generate.GenerateLibs | ||
|
||
plugins { | ||
id 'java' | ||
} | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
assemble.dependsOn clean | ||
task generateLibs(type: GenerateLibs, dependsOn: assemble) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package imgui; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
|
||
public final class DrawData { | ||
public final static int vBufferSize = (4 + 1) * 4; | ||
public final static int iBufferSize = 2; | ||
public final static int cmdBufferSize = (1 + 4 + 1) * 4; | ||
public int cmdListsCount; // Number of ImDrawList* to render | ||
public int totalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size | ||
public int totalVtxCount; | ||
public int totalCmdCount; | ||
public float displayPosX; | ||
public float displayPosY; | ||
public float displaySizeX; | ||
public float displaySizeY; | ||
public float framebufferScaleX; | ||
public float framebufferScaleY; | ||
public ByteBuffer vByteBuffer; | ||
public ByteBuffer iByteBuffer; | ||
public ByteBuffer cmdByteBuffer; | ||
|
||
public DrawData(ByteBuffer vByteBuffer, ByteBuffer iByteBuffer, ByteBuffer cmdByteBuffer) { | ||
this.vByteBuffer = vByteBuffer; | ||
this.iByteBuffer = iByteBuffer; | ||
this.cmdByteBuffer = cmdByteBuffer; | ||
} | ||
|
||
public DrawData(int maxVertice, int maxIndices, int maxCmd) { | ||
this.vByteBuffer = ByteBuffer.allocateDirect(maxVertice * vBufferSize); | ||
this.iByteBuffer = ByteBuffer.allocateDirect(maxIndices * iBufferSize); | ||
this.cmdByteBuffer = ByteBuffer.allocateDirect(maxCmd * cmdBufferSize); | ||
vByteBuffer.order(ByteOrder.nativeOrder()); | ||
iByteBuffer.order(ByteOrder.nativeOrder()); | ||
cmdByteBuffer.order(ByteOrder.nativeOrder()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package imgui; | ||
|
||
import imgui.enums.ImDrawCornerFlags; | ||
|
||
public class ImDrawList { | ||
|
||
public final static int TYPE_DEFAULT = 0; | ||
public final static int TYPE_BACKGROUND = 1; | ||
public final static int TYPE_FOREGROUND = 2; | ||
|
||
private int type = TYPE_DEFAULT; | ||
|
||
public ImDrawList(int type) { | ||
this.type = type; | ||
} | ||
|
||
public void AddLine(float a_x, float a_y, float b_x, float b_y, int col) { | ||
Native.AddLine(type, a_x, a_y, b_x, b_y, col); | ||
} | ||
|
||
public void AddLine(float a_x, float a_y, float b_x, float b_y, int col, float thinkness) { | ||
Native.AddLine(type, a_x, a_y, b_x, b_y, col, thinkness); | ||
} | ||
|
||
public void AddRect(float a_x, float a_y, float b_x, float b_y, int col) { | ||
Native.AddRect(type, a_x, a_y, b_x, b_y, col); | ||
} | ||
|
||
public void AddRect(float a_x, float a_y, float b_x, float b_y, int col, float rounding) { | ||
Native.AddRect(type, a_x, a_y, b_x, b_y, col, rounding); | ||
} | ||
|
||
public void AddRect(float a_x, float a_y, float b_x, float b_y, int col, float rounding, ImDrawCornerFlags rounding_corners_flags) { | ||
Native.AddRect(type, a_x, a_y, b_x, b_y, col, rounding, rounding_corners_flags.getValue()); | ||
} | ||
|
||
public void AddRect(float a_x, float a_y, float b_x, float b_y, int col, float rounding, ImDrawCornerFlags rounding_corners_flags, float thickness) { | ||
Native.AddRect(type, a_x, a_y, b_x, b_y, col, rounding, rounding_corners_flags.getValue(), thickness); | ||
} | ||
|
||
public void AddRectFilled(float a_x, float a_y, float b_x, float b_y, int col) { | ||
Native.AddRectFilled(type, a_x, a_y, b_x, b_y, col); | ||
} | ||
|
||
public void AddRectFilled(float a_x, float a_y, float b_x, float b_y, int col, float rounding) { | ||
Native.AddRectFilled(type, a_x, a_y, b_x, b_y, col, rounding); | ||
} | ||
|
||
public void AddRectFilled(float a_x, float a_y, float b_x, float b_y, int col, float rounding, ImDrawCornerFlags rounding_corners_flags) { | ||
Native.AddRectFilled(type, a_x, a_y, b_x, b_y, col, rounding, rounding_corners_flags.getValue()); | ||
} | ||
|
||
public void AddRectFilledMultiColor(float a_x, float a_y, float b_x, float b_y, int col_upr_left, float col_upr_right, int col_bot_right, int col_bot_left) { | ||
Native.AddRectFilledMultiColor(type, a_x, a_y, b_x, b_y, col_upr_left, col_upr_right, col_bot_right, col_bot_left); | ||
} | ||
|
||
public void AddQuad(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col) { | ||
Native.AddQuad(type, a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y, col); | ||
} | ||
|
||
public void AddQuad(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col, float thickness) { | ||
Native.AddQuad(type, a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y, col, thickness); | ||
} | ||
|
||
public void AddQuadFilled(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, float d_x, float d_y, int col) { | ||
Native.AddQuadFilled(type, a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y, col); | ||
} | ||
|
||
public void AddTriangle(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col) { | ||
Native.AddTriangle(type, a_x, a_y, b_x, b_y, c_x, c_y, col); | ||
} | ||
|
||
public void AddTriangle(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col, float thickness) { | ||
Native.AddTriangle(type, a_x, a_y, b_x, b_y, c_x, c_y, col, thickness); | ||
} | ||
|
||
public void AddTriangleFilled(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y, int col) { | ||
Native.AddTriangleFilled(type, a_x, a_y, b_x, b_y, c_x, c_y, col); | ||
} | ||
|
||
public void AddCircle(float centre_x, float centre_y, float radius, float col, int num_segments, float thickness) { | ||
Native.AddCircle(type, centre_x, centre_y, radius, col, num_segments, thickness); | ||
} | ||
|
||
public void AddCircleFilled(float centre_x, float centre_y, float radius, float col) { | ||
Native.AddCircleFilled(type, centre_x, centre_y, radius, col); | ||
} | ||
|
||
public void AddCircleFilled(float centre_x, float centre_y, float radius, float col, int num_segments) { | ||
Native.AddCircleFilled(type, centre_x, centre_y, radius, col, num_segments); | ||
} | ||
|
||
public void AddText(float pos_x, float pos_y, int col, String text_begin) { | ||
Native.AddText(type, pos_x, pos_y, col, text_begin); | ||
} | ||
|
||
public void AddText(float pos_x, float pos_y, int col, String text_begin, String text_end) { | ||
Native.AddText(type, pos_x, pos_y, col, text_begin, text_end); | ||
} | ||
|
||
// TODO AddText | ||
|
||
public void AddImage(int textureID, float a_x, float a_y, float b_x, float b_y) { | ||
Native.AddImage(type, textureID, a_x, a_y, b_x, b_y); | ||
} | ||
|
||
public void AddImage(int textureID, float a_x, float a_y, float b_x, float b_y, float uv_a_x, float uv_a_y, float uv_b_x, float uv_b_y) { | ||
Native.AddImage(type, textureID, a_x, a_y, b_x, b_y, uv_a_x, uv_a_y, uv_b_x, uv_b_y); | ||
} | ||
|
||
//TODO AddImageQuad, AddImageRounded, AddPolyline, AddConvexPolyFilled | ||
|
||
public void AddBezierCurve(float pos0_x, float pos0_y, float cp0_x, float cp0_y, float cp1_x, float cp1_y, float pos1_x, float pos1_y, float col, float thickness) { | ||
Native.AddBezierCurve(type, pos0_x, pos0_y, cp0_x, cp0_y, cp1_x, cp1_y, pos1_x, pos1_y, col, thickness); | ||
} | ||
|
||
public void ChannelsSplit(int count) { | ||
Native.ChannelsSplit(type, count); | ||
} | ||
|
||
public void ChannelsMerge() { | ||
Native.ChannelsMerge(type); | ||
} | ||
|
||
public void ChannelsSetCurrent(int n) { | ||
Native.ChannelsSetCurrent(type, n); | ||
} | ||
} |
Oops, something went wrong.