{"id":13682712,"url":"https://github.com/Hopson97/rusty-gl","last_synced_at":"2025-04-30T09:33:48.873Z","repository":{"id":32883397,"uuid":"145049108","full_name":"Hopson97/rusty-gl","owner":"Hopson97","description":"Wrapper over gl-rs, to make code look more like Rust and less like C while still having classical OpenGL control as you would in C","archived":false,"fork":false,"pushed_at":"2022-06-18T17:50:59.000Z","size":92,"stargazers_count":24,"open_issues_count":2,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-09T10:28:23.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hopson97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-16T23:31:29.000Z","updated_at":"2024-06-24T18:58:42.000Z","dependencies_parsed_at":"2022-09-01T06:01:31.252Z","dependency_job_id":null,"html_url":"https://github.com/Hopson97/rusty-gl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopson97%2Frusty-gl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopson97%2Frusty-gl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopson97%2Frusty-gl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hopson97%2Frusty-gl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hopson97","download_url":"https://codeload.github.com/Hopson97/rusty-gl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224206172,"owners_count":17273403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:01:51.587Z","updated_at":"2024-11-12T02:31:33.220Z","avatar_url":"https://github.com/Hopson97.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Rusty GL\n\nNote: This is a work in progress.\n\nCrate: https://crates.io/crates/rgl\n\n[![Build Status](https://travis-ci.org/Hopson97/rusty-gl.svg?branch=master)](https://travis-ci.org/Hopson97/rusty-gl)\n\n## Summary\n\nVery thin wrapper over gl-rs, aiming to make code more \"rust-like\" and safer, while still allowing the control you have with classic OpenGL code.\n\n# Current features\n\n* Vertex buffer objects\n* Vertex array objects\n* Shaders\n* Texture 2D\n* Single-tuple struct such as `VAO(GLuint)` to enforce correct OpenGL object type is passed in functions\n\n# Tuple Struct\n\nCurrent tuple structs:\n\n* `pub struct VBO(GLuint);` for vertex buffer objects\n* `pub struct VAO(GLuint);` for vertex array objects\n* `pub struct GLTexture(GLuint);` for texture objects\n* `pub struct GLShader(GLuint);` for programs/ shader object\n\nThese structs have no implemention (assosiated function), they are just there to enforce that the correct OpenGL functions are passed into functions.\nFor example:\n\n```rust\nlet mut vao = gl_gen_vertex_array();\ngl_bind_buffer(GLTarget::ArrayBuffer, vao);\n```\n\nwould not work, as `gl_bind_buffer` expects type `struct VBO(GLuint)`, but vao is of type `VAO(GLuint)`.\n\n# Roadmap\n\n* Framebuffer objects\n* More OpenGL functions (Right now there is basically only the minimum!)\n\n# Usage\n```toml\n[dependancies]\nrgl = \"0.2.0\"\ngl = \"0.6.0\"\n```\n\nThe `gl-rs` create (`gl`) is still needed for certain things such as window proc address and types (eg `GLuint`, `GLfloat` etc)\n\n## Examples\n\nAs mentioned above, this crate aims to be a more rust-like alternative to gl-rs.\n\nFor example, code from gl-rs such as:\n\n```rust\nlet mut vao = 0;\nlet mut vbo = 0;\n\nunsafe {\n    // Create Vertex Array Object\n    gl::GenVertexArrays(1, \u0026mut vao);\n    gl::BindVertexArray(vao);\n\n    // Create a Vertex Buffer Object and copy the vertex data to it\n    gl::GenBuffers(1, \u0026mut vbo);\n    gl::BindBuffer(gl::ARRAY_BUFFER, vbo);\n    gl::BufferData(\n        gl::ARRAY_BUFFER,\n        (VERTEX_DATA.len() * mem::size_of::\u003cGLfloat\u003e()) as GLsizeiptr,\n        mem::transmute(\u0026VERTEX_DATA[0]),\n        gl::STATIC_DRAW,\n    );\n    gl::EnableVertexAttribArray(0);\n    gl::VertexAttribPointer(\n        0,\n        2,\n        gl::FLOAT,\n        gl::FALSE as GLboolean,\n        0,\n        ptr::null(),\n    );\n}\n```\n\nIs instead written like\n\n```rust\n    //Create a vertex array object and a vertex buffer object\n    let mut vao = rgl::gen_vertex_array();\n    let mut vbo = rgl::gen_buffer();\n\n    //Generate and bind the VAO\n    rgl::gl_bind_vertex_array(vao);\n\n    //Generate and bind the VBO\n    rgl::gl_bind_buffer(rgl::Target::ArrayBuffer, vbo);\n\n    //Buffer the vertex data and tell OpenGL the structure\n    rgl::buffer_data(rgl::Target::ArrayBuffer, \u0026VERTEX_DATA, rgl::Usage::StaticDraw);\n    rgl::enable_vertex_attrib_array(0);\n    rgl::vertex_attrib_pointer(0, 2, rgl::Type::Float, false, 0);\n```\n\nChanges include:\n\n* snake_case over PascalCase for function names\n* rgl crate\n* No need for the `unsafe {...}` blocks\n* Strongly typed enums over the error-prone GLenum (Where you can easily pass the incorrect enum)\n* No need to cast types to `std::os::raw::c_void`, rusty-gl will do this for you\n* No need to cast string to `std::ffi::CString`, rusty-gl will do this for you\n\n## More examples\n\nExamples on using this crate can be found in the examples folder: https://github.com/Hopson97/rusty-gl/tree/master/Examples\n\nRun the examples with `cargo run`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHopson97%2Frusty-gl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHopson97%2Frusty-gl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHopson97%2Frusty-gl/lists"}