Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 1 | |
2 | #include "main/colormac.h" |
||
3 | #include "main/fbobject.h" |
||
4 | #include "main/macros.h" |
||
5 | #include "main/teximage.h" |
||
6 | #include "main/renderbuffer.h" |
||
7 | #include "swrast/swrast.h" |
||
8 | #include "swrast/s_context.h" |
||
9 | #include "swrast/s_texfetch.h" |
||
10 | |||
11 | |||
12 | |||
13 | * Render-to-texture code for GL_EXT_framebuffer_object |
||
14 | */ |
||
15 | |||
16 | |||
17 | |||
18 | delete_texture_wrapper(struct gl_context *ctx, struct gl_renderbuffer *rb) |
||
19 | { |
||
20 | ASSERT(rb->RefCount == 0); |
||
21 | free(rb); |
||
22 | } |
||
23 | |||
24 | |||
25 | * Update the renderbuffer wrapper for rendering to a texture. |
||
26 | * For example, update the width, height of the RB based on the texture size, |
||
27 | * update the internal format info, etc. |
||
28 | */ |
||
29 | static void |
||
30 | update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) |
||
31 | { |
||
32 | struct gl_renderbuffer *rb = att->Renderbuffer; |
||
33 | struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); |
||
34 | struct swrast_texture_image *swImage; |
||
35 | gl_format format; |
||
36 | GLuint zOffset; |
||
37 | |||
38 | |||
39 | |||
40 | |||
41 | assert(swImage); |
||
42 | |||
43 | |||
44 | |||
45 | |||
46 | zOffset = 0; |
||
47 | } |
||
48 | else { |
||
49 | zOffset = att->Zoffset; |
||
50 | } |
||
51 | |||
52 | |||
53 | rb->Format = _mesa_get_srgb_format_linear(format); |
||
54 | |||
55 | |||
56 | } |
||
57 | |||
58 | |||
59 | |||
60 | |||
61 | * Called when rendering to a texture image begins, or when changing |
||
62 | * the dest mipmap level, cube face, etc. |
||
63 | * This is a fallback routine for software render-to-texture. |
||
64 | * |
||
65 | * Called via the glRenderbufferTexture1D/2D/3D() functions |
||
66 | * and elsewhere (such as glTexImage2D). |
||
67 | * |
||
68 | * The image we're rendering into is |
||
69 | * att->Texture->Image[att->CubeMapFace][att->TextureLevel]; |
||
70 | * It'll never be NULL. |
||
71 | * |
||
72 | * \param fb the framebuffer object the texture is being bound to |
||
73 | * \param att the fb attachment point of the texture |
||
74 | * |
||
75 | * \sa _mesa_framebuffer_renderbuffer |
||
76 | */ |
||
77 | void |
||
78 | _swrast_render_texture(struct gl_context *ctx, |
||
79 | struct gl_framebuffer *fb, |
||
80 | struct gl_renderbuffer_attachment *att) |
||
81 | { |
||
82 | struct gl_renderbuffer *rb = att->Renderbuffer; |
||
83 | (void) fb; |
||
84 | |||
85 | |||
86 | rb->Delete = delete_texture_wrapper; |
||
87 | |||
88 | |||
89 | } |
||
90 | |||
91 | |||
92 | |||
93 | _swrast_finish_render_texture(struct gl_context *ctx, |
||
94 | struct gl_renderbuffer *rb) |
||
95 | { |
||
96 | /* do nothing */ |
||
97 | /* The renderbuffer texture wrapper will get deleted by the |
||
98 | * normal mechanism for deleting renderbuffers. |
||
99 | */ |
||
100 | (void) ctx; |
||
101 | (void) rb; |
||
102 | } |
||
103 |