GlEnable: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''_glEnable:''' enable or disable server-side GL capabilities
{{DISPLAYTITLE:_glEnable}}
The '''_glEnable''' and '''_glDisable''' statements enable or disable OpenGL capabilities.




{{PageSyntax}}
{{PageSyntax}}
: [[_glEnable]] GLenum {{Parameter|cap}}


  SUB _glEnable (BYVAL cap AS _UNSIGNED LONG)
  void '''_glEnable'''(GLenum {{Parameter|cap}});


  SUB _glDisable (BYVAL cap AS _UNSIGNED LONG)
{{PageParameters}}
  void '''_glDisable'''(GLenum {{Parameter|cap}});
* OpenGL is using its own set of variable types to describe its command parameters.
 
* Use the following table to find the respective QB64 [[Variable Types]].
 
{{OpenGLTypesPlugin}}
; cap
: Specifies a symbolic constant indicating a GL capability.
 
 
{{PageSyntax}}
 
| name = glEnablei, glDisablei
| core = 3.0
}}
 
  void '''_glEnablei'''(GLenum {{Parameter|cap}}, GLuint {{Parameter|index}});
  void '''_glDisablei'''(GLenum {{Parameter|cap}}, GLuint {{Parameter|index}});
 
; cap
: Specifies a symbolic constant indicating a GL capability.
; index
: Specifies the index of the capability to enable/disable.




{{PageDescription}}
{{PageDescription}}
 
* OpenGL's documentation is available in several places, so we won't reproduce it here for another time.
'''_glEnable''' and {{KW|_glDisable}} enable and disable various capabilities. Use {{KW|_glIsEnabled}} or {{KW|_glGet}} to determine the current setting of any capability. The initial value for each capability with the exception of {{KW|_GL_DITHER}} and {{KW|_GL_MULTISAMPLE}} is {{KW|_GL_FALSE}}. The initial value for {{KW|_GL_DITHER}} and {{KW|_GL_MULTISAMPLE}} is {{KW|_GL_TRUE}}.
* The full description for this command can be found at [https://learn.microsoft.com/en-us/windows/win32/opengl/glenable Microsoft Docs] and is also valid for QB64 usage.
 
Both '''_glEnable''' and {{KW|_glDisable}} take a single argument, {{Parameter|cap}}, which can assume one of the following values:
 
; {{KW|_GL_BLEND}}
: If enabled, blend the computed fragment color values with the values in the color buffers. See [[GLAPI/glBlendFunc|glBlendFunc]]. Sets the blend enable/disable flag for all color buffers.
; {{KW|_GL_CLIP_DISTANCE}}''i''
: If enabled, clip geometry against user-defined half space ''i''.
; {{KW|_GL_COLOR_LOGIC_OP}}
: If enabled, apply the currently selected logical operation to the computed fragment color and color buffer values. See [[GLAPI/glLogicOp|glLogicOp]].
; {{KW|_GL_CULL_FACE}}
: If enabled, cull polygons based on their winding in window coordinates. See [[GLAPI/glCullFace|glCullFace]].
; {{KW|_GL_DEBUG_OUTPUT}}
: If enabled, debug messages are produced by a debug context. When disabled, the debug message log is silenced. Note that in a non-debug context, very few, if any messages might be produced, even when {{KW|_GL_DEBUG_OUTPUT}} is enabled.
; {{KW|_GL_DEBUG_OUTPUT_SYNCHRONOUS}}
: If enabled, debug messages are produced synchronously by a debug context. If disabled, debug messages may be produced asynchronously. In particular, they may be delayed relative to the execution of GL commands, and the debug callback function may be called from a thread other than that in which the commands are executed. See {{KW|_glDebugMessageCallback}}.
; {{KW|_GL_DEPTH_CLAMP}}
: If enabled, the -w<sub>c</sub> <= z<sub>c</sub> <= w<sub>c</sub> plane equation is ignored by view volume clipping (effectively, there is no near or far plane clipping). See [[GLAPI/glDepthRange|glDepthRange]].
; {{KW|_GL_DEPTH_TEST}}
: If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See [[GLAPI/glDepthFunc|glDepthFunc]] and [[GLAPI/glDepthRange|glDepthRange]].
; {{KW|_GL_DITHER}}
: If enabled, dither color components or indices before they are written to the color buffer.
; {{KW|_GL_FRAMEBUFFER_SRGB}}
: If enabled and the value of {{KW|_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING}} for the framebuffer attachment corresponding to the destination buffer is {{KW|_GL_SRGB}}, the R, G, and B destination color values (after conversion from fixed-point to floating-point) are considered to be encoded for the sRGB color space and hence are linearized prior to their use in blending.
; {{KW|_GL_LINE_SMOOTH}}
: If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See [[GLAPI/glLineWidth|glLineWidth]].
; {{KW|_GL_MULTISAMPLE}}
: If enabled, use multiple fragment samples in computing the final color of a pixel. See [[GLAPI/glSampleCoverage|glSampleCoverage]].
; {{KW|_GL_POLYGON_OFFSET_FILL}}
: If enabled, and if the polygon is rendered in {{KW|_GL_FILL}} mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See [[GLAPI/glPolygonOffset|glPolygonOffset]].
; {{KW|_GL_POLYGON_OFFSET_LINE}}
: If enabled, and if the polygon is rendered in {{KW|_GL_LINE}} mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See [[GLAPI/glPolygonOffset|glPolygonOffset]].
; {{KW|_GL_POLYGON_OFFSET_POINT}}
: If enabled, an offset is added to depth values of a polygon's fragments before the depth comparison is performed, if the polygon is rendered in {{KW|_GL_POINT}} mode. See [[GLAPI/glPolygonOffset|glPolygonOffset]].
; {{KW|_GL_POLYGON_SMOOTH}}
: If enabled, draw polygons with proper filtering. Otherwise, draw aliased polygons. For correct antialiased polygons, an alpha buffer is needed and the polygons must be sorted front to back.
; {{KW|_GL_PRIMITIVE_RESTART}}
: Enables primitive restarting. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the primitive restart index. See {{KW|_glPrimitiveRestartIndex}}.
; {{KW|_GL_PRIMITIVE_RESTART_FIXED_INDEX}}
: Enables primitive restarting with a fixed index. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the fixed primitive index for the specified index type. The fixed index is equal to <math>2^n - 1</math> where ''n'' is equal to 8 for {{KW|_GL_UNSIGNED_BYTE}}, 16 for {{KW|_GL_UNSIGNED_SHORT}} and 32 for {{KW|_GL_UNSIGNED_INT}}.
; {{KW|_GL_RASTERIZER_DISCARD}}
: If enabled, all primitives are discarded before rasterization, but ''after'' any optional transform feedback. Also causes {{KW|_glClear}} and {{KW|_glClearBuffer}} commands to be ignored.
; {{KW|_GL_SAMPLE_ALPHA_TO_COVERAGE}}
: If enabled, compute a temporary coverage value where each bit is determined by the alpha value at the corresponding sample location. The temporary coverage value is then ANDed with the fragment coverage value.
; {{KW|_GL_SAMPLE_ALPHA_TO_ONE}}
: If enabled, each sample alpha value is replaced by the maximum representable alpha value.
; {{KW|_GL_SAMPLE_COVERAGE}}
: If enabled, the fragment's coverage is ANDed with the temporary coverage value. If {{KW|_GL_SAMPLE_COVERAGE_INVERT}} is set to {{KW|_GL_TRUE}}, invert the coverage value. See [[GLAPI/glSampleCoverage|glSampleCoverage]].
; {{KW|_GL_SAMPLE_SHADING}}
: If enabled, the active fragment shader is run once for each covered sample, or at fraction of this rate as determined by the current value of {{KW|_GL_MIN_SAMPLE_SHADING_VALUE}}. See [[GLAPI/glMinSampleShading|glMinSampleShading]].
; {{KW|_GL_SAMPLE_MASK}}
: If enabled, the sample coverage mask generated for a fragment during rasterization will be ANDed with the value of {{KW|_GL_SAMPLE_MASK_VALUE}} before shading occurs. See [[GLAPI/glSampleMaski|glSampleMaski]].
; {{KW|_GL_SCISSOR_TEST}}
: If enabled, discard fragments that are outside the scissor rectangle. See [[GLAPI/glScissor|glScissor]].
; {{KW|_GL_STENCIL_TEST}}
: If enabled, do stencil testing and update the stencil buffer. See [[GLAPI/glStencilFunc|glStencilFunc]] and [[GLAPI/glStencilOp|glStencilOp]].
; {{KW|_GL_TEXTURE_CUBE_MAP_SEAMLESS}}
: If enabled, cubemap textures are sampled such that when linearly sampling from the border between two adjacent faces, texels from both faces are used to generate the final sample value. When disabled, texels from only a single face are used to construct the final sample value.
; {{KW|_GL_PROGRAM_POINT_SIZE}}
: If enabled and a vertex or geometry shader is active, then the derived point size is taken from the (potentially clipped) shader builtin {{code|gl_PointSize}} and clamped to the implementation-dependent point size range.
 
=== Indexed Capabilities ===
 
Some of the GL's capabilities are indexed. '''_glEnablei''' and '''_glDisablei''' enable and disable indexed capabilities. Only the following capabilities may be used with indices higher than zero:
 
; {{KW|_GL_BLEND}}
: If enabled, blend the computed fragment color values with the values in the specified color buffer. {{Parameter|index}} must be less than {{KW|_GL_MAX_DRAW_BUFFERS}} or {{KW|_GL_INVALID_VALUE}} will result. See [[GLAPI/glBlendFunc|glBlendFunc]].
 
 
{{PageErrors}}
 
{{KW|_GL_INVALID_ENUM}} is generated if {{Parameter|cap}} is not one of the values listed previously.
 
{{KW|_GL_INVALID_VALUE}} is generated by '''_glEnablei''' and '''_glDisablei''' if {{Parameter|index}} is greater than or equal to the number of indexed capabilities for {{Parameter|cap}}.
 
 
{{PageNotes}}
 
{{KW|_GL_PRIMITIVE_RESTART}} is available only if the GL version is 3.1 or greater.
 
{{KW|_GL_TEXTURE_CUBE_MAP_SEAMLESS}} is available only if the GL version is 3.2 or greater.
 
{{KW|_GL_PRIMITIVE_RESTART_FIXED_INDEX}} is available only if the GL version is 4.3 or greater.
 
{{KW|_GL_DEBUG_OUTPUT}} and {{KW|_GL_DEBUG_OUTPUT_SYNCHRONOUS}} are available only if the GL version is 4.3 or greater.
 
Any token accepted by '''_glEnable''' or '''_glDisable''' is also accepted by '''_glEnablei''' and '''_glDisablei''', but if the capability is not indexed, the maximum value that {{Parameter|index}} may take is zero.
 
In general, passing an indexed capability to '''_glEnable''' or '''_glDisable''' will enable or disable that capability for all indices, resepectively.
 
 
{{PageUseWith}}
 
{{KW|_glIsEnabled}}
 
{{KW|_glGet}}




{{PageSeeAlso}}
{{PageSeeAlso}}
* [[_GL|SUB _GL]]
* [[_glAlphaFunc]], [[_glArrayElement]], [[_glBegin]], [[_glBlendFunc]]
* [[_glClipPlane]], [[_glColorMaterial]], [[_glColorPointer]], [[_glCullFace]]
* [[_glDepthFunc]], [[_glDepthRange]], [[_glDisable]], [[_glDrawArrays]]
* [[_glEdgeFlagPointer]], [[_glEnd]], [https://learn.microsoft.com/en-us/windows/win32/opengl/glevalcoord-functions _glEvalCoord], [https://learn.microsoft.com/en-us/windows/win32/opengl/glevalmesh-functions _glEvalMesh]
* [https://learn.microsoft.com/en-us/windows/win32/opengl/glevalpoint _glEvalPoint], [https://learn.microsoft.com/en-us/windows/win32/opengl/glfog _glFog], [https://learn.microsoft.com/en-us/windows/win32/opengl/glgetbooleanv--glgetdoublev--glgetfloatv--glgetintegerv _glGet], [[_glIndexPointer]]
* [[_glIsEnabled]], [https://learn.microsoft.com/en-us/windows/win32/opengl/gllight-functions _glLight], [https://learn.microsoft.com/en-us/windows/win32/opengl/gllightmodel-functions _glLightModel], [[_glLineWidth]]
* [[_glLineStipple]], [[_glLogicOp]], [https://learn.microsoft.com/en-us/windows/win32/opengl/glmap1 _glMap1], [https://learn.microsoft.com/en-us/windows/win32/opengl/glmap2 _glMap2]
* [https://learn.microsoft.com/en-us/windows/win32/opengl/glmaterial-functions _glMaterial], [https://learn.microsoft.com/en-us/windows/win32/opengl/glnormal-functions _glNormal], [[_glNormalPointer]], [[_glPointSize]]
* [[_glPolygonMode]], [[_glPolygonStipple]], [[_glScissor]], [[_glStencilFunc]]
* [[_glStencilOp]], [[_glTexCoordPointer]], [https://learn.microsoft.com/en-us/windows/win32/opengl/gltexgen-functions _glTexGen], [[_glTexImage1D]]
* [[_glTexImage2D]]


[[_GL|SUB _GL]]
{{KW|_glActiveTexture}}, {{KW|_glBlendFunc}}, {{KW|_glCullFace}}, {{KW|_glDepthFunc}}, {{KW|_glDepthRange}}, {{KW|_glGet}}, {{KW|_glIsEnabled}}, {{KW|_glLineWidth}}, {{KW|_glLogicOp}}, {{KW|_glPointSize}}, {{KW|_glPolygonMode}}, {{KW|_glPolygonOffset}}, {{KW|_glSampleCoverage}}, {{KW|_glScissor}}, {{KW|_glStencilFunc}}, {{KW|_glStencilOp}}, {{KW|_glTexImage1D}}, {{KW|_glTexImage2D}}, {{KW|_glTexImage3D}}
{{PageCopyright}}


Copyright 1991-2006 Silicon Graphics, Inc. Copyright 2010-2011 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see [http://oss.sgi.com/projects/FreeB/ http://oss.sgi.com/projects/FreeB/].
{{PageNavigation}}

Latest revision as of 00:51, 28 January 2023

The _glEnable and _glDisable statements enable or disable OpenGL capabilities.


Syntax

_glEnable GLenum cap


Parameters

  • OpenGL is using its own set of variable types to describe its command parameters.
  • Use the following table to find the respective QB64 Variable Types.
   Table 2: Relations between the OpenGL variable types vs. C/C++ and QB64.
 ┌──────────────┬────────────────┬──────────────────────────────────────────┐
 │    OpenGLC/C++QB64                                 │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLenum       │ unsigned int   │ _UNSIGNED LONG                           │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLboolean    │ unsigned char  │ _UNSIGNED _BYTE                          │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLbitfield   │ unsigned int   │ _UNSIGNED LONG                           │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLbyte       │ signed char    │ _BYTE                                    │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLshort      │ short          │ INTEGER                                  │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLint        │ int            │ LONG                                     │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLsizei      │ int            │ LONG                                     │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLubyte      │ unsigned char  │ _UNSIGNED _BYTE                          │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLushort     │ unsigned short │ _UNSIGNED INTEGER                        │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLuint       │ unsigned int   │ _UNSIGNED LONG                           │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLfloat      │ float          │ SINGLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLclampf     │ float          │ SINGLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLdouble     │ double         │ DOUBLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLclampd     │ double         │ DOUBLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLvoid   (1) │ void           │ _OFFSET(any fixed lenght string or _BYTE │
 │              │                │         array element)                   │
 └──────────────┴────────────────┴──────────────────────────────────────────┘
 Note: If a parameter has an asterisk (*) in front, then it's a pointer to
       the designated OpenGL variable type, rather than a value of that type.
       Those must be passed using the _OFFSET(...) notation.

 E.g.  GLuint *anyParam is actually the offset of a _UNSIGNED LONG (~&)
       variable or array, which must be passed as _OFFSET(anyVar~&) or
       _OFFSET(anyArr~&()) respectively.

  (1)  This type is regularly only used for pointers (with asterisk (*)) to
       any byte sized memory data, hence _BYTE or fixed length strings.


Description

  • OpenGL's documentation is available in several places, so we won't reproduce it here for another time.
  • The full description for this command can be found at Microsoft Docs and is also valid for QB64 usage.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link