The Open Source BlitzMax Compiler Project.
bmx-ng / glfw.mod Goto Github PK
View Code? Open in Web Editor NEWBlitzMax bindings for GLFW
BlitzMax bindings for GLFW
Hi Brucey,
We think there may be a problem somewhere that's causing a projection error -- both me and medi71 have run into it.
My example has a switchable setting showing the different projection settings needed to get a cube on-screen, as compared to the various tutorials, while medi71's own take is frankly way tidier!
See next few posts from here with samples...
https://www.syntaxbomb.com/index.php/topic,7495.msg347041994.html#msg347041994
May turn out to be user error, but we've both run into it and are both stumped, so seems like it may be a problem in GFLW (or one of the math libs?).
No matter what I do, I can't get the view to match that of various tutorials, the main one being this:
https://www.tomdalling.com/blog/modern-opengl/03-matrices-depth-buffering-animation/
... the code for which is here:
https://github.com/tomdalling/opengl-series/blob/master/source/03_matrices/source/main.cpp
I've attached a sample, and the relevant settings are a few lines above LoadCube () -- note:
50 degrees fov
0.1, 10.0 for near/far
3, 3, 3 for camera position.
projection_matrix = SMat4F.Perspective (50, _RetroGraphicsWidth, _RetroGraphicsHeight, 0.1, 10.0)
Local uni_prj:Int = glGetUniformLocation (Program, "projection")
glUniformMatrix4fv (uni_prj, 1, False, Varptr projection_matrix.a)
view_matrix = SMat4F.LookAt (New SVec3F (3, 3, 3), New SVec3f (0.0, 0.0, 0.0), New SVec3f (0.0, 1.0, 0.0))
' view_matrix = SMat4F.LookAt (New SVec3F (1.1, 1.1, 1.1), New SVec3f (0.0, 0.0, 0.0), New SVec3f (0.0, 1.0, 0.0)) ' VISIBLE
I have to use the last line just to get something to show, but the perspective is then all wrong.
These settings in the original, for comparison:
//set the "projection" uniform in the vertex shader, because it's not going to change
glm::mat4 projection = glm::perspective(glm::radians(50.0f), SCREEN_SIZE.x/SCREEN_SIZE.y, 0.1f, 10.0f);
gProgram->setUniform("projection", projection);
//set the "camera" uniform in the vertex shader, because it's also not going to change
glm::mat4 camera = glm::lookAt(glm::vec3(3,3,3), glm::vec3(0,0,0), glm::vec3(0,1,0));
I'd really like to get these to match up when using the original settings before trying to move on, unless there's actually a good reason to expect this result... which there may well be!
Runnable sample: texcube.zip
In passing: by messing about with the LookAt matrix (hacking in glm's version), I got something close, but still not quite right, so I assume that's not actually the problem and that I was just lucky it came out similar...
https://www.syntaxbomb.com/index.php/topic,7495.msg347042033.html#msg347042033
I went back to the original LookAt, as medi71 felt it was working, and I then converted/hacked the original C source linked above, but it's frankly a horrible mess, and it still gives the wrong results! (The code attachment.)
Please can you have a look and put me out of my misery... one way or another?! (Or, put another way, try converting the original C code and getting it to show the same result!)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.