void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
    
    int primitiveIndex = 0;
    GLenum primitive = GL_POINTS;
    int doRasterizerDiscard = 0;
    
    int status;
    GLenum error = GL_NO_ERROR;
    
    dotsMglClearGLErrors();
    
    // check for transform feedback extension!
    if (!dotsMglIsExtensionSupported(EXTENSION)){
        plhs[0] = mxCreateDoubleScalar(-1);
        mexPrintf("(dotsMglBeginTransformFeedback) %s is not supported!\n",
                EXTENSION);
        return;
    }
    
    // check input arguments
    if (nrhs < 1 || nrhs > 2 || !mxIsDouble(prhs[0]) || mxIsEmpty(prhs[0])) {
        plhs[0] = mxCreateDoubleScalar(-2);
        usageError("dotsMglBeginTransformFeedback");
        return;
    }
    
    // choose kind of primitive will be captured
    primitiveIndex = mxGetScalar(prhs[0]);
    if (primitiveIndex >= 0 && primitiveIndex < NUM_GL_PRIMITIVES)
        primitive = GL_PRIMITIVES[primitiveIndex];
    
    // choose to truncate the GL pipeline or allow drawing
    if (nrhs >= 2 && mxIsDouble(prhs[1]) && !mxIsEmpty(prhs[1])) {
        if (mxGetScalar(prhs[1]))
            glEnable(GL_RASTERIZER_DISCARD_EXT);
        else
            glDisable(GL_RASTERIZER_DISCARD_EXT);
    }
    
    // start capturing varyings
    glBeginTransformFeedbackEXT(primitive);
    error = glGetError();
    if (error != GL_NO_ERROR) {
        mexPrintf("(dotsMglSelectTransformFeedback) Could not begin transform feedback for primitive index %d (primitive=%d).  glGetError()=%d\n",
                primitiveIndex, primitive, error);
        plhs[0] = mxCreateDoubleScalar(-3);
        return;
    }
    
    // success!
    plhs[0] = mxCreateDoubleScalar(0);
}
Exemple #2
0
static bool
test_transform_feedback_prim(GLenum tf_prim, const char *tf_name)
{
	bool pass = true;
	int i;

	glBeginTransformFeedbackEXT(tf_prim);
	for (i = 0; i < ARRAY_SIZE(prims); i++) {
		pass = pass && test_one_prim(tf_prim, tf_name, i);
	}
	glEndTransformFeedbackEXT();

	return pass;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_glBeginTransformFeedbackEXT(JNIEnv *__env, jclass clazz, jint primitiveMode) {
    glBeginTransformFeedbackEXTPROC glBeginTransformFeedbackEXT = (glBeginTransformFeedbackEXTPROC)tlsGetFunction(1828);
    UNUSED_PARAM(clazz)
    glBeginTransformFeedbackEXT(primitiveMode);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_nglBeginTransformFeedbackEXT(JNIEnv *env, jclass clazz, jint primitiveMode, jlong function_pointer) {
	glBeginTransformFeedbackEXTPROC glBeginTransformFeedbackEXT = (glBeginTransformFeedbackEXTPROC)((intptr_t)function_pointer);
	glBeginTransformFeedbackEXT(primitiveMode);
}