34 lines
11 KiB
HTML
34 lines
11 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="raylib-rs"><meta name="keywords" content="rust, rustlang, rust-lang, raylib"><title>raylib - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script src="../crates.js"></script><script defer src="../main.js"></script>
|
||
<noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">☰</div><a class="sidebar-logo" href="../raylib/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.png" alt="logo"></div>
|
||
</a><h2 class="location">Crate raylib</h2><div class="block version"><div class="narrow-helper"></div><p>Version 3.7.0</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all raylib's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li></ul></div><div id="sidebar-vars" data-name="raylib" data-ty="mod" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../raylib/index.html"><img class="rust-logo" src="../rust-logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">raylib</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/raylib/lib.rs.html#17-80" title="goto source code">[src]</a></span></h1><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="raylib-rs" class="section-header"><a href="#raylib-rs">raylib-rs</a></h2>
|
||
<p><code>raylib</code> is a safe Rust binding to <a href="https://www.raylib.com/">Raylib</a>, a C library for enjoying games programming.</p>
|
||
<p>To get started, take a look at the <a href="fn.init_window.html"><code>init_window</code></a> function. This initializes Raylib and shows a window, and returns a <a href="struct.RaylibHandle.html"><code>RaylibHandle</code></a>. This handle is very important, because it is the way in which one accesses the vast majority of Raylib’s functionality. This means that it must not go out of scope until the game is ready to exit. You will also recieve a !Send and !Sync <a href="struct.RaylibThread.html"><code>RaylibThread</code></a> required for thread local functions.</p>
|
||
<p>For more control over the game window, the <a href="fn.init.html"><code>init</code></a> function will return a <a href="struct.RaylibBuilder.html"><code>RaylibBuilder</code></a> which allows for tweaking various settings such as VSync, anti-aliasing, fullscreen, and so on. Calling <a href="struct.RaylibBuilder.html#method.build"><code>RaylibBuilder::build</code></a> will then provide a <a href="struct.RaylibHandle.html"><code>RaylibHandle</code></a>.</p>
|
||
<p>Some useful constants can be found in the <a href="consts/index.html"><code>consts</code></a> module, which is also re-exported in the <a href="prelude/index.html"><code>prelude</code></a> module. In most cases you will probably want to <code>use raylib::prelude::*;</code> to make your experience more smooth.</p>
|
||
<h2 id="examples" class="section-header"><a href="#examples">Examples</a></h2>
|
||
<p>The classic “Hello, world”:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">raylib::prelude</span>::<span class="kw-2">*</span>;
|
||
|
||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">rl</span>, <span class="ident">thread</span>) <span class="op">=</span> <span class="ident">raylib::init</span>()
|
||
.<span class="ident">size</span>(<span class="number">640</span>, <span class="number">480</span>)
|
||
.<span class="ident">title</span>(<span class="string">"Hello, World"</span>)
|
||
.<span class="ident">build</span>();
|
||
|
||
<span class="kw">while</span> <span class="op">!</span><span class="ident">rl</span>.<span class="ident">window_should_close</span>() {
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">d</span> <span class="op">=</span> <span class="ident">rl</span>.<span class="ident">begin_drawing</span>(<span class="kw-2">&</span><span class="ident">thread</span>);
|
||
|
||
<span class="ident">d</span>.<span class="ident">clear_background</span>(<span class="ident">Color::WHITE</span>);
|
||
<span class="ident">d</span>.<span class="ident">draw_text</span>(<span class="string">"Hello, world!"</span>, <span class="number">12</span>, <span class="number">12</span>, <span class="number">20</span>, <span class="ident">Color::BLACK</span>);
|
||
}
|
||
}</code></pre></div>
|
||
</div></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2>
|
||
<div class="item-table"><div class="item-row"><div class="item-left import-item"><code>pub use crate::core::<a class="mod" href="core/collision/index.html" title="mod raylib::core::collision">collision</a>::*;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use crate::core::<a class="mod" href="core/file/index.html" title="mod raylib::core::file">file</a>::*;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use crate::core::<a class="mod" href="core/logging/index.html" title="mod raylib::core::logging">logging</a>::*;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use crate::core::misc::<a class="fn" href="core/misc/fn.get_random_value.html" title="fn raylib::core::misc::get_random_value">get_random_value</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use crate::core::misc::<a class="fn" href="core/misc/fn.open_url.html" title="fn raylib::core::misc::open_url">open_url</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use crate::<a class="mod" href="core/index.html" title="mod raylib::core">core</a>::*;</code></div><div class="item-right docblock-short"></div></div></div><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2>
|
||
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="consts/index.html" title="raylib::consts mod">consts</a></div><div class="item-right docblock-short"><p>Various constant enums to use with raylib</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="core/index.html" title="raylib::core mod">core</a></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="ease/index.html" title="raylib::ease mod">ease</a></div><div class="item-right docblock-short"><p>Easing and interpolation helpers.</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="ffi/index.html" title="raylib::ffi mod">ffi</a></div><div class="item-right docblock-short"><p>The raw, unsafe FFI binding, in case you need that escape hatch or the safe layer doesn’t provide something you need.</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="prelude/index.html" title="raylib::prelude mod">prelude</a></div><div class="item-right docblock-short"><p>The raylib-rs prelude.</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="rgui/index.html" title="raylib::rgui mod">rgui</a></div><div class="item-right docblock-short"></div></div></div><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2>
|
||
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.rstr.html" title="raylib::rstr macro">rstr</a></div><div class="item-right docblock-short"></div></div></div></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="raylib" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.59.0 (9d1b2106e 2022-02-23)" ></div>
|
||
</body></html> |