1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title xmlns:xlink="http://www.w3.org/1999/xlink">eglCreateContext - EGL Reference Pages</title> 5 <link rel="stylesheet" type="text/css" href="khronos-man.css"/> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"/> 7 </head> 8 <body> 9 <header/> 10 <div class="refentry" id="eglCreateContext"> 11 <div class="titlepage"/> 12 <div class="refnamediv"> 13 <h2>Name</h2> 14 <p>eglCreateContext — 15 create a new <abbr class="acronym">EGL</abbr> rendering context 16 </p> 17 </div> 18 <div class="refsynopsisdiv"> 19 <h2>C Specification</h2> 20 <div class="funcsynopsis"> 21 <table style="border: 0; cellspacing: 0; cellpadding: 0;" class="funcprototype-table"> 22 <tr> 23 <td> 24 <code class="funcdef">EGLContext <strong class="fsfunc">eglCreateContext</strong>(</code> 25 </td> 26 <td>EGLDisplay <var class="pdparam">display</var>, </td> 27 </tr> 28 <tr> 29 <td> </td> 30 <td>EGLConfig <var class="pdparam">config</var>, </td> 31 </tr> 32 <tr> 33 <td> </td> 34 <td>EGLContext <var class="pdparam">share_context</var>, </td> 35 </tr> 36 <tr> 37 <td> </td> 38 <td>EGLint const * <var class="pdparam">attrib_list</var><code>)</code>;</td> 39 </tr> 40 </table> 41 <div class="funcprototype-spacer"> </div> 42 </div> 43 </div> 44 <div class="refsect1" id="parameters"> 45 <h2>Parameters</h2> 46 <div class="variablelist"> 47 <dl class="variablelist"> 48 <dt> 49 <span class="term"> 50 <em class="parameter"> 51 <code>display</code> 52 </em> 53 </span> 54 </dt> 55 <dd> 56 <p> 57 Specifies the 58 <abbr class="acronym">EGL</abbr> 59 display connection. 60 </p> 61 </dd> 62 <dt> 63 <span class="term"> 64 <em class="parameter"> 65 <code>config</code> 66 </em> 67 </span> 68 </dt> 69 <dd> 70 <p>Specifies the EGL frame buffer configuration that 71 defines the frame buffer resource available to the rendering context. 72 </p> 73 </dd> 74 <dt> 75 <span class="term"> 76 <em class="parameter"> 77 <code>share_context</code> 78 </em> 79 </span> 80 </dt> 81 <dd> 82 <p> 83 Specifies another 84 <abbr class="acronym">EGL</abbr> 85 rendering context with which to share data, as 86 defined by the client API corresponding to the 87 contexts. Data is also shared with all other 88 contexts with which 89 <em class="parameter"><code>share_context</code></em> shares data. 90 <code class="constant">EGL_NO_CONTEXT</code> indicates that 91 no sharing is to take place. 92 </p> 93 </dd> 94 <dt> 95 <span class="term"> 96 <em class="parameter"> 97 <code>attrib_list</code> 98 </em> 99 </span> 100 </dt> 101 <dd> 102 <p> 103 Specifies attributes and attribute values for the 104 context being created. Only the attribute 105 <code class="constant">EGL_CONTEXT_CLIENT_VERSION</code> may 106 be specified. 107 </p> 108 </dd> 109 </dl> 110 </div> 111 </div> 112 <div class="refsect1" id="description"> 113 <h2>Description</h2> 114 <p> 115 <code class="function">eglCreateContext</code> creates an EGL 116 rendering context for the current rendering API (as set with 117 <code class="function">eglBindAPI</code>) and returns a handle to the 118 context. The context can then be used to render into an EGL 119 drawing surface. If <code class="function">eglCreateContext</code> 120 fails to create a rendering context, 121 <code class="constant">EGL_NO_CONTEXT</code> is returned. 122 </p> 123 <p> 124 If <em class="parameter"><code>share_context</code></em> is not 125 <code class="constant">EGL_NO_CONTEXT</code>, then all shareable data 126 in the context (as defined by the client API specification 127 for the current rendering API) are shared by context 128 <em class="parameter"><code>share_context</code></em>, all other contexts 129 <em class="parameter"><code>share_context</code></em> already shares with, 130 and the newly created context. An arbitrary number of 131 rendering contexts can share data. However, all rendering 132 contexts that share data must themselves exist in the same 133 address space. Two rendering contexts share an address space 134 if both are owned by a single process. 135 </p> 136 <p> 137 <em class="parameter"><code>attrib_list</code></em> specifies a list of 138 attributes for the context. The list has the same structure 139 as described for <code class="function">eglChooseConfig</code>. The 140 attributes and attribute values which may be specified are 141 as follows: 142 </p> 143 <div class="variablelist"> 144 <dl class="variablelist"> 145 <dt> 146 <span class="term"> 147 <code class="constant">EGL_CONTEXT_CLIENT_VERSION</code> 148 </span> 149 </dt> 150 <dd> 151 <p> 152 Must be followed by an integer that determines which 153 version of an OpenGL ES context to create. A value 154 of 1 specifies creation of an OpenGL ES 1.x context. 155 An attribute value of 2 specifies creation of an 156 OpenGL ES 2.x context. The default value is 1. This 157 attribute can only be specified when creating a 158 OpenGL ES context (e.g. when the current rendering 159 API is <code class="constant">EGL_OPENGL_ES_API</code>). 160 </p> 161 </dd> 162 </dl> 163 </div> 164 </div> 165 <div class="refsect1" id="notes"> 166 <h2>Notes</h2> 167 <p> 168 The current rendering API is only respected if the EGL 169 version is 1.2 or greater. Otherwise, an OpenGL ES context 170 will always be created. 171 </p> 172 <p> 173 The <code class="constant">EGL_CONTEXT_CLIENT_VERSION</code> 174 attribute is only supported if the EGL version is 1.3 or 175 greater. 176 </p> 177 <p> 178 A <em class="firstterm">process</em> is a single execution environment, 179 implemented in a single address space, consisting of one or more threads. 180 </p> 181 <p> 182 A <em class="firstterm">thread</em> is one of a set of subprocesses that 183 share a single address space, but maintain separate program counters, 184 stack spaces, and other related global data. 185 A thread is the only member of its subprocess group is equivalent to a 186 process. 187 </p> 188 </div> 189 <div class="refsect1" id="errors"> 190 <h2>Errors</h2> 191 <p> 192 <code class="constant">EGL_NO_CONTEXT</code> is returned if creation of 193 the context fails. 194 </p> 195 <p> 196 <code class="constant">EGL_BAD_MATCH</code> is generated if the 197 current rendering API is <code class="constant">EGL_NONE</code> (this 198 can only arise in an EGL implementation which does not 199 support OpenGL ES, prior to the first call to 200 <code class="function">eglBindAPI</code>). 201 </p> 202 <p> 203 <code class="constant">EGL_BAD_MATCH</code> is generated if the 204 server context state for 205 <em class="parameter"><code>share_context</code></em> exists in an address 206 space which cannot be shared with the newly created context, 207 if <em class="parameter"><code>share_context</code></em> was created on a 208 different display than the one referenced by 209 <em class="parameter"><code>config</code></em>, or if the contexts are 210 otherwise incompatible. 211 </p> 212 <p> 213 <code class="constant">EGL_BAD_DISPLAY</code> is generated if 214 <em class="parameter"><code>display</code></em> is not an EGL display connection. 215 </p> 216 <p> 217 <code class="constant">EGL_NOT_INITIALIZED</code> is generated if 218 <em class="parameter"><code>display</code></em> has not been initialized. 219 </p> 220 <p> 221 <code class="constant">EGL_BAD_CONFIG</code> is generated if 222 <em class="parameter"><code>config</code></em> is not an EGL frame buffer 223 configuration, or does not support the current rendering 224 API. This includes requesting creation of an OpenGL ES 1.x 225 context when the <code class="constant">EGL_RENDERABLE_TYPE</code> 226 attribute of <em class="parameter"><code>config</code></em> does not contain 227 <code class="constant">EGL_OPENGL_ES_BIT</code>, or creation of an 228 OpenGL ES 2.x context when the attribute does not contain 229 <code class="constant">EGL_OPENGL_ES2_BIT</code>. 230 </p> 231 <p> 232 <code class="constant">EGL_BAD_CONTEXT</code> is generated if 233 <em class="parameter"><code>share_context</code></em> is not an EGL rendering 234 context of the same client API type as the newly created 235 context and is not <code class="constant">EGL_NO_CONTEXT</code>. 236 </p> 237 <p> 238 <code class="constant">EGL_BAD_ATTRIBUTE</code> is generated if 239 <em class="parameter"><code>attrib_list</code></em> contains an invalid 240 context attribute or if an attribute is not recognized or 241 out of range. Note that attribute 242 <code class="constant">EGL_CONTEXT_CLIENT_VERSION</code> is 243 only valid when the current rendering API is 244 <code class="constant">EGL_OPENGL_ES_API</code>. 245 </p> 246 <p> 247 <code class="constant">EGL_BAD_ALLOC</code> is generated if there are not 248 enough resources to allocate the new context. 249 </p> 250 </div> 251 <div class="refsect1" id="seealso"> 252 <h2>See Also</h2> 253 <p> 254 <a class="citerefentry" href="eglDestroyContext.xhtml"><span class="citerefentry"><span class="refentrytitle">eglDestroyContext</span></span></a>, 255 <a class="citerefentry" href="eglChooseConfig.xhtml"><span class="citerefentry"><span class="refentrytitle">eglChooseConfig</span></span></a>, 256 <a class="citerefentry" href="eglGetConfigs.xhtml"><span class="citerefentry"><span class="refentrytitle">eglGetConfigs</span></span></a>, 257 <a class="citerefentry" href="eglMakeCurrent.xhtml"><span class="citerefentry"><span class="refentrytitle">eglMakeCurrent</span></span></a> 258 </p> 259 </div> 260 <p> 261 </p> 262 <div class="refsect3" id="copyright"> 263 <img src="KhronosLogo.jpg"/> 264 <p> 265 Copyright © 2003-2014 The Khronos Group Inc. 266 Permission is hereby granted, free of charge, to any person obtaining a 267 copy of this software and/or associated documentation files (the 268 "Materials"), to deal in the Materials without restriction, including 269 without limitation the rights to use, copy, modify, merge, publish, 270 distribute, sublicense, and/or sell copies of the Materials, and to 271 permit persons to whom the Materials are furnished to do so, subject to 272 the condition that this copyright notice and permission notice shall be included 273 in all copies or substantial portions of the Materials. 274 </p> 275 </div> 276 <p> 277</p> 278 </div> 279 <footer/> 280 </body> 281</html> 282