1 /* $Id: ss_context.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Keith Whitwell <keithw@valinux.com>
32 #include "ss_context.h"
33 #include "ss_triangle.h"
35 #include "swrast_setup.h"
37 #include "tnl/t_context.h"
38 #include "tnl/t_pipeline.h"
41 #define _SWSETUP_NEW_VERTS (_NEW_RENDERMODE| \
49 #define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT)
54 _swsetup_CreateContext( GLcontext
*ctx
)
56 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
57 SScontext
*swsetup
= (SScontext
*)CALLOC(sizeof(SScontext
));
62 swsetup
->verts
= (SWvertex
*) ALIGN_MALLOC( sizeof(SWvertex
) * tnl
->vb
.Size
,
64 if (!swsetup
->verts
) {
69 ctx
->swsetup_context
= swsetup
;
71 swsetup
->NewState
= ~0;
72 _swsetup_vb_init( ctx
);
73 _swsetup_trifuncs_init( ctx
);
79 _swsetup_DestroyContext( GLcontext
*ctx
)
81 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
85 ALIGN_FREE(swsetup
->verts
);
87 if (swsetup
->ChanSecondaryColor
.Ptr
)
88 ALIGN_FREE(swsetup
->ChanSecondaryColor
.Ptr
);
90 if (swsetup
->ChanColor
.Ptr
)
91 ALIGN_FREE(swsetup
->ChanColor
.Ptr
);
94 ctx
->swsetup_context
= 0;
99 _swsetup_RenderPrimitive( GLcontext
*ctx
, GLenum mode
)
101 SWSETUP_CONTEXT(ctx
)->render_prim
= mode
;
105 _swsetup_RenderStart( GLcontext
*ctx
)
107 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
108 GLuint new_state
= swsetup
->NewState
;
110 if (new_state
& _SWSETUP_NEW_RENDERINDEX
) {
111 _swsetup_choose_trifuncs( ctx
);
114 if (new_state
& _SWSETUP_NEW_VERTS
) {
115 _swsetup_choose_rastersetup_func( ctx
);
118 swsetup
->NewState
= 0;
120 if (swsetup
->Driver
.Start
)
121 swsetup
->Driver
.Start( ctx
);
125 _swsetup_RenderFinish( GLcontext
*ctx
)
127 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
129 _swrast_flush( ctx
);
131 if (swsetup
->Driver
.Finish
)
132 swsetup
->Driver
.Finish( ctx
);
136 _swsetup_InvalidateState( GLcontext
*ctx
, GLuint new_state
)
138 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
139 swsetup
->NewState
|= new_state
;
144 _swsetup_Wakeup( GLcontext
*ctx
)
146 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
147 tnl
->Driver
.Render
.Start
= _swsetup_RenderStart
;
148 tnl
->Driver
.Render
.Finish
= _swsetup_RenderFinish
;
149 tnl
->Driver
.Render
.PrimitiveNotify
= _swsetup_RenderPrimitive
;
152 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
; /* new */
153 tnl
->Driver
.Render
.ClippedLine
= _tnl_RenderClippedLine
; /* new */
158 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
159 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
160 tnl
->Driver
.Render
.ResetLineStipple
= _swrast_ResetLineStipple
;
162 tnl
->Driver
.Render
.Multipass
= 0;
163 _tnl_need_projected_coords( ctx
, GL_TRUE
);
164 _swsetup_InvalidateState( ctx
, ~0 );