v2.0.2
Classes | Macros | Functions
CC3OpenGL.h File Reference
#import "CC3Identifiable.h"
#import "CC3OSExtensions.h"
#import "CC3Matrix4x4.h"

Classes

class  CC3OpenGL
 
protocol  <CC3OpenGLDelegate>
 
struct  CC3VertexAttr
 

Macros

#define cc3_CheckGLPrim(val, var, isKnown)   cc3_CheckGLValue((val), ((var) == (val)), var, isKnown)
 
#define cc3_CheckGLStructValue(sArray, idx, val, VAR, IS_KNOWN)
 
#define cc3_CheckGLValue(val, equal, var, isKnown)
 
#define cc3_GetGLCap(cap, var, isKnown)
 
#define cc3_SetGLCap(cap, val, var, isKnown)
 
#define kCC3VertexAttributeIndexUnavailable   -1
 
#define LogInfoIfPrimary(fmt,...)   LogInfoIf(self.isRenderingContext, fmt, ##__VA_ARGS__)
 

Functions

BOOL CC3CheckGLBooleanAt (GLuint idx, BOOL val, GLbitfield *stateBits, GLbitfield *isKnownBits)
 
BOOL CC3CheckGLColorAt (GLuint idx, ccColor4F val, ccColor4F *stateArray, GLbitfield *isKnownBits)
 
BOOL CC3CheckGLfloatAt (GLuint idx, GLfloat val, GLfloat *stateArray, GLbitfield *isKnownBits)
 
BOOL CC3CheckGLuintAt (GLuint idx, GLuint val, GLuint *stateArray, GLbitfield *isKnownBits)
 
BOOL CC3CheckGLVector4At (GLuint idx, CC3Vector4 val, CC3Vector4 *stateArray, GLbitfield *isKnownBits)
 
BOOL CC3CheckGLVectorAt (GLuint idx, CC3Vector val, CC3Vector *stateArray, GLbitfield *isKnownBits)
 
void CC3SetGLCapAt (GLenum cap, GLuint idx, BOOL val, GLbitfield *stateBits, GLbitfield *isKnownBits)
 

Macro Definition Documentation

#define cc3_CheckGLPrim (   val,
  var,
  isKnown 
)    cc3_CheckGLValue((val), ((var) == (val)), var, isKnown)

Macro for checking the state of a single state primitive variable and updating the cached value if needed.

Evaluates the cc3_CheckGLValue macro, passing a simple ((var) == (val)) test as the equal expression.

#define cc3_CheckGLStructValue (   sArray,
  idx,
  val,
  VAR,
  IS_KNOWN 
)
Value:
BOOL needsUpdate = NO; \
if ( !((sArray[idx].VAR) == (val)) || !sArray[idx].IS_KNOWN) { \
sArray[idx].VAR = (val); \
sArray[idx].IS_KNOWN = YES; \
needsUpdate = YES; \
}

Macro for checking the state of a single state primitive value contained with an indexed array of structs, and updating the cached value if needed.

The sArray parameter is an array of structs, and the VAR and IS_KNOWN parameters are the names of the struct elements holding the value and isKnown indicator for the state, respectively. The idx parameter indexes into a particualr struct in the array.

Defines and sets a local variable called needsUpdate, to indicate whether the GL engine state should be updated by the method or function that invoked this macro. This needsUpdate flag is set to YES if the equal expression evaluates to NO, or the isKnown variable is set to NO.

Both the var and isKnown instance variables are updated.

This macro does not update the GL engine state. The calling function or method should do so if the needsUpdate local variable is YES.

#define cc3_CheckGLValue (   val,
  equal,
  var,
  isKnown 
)
Value:
BOOL needsUpdate = NO; \
if ( !(equal) || !isKnown) { \
var = (val); \
isKnown = YES; \
needsUpdate = YES; \
}

Macro for checking the state of a single state value and updating the cached value if needed.

  • val is the value to test.
  • var is the instance variable used to cache the state value. May be updated.
  • isKnown is the boolean instance variable that indicates whether the value is known. May be updated.
  • equal contains a logical expression that determines whether val and var are equal.

Defines and sets a local variable called needsUpdate, to indicate whether the GL engine state should be updated by the method or function that invoked this macro. This needsUpdate flag is set to YES if the equal expression evaluates to NO, or the isKnown variable is set to NO.

Both the var and isKnown instance variables are updated.

This macro does not update the GL engine state. The calling function or method should do so if the needsUpdate local variable is YES.

#define cc3_GetGLCap (   cap,
  var,
  isKnown 
)
Value:
if (!isKnown) var = glIsEnabled(cap); \
return var;

Macro for returning the state of a capability, retriving it from the GL engine if needed.

#define cc3_SetGLCap (   cap,
  val,
  var,
  isKnown 
)
Value:
if ( !CC3BooleansAreEqual(val, var) || !isKnown) { \
isKnown = YES; \
var = val; \
if (val) glEnable(cap); \
else glDisable(cap); \
LogGLErrorTrace(@"gl%@able(%@)", (onOff ? @"En" : @"Dis"), NSStringFromGLEnum(cap)); \
}

Macro for checking the state of a single capability and setting it in GL engine if needed.

#define kCC3VertexAttributeIndexUnavailable   -1

Indicates that vertex attribute array is not available.

#define LogInfoIfPrimary (   fmt,
  ... 
)    LogInfoIf(self.isRenderingContext, fmt, ##__VA_ARGS__)

If info logging is enabled AND this is the primary rendering context, logs the specified info message, otherwise does nothing.

Function Documentation

BOOL CC3CheckGLBooleanAt ( GLuint  idx,
BOOL  val,
GLbitfield *  stateBits,
GLbitfield *  isKnownBits 
)

Checks whether the specified boolean value changes the state of the GL engine for the state tracked at the specified index in the specified stateBits.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.

If either the GL state is not known, or the specified value is different than the value currently being tracked, this method updates the new value in the state cache, and marks the state value as known, and returns YES, indicating that the state in the GL engine should be updated. If the specified value is the same as the currently tracked state, this method returns NO.

BOOL CC3CheckGLColorAt ( GLuint  idx,
ccColor4F  val,
ccColor4F *  stateArray,
GLbitfield *  isKnownBits 
)

Checks whether the specified color value changes the state of the GL engine for the state tracked at the specified index in the specified stateArray.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.

If either the GL state is not known, or the specified value is different than the value currently being tracked, this method updates the new value in the state cache, and marks the state value as known, and returns YES, indicating that the state in the GL engine should be updated. If the specified value is the same as the currently tracked state, this method returns NO.

BOOL CC3CheckGLfloatAt ( GLuint  idx,
GLfloat  val,
GLfloat *  stateArray,
GLbitfield *  isKnownBits 
)

Checks whether the specified float value changes the state of the GL engine for the state tracked at the specified index in the specified stateArray.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.

If either the GL state is not known, or the specified value is different than the value currently being tracked, this method updates the new value in the state cache, and marks the state value as known, and returns YES, indicating that the state in the GL engine should be updated. If the specified value is the same as the currently tracked state, this method returns NO.

BOOL CC3CheckGLuintAt ( GLuint  idx,
GLuint  val,
GLuint *  stateArray,
GLbitfield *  isKnownBits 
)

Checks whether the specified uint value changes the state of the GL engine for the state tracked at the specified index in the specified stateArray.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.

If either the GL state is not known, or the specified value is different than the value currently being tracked, this method updates the new value in the state cache, and marks the state value as known, and returns YES, indicating that the state in the GL engine should be updated. If the specified value is the same as the currently tracked state, this method returns NO.

BOOL CC3CheckGLVector4At ( GLuint  idx,
CC3Vector4  val,
CC3Vector4 stateArray,
GLbitfield *  isKnownBits 
)

Checks whether the specified 4D vector value changes the state of the GL engine for the state tracked at the specified index in the specified stateArray.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.

If either the GL state is not known, or the specified value is different than the value currently being tracked, this method updates the new value in the state cache, and marks the state value as known, and returns YES, indicating that the state in the GL engine should be updated. If the specified value is the same as the currently tracked state, this method returns NO.

BOOL CC3CheckGLVectorAt ( GLuint  idx,
CC3Vector  val,
CC3Vector stateArray,
GLbitfield *  isKnownBits 
)

Checks whether the specified vector value changes the state of the GL engine for the state tracked at the specified index in the specified stateArray.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.

If either the GL state is not known, or the specified value is different than the value currently being tracked, this method updates the new value in the state cache, and marks the state value as known, and returns YES, indicating that the state in the GL engine should be updated. If the specified value is the same as the currently tracked state, this method returns NO.

void CC3SetGLCapAt ( GLenum  cap,
GLuint  idx,
BOOL  val,
GLbitfield *  stateBits,
GLbitfield *  isKnownBits 
)

Checks whether the specified value changes the state of the GL engine for the capability tracked at the specified index in the specified stateBits, and updates the GL engine with the new value if it has changed.

The isKnownBits bitfield keeps track of whether or not the GL state is known at this time.