2 Copyright 2009-2010, The AROS Development Team. All rights reserved.
6 #include "arosmesa_funcs.h"
7 #include "arosmesa_funcs_gallium.h"
8 #include <proto/exec.h>
9 #include <aros/debug.h>
10 #include <proto/gallium.h>
11 #include <gallium/gallium.h>
12 #include <gallium/pipe/p_context.h>
13 #include <gallium/pipe/p_screen.h>
15 /*****************************************************************************
19 GLAContext
glACreateContext(
22 struct TagItem
*tagList
)
26 Crates a GL rendering context that can be later used in subsequent
31 tagList - a pointer to tags to be used during creation.
35 GLA_Left - specifies the left rendering offset on the rastport.
36 Typically equals to window->BorderLeft.
38 GLA_Top - specifies the top rendering offset on the rastport.
39 Typically equals to window->BorderTop.
41 GLA_Right - specifies the right rendering offset on the rastport.
42 Typically equals to window->BorderRight.
44 GLA_Bottom - specifies the bottom rendering offset on the rastport.
45 Typically equals to window->BorderBottom.
47 GLA_Width - specifies the width of the rendering area.
48 GLA_Width + GLA_Left + GLA_Right should equal the width of
49 the rastport. The GLA_Width is interchangable at cration
50 time with GLA_Right. Later durring window resizing, width
51 is calculated from scalled left, righ and window width.
53 GLA_Height - specifies the height of the rendering area.
54 GLA_Height + GLA_Top + GLA_Bottom should equal the height
55 of the rastport. The GLA_Height is interchangable at
56 cration time with GLA_Bottom. Later durring window resizing
57 , height is calculated from scalled top, bottom and window
60 GLA_Screen - pointer to Screen onto which scene is to be rendered. When
61 selecting RastPort has lower priority than GLA_Window.
63 GLA_Window - pointer to Window onto which scene is to be rendered. Must
66 GLA_RastPort - ignored. Use GLA_Window.
68 GLA_DoubleBuf - ignored. All rendering is always double buffered.
70 GLA_RGBMode - ignored. All rendering is done in RGB. Indexed modes are
73 GLA_AlphaFlag - ignored. All rendering is done with alpha channel.
75 GLA_NoDepth - disables the depth/Z buffer. Depth buffer is enabled by
76 default and is 16 or 24 bit based on rendering
79 GLA_NoStencil - disables the stencil buffer. Stencil buffer is enabled
82 GLA_NoAccum - disables the accumulation buffer. Accumulation buffer is
87 A valid GL context or NULL of creation was not succesfull.
95 *****************************************************************************/
97 struct arosmesa_context
* amesa
= NULL
;
98 struct pipe_screen
* pscreen
= NULL
;
99 struct st_context_attribs attribs
= {0};
101 /* Allocate arosmesa_context struct initialized to zeros */
102 if (!(amesa
= (struct arosmesa_context
*)AllocVec(sizeof(struct arosmesa_context
), MEMF_PUBLIC
| MEMF_CLEAR
)))
104 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to allocate AROSMesaContext\n"));
108 AROSMesaSelectRastPort(amesa
, tagList
);
109 if (!amesa
->visible_rp
)
111 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to select visible rastport\n"));
115 AROSMesaStandardInit(amesa
, tagList
);
117 pscreen
= CreatePipeScreenV(NULL
);
120 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create gallium pipe screen\n"));
124 if (!(amesa
->stmanager
= AROSMesaNewStManager(pscreen
)))
126 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create ST Manager\n"));
127 DestroyPipeScreen(pscreen
);
131 D(bug("[AROSMESA] AROSMesaCreateContext: Filling ST Visual \n"));
132 if (!AROSMesaFillVisual(&amesa
->stvis
, amesa
->stmanager
->screen
, amesa
->BitsPerPixel
, tagList
))
134 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to fill ST Visual\n"));
138 attribs
.profile
= ST_PROFILE_DEFAULT
;
139 attribs
.visual
= amesa
->stvis
;
141 amesa
->st
= glstapi
->create_context(glstapi
, amesa
->stmanager
, &attribs
, NULL
);
144 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create mesa state tracker context\n"));
148 amesa
->framebuffer
= AROSMesaNewFrameBuffer(amesa
, &amesa
->stvis
);
150 if (!amesa
->framebuffer
)
152 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create frame buffer\n"));
159 if (amesa
->stmanager
) AROSMesaFreeStManager(amesa
->stmanager
);
160 if (amesa
) AROSMesaFreeContext(amesa
);