Skip to content

Commit

Permalink
Created textExample.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
arhik committed Nov 19, 2023
1 parent e22861b commit b06c2b0
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions examples/textExample.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

using Revise
using WGPUgfx
using WGPUCore
using GLFW
using GLFW: WindowShouldClose, PollEvents, DestroyWindow
using LinearAlgebra
using Rotations
using StaticArrays
using WGPUNative
using Debugger
using Images
using ImageView

WGPUCore.SetLogLevel(WGPUCore.WGPULogLevel_Debug)

scene = Scene();
renderer = getRenderer(scene);
camera = defaultCamera();
addCamera!(scene, camera)

using FreeTypeAbstraction

# load a font
face = FTFont("$(ENV["HOMEPATH"])/JuliaMono-Light.ttf")

# render a character
img, metric = renderface(face, 'C', 50)

imageF = ones(RGBA{N0f8}, size(img) |> reverse)

imageF[:, :, :, 1] = imrotate(RGB{N0f8}.(img./255f0), -pi/2)

textureData = begin
img = imrotate((imageF), pi/2)
imgview = channelview(img) |> collect
end

quad = defaultQuad(; imgData = Ref(textureData));

addObject!(renderer, quad, camera);

# attachEventSystem(renderer)

function runApp(renderer)
init(renderer)
render(renderer)
# render(renderer, renderer.scene.objects[1], camera; dims=(50, 50, 300, 300))
deinit(renderer)
end

# runApp(renderer)

main = () -> begin
try
while !WindowShouldClose(scene.canvas.windowRef[])
runApp(renderer)
PollEvents()
end
finally
WGPUCore.destroyWindow(scene.canvas)
end
end

if abspath(PROGRAM_FILE)==@__FILE__
main()
else
main()
end

2 comments on commit b06c2b0

@arhik
Copy link
Member Author

@arhik arhik commented on b06c2b0 Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/95600

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" b06c2b0eb38ea9f127c8df2a089689573d7fb226
git push origin v0.1.1

Please sign in to comment.