This file contains hidden or 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
using ModernGL, GLWindow, GLUtil, React, ImmutableArrays | |
const window = createwindow("Example", 512, 512) | |
window_size = window.inputs[:window_size] | |
w,h = window_size.value # get initial window size | |
#Resize glviewport, when window size changes. | |
lift(window_size -> glViewport(0,0, window_size[1], window_size[2]), window_size) | |
const vsh = """ | |
in vec2 position; |
This file contains hidden or 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
function movecam{T}(state0::Rotatable{T}, state1::Rotatable{T}) | |
xangle = state0.xangle - state1.xangle #get the difference from the previous state | |
yangle = state0.yangle - state1.yangle | |
zoom = state0.zoom - state1.zoom | |
dir = state0.position - state1.lookat | |
right = unit(cross(dir, state1.up)) | |
xrotation = rotate2(deg2rad(xangle), state1.up) #rotation matrix around up | |
yrotation = rotate2(deg2rad(yangle), right) |
This file contains hidden or 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
//Configure Stereo settings. | |
Sizei recommenedTex0Size = ovrHmd_GetFovTextureSize(HMD, ovrEye_Left, HMD->DefaultEyeFov[0], 1.0f); | |
Sizei recommenedTex1Size = ovrHmd_GetFovTextureSize(HMD, ovrEye_Right, HMD->DefaultEyeFov[1], 1.0f); | |
Sizei RenderTargetSize; | |
RenderTargetSize.w = recommenedTex0Size.w + recommenedTex1Size.w; | |
RenderTargetSize.h = max ( recommenedTex0Size.h, recommenedTex1Size.h ); | |
const int eyeRenderMultisample = 1; | |
pRendertargetTexture = pRender->CreateTexture(Texture_RGBA | Texture_RenderTarget | | |
eyeRenderMultisample, |
This file contains hidden or 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
using ModernGL, GLPlot, GLAbstraction, GLWindow, GLFW, ImmutableArrays, Images, React, Quaternions | |
window = createwindow("test", 1000, 800) | |
mouseposition = window.inputs[:mouseposition] | |
clicked = window.inputs[:mousebuttonspressed] | |
keypressed = window.inputs[:buttonspressed] | |
clickedwithoutkeyL = lift((mb, kb) -> in(0, mb) && isempty(kb), Bool, clicked, keypressed) |
This file contains hidden or 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
using GLWindow, GLAbstraction, GLFW, ModernGL | |
global const window = createwindow("Mesh Display", 1000, 1000, debugging = false) # debugging just works on linux and windows | |
const cam = PerspectiveCamera(window.inputs, Vec3(2, 2, 0.5), Vec3(0.5)) | |
#Shader are written in a c-like langauge(GLSL) and allow for rasterization on the GPU | |
vert = " | |
{{GLSL_VERSION}} |
This file contains hidden or 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
using Meshes, ModernGL, GLAbstraction, GLWindow, ImmutableArrays, GLPlot | |
global const window = createwindow("Mesh Display", 1000, 1000, debugging = false) # debugging just works on linux and windows | |
const cam = PerspectiveCamera(window.inputs, Vec3(2,2,0.5), Vec3(0.5,0.5,0)) | |
function importOBJ(fn::String; topology=false, vertextype=Float64, faceindextype=Int) | |
str = open(fn,"r") | |
mesh = importOBJ(str, topology=topology, vertextype=vertextype, faceindextype=faceindextype) | |
close(str) | |
return mesh | |
end |
This file contains hidden or 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
using GLWindow, GLAbstraction, GLFW, ModernGL, React, GLPlot, ImmutableArrays | |
half_frame = [960, 1080] | |
frame = half_frame .* [2,1] | |
# When oculus works, you can just make dummy window with width,heigh = (1,1) | |
window = createwindow("Dummy", frame..., debugging = false) # debugging just works on linux and windows | |
# Camera setup | |
inputsL = copy(window.inputs) |
This file contains hidden or 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
import Base: eltype, getindex, length, ndims, size, convert, vcat | |
## Abstract Types | |
abstract AbstractFixedArray{T,N,SZ} <: DenseArray{T,N} | |
abstract AbstractMutableFixedArray{T,N,SZ} <: AbstractFixedArray{T,N,SZ} | |
abstract AbstractImmutableFixedArray{T,N,SZ} <: AbstractFixedArray{T,N,SZ} | |
typealias FixedVector{T, L} AbstractFixedArray{T,1,(L,)} | |
typealias FixedMatrix{T, RD, CD} AbstractFixedArray{T,2,(RD,CD)} |
This file contains hidden or 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
using GLPlot, GLAbstraction, ModernGL | |
window = createdisplay(w=1000,h=1000,eyeposition=Vec3(1,1,1), lookat=Vec3(0)) | |
function zcolor(i, j, t) | |
x = float32(i - 0.5) | |
z = float32(j - 0.5) | |
radius = sqrt((x * x) + (z * z)) | |
r = sin(10.0f0 * radius + t) | |
g = cos(10.0f0 * radius + t) |
This file contains hidden or 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
using GLPlot, GLAbstraction, ModernGL, ApproxFun, React | |
const h = 0.01 | |
const u0 = TensorFun((x,y)->exp(-10x.^2-20(y-.1).^2)) | |
const d = Interval()⊗Interval() | |
const L = I-h^2*lap(d) | |
const B = [ neumann(Interval())⊗I; | |
I⊗dirichlet(Interval())] | |
const S = schurfact([B,L],100) | |
const u = Array(TensorFun,10000) |