1 | <HTML> |
---|
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
3 | <!-- Created on , 12 2006 by texi2html 1.64 --> |
---|
4 | <!-- |
---|
5 | Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) |
---|
6 | Karl Berry <karl@freefriends.org> |
---|
7 | Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
8 | and many others. |
---|
9 | Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
10 | Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> |
---|
11 | |
---|
12 | --> |
---|
13 | <HEAD> |
---|
14 | <TITLE>OGRE Manual v1.2.0 ('Dagon'): Textures</TITLE> |
---|
15 | |
---|
16 | <META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Textures"> |
---|
17 | <META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Textures"> |
---|
18 | <META NAME="resource-type" CONTENT="document"> |
---|
19 | <META NAME="distribution" CONTENT="global"> |
---|
20 | <META NAME="Generator" CONTENT="texi2html 1.64"> |
---|
21 | <LINK TYPE="text/css" rel="stylesheet" href="../style.css"> |
---|
22 | </HEAD> |
---|
23 | |
---|
24 | <BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"> |
---|
25 | |
---|
26 | <A NAME="SEC250"></A> |
---|
27 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
28 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_55.html#SEC249"> < </A>]</TD> |
---|
29 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_55.html#SEC249"> Up </A>]</TD> |
---|
30 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_57.html#SEC254"> > </A>]</TD> |
---|
31 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
32 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
33 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
34 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
35 | </TR></TABLE> |
---|
36 | <HR SIZE=1> |
---|
37 | <H3> 5.8.1 Textures </H3> |
---|
38 | <!--docid::SEC250::--> |
---|
39 | <P> |
---|
40 | |
---|
41 | A texture is an image that can be applied onto the surface of a three dimensional model. In Ogre, textures are represented by the Texture resource class. |
---|
42 | </P><P> |
---|
43 | |
---|
44 | <A NAME="SEC251"></A> |
---|
45 | <H3> Creating a texture </H3> |
---|
46 | <!--docid::SEC251::--> |
---|
47 | <P> |
---|
48 | |
---|
49 | Textures are created through the TextureManager. In most cases they are created from image files directly by the |
---|
50 | Ogre resource system. If you are reading this, you most probably want to create a texture manually so that you can provide it with image data yourself. This is done through TextureManager::createManual: |
---|
51 | </P><P> |
---|
52 | |
---|
53 | <TABLE><tr><td> </td><td class=example><pre>ptex = TextureManager::getSingleton().createManual( |
---|
54 | "MyManualTexture", // Name of texture |
---|
55 | "General", // Name of resource group in which the texture should be created |
---|
56 | TEX_TYPE_2D, // Texture type |
---|
57 | 256, // Width |
---|
58 | 256, // Height |
---|
59 | 1, // Depth (Must be 1 for two dimensional textures) |
---|
60 | 0, // Number of mipmaps |
---|
61 | PF_A8R8G8B8, // Pixel format |
---|
62 | TU_DYNAMIC_WRITE_ONLY // usage |
---|
63 | ); |
---|
64 | </pre></td></tr></table></P><P> |
---|
65 | |
---|
66 | This example creates a texture named <EM>MyManualTexture</EM> in resource group <EM>General</EM>. It is a |
---|
67 | square <EM>two dimensional</EM> texture, with width 256 and height 256. It has <EM>no mipmaps</EM>, internal |
---|
68 | format <EM>PF_A8R8G8B8</EM> and usage <EM>TU_DYNAMIC_WRITE_ONLY</EM>. |
---|
69 | </P><P> |
---|
70 | |
---|
71 | The different texture types will be discussed in <A HREF="manual_58.html#SEC257">5.8.3 Texture Types</A>. Pixel formats are summarised in |
---|
72 | <A HREF="manual_59.html#SEC259">5.8.4 Pixel Formats</A>. |
---|
73 | </P><P> |
---|
74 | |
---|
75 | <A NAME="SEC252"></A> |
---|
76 | <H3> Texture usages </H3> |
---|
77 | <!--docid::SEC252::--> |
---|
78 | <P> |
---|
79 | |
---|
80 | In addition to the hardware buffer usages as described in See section <A HREF="manual_43.html#SEC232">5.2 Buffer Usage</A> there are some usage flags specific to textures: |
---|
81 | <DL COMPACT> |
---|
82 | <DT>TU_AUTOMIPMAP |
---|
83 | <DD>Mipmaps for this texture will be automatically generated by the graphics hardware. The exact algorithm used is not |
---|
84 | defined, but you can assume it to be a 2x2 box filter. |
---|
85 | <DT>TU_RENDERTARGET |
---|
86 | <DD>This texture will be a render target, ie. used as a target for render to texture. Setting this flag will ignore all other texture usages except TU_AUTOMIPMAP. |
---|
87 | <DT>TU_DEFAULT |
---|
88 | <DD>This is actualy a combination of usage flags, and is equivalent to TU_AUTOMIPMAP | TU_STATIC_WRITE_ONLY. The resource |
---|
89 | system uses these flags for textures that are loaded from images. |
---|
90 | <P> |
---|
91 | |
---|
92 | </DL> |
---|
93 | <P> |
---|
94 | |
---|
95 | <A NAME="SEC253"></A> |
---|
96 | <H3> Getting a PixelBuffer </H3> |
---|
97 | <!--docid::SEC253::--> |
---|
98 | <P> |
---|
99 | |
---|
100 | A Texture can consist of multiple PixelBuffers, one for each combo if mipmap level and face number. To get a PixelBuffer from a Texture object the method Texture::getBuffer(face, mipmap) is used: |
---|
101 | </P><P> |
---|
102 | |
---|
103 | <EM>face</EM> should be zero for non-cubemap textures. For cubemap textures it identifies the face to use, which is one of the cube faces described in See section <A HREF="manual_58.html#SEC257">5.8.3 Texture Types</A>. |
---|
104 | </P><P> |
---|
105 | |
---|
106 | <EM>mipmap</EM> is zero for the zeroth mipmap level, one for the first mipmap level, and so on. On textures that have automatic mipmap generation (TU_AUTOMIPMAP) only level 0 should be accessed, the rest will be taken care of by the rendering API. |
---|
107 | </P><P> |
---|
108 | |
---|
109 | A simple example of using getBuffer is |
---|
110 | <TABLE><tr><td> </td><td class=example><pre>// Get the PixelBuffer for face 0, mipmap 0. |
---|
111 | HardwarePixelBufferSharedPtr ptr = tex->getBuffer(0,0); |
---|
112 | </pre></td></tr></table></P><P> |
---|
113 | |
---|
114 | <A NAME="Updating Pixel Buffers"></A> |
---|
115 | <HR SIZE=1> |
---|
116 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
117 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_55.html#SEC249"> < </A>]</TD> |
---|
118 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_55.html#SEC249"> Up </A>]</TD> |
---|
119 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_57.html#SEC254"> > </A>]</TD> |
---|
120 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
121 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
122 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
123 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
124 | </TR></TABLE> |
---|
125 | <BR> |
---|
126 | <FONT SIZE="-1"> |
---|
127 | This document was generated |
---|
128 | by <I>Steve Streeting</I> on <I>, 12 2006</I> |
---|
129 | using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html |
---|
130 | "><I>texi2html</I></A> |
---|
131 | |
---|
132 | </BODY> |
---|
133 | </HTML> |
---|