-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.cpcache | ||
docs/apidocs | ||
target | ||
build | ||
|
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,8 @@ | ||
{:deps {org.jetbrains.skija/skija-macos {:mvn/version "0.6.6"} | ||
org.lwjgl/lwjgl {:mvn/version "3.2.3"} | ||
org.lwjgl/lwjgl$natives-macos {:mvn/version "3.2.3"} | ||
org.lwjgl/lwjgl-glfw {:mvn/version "3.2.3"} | ||
org.lwjgl/lwjgl-glfw$natives-macos {:mvn/version "3.2.3"} | ||
org.lwjgl/lwjgl-opengl {:mvn/version "3.2.3"} | ||
org.lwjgl/lwjgl-opengl$natives-macos {:mvn/version "3.2.3"}} | ||
:mvn/repos {"space-maven" {:url "https://packages.jetbrains.team/maven/p/skija/maven"}}} |
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,5 @@ | ||
#!/bin/bash | ||
set -o errexit -o nounset -o pipefail | ||
cd "`dirname $0`/.." | ||
|
||
clj -J-XstartOnFirstThread -X lwjgl.main/-main |
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,47 @@ | ||
(ns lwjgl.main | ||
(:import | ||
[org.jetbrains.skija BackendRenderTarget Canvas ColorSpace DirectContext FramebufferFormat Paint Rect Surface SurfaceColorFormat SurfaceOrigin] | ||
[org.lwjgl.glfw GLFW] | ||
[org.lwjgl.opengl GL GL11] | ||
[org.lwjgl.system MemoryUtil])) | ||
|
||
(set! *warn-on-reflection* true) | ||
|
||
(defn color [^long l] | ||
(.intValue (Long/valueOf l))) | ||
|
||
(defn draw [^Canvas canvas] | ||
(.clear canvas (color 0xFFFFFFFF)) | ||
(let [layer (.save canvas) | ||
paint (doto (Paint.) (.setColor (color 0xFFCC3333)))] | ||
(.translate canvas 320 240) | ||
(.rotate canvas (mod (/ (System/currentTimeMillis) 10) 360)) | ||
(.drawRect canvas (Rect/makeXYWH -50 -50 100 100) paint) | ||
(.restoreToCount canvas layer))) | ||
|
||
(defn -main [& args] | ||
(GLFW/glfwInit) | ||
(GLFW/glfwWindowHint GLFW/GLFW_VISIBLE GLFW/GLFW_FALSE) | ||
(GLFW/glfwWindowHint GLFW/GLFW_RESIZABLE GLFW/GLFW_TRUE) | ||
(let [width 640 | ||
height 480 | ||
window (GLFW/glfwCreateWindow width height "Skija LWJGL Demo" MemoryUtil/NULL MemoryUtil/NULL)] | ||
(GLFW/glfwMakeContextCurrent window) | ||
(GLFW/glfwSwapInterval 1) | ||
(GLFW/glfwShowWindow window) | ||
(GL/createCapabilities) | ||
|
||
(let [context (DirectContext/makeGL) | ||
fb-id (GL11/glGetInteger 0x8CA6) | ||
target (BackendRenderTarget/makeGL width height 0 8 fb-id FramebufferFormat/GR_GL_RGBA8) | ||
surface (Surface/makeFromBackendRenderTarget context target SurfaceOrigin/BOTTOM_LEFT SurfaceColorFormat/RGBA_8888 (ColorSpace/getSRGB)) | ||
canvas (.getCanvas surface)] | ||
(loop [] | ||
(when (not (GLFW/glfwWindowShouldClose window)) | ||
(draw canvas) | ||
|
||
(.flush context) | ||
(GLFW/glfwSwapBuffers window) | ||
(GLFW/glfwPollEvents) | ||
(recur))) | ||
))) |