예제 #1
0
GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
{
    if (!array)
        return GL_FALSE;
    
    m_context->makeContextCurrent();
#if !PLATFORM(GTK) && !PLATFORM(QT) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
    return glIsVertexArrayAPPLE(array);
#else
    return GL_FALSE;
#endif
}
예제 #2
0
GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
{
    if (!array)
        return GL_FALSE;

    m_context->makeContextCurrent();
#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(NIX) || PLATFORM(JS))
    if (isVertexArrayObjectSupported())
        return glIsVertexArray(array);
#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
    return glIsVertexArrayAPPLE(array);
#endif
    return GL_FALSE;
}
예제 #3
0
GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
{
    if (!array)
        return GL_FALSE;

    m_context->makeContextCurrent();
#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN))
    if (isVertexArrayObjectSupported())
        return glIsVertexArray(array);
#elif PLATFORM(QT)
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
    if (isVertexArrayObjectSupported())
        return m_vaoFunctions->glIsVertexArray(array);
#endif
#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
    return glIsVertexArrayAPPLE(array);
#endif

    m_context->synthesizeGLError(GL_INVALID_OPERATION);
    return GL_FALSE;
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_APPLEVertexArrayObject_nglIsVertexArrayAPPLE(JNIEnv *env, jclass clazz, jint array, jlong function_pointer) {
	glIsVertexArrayAPPLEPROC glIsVertexArrayAPPLE = (glIsVertexArrayAPPLEPROC)((intptr_t)function_pointer);
	GLboolean __result = glIsVertexArrayAPPLE(array);
	return __result;
}
예제 #5
0
파일: vertex_draw.cpp 프로젝트: megrimm/Gem
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
void vertex_draw :: render(GemState *state)
{
  bool rebuild=(state->VertexDirty);
  //if(rebuild)post("rebuild");

  if (state->VertexArray == NULL || state->VertexArraySize <= 0) {
    //  post("no vertex array!");
    return;
  }
  int size = state->VertexArraySize;

  int color=m_color;
  if (state->ColorArray == NULL || state->HaveColorArray == 0) {
    //color = 0;
  }

  bool texcoord=m_texcoord;
  if (texcoord && (state->TexCoordArray == NULL
                   || state->HaveTexCoordArray == 0)) {
    post("no Texture Coordinate array!");
    texcoord = 0;
  }

  GLint drawType=m_drawType;
  if (state->drawType && m_defaultDraw) {
    drawType = state->drawType;
  }

  glShadeModel( GL_SMOOTH );
  glEnable(GL_BLEND);
  glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

#ifndef __VBO
///////////////////////////////////////////
// vertex_array_object

# ifdef __APPLE__
  if (m_vao) {
    if (!glIsVertexArrayAPPLE(1)) {
      post("vertex draw: not using VAO");
    }
    glBindVertexArrayAPPLE(1);
  }
# endif

  glDisableClientState(GL_INDEX_ARRAY);

  if(color && (state->ColorArray != NULL || state->HaveColorArray == 0) ) {
    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer(4,GL_FLOAT,0,state->ColorArray);
  } else {
    glDisableClientState(GL_COLOR_ARRAY);
  }

  if(texcoord) {
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,0,state->TexCoordArray);
//    glTexCoordPointer(2,GL_FLOAT,16,state->TexCoordArray);
  } else {
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  }

  if(state->HaveNormalArray || state->NormalArray!=NULL) {
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_FLOAT,0,state->NormalArray);
//      glNormalPointer(GL_FLOAT,16,state->NormalArray);
  }

  glEnableClientState(GL_VERTEX_ARRAY);
  glVertexPointer(4,GL_FLOAT,0,
                  reinterpret_cast<GLfloat *>(state->VertexArray));

#if defined GL_VERTEX_ARRAY_RANGE_APPLE
  glVertexArrayParameteriAPPLE(GL_VERTEX_ARRAY_STORAGE_HINT_APPLE,
                               GL_STORAGE_SHARED_APPLE);
  glVertexArrayRangeAPPLE( size,
                           reinterpret_cast<GLvoid *>(state->VertexArray));
  glEnableClientState( GL_VERTEX_ARRAY_RANGE_APPLE );
  glFlushVertexArrayRangeAPPLE( size,
                                reinterpret_cast<GLvoid *>(state->VertexArray));
#endif

  glDrawArrays(m_drawType,0,size);
  glDisableClientState(GL_VERTEX_ARRAY);

#if defined GL_VERTEX_ARRAY_RANGE_APPLE
  glDisableClientState(GL_VERTEX_ARRAY_RANGE_APPLE);
  glVertexArrayRangeAPPLE(0,0);
# endif

  if(color) {
    glDisableClientState(GL_COLOR_ARRAY);
  }
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);

  glDisable(GL_BLEND);

#else   /* YES, we want VBO ! */

  // set-up the VertexArray
  if (m_vao) {
    if (rebuild || !m_nVBOVertices ) {
      if(!m_nVBOVertices) {
        glGenBuffersARB( 1, &m_nVBOVertices );
      }

      glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOVertices);
      glBufferDataARB( GL_ARRAY_BUFFER_ARB,
                       size * state->VertexArrayStride * sizeof(float),
                       state->VertexArray, GL_DYNAMIC_DRAW_ARB );
      glVertexPointer( state->VertexArrayStride, GL_FLOAT,0,
                       reinterpret_cast<char*>(NULL));
    } else {
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOVertices);
      glVertexPointer( state->VertexArrayStride, GL_FLOAT,0,
                       reinterpret_cast<char*>(NULL));
    }
    glEnableClientState( GL_VERTEX_ARRAY );
  }

  // setup the ColorArray
  if( state->HaveColorArray || state->ColorArray != NULL ) {
    glEnableClientState(GL_COLOR_ARRAY);
    if (rebuild || !m_nVBOColor ) {
      if(!m_nVBOColor) {
        glGenBuffersARB( 1, &m_nVBOColor );
      }

      glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOColor);
      glBufferDataARB( GL_ARRAY_BUFFER_ARB, size*4*sizeof(float),
                       state->ColorArray, GL_DYNAMIC_DRAW_ARB );
      glColorPointer(4,GL_FLOAT,0,reinterpret_cast<char*>(NULL));
    } else {
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOColor);
      glColorPointer(4,GL_FLOAT,0,reinterpret_cast<char*>(NULL));
    }
  } else {
    glDisableClientState(GL_COLOR_ARRAY);
  }

  // setup the TexCoordArray
  if ( state->HaveTexCoordArray || state->TexCoordArray != NULL ) {
    if (rebuild || !m_nVBOTexCoords ) {
      if(!m_nVBOTexCoords) {
        glGenBuffersARB( 1, &m_nVBOTexCoords );
      }
      glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords);
      glBufferDataARB( GL_ARRAY_BUFFER_ARB, size*2*sizeof(float),
                       state->TexCoordArray, GL_DYNAMIC_DRAW_ARB );
      glTexCoordPointer(2, GL_FLOAT, 0, reinterpret_cast<char *>(NULL));
    } else {
      glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords);
      glTexCoordPointer(2, GL_FLOAT, 0, reinterpret_cast<char *>(NULL));
    }
  }

  // setup the NormalArray
  if(state->HaveNormalArray || state->NormalArray!=NULL) {
    glEnableClientState(GL_NORMAL_ARRAY);
    if (rebuild || !m_nVBONormals ) {
      if(!m_nVBONormals) {
        glGenBuffersARB( 1, &m_nVBONormals );
      }
      glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBONormals );
      glBufferDataARB( GL_ARRAY_BUFFER_ARB, size*1*sizeof(float),
                       state->NormalArray, GL_DYNAMIC_DRAW_ARB );
      glNormalPointer(GL_FLOAT,0, reinterpret_cast<char *>(NULL));
    } else {
      glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBONormals );
      glNormalPointer(GL_FLOAT,0, reinterpret_cast<char *>(NULL));
    }
  }

//  glEnableClientState(GL_VERTEX_ARRAY);
//  glVertexPointer( 4, GL_FLOAT,0, reinterpret_cast<char*>(NULL));

  glDrawArrays(drawType,0,size);
  glDisableClientState(GL_VERTEX_ARRAY);
  if(color) {
    glDisableClientState(GL_COLOR_ARRAY);
  }

  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  // if(texcoord)glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisable(GL_BLEND);
# endif /* VBO */
}
예제 #6
0
파일: vao-02.c 프로젝트: nobled/piglit
void
piglit_init(int argc, char **argv)
{
	GLuint obj;
	int pass = 1;
	void * ptr;
	GLenum err;

	piglit_require_extension("GL_APPLE_vertex_array_object");

	glGenVertexArraysAPPLE(1, & obj);
	glBindVertexArrayAPPLE(obj);
	glVertexPointer(4, GL_FLOAT, sizeof(GLfloat) * 4, (void *) 0xDEADBEEF);
	glEnableClientState(GL_VERTEX_ARRAY);

	glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);

	glDeleteVertexArraysAPPLE(1, & obj);
   
	err = glGetError();
	if (err) {
		printf("glGetError incorrectly returned 0x%04x.\n", err);
		pass = 0;
	}

	if ((*glIsVertexArrayAPPLE)(obj)) {
		printf("Array object is incorrectly still valid.\n");
		pass = 0;
	}

	err = glGetError();
	if (err) {
		printf("glGetError incorrectly returned 0x%04x.\n", err);
		pass = 0;
	}

	glPopClientAttrib();

	err = glGetError();
	if (err) {
		printf("glGetError incorrectly returned 0x%04x.\n", err);
		pass = 0;
	}

	if (! glIsVertexArrayAPPLE(obj)) {
		printf("Array object is incorrectly invalid.\n");
		pass = 0;
	}

	if (! glIsEnabled(GL_VERTEX_ARRAY)) {
		printf("Array state is incorrectly disabled.\n");
		pass = 0;
	}

	glGetPointerv(GL_VERTEX_ARRAY_POINTER, & ptr);
	if (ptr != (void *) 0xDEADBEEF) {
		printf("Array pointer is incorrectly set to 0x%p.\n", ptr);
		pass = 0;
	}

	if (! pass) {
		piglit_report_result(PIGLIT_FAIL);
	} else {
		piglit_report_result(PIGLIT_PASS);
	}
}