Пример #1
0
void GLBackend::do_setUniformBuffer(Batch& batch, size_t paramOffset) {
    GLuint slot = batch._params[paramOffset + 3]._uint;
    BufferPointer uniformBuffer = batch._buffers.get(batch._params[paramOffset + 2]._uint);
    GLintptr rangeStart = batch._params[paramOffset + 1]._uint;
    GLsizeiptr rangeSize = batch._params[paramOffset + 0]._uint;




#if (GPU_FEATURE_PROFILE == GPU_CORE)
    if (!uniformBuffer) {
        releaseUniformBuffer(slot);
        return;
    }
    
    // check cache before thinking
    if (_uniform._buffers[slot] == uniformBuffer) {
        return;
    }

    // Sync BufferObject
    auto* object = GLBackend::syncGPUObject(*uniformBuffer);
    if (object) {
        glBindBufferRange(GL_UNIFORM_BUFFER, slot, object->_buffer, rangeStart, rangeSize);

        _uniform._buffers[slot] = uniformBuffer;
        (void) CHECK_GL_ERROR();
    } else {
        releaseResourceTexture(slot);
        return;
    }
#else
    // because we rely on the program uniform mechanism we need to have
    // the program bound, thank you MacOSX Legacy profile.
    updatePipeline();
    
    GLfloat* data = (GLfloat*) (uniformBuffer->getData() + rangeStart);
    glUniform4fv(slot, rangeSize / sizeof(GLfloat[4]), data);
 
    // NOT working so we ll stick to the uniform float array until we move to core profile
    // GLuint bo = getBufferID(*uniformBuffer);
    //glUniformBufferEXT(_shader._program, slot, bo);

    (void) CHECK_GL_ERROR();

#endif
}
Пример #2
0
void GLBackend::do_setUniformBuffer(Batch& batch, uint32 paramOffset) {
    GLuint slot = batch._params[paramOffset + 3]._uint;
    BufferPointer uniformBuffer = batch._buffers.get(batch._params[paramOffset + 2]._uint);
    GLintptr rangeStart = batch._params[paramOffset + 1]._uint;
    GLsizeiptr rangeSize = batch._params[paramOffset + 0]._uint;

#if (GPU_FEATURE_PROFILE == GPU_CORE)
    GLuint bo = getBufferID(*uniformBuffer);
    glBindBufferRange(GL_UNIFORM_BUFFER, slot, bo, rangeStart, rangeSize);
#else
    GLfloat* data = (GLfloat*) (uniformBuffer->getData() + rangeStart);
    glUniform4fv(slot, rangeSize / sizeof(GLfloat[4]), data);
 
    // NOT working so we ll stick to the uniform float array until we move to core profile
    // GLuint bo = getBufferID(*uniformBuffer);
    //glUniformBufferEXT(_shader._program, slot, bo);
#endif
    (void) CHECK_GL_ERROR();
}
Пример #3
0
	void Client::send(BufferPointer buffer, bool reliable)
	{
		ENetPacket *packet = enet_packet_create(buffer->getData(),
			buffer->getSize(), reliable?ENET_PACKET_FLAG_RELIABLE:0);
		enet_peer_send(peer, 0, packet);
	}