disable debug
[AROS.git] / workbench / libs / mesa / src / aros / mesa3dgl / mesa3dgl_glacreatecontext.c
blobc5bb5ea020f27e763587c9dd8d08b2a048ec36d4
1 /*
2 Copyright 2009-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
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 /*****************************************************************************
21 NAME */
23 GLAContext glACreateContext(
25 /* SYNOPSIS */
26 struct TagItem *tagList)
28 /* FUNCTION
30 Crates a GL rendering context that can be later used in subsequent
31 calls.
33 INPUTS
35 tagList - a pointer to tags to be used during creation.
37 TAGS
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
62 height.
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
68 be provided.
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
75 not supported.
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
81 capabilities.
83 GLA_NoStencil - disables the stencil buffer. Stencil buffer is enabled
84 by default.
86 GLA_NoAccum - disables the accumulation buffer. Accumulation buffer is
87 enabled by default.
89 RESULT
91 A valid GL context or NULL of creation was not succesfull.
93 BUGS
95 INTERNALS
97 HISTORY
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__);
109 return NULL;
112 MESA3DGLSelectRastPort(ctx, tagList);
113 if (!ctx->visible_rp)
115 bug("%s: ERROR - failed to select visible rastport\n", __PRETTY_FUNCTION__);
116 goto error_out;
119 MESA3DGLStandardInit(ctx, tagList);
121 pscreen = CreatePipeScreenV(NULL);
122 if (!pscreen)
124 bug("%s: ERROR - failed to create gallium pipe screen\n", __PRETTY_FUNCTION__);
125 goto error_out;
128 if (!(ctx->stmanager = MESA3DGLNewStManager(pscreen)))
130 bug("%s: ERROR - failed to create ST Manager\n");
131 DestroyPipeScreen(pscreen);
132 goto error_out;
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__);
139 goto error_out;
142 attribs.profile = ST_PROFILE_DEFAULT;
143 attribs.visual = ctx->stvis;
145 ctx->st = glstapi->create_context(glstapi, ctx->stmanager, &attribs, NULL);
146 if (!ctx->st)
148 bug("%s: ERROR - failed to create mesa state tracker context\n", __PRETTY_FUNCTION__);
149 goto error_out;
152 ctx->framebuffer = MESA3DGLNewFrameBuffer(ctx, &ctx->stvis);
154 if (!ctx->framebuffer)
156 bug("%s: ERROR - failed to create frame buffer\n", __PRETTY_FUNCTION__);
157 goto error_out;
160 return (GLAContext)ctx;
162 error_out:
163 if (ctx->stmanager) MESA3DGLFreeStManager(ctx->stmanager);
164 if (ctx) MESA3DGLFreeContext(ctx);
165 return (GLAContext)NULL;