Package com.ardor3d.util.shader.uniformtypes

Source Code of com.ardor3d.util.shader.uniformtypes.ShaderVariablePointerInt

/**
* Copyright (c) 2008-2012 Ardor Labs, Inc.
*
* This file is part of Ardor3D.
*
* Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/

package com.ardor3d.util.shader.uniformtypes;

import java.io.IOException;
import java.nio.IntBuffer;

import com.ardor3d.scenegraph.IntBufferData;
import com.ardor3d.util.export.InputCapsule;
import com.ardor3d.util.export.OutputCapsule;
import com.ardor3d.util.shader.ShaderVariable;

/** ShaderVariablePointerInt */
public class ShaderVariablePointerInt extends ShaderVariable {
    /**
     * Specifies the number of values for each element of the generic vertex attribute array. Must be 1, 2, 3, or 4.
     */
    public int size;
    /**
     * Specifies the byte offset between consecutive attribute values. If stride is 0 (the initial value), the attribute
     * values are understood to be tightly packed in the array.
     */
    public int stride;
    /**
     * Specifies whether fixed-point data values should be normalized (true) or converted directly as fixed-point values
     * (false) when they are accessed.
     */
    public boolean normalized;
    /** Specifies if the data is in signed or unsigned format */
    public boolean unsigned;
    /** The data for the attribute value */
    public IntBufferData data;

    @Override
    public boolean hasData() {
        return data != null && data.getBuffer() != null;
    }

    @Override
    public void write(final OutputCapsule capsule) throws IOException {
        super.write(capsule);
        capsule.write(size, "size", 0);
        capsule.write(stride, "stride", 0);
        capsule.write(normalized, "normalized", false);
        capsule.write(unsigned, "unsigned", false);
        capsule.write(data, "data", null);
    }

    @Override
    public void read(final InputCapsule capsule) throws IOException {
        super.read(capsule);
        size = capsule.readInt("size", 0);
        stride = capsule.readInt("stride", 0);
        normalized = capsule.readBoolean("normalized", false);
        unsigned = capsule.readBoolean("unsigned", false);
        data = (IntBufferData) capsule.readSavable("data", null);
        // XXX: transitional
        if (data == null) {
            final IntBuffer buff = capsule.readIntBuffer("data", null);
            if (buff != null) {
                data = new IntBufferData(buff);
            }
        }
    }
}
TOP

Related Classes of com.ardor3d.util.shader.uniformtypes.ShaderVariablePointerInt

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.