2020-02-12 00:29:35 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// GLEW
|
|
|
|
#include <glew.h>
|
|
|
|
|
|
|
|
// DGL
|
|
|
|
#include "DGL_Enum.hpp"
|
2020-02-20 22:18:07 -08:00
|
|
|
#include "DGL_Types.hpp"
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
// Non-Standard C++
|
|
|
|
#include "Cpp_Alias.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-14 23:21:27 -08:00
|
|
|
namespace DGL
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn BindBuffer(EBufferTarget _targetType, ID<VertexBuffer> _buffer)
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-13 22:13:16 -08:00
|
|
|
glBindBuffer(GLenum(_targetType), _buffer);
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn BindVertexArray(gUInt _referenceToTrackArray)
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-13 22:13:16 -08:00
|
|
|
glBindVertexArray(_referenceToTrackArray);
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-13 22:13:16 -08:00
|
|
|
template<typename TypeOfData>
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn BufferData(ro Ref(TypeOfData) _data, EBufferTarget _targetType, EBufferUsage _usageType)
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
glBufferData(GLenum(_targetType), sizeof(TypeOfData), Address(_data), GLenum(_usageType));
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
template<typename Type>
|
|
|
|
sfn BufferData(ro Ref(Type) _data, gSize _sizeOfData, EBufferTarget _targetType, EBufferUsage _usageType)
|
2020-02-16 22:28:24 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
glBufferData(GLenum(_targetType), _sizeOfData, Address(_data), GLenum(_usageType));
|
2020-02-16 22:28:24 -08:00
|
|
|
}
|
|
|
|
|
2020-02-13 22:13:16 -08:00
|
|
|
template<typename... Type, typename = EFrameBuffer>
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn ClearBuffer(Type... _buffersToClear)
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
glClear( (gBitfield(_buffersToClear) | ...) );
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn DisableVertexAttributeArray(gInt _vertexAttributeArrayIndex)
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
|
|
|
glDisableVertexAttribArray(_vertexAttributeArrayIndex);
|
|
|
|
}
|
|
|
|
|
2020-02-16 22:28:24 -08:00
|
|
|
sfn DrawArrays(EPrimitives _primitive, gInt _startingIndex, gInt _numToRender)
|
|
|
|
{
|
|
|
|
glDrawArrays(GLenum(_primitive), _startingIndex, _numToRender); // Starting from vertex 0; 3 vertices total -> 1 triangle.
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn DrawElements(EPrimitives _primitive, gSize _numElements, EDataType _dataType, ro DataPtr _offfsetAddressFromFirstIndex)
|
2020-02-16 22:28:24 -08:00
|
|
|
{
|
|
|
|
glDrawElements(GLenum(_primitive), _numElements, GLenum(_dataType), _offfsetAddressFromFirstIndex);
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn EnableVertexAttributeArray(gInt _vertexAttributeArrayIndex)
|
2020-02-13 22:13:16 -08:00
|
|
|
{
|
|
|
|
glEnableVertexAttribArray(_vertexAttributeArrayIndex);
|
|
|
|
}
|
|
|
|
|
2020-02-12 00:29:35 -08:00
|
|
|
template<typename VertType>
|
|
|
|
sfn FormatVertexAttributes
|
|
|
|
(
|
2020-02-20 22:18:07 -08:00
|
|
|
gUInt _attributeIndex ,
|
|
|
|
EDataType _vertexComponenetType ,
|
|
|
|
ro ptr<void> _firstVertexComponentLocation,
|
|
|
|
gInt _numberOfVertexComponents ,
|
|
|
|
gBoolean _shouldNormalize
|
2020-02-12 00:29:35 -08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
glVertexAttribPointer
|
|
|
|
(
|
|
|
|
_attributeIndex ,
|
|
|
|
_numberOfVertexComponents ,
|
|
|
|
GLenum(_vertexComponenetType),
|
2020-02-20 22:18:07 -08:00
|
|
|
_shouldNormalize ,
|
2020-02-12 00:29:35 -08:00
|
|
|
sizeof(VertType ),
|
|
|
|
_firstVertexComponentLocation
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn GenerateBuffers(Ref(gUInt) _bufferReferencer, gSize _numberOfBuffersToReserve)
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
glGenBuffers(_numberOfBuffersToReserve, Address(_bufferReferencer));
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn GenerateVertexBuffers(Ref(gUInt) __referenceRetainerToBuffer, gSize _numOfObjectsToReserveFor)
|
2020-02-12 00:29:35 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
glGenVertexArrays(_numOfObjectsToReserveFor, Address(__referenceRetainerToBuffer));
|
2020-02-12 00:29:35 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2020-02-16 22:28:24 -08:00
|
|
|
|
2020-02-20 22:18:07 -08:00
|
|
|
sfn GetBufferParameterIV(EBufferTarget _target, EBufferParam _param, Ref(gInt) _dataStore)
|
2020-02-16 22:28:24 -08:00
|
|
|
{
|
2020-02-20 22:18:07 -08:00
|
|
|
glGetBufferParameteriv(GLenum(_target), GLenum(_param), Address(_dataStore));
|
2020-02-16 22:28:24 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2020-02-20 22:18:07 -08:00
|
|
|
|
|
|
|
// Used to get an offset from a specified location.
|
|
|
|
sfn Offset(uInt64 _offsetAmount)
|
|
|
|
{
|
|
|
|
return DataPtr(_offsetAmount);
|
|
|
|
}
|
|
|
|
|
|
|
|
sfn UnbindVertexArray()
|
|
|
|
{
|
|
|
|
BindVertexArray(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Provides an zero offset pointer specifier.
|
|
|
|
constexpr sfn ZeroOffset() -> ptr<void>
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2020-02-12 00:29:35 -08:00
|
|
|
}
|