void StaticGeometryHandler::add_for_draw(DatasetReference dataset, const LMatrix4f &transform) {

    PTA_uchar handle = _drawn_objects_tex->modify_ram_image();
    float* f_handle = reinterpret_cast<float*>(handle.p());
    
    // Store the new amount of rendered objects
    f_handle[0] = _num_rendered_objects + 1;
    f_handle[1] = 0;
    f_handle[2] = 0;
    f_handle[3] = 0;

    int data_offset = 4 + _num_rendered_objects * 20;

    f_handle[data_offset++] = dataset; // Render object with ID n
    f_handle[data_offset++] = 0; // reserved
    f_handle[data_offset++] = 0; // reserved
    f_handle[data_offset++] = 0; // reserved

    for (LMatrix4f::iterator iter = transform.begin(); iter != transform.end(); ++iter) {
        f_handle[data_offset++] = (*iter);
    }

    _num_rendered_objects ++;

}
Exemple #2
0
/**
 * @brief Writes the GPU command to a given target.
 * @details This method writes all the data of the GPU command to a given target.
 *   The target should be a pointer to memory being big enough to hold the
 *   data. Presumably #dest will be a handle to texture memory.
 *   The command_index controls the offset where the data will be written
 *   to.
 *
 * @param dest Handle to the memory to write the command to
 * @param command_index Offset to write the command to. The command will write
 *   its data to command_index * GPU_COMMAND_ENTRIES. When writing
 *   the GPUCommand in a GPUCommandList, the command_index will
 *   most likely be the index of the command in the list.
 */
void GPUCommand::write_to(const PTA_uchar &dest, size_t command_index) {
    size_t command_size = GPU_COMMAND_ENTRIES * sizeof(float);
    size_t offset = command_index * command_size;
    memcpy(dest.p() + offset, &_data, command_size);
}