50 lines
10 KiB
HTML
50 lines
10 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Game Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheGameKit_Overview.html" title="The Game Kit" /><link rel="prev" href="BWindowScreen_Overview.html" title="BWindowScreen" /><link rel="next" href="TheInputServer_Overview.html" title="The Input Server" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BWindowScreen_Overview.html" title="BWindowScreen"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheGameKit_Overview.html" title="The Game Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheInputServer_Overview.html" title="The Input Server"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Game Kit</div></div><div id="headerB">Prev: <a href="BWindowScreen_Overview.html">BWindowScreen</a> Up: <a href="TheGameKit_Overview.html">The Game Kit</a> Next: <a href="TheInputServer_Overview.html">The Input Server</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheGameKit_CardHooks_Overview"></a>Graphics Card Hook Functions</h2></div></div></div><p>A graphics card driver can implement a
|
||
<a class="link" href="TheGameKit_CardHooks.html" title="Graphics Card Hook Functions">set of hook functions</a> that perform
|
||
specific tasks on behalf of the Application Server and the Game Kit's
|
||
<a class="link" href="BWindowScreen.html" title="BWindowScreen"><code class="classname">BWindowScreen</code></a>
|
||
object. Drivers should implement as many of these functions as they can.</p><p>The Application Server asks the driver for the locations of its hook
|
||
functions by passing the <code class="constant">B_GET_GRAPHICS_CARD_HOOKS</code> opcode. In response to
|
||
this request, the driver writes an array of function pointers to data,
|
||
cast as a <span class="type">graphics_card_hook</span> pointer (described below). The
|
||
<code class="constant">B_GET_GRAPHICS_CARD_HOOKS</code> request is made whenever the configuration of
|
||
the frame buffer changes. The driver can thus provide hook functions that
|
||
are tailored to specific frame buffer configurations.</p><p>The system can accommodate <code class="constant">B_GRAPHICS_HOOK_COUNT</code> (48) hook functions.
|
||
Currently, only the first 14 functions are used. These functions fall
|
||
into four groups:</p><dl class="variablelist"><dt><span class="term"><a class="link" href="TheGameKit_CardHooks.html#define_cursor" title="define_cursor()">Indices 0–2: Cursor management.</a></span></dt><dd><p>Drivers must implement all
|
||
three of these functions, or none of them.</p></dd><dt><span class="term"><a class="link" href="TheGameKit_CardHooks.html#draw_line_with_8_bit_depth" title="draw_line_with_8_bit_depth()">Indices 3–9,
|
||
12, and 13: Drawing functions.</a></span></dt><dd><p>These are specific drawing tasks, such as drawing a line or filling
|
||
a rectangle. A driver can implement as many of these as it wishes.</p></dd><dt><span class="term"><a class="link" href="TheGameKit_CardHooks.html#sync" title="sync()">Index 10: Driver/Application Server
|
||
synchronization.</a></span></dt><dd><p>Drivers should implement this function only if the other hook
|
||
functions are performed asynchronously.</p></dd><dt><span class="term"><a class="link" href="TheGameKit_CardHooks.html#invert_rect" title="invert_rect()">Index 11: Color inversion.</a></span></dt><dd><p>This function inverts the colors in a rectangle.</p></dd></dl><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id530724"></a>The graphics_card_hook Type</h3></div></div></div><p>All pointers in the hook function array are declared to be of type
|
||
<span class="type">graphics_card_hook</span>:</p><pre class="programlisting example c">typedef <span class="type">void</span> (*<span class="type">graphics_card_hook</span>)(<span class="type">void</span>)</pre><p>The code that fills data will look something like this:</p><pre class="programlisting example c"><span class="type">int32</span> <code class="function">control_graphics_card</code>(<span class="type">uint32</span> <code class="parameter">opcode</code>, <span class="type">void *</span><code class="parameter">data</code>)
|
||
{
|
||
switch (<code class="parameter">opcode</code>) {
|
||
...
|
||
case <code class="constant">B_GET_GRAPHICS_CARD_HOOKS</code>:
|
||
((<span class="type">graphics_card_hook *</span>)<code class="varname">data</code>)[0] =
|
||
(<span class="type">graphics_card_hook</span>)<code class="varname">define_cursor</code>;
|
||
|
||
((<span class="type">graphics_card_hook *</span>)<code class="varname">data</code>)[1] =
|
||
(<span class="type">graphics_card_hook</span>)<code class="varname">move_cursor</code>;
|
||
...
|
||
}
|
||
}</pre><p>Despite the <span class="type">graphics_card_hook</span> declaration, each
|
||
function has its own set of arguments and returns an integer error code.
|
||
All functions should return <code class="constant">B_OK</code> if they're
|
||
successful, and <code class="constant">B_ERROR</code> if not.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id530849"></a>Unimplemented Functions</h3></div></div></div><p>All hook functions that the driver doesn't implement (including indices
|
||
14–47) should be set to <code class="constant">NULL</code>. For example:</p><pre class="programlisting example c">((<span class="type">graphics_card_hook *</span>)<code class="varname">data</code>)[14] = (<span class="type">graphics_card_hook</span>)<code class="constant">NULL</code>;</pre><p>A driver can chose to nullify functions it does implement if it wants to
|
||
defer to the Application Server version.</p><div class="admonition warning"><div class="title">Warning</div><div class="graphic"><img class="icon" alt="Warning" width="32" src="./images/admonitions/Stop_32.png" /><div class="text"><p>Don't implement a function to simply (always) return <code class="constant">B_ERROR</code>. If you
|
||
want to declare a hook as a no-op, you must pass <code class="constant">NULL</code> as the pointer.</p></div></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id530912"></a>Coordinate Spaces</h3></div></div></div><p>Most hook function coordinates are in depth-independent "frame buffer
|
||
space" (the exceptions are well noted below). In other words, a
|
||
coordinate pair gives the location of a pixel in the frame buffer
|
||
independent of the buffer's depth; pixel (0, 0) is at the left top corner
|
||
of the frame buffer.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id530928"></a>Naming</h3></div></div></div><p>You can name the functions whatever you wish—the Application Server
|
||
finds the functions by index in the hook function array. For convenience
|
||
and clarity, the following descriptions suggest default names.</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BWindowScreen_Overview.html">BWindowScreen</a> Up: <a href="TheGameKit_Overview.html">The Game Kit</a> Next: <a href="TheInputServer_Overview.html">The Input Server</a> </div><div id="footerB"><div id="footerBL"><a href="BWindowScreen_Overview.html" title="BWindowScreen"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheGameKit_Overview.html" title="The Game Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheInputServer_Overview.html" title="The Input Server"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|