void VideoDriverGLES20::draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl_, const void* vdata, unsigned int size)
    {
        const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(decl_);

        const unsigned char* verticesData = (const unsigned char*)vdata;

        const VertexDeclarationGL::Element* el = decl->elements;
        for (int i = 0; i < decl->numElements; ++i)
        {
            oxglEnableVertexAttribArray(el->index);
            oxglVertexAttribPointer(el->index, el->size, el->elemType, el->normalized, decl->size, verticesData + el->offset);
            el++;
        }

        size_t primitives = size / decl->size;
        glDrawArrays(getPT(pt), 0, (GLsizei)primitives);

        el = decl->elements;
        for (int i = 0; i < decl->numElements; ++i)
        {
            oxglDisableVertexAttribArray(el->index);
            el++;
        }


#if OXYGINE_TRACE_VIDEO_STATS
        _debugAddPrimitives(pt, (int)(GLsizei)primitives);
#endif

        CHECKGL();
    }
    void VideoDriverGLES20::draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl_, const void* vdata, unsigned int verticesDataSize, const void* indicesData, unsigned int numIndices, bool indicesShortType)
    {
        const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(decl_);

        const unsigned char* verticesData = (const unsigned char*)vdata;

        const VertexDeclarationGL::Element* el = decl->elements;
        for (int i = 0; i < decl->numElements; ++i)
        {
            oxglEnableVertexAttribArray(el->index);
            oxglVertexAttribPointer(el->index, el->size, el->elemType, el->normalized, decl->size, verticesData + el->offset);
            el++;
        }

        glDrawElements(getPT(pt), numIndices, indicesShortType ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE, indicesData);

        el = decl->elements;
        for (int i = 0; i < decl->numElements; ++i)
        {
            oxglDisableVertexAttribArray(el->index);
            el++;
        }


#if OXYGINE_TRACE_VIDEO_STATS
        _debugAddPrimitives(pt, numIndices);
#endif
        CHECKGL();
    }
Ejemplo n.º 3
0
    void VideoDriverGLES20::draw(PRIMITIVE_TYPE pt, const VertexDeclaration *decl_, const void *vdata, unsigned int verticesDataSize, const void *indicesData, unsigned int numIndices, bool indicesShortType)
	{
		glBindBuffer(GL_ARRAY_BUFFER, _vbo);
		glBufferData(GL_ARRAY_BUFFER, verticesDataSize * decl_->size, vdata, GL_DYNAMIC_DRAW);

		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices * (indicesShortType ? 2 : 1), indicesData, GL_DYNAMIC_DRAW);

		const VertexDeclarationGL *decl = static_cast<const VertexDeclarationGL*>(decl_);

		const unsigned char *verticesData = (const unsigned char *)vdata;


		const VertexDeclarationGL::Element *el = decl->elements;
		for (int i = 0; i < decl->numElements; ++i)		
		{	
			glEnableVertexAttribArray(el->index);
			glVertexAttribPointer(el->index, el->size, el->elemType, el->normalized, decl->size, (void*)(el->offset));
			el++;
		}

		
		glDrawElements(getPT(pt), numIndices, indicesShortType ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE, 0);

		el = decl->elements;
		for (int i = 0; i < decl->numElements; ++i)		
		{			
			glDisableVertexAttribArray(el->index);
			el++;
		}

		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);


#if OXYGINE_TRACE_VIDEO_STATS
		_debugAddPrimitives(pt, numIndices);
#endif
        CHECKGL();
	}