Files
libsst/Include/ZRenderer/ZIndexParams.hpp
2026-04-03 00:22:39 -05:00

164 lines
3.7 KiB
C++

/*
ZIndexParams.hpp
Author: James Russell <jcrussell@762studios.com>
Created: 7/1/2012
Purpose:
TODO
License:
TODO
*/
#pragma once
#ifndef _ZINDEXPARAMS_HPP
#define _ZINDEXPARAMS_HPP
#include <ZRenderer/ZDrawParams.hpp>
#include <ZSTL/ZSTL.hpp>
#include <ZUtil/ZUtil.hpp>
#include <ZRenderer/ZDataBuffer.hpp>
typedef enum ZIndexPrimitiveType {
ZIPT_TRIANGLES, //Unrelated triangles, n/3 primitives are drawn
ZIPT_TRISTRIP, //Triangle Strip, n-2 primitives are drawn
ZIPT_LINES, //Unrelated lines, n/2 primitives are drawn
ZIPT_LINESTRIP, //Line Strip, n-1 primitives are drawn
ZIPT_POINTS, //Point list, n primitives are drawn
} ZIndexPrimitiveType;
class ZIndexParams : public ZDrawParams
{
private:
//This is the bound index buffer and block
ZPtr<ZDataBuffer> IndexBuffer;
ZPair<ZDataBuffer*, const ZDataBufferBlock*> Binding;
ZIndexPrimitiveType primType;
size_t nrPrims;
size_t offset;
public:
/*
Default Constructor.
*/
ZIndexParams();
/*
public ZIndexParams::ClearBlock
Clears the current block definition and index buffer.
@return (void)
@context (all)
*/
void ClearIndexBlock();
/*
public ZIndexParams::SetBlock
Sets the index buffer and index block that will be being used.
@param _indexBuffer - data buffer containing index data
@param _block - the index block
@return (void)
@context (all)
*/
void SetIndexBlock(ZPtr<ZDataBuffer> _indexBuffer, const ZDataBufferBlock* _block);
/*
public ZIndexParams::SetPrimitiveDrawCount
Sets the number of primitives that will be drawn. This is not the number
of indices used in total. For example, 300 indices with triangles will draw
100 triangles, so the primitive draw count should be 100.
The special value of '0' is interpreted as "draw as many as possible".
@param count - The number of primitives
@return (void)
@context (all)
*/
void SetPrimitiveDrawCount(size_t _count) { nrPrims = _count; }
/*
public ZIndexParams::GetPrimitiveDrawCount
Gets the number of primitives that will be drawn.
@return (size_t) - The number of primitives
@context (all)
*/
size_t GetPrimitiveDrawCount() const { return nrPrims; }
/*
public ZIndexParams::SetDrawOffset
Sets starting point for drawing, measured in whole indices (not bytes). For example,
if you had a stream that contained { 1, 3, 5, 7 } and you wanted to draw
starting at '3', then you would use an offset of 1 -- regardless of the
type of index (8, 16, 32-bit).
@param _offset - The offset measured in whole indices
@return (void)
@context (all)
*/
void SetDrawOffset(size_t _offset) { offset = _offset; }
/*
public ZIndexParams::GetDrawOffset
Gets starting point for drawing, measured in whole indices (not bytes)
@return (size_t) - The offset
@context (all)
*/
size_t GetDrawOffset() const { return offset; }
/*
public ZIndexParams::SetPrimitiveType
Sets primitive type to draw.
@param _type - The primitive type
@return (void)
@context (all)
*/
void SetPrimitiveType(ZIndexPrimitiveType _type) { primType = _type; }
/*
public ZIndexParams::GetPrimitiveType
Gets the type of primitive being rendered
@return (ZIndexPrimitiveType) - The primitive type
@context (all)
*/
ZIndexPrimitiveType GetPrimitiveType() { return primType; }
/*
The following methods are used by the renderer to get the values needed when
binding shader parameter values to pass to the shader program, to mark
all bound resources as contended, and release contention.
*/
const ZPair<ZDataBuffer*, const ZDataBufferBlock*>* GetIndexBlock();
ZDataBuffer* GetIndexBuffer();
//Subclass Override
virtual void MarkResourcesContended();
//Subclass Override
virtual void ReleaseResourceContention();
};
#endif