make directory name inline with other tests
[AROS.git] / workbench / libs / mesa / src / gallium / state_trackers / arosmesa / glacreatecontext.c
blob12bee0f0c3fc30b2f72405fb74cd6fcde64c8c06
1 /*
2 Copyright 2009-2010, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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 /*****************************************************************************
17 NAME */
19 GLAContext glACreateContext(
21 /* SYNOPSIS */
22 struct TagItem *tagList)
24 /* FUNCTION
26 Crates a GL rendering context that can be later used in subsequent
27 calls.
29 INPUTS
31 tagList - a pointer to tags to be used during creation.
33 TAGS
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
58 height.
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
64 be provided.
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
71 not supported.
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
77 capabilities.
79 GLA_NoStencil - disables the stencil buffer. Stencil buffer is enabled
80 by default.
82 GLA_NoAccum - disables the accumulation buffer. Accumulation buffer is
83 enabled by default.
85 RESULT
87 A valid GL context or NULL of creation was not succesfull.
89 BUGS
91 INTERNALS
93 HISTORY
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"));
105 return NULL;
108 AROSMesaSelectRastPort(amesa, tagList);
109 if (!amesa->visible_rp)
111 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to select visible rastport\n"));
112 goto error_out;
115 AROSMesaStandardInit(amesa, tagList);
117 pscreen = CreatePipeScreenV(NULL);
118 if (!pscreen)
120 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create gallium pipe screen\n"));
121 goto error_out;
124 if (!(amesa->stmanager = AROSMesaNewStManager(pscreen)))
126 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create ST Manager\n"));
127 DestroyPipeScreen(pscreen);
128 goto error_out;
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"));
135 goto error_out;
138 attribs.profile = ST_PROFILE_DEFAULT;
139 attribs.visual = amesa->stvis;
141 amesa->st = glstapi->create_context(glstapi, amesa->stmanager, &attribs, NULL);
142 if (!amesa->st)
144 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create mesa state tracker context\n"));
145 goto error_out;
148 amesa->framebuffer = AROSMesaNewFrameBuffer(amesa, &amesa->stvis);
150 if (!amesa->framebuffer)
152 D(bug("[AROSMESA] AROSMesaCreateContext: ERROR - failed to create frame buffer\n"));
153 goto error_out;
156 return amesa;
158 error_out:
159 if (amesa->stmanager) AROSMesaFreeStManager(amesa->stmanager);
160 if (amesa) AROSMesaFreeContext(amesa);
161 return NULL;