mesa: Pass GL context to _mesa_create_save_table
[mesa.git] / src / mesa / main / context.h
index 4e391dde4946a3d106d28131f0ec198318a5a8ae..e2387521f57879c649596c95937f4a9f7f47f8e8 100644 (file)
  * There are three large Mesa data types/classes which are meant to be
  * used by device drivers:
  * - struct gl_context: this contains the Mesa rendering state
- * - struct gl_config:  this describes the color buffer (RGB vs. ci), whether or not
- *   there's a depth buffer, stencil buffer, etc.
- * - struct gl_framebuffer:  contains pointers to the depth buffer, stencil buffer,
- *   accum buffer and alpha buffers.
+ * - struct gl_config:  this describes the color buffer (RGB vs. ci), whether
+ *   or not there's a depth buffer, stencil buffer, etc.
+ * - struct gl_framebuffer:  contains pointers to the depth buffer, stencil
+ *   buffer, accum buffer and alpha buffers.
  *
  * These types should be encapsulated by corresponding device driver
  * data types.  See xmesa.h and xmesaP.h for an example.
  *
- * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer are base classes
- * which the device driver must derive from.
+ * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer
+ * are base classes which the device driver must derive from.
  *
  * The following functions create and destroy these data types.
  */
 #include "mtypes.h"
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 struct _glapi_table;
 
 
@@ -233,7 +238,7 @@ do {                                                                \
  * glBegin()/glEnd() pair, with return value.
  * 
  * \param ctx GL context.
- * \param retval value to return value in case the assertion fails.
+ * \param retval value to return in case the assertion fails.
  */
 #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval)              \
 do {                                                                   \
@@ -274,7 +279,7 @@ do {                                                                        \
  * glBegin()/glEnd() pair and flush the vertices, with return value.
  * 
  * \param ctx GL context.
- * \param retval value to return value in case the assertion fails.
+ * \param retval value to return in case the assertion fails.
  */
 #define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)    \
 do {                                                                   \
@@ -285,29 +290,39 @@ do {                                                                      \
 /*@}*/
 
 
+/**
+ * Checks if the context is for Desktop GL (Compatibility or Core)
+ */
+static inline GLboolean
+_mesa_is_desktop_gl(const struct gl_context *ctx)
+{
+   return ctx->API == API_OPENGL || ctx->API == API_OPENGL_CORE;
+}
+
 
 /**
- * Is the secondary color needed?
+ * Checks if the context is for any GLES version
  */
-#define NEED_SECONDARY_COLOR(CTX)                                      \
-   (((CTX)->Light.Enabled &&                                           \
-     (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)    \
-    || (CTX)->Fog.ColorSumEnabled                                      \
-    || ((CTX)->VertexProgram._Current &&                               \
-        ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) &&    \
-        ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \
-    || ((CTX)->FragmentProgram._Current &&                             \
-        ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) &&  \
-        ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \
-   )
+static inline GLboolean
+_mesa_is_gles(const struct gl_context *ctx)
+{
+   return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
+}
 
 
 /**
- * Is RGBA LogicOp enabled?
+ * Checks if the context is for GLES 3.x
  */
-#define RGBA_LOGICOP_ENABLED(CTX) \
-  ((CTX)->Color.ColorLogicOpEnabled || \
-   ((CTX)->Color.BlendEnabled && (CTX)->Color.Blend[0].EquationRGB == GL_LOGIC_OP))
+static inline GLboolean
+_mesa_is_gles3(const struct gl_context *ctx)
+{
+   return ctx->API == API_OPENGLES2 && ctx->Version >= 30;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
 
 
 #endif /* CONTEXT_H */