2 Copyright 2009-2016, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include <proto/gallium.h>
12 #include <gallium/gallium.h>
13 #include <gallium/pipe/p_context.h>
14 #include <gallium/pipe/p_screen.h>
16 #include "mesa3dgl_support.h"
17 #include "mesa3dgl_gallium.h"
19 /*****************************************************************************
23 GLAContext
glACreateContext(
26 struct TagItem
*tagList
)
30 Crates a GL rendering context that can be later used in subsequent
35 tagList - a pointer to tags to be used during creation.
39 GLA_Left - specifies the left rendering offset on the rastport.
40 Typically equals to window->BorderLeft.
42 GLA_Top - specifies the top rendering offset on the rastport.
43 Typically equals to window->BorderTop.
45 GLA_Right - specifies the right rendering offset on the rastport.
46 Typically equals to window->BorderRight.
48 GLA_Bottom - specifies the bottom rendering offset on the rastport.
49 Typically equals to window->BorderBottom.
51 GLA_Width - specifies the width of the rendering area.
52 GLA_Width + GLA_Left + GLA_Right should equal the width of
53 the rastport. The GLA_Width is interchangable at cration
54 time with GLA_Right. Later durring window resizing, width
55 is calculated from scalled left, righ and window width.
57 GLA_Height - specifies the height of the rendering area.
58 GLA_Height + GLA_Top + GLA_Bottom should equal the height
59 of the rastport. The GLA_Height is interchangable at
60 cration time with GLA_Bottom. Later durring window resizing
61 , height is calculated from scalled top, bottom and window
64 GLA_Screen - pointer to Screen onto which scene is to be rendered. When
65 selecting RastPort has lower priority than GLA_Window.
67 GLA_Window - pointer to Window onto which scene is to be rendered. Must
70 GLA_RastPort - ignored. Use GLA_Window.
72 GLA_DoubleBuf - ignored. All rendering is always double buffered.
74 GLA_RGBMode - ignored. All rendering is done in RGB. Indexed modes are
77 GLA_AlphaFlag - ignored. All rendering is done with alpha channel.
79 GLA_NoDepth - disables the depth/Z buffer. Depth buffer is enabled by
80 default and is 16 or 24 bit based on rendering
83 GLA_NoStencil - disables the stencil buffer. Stencil buffer is enabled
86 GLA_NoAccum - disables the accumulation buffer. Accumulation buffer is
91 A valid GL context or NULL of creation was not successful.
99 *****************************************************************************/
101 struct mesa3dgl_context
* ctx
= NULL
;
102 struct pipe_screen
* pscreen
= NULL
;
103 struct st_context_attribs attribs
= {0};
105 /* Allocate MESA3DGL context */
106 if (!(ctx
= (struct mesa3dgl_context
*)AllocVec(sizeof(struct mesa3dgl_context
), MEMF_PUBLIC
| MEMF_CLEAR
)))
108 bug("%s: ERROR - failed to allocate GLAContext\n", __PRETTY_FUNCTION__
);
112 MESA3DGLSelectRastPort(ctx
, tagList
);
113 if (!ctx
->visible_rp
)
115 bug("%s: ERROR - failed to select visible rastport\n", __PRETTY_FUNCTION__
);
119 MESA3DGLStandardInit(ctx
, tagList
);
121 pscreen
= CreatePipeScreenV(NULL
);
124 bug("%s: ERROR - failed to create gallium pipe screen\n", __PRETTY_FUNCTION__
);
128 if (!(ctx
->stmanager
= MESA3DGLNewStManager(pscreen
)))
130 bug("%s: ERROR - failed to create ST Manager\n");
131 DestroyPipeScreen(pscreen
);
135 D(bug("[MESA3DGL] %s: Filling ST Visual \n", __PRETTY_FUNCTION__
));
136 if (!MESA3DGLFillVisual(&ctx
->stvis
, ctx
->stmanager
->screen
, ctx
->BitsPerPixel
, tagList
))
138 bug("%s: ERROR - failed to fill ST Visual\n", __PRETTY_FUNCTION__
);
142 attribs
.profile
= ST_PROFILE_DEFAULT
;
143 attribs
.visual
= ctx
->stvis
;
145 ctx
->st
= glstapi
->create_context(glstapi
, ctx
->stmanager
, &attribs
, NULL
);
148 bug("%s: ERROR - failed to create mesa state tracker context\n", __PRETTY_FUNCTION__
);
152 ctx
->framebuffer
= MESA3DGLNewFrameBuffer(ctx
, &ctx
->stvis
);
154 if (!ctx
->framebuffer
)
156 bug("%s: ERROR - failed to create frame buffer\n", __PRETTY_FUNCTION__
);
160 return (GLAContext
)ctx
;
163 if (ctx
->stmanager
) MESA3DGLFreeStManager(ctx
->stmanager
);
164 if (ctx
) MESA3DGLFreeContext(ctx
);
165 return (GLAContext
)NULL
;