-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work if target language is C++ #57
Comments
For some more detail this is on Windows Version 20H2 and Nim 1.4.2. Also is x86 supported? Doesn't seem to compile if targeting x86. |
I just tried the examples with C and C++. No problems on my machine. I however use Linux, not Windows. This library doesn't use ancy fancy trickery that would break x86, so that one should work out of the box. Can you post the exact code that you used for testing and the generated C++ code? My first guess would be that it is a regression in the Nim compiler. |
on my system, the generated c++ code for |
Since I don't have Windows, I can't reproduce the problem. Maybe somebody else can. Maybe you can reproduce the problem in an online compiler Nim compiler, so I might be able to address the problem there. If I don't hear back from you I might close this issue as not reproduceable. |
@krux02 Apologies for the late response here is the example code with error logs: Here is the example code I am using: The files math, vec, and quat are the nim files from the repo in nim-glm/glm folder. import mat
import vec
import quat
import math
proc lookAtRH[T](eye,center,up:Vec3[T]): Mat4[T] =
let
f = normalize(center - eye)
s = normalize(cross(f, up))
u = cross(s,f)
result = mat4[T](1.0)
result.row0 = vec4( s,0)
result.row1 = vec4( u,0)
result.row2 = vec4(-f,0)
result.arr[3] = vec4(-dot(s,eye), -dot(u,eye), dot(f,eye), 1)
result[3,0] = -dot(s, eye)
result[3,1] = -dot(u, eye)
result[3,2] = dot(f, eye)
proc perspectiveRH[T]( fovy, aspect, zNear, zFar:T): Mat4[T] =
let tanHalfFovy = tan(fovy / T(2))
result = mat4[T](0.0)
result[0,0] = T(1) / (aspect * tanHalfFovy)
result[1,1] = T(1) / (tanHalfFovy)
result[2,3] = T(-1)
result[2,2] = -(zFar + zNear) / (zFar - zNear)
result[3,2] = -(T(2) * zFar * zNear) / (zFar - zNear)
proc perspective*[T]( fovy, aspect, zNear, zFar:T):Mat4[T]=
perspectiveRH(fovy, aspect, zNear, zFar)
proc lookAt*[T](eye,center,up:Vec3[T]):Mat4[T]=
lookAtRH(eye, center, up)
proc Calculate(): int =
var
v = vec3(1.0, 5.0, 6.0)
a = vec3(2.0, 2.0, 5.0)
v4 = vec4(v, 1.0)
c = cross(v,a)
# m = rotate(mat4d(), 5.0, vec3(1.0, 0.0, 0.0))
# r = v4 * c
echo "a: "
echo $a
var
eye = vec3(50.0, 50.0, 10.0)
center = vec3(0.0)
up = vec3(0.0, 1.0, 0.0)
viewMatrix = lookAt(eye, center, up)
# math.PI
projectionMat = perspective(4/2, 1.0, 0.01, 100.0)
echo viewMatrix * projectionMat
# TODO replace result with matrix[1][1]
result = 1
var res = Calculate()
echo $res This is how I am compiling it:
and the error logs:
When compiling for x64 and the target language is C the program works just fine.
When the target language is C++ this is the error log (all I see):
I will test on Linux sometime this week. |
Can you post the content of these three files from your system after you got the problem:
I think that should be enough for me to remote diagnose the problem. |
Hello, I recently wanted to use this for a project I was working on. However, with the first example in the readme it works great when the target language is C but not when it's C++. I do not have a stack trace available as it does not provide one when compiling as C++.
The text was updated successfully, but these errors were encountered: