rust-tutorials / triangle-from-scratch Goto Github PK
View Code? Open in Web Editor NEWDrawing a triangle with no other crate dependencies.
Home Page: https://rust-tutorials.github.io/triangle-from-scratch/
Drawing a triangle with no other crate dependencies.
Home Page: https://rust-tutorials.github.io/triangle-from-scratch/
It’d be nice to mention the full quantified name for C constants when they’re mentioned for the first time, i.e CS_OWNDC
is Class Style OWNed Device Context
we don't say what othe rust skill a person needs.
(probably just having read The Rust Book)
Separate from initializing a GL context (very platform specific) is the issue of making that GL context even slightly easy to use (fairly platform neutral).
Basically you usually end up with a function like:
fn gl_get_proc_address(name: &[u8]) -> *mut c_void;
And from there you fill in a struct of pointers or you fill in some global static values.
// global fn style
glClearColor(1.0, 1.0, 0.5, 1.0);
// struct style
gl.Clear(GL_COLOR_BUFFER_BIT);
The global functions style is a hair easier to use, but the struct style connects the fns more closely to their context (which is essentially "more correct").
So we should have a lesson about how you do all this. We don't have to do the full thing necessarily, since our actual GL usage is very modest. We can just show people what they would do and then say "now go use the crate".
this is a unix-y subject. you can use pdcurses on windows, but the point is more about having a little practice with man pages.
https://rust-tutorials.github.io/triangle-from-scratch/opening_a_window/win32.html#creating-the-window introduces constants derived from C #define
s. Earlier asides such as Reading a C struct declaration
seem to imply the audience isn't assumed to know C - so it might be worth briefly noting what these look like in the original C headers (e.g. #define WS_OVERLAPPED ...
/ enum { ... }
) and how the exact type these match to in Rust can be somewhat ambiguous / down to the author's own personal guesswork.
https://docs.rs/wchar/ is a nice pre-built crate so you don't have to roll your own for https://rust-tutorials.github.io/triangle-from-scratch/appendix/utf16_literals.html
For WebGL, and general "web stuff", I think we could cave and use wasm_pack
, and the associated proc_macro and such.
The win32 examples that handle the WM_NCCREATE
event without using DefWindowProcW
don't have their non-client area drawn properly, which means that they don't get the title text drawn.
Make sure all unsafe calls in Default implementation explains that the zeroed variant of the struct is valid
an excuse to dabble with volatile / mmio, and also direct video memory drawing.
Currently the only CI is a github pages run when a commit goes to the main branch.
It would be better for bug catching if there was also CI to build examples and run tests. The only major complication would be that not all examples build on all platforms. Possibly we could narrow the scope of lib testing and example building on each platform so that win32 bins are only built on windows and so on.
In our tutorials, we set the windows subsystem:
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
but with no explanation why, or what's going on with that.
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.