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 GLUT, ModernGL | |
| function aglGetProcAddress(glFuncName::String) | |
| tmp = "_"*glFuncName | |
| if ccall(:NSIsSymbolNameDefined, Cint, (Ptr{Uint8},), tmp) == 0 | |
| return convert(Ptr{Void}, 0) | |
| else | |
| symbol = ccall(:NSLookupAndBindSymbol, Ptr{Void}, (Ptr{Uint8},), tmp) | |
| return ccall(:NSAddressOfSymbol, Ptr{Void}, (Ptr{Void},), symbol) | |
| 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
| #Find the correct type of the data | |
| imgType = eltype(data) | |
| if imgType == Uint8 | |
| glImgType = GL_UNSIGNED_BYTE | |
| elseif imgType == Float32 | |
| glImgType = GL_FLOAT | |
| elseif imgType == Int8 | |
| glImgType = GL_BYTE | |
| else | |
| error("Type: $(imgType) not supported") |
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
| abstract Enum | |
| macro GenEnums(list) | |
| const result = {} | |
| enumlist = Dict{Symbol, Dict{Int, Symbol}}() | |
| tmp = list.args[2].args | |
| tmp2 = tmp[2].args | |
| enumdict1 = Dict{Int, Symbol}() | |
| for elem in tmp2 |
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
| #include <GLFW/glfw3.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| static void error_callback(int error, const char* description) | |
| { | |
| fputs(description, stderr); | |
| } | |
| static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) |
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
| mesh = | |
| [ | |
| :indexes => GLBuffer{GLuint}(convert(Ptr{GLuint}, pointer(indices)), sizeof(indices), 1, GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :vertex => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(xyz)), sizeof(xyz), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :normal => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(normals)), sizeof(normals), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :tangent => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(tangents)), sizeof(tangents), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :binormal => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(binormals)), sizeof(binormals), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :view => cam.view, |
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
| mesh = | |
| [ | |
| :indexes => GLBuffer{GLuint}(convert(Ptr{GLuint}, pointer(indices)), sizeof(indices), 1, GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :vertex => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(xyz)), sizeof(xyz), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :normal => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(normals)), sizeof(normals), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :tangent => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(tangents)), sizeof(tangents), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :binormal => GLBuffer{Float32}(convert(Ptr{Float32}, pointer(binormals)), sizeof(binormals), 3,GL_ARRAY_BUFFER, GL_STATIC_DRAW), | |
| :view => cam.view, |
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 fieldtype(x::Any) | |
| T = typeof(x) | |
| if !isbits(T) | |
| error(T, " is not a bitstype, so it doesn't have the right memory layout") | |
| end | |
| types = T.types | |
| @assert !isempty(types) | |
| ftype = types[1] | |
| if any(t -> t!= ftype, types) | |
| error("field types are not homogenious for: ", 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
| function fieldtype(x::Any) | |
| T = typeof(x) | |
| if !isbits(T) | |
| error(T, " is not a bitstype, so it doesn't have the right memory layout") | |
| end | |
| types = T.types | |
| @assert !isempty(types) | |
| ftype = types[1] | |
| if any(t -> t!= ftype, types) | |
| error("field types are not homogenious for: ", 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
| function fieldtype(x::Any) | |
| T = typeof(x) | |
| if !isbits(T) | |
| error(T, " is not a bitstype, so it doesn't have the right memory layout") | |
| end | |
| types = T.types | |
| @assert !isempty(types) | |
| ftype = types[1] | |
| if any(t -> t!= ftype, types) | |
| error("field types are not homogenious for: ", 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
| function fieldtype(x::Any) | |
| T = typeof(x) | |
| # type checks | |
| if !isbits(T) | |
| error(T, " is not a bitstype, so it doesn't have the right memory layout") | |
| end | |
| types = T.types | |
| @assert !isempty(types) # type must have at least one field | |
| ftype = types[1] | |
| if any(t -> t!= ftype, types) |