Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Ult::RenderInterface Class Referenceabstract

#include <RenderInterface.h>

Inheritance diagram for Ult::RenderInterface:
Ult::OpenGLRenderer

Public Member Functions

 RenderInterface ()
 
virtual ~RenderInterface ()
 
virtual bool Initialize (const RenderParams *params)=0
 
virtual void Shutdown ()=0
 
virtual void SetViewport (int x, int y, int width, int height)=0
 
virtual void ResizeWindow (float fov, float nearDist, float farDist, int width, int height)=0
 
virtual void ResizeWindowOrtho (int left, int right, int bottom, int top, float nearDist, float farDist)=0
 
virtual void SetClearColor (int r, int g, int b, int a)=0
 
virtual void StartRendering (bool color, bool depth, bool stencil)=0
 
virtual void EndRendering ()=0
 
virtual bool Enable (RenderState state)=0
 
virtual bool Disable (RenderState state)=0
 
virtual void SetAlphaFunc (AlphaState state, float val)=0
 
virtual void SetView (float posX, float posY, float posZ, float lookX, float lookY, float lookZ, float upX, float upY, float upZ)=0
 
virtual void SetMatrix (const float *matrix)=0
 
virtual void MultiplyToCurrentMatrix (const float *m)=0
 
virtual bool SwitchMatrixType (MatrixType type)=0
 
virtual void GetMatrix (MatrixType type, float *matrix)=0
 
virtual void RotateMatrix (float angle, float x, float y, float z)=0
 
virtual void TranslateMatrix (float x, float y, float z)=0
 
virtual void LoadIdentityMatrix ()=0
 
virtual void PushMatrix ()=0
 
virtual void PopMatrix ()=0
 
virtual void ApplyFilters (Texture &handle, FilterListPtr filters)=0
 
virtual bool AddEmptyTexture (const char *name, int width, int height, int numComponents, TextureType type, TextureFormat format, Texture *handle)=0
 
virtual bool LoadTexFromFile (const char *fileName, TextureType type, Texture *handle)=0
 
virtual bool LoadTexFromMemory (const char *name, char *fileData, int length, TextureType type, Texture *handle)=0
 
virtual bool ApplyTexture (int texUnit, Texture &handle)=0
 
virtual void DeleteTexture (Texture &handle)=0
 
virtual bool CreateShaderFromFile (const char *vs, const char *ps, ShaderHandle *handle)=0
 
virtual bool CreateShaderFromMemory (const char *vsFile, const char *psFile, ShaderHandle *handle)=0
 
virtual void ApplyShader (ShaderHandle shader)=0
 
virtual void SetupShaderParameter (const char *pname, ShaderHandle shader, ParameterHandle *param)=0
 
virtual void SetShaderParameter1i (ParameterHandle param, float val)=0
 
virtual void SetShaderParameter1f (ParameterHandle param, float val)=0
 
virtual void SetShaderParameter2f (ParameterHandle param, float x, float y)=0
 
virtual void SetShaderParameter3f (ParameterHandle param, float x, float y, float z)=0
 
virtual void SetShaderParameter4f (ParameterHandle param, float x, float y, float z, float w)=0
 
virtual void Render (PrimitiveType type, VertexDescriptor *desc, char *vertexData, unsigned int *indices, int totalVertices, int totalIndices, int stride)=0
 

Protected Attributes

int mRed
 
int mGreen
 
int mBlue
 
int mAlpha
 
bool mMultiTexSupport
 
bool mCubeMapSupport
 
RenderParams mParams
 
CGcontext mCgContext
 
CGprofile mVsProfile
 
CGprofile mPsProfile
 

Detailed Description

Base class/interface for rendering graphics.

Constructor & Destructor Documentation

◆ RenderInterface()

Ult::RenderInterface::RenderInterface ( )

RenderInterface constructor.

◆ ~RenderInterface()

Ult::RenderInterface::~RenderInterface ( )
virtual

RenderInterface destructor.

Member Function Documentation

◆ AddEmptyTexture()

virtual bool Ult::RenderInterface::AddEmptyTexture ( const char * name,
int width,
int height,
int numComponents,
TextureType type,
TextureFormat format,
Texture * handle )
pure virtual

Initialize an empty texture and store a handle to it in 'handle'.

Implemented in Ult::OpenGLRenderer.

◆ ApplyFilters()

virtual void Ult::RenderInterface::ApplyFilters ( Texture & handle,
FilterListPtr filters )
pure virtual

Apply the input filters to the input texture.

Implemented in Ult::OpenGLRenderer.

◆ ApplyShader()

virtual void Ult::RenderInterface::ApplyShader ( ShaderHandle shader)
pure virtual

Use the given input shader for rendering.

Implemented in Ult::OpenGLRenderer.

◆ ApplyTexture()

virtual bool Ult::RenderInterface::ApplyTexture ( int texUnit,
Texture & handle )
pure virtual

Use the given texture for rendering in the given texture unit.

Implemented in Ult::OpenGLRenderer.

◆ CreateShaderFromFile()

virtual bool Ult::RenderInterface::CreateShaderFromFile ( const char * vs,
const char * ps,
ShaderHandle * handle )
pure virtual

Load/create a shader from the vertex/pixel files and store the result in handle.

Returns
True on success, false on failure.

Implemented in Ult::OpenGLRenderer.

◆ CreateShaderFromMemory()

virtual bool Ult::RenderInterface::CreateShaderFromMemory ( const char * vsFile,
const char * psFile,
ShaderHandle * handle )
pure virtual

Load/create a shader from vertex/pixel shader strings and store the result in handle.

Returns
True on success, false on failure.

Implemented in Ult::OpenGLRenderer.

◆ DeleteTexture()

virtual void Ult::RenderInterface::DeleteTexture ( Texture & handle)
pure virtual

Free the texture given by the input handle.

Implemented in Ult::OpenGLRenderer.

◆ Disable()

virtual bool Ult::RenderInterface::Disable ( RenderState state)
pure virtual

Disables the input render parameter.

Implemented in Ult::OpenGLRenderer.

◆ Enable()

virtual bool Ult::RenderInterface::Enable ( RenderState state)
pure virtual

Enables the input render parameter.

Implemented in Ult::OpenGLRenderer.

◆ EndRendering()

virtual void Ult::RenderInterface::EndRendering ( )
pure virtual

Updates the window, swaps front/back render buffers.

Implemented in Ult::OpenGLRenderer.

◆ GetMatrix()

virtual void Ult::RenderInterface::GetMatrix ( MatrixType type,
float * matrix )
pure virtual

Copy the matrix of the input type into the input matrix (as 16 floats).

Implemented in Ult::OpenGLRenderer.

◆ Initialize()

virtual bool Ult::RenderInterface::Initialize ( const RenderParams * params)
pure virtual

Initialize the render system with the given parameters. Assumes the window handle is already created/set.

Implemented in Ult::OpenGLRenderer.

◆ LoadIdentityMatrix()

virtual void Ult::RenderInterface::LoadIdentityMatrix ( )
pure virtual

Set the current matrix to an identity matrix.

Implemented in Ult::OpenGLRenderer.

◆ LoadTexFromFile()

virtual bool Ult::RenderInterface::LoadTexFromFile ( const char * fileName,
TextureType type,
Texture * handle )
pure virtual

Initialize a texture from a file and store a handle to it in 'handle'.

Implemented in Ult::OpenGLRenderer.

◆ LoadTexFromMemory()

virtual bool Ult::RenderInterface::LoadTexFromMemory ( const char * name,
char * fileData,
int length,
TextureType type,
Texture * handle )
pure virtual

Initialize a texture from memory and store a handle to it in 'handle'.

Implemented in Ult::OpenGLRenderer.

◆ MultiplyToCurrentMatrix()

virtual void Ult::RenderInterface::MultiplyToCurrentMatrix ( const float * m)
pure virtual

Multiplies the input matrix (as 16 floats) with the current matrix type.

Implemented in Ult::OpenGLRenderer.

◆ PopMatrix()

virtual void Ult::RenderInterface::PopMatrix ( )
pure virtual

Pop the top of the internal matrix stack to the current matrix.

Implemented in Ult::OpenGLRenderer.

◆ PushMatrix()

virtual void Ult::RenderInterface::PushMatrix ( )
pure virtual

Push the current matrix to the internal matrix stack.

Implemented in Ult::OpenGLRenderer.

◆ Render()

virtual void Ult::RenderInterface::Render ( PrimitiveType type,
VertexDescriptor * desc,
char * vertexData,
unsigned int * indices,
int totalVertices,
int totalIndices,
int stride )
pure virtual

Render a buffer of primitives using the current renderer settings.

Parameters
typeThe type of primitives contained in vertexData.
descPointer to a descriptor listing the different elements within a single vertex.
vertexDataByte pointer to the buffer of vertices to render.
indicesOptional pointer to an index buffer to render with.
totalVerticesThe size of vertexData in bytes.
totalIndicesThe count/number of indices contained in the indices pointer.
strideThe size of 1 vertex in bytes.

Implemented in Ult::OpenGLRenderer.

◆ ResizeWindow()

virtual void Ult::RenderInterface::ResizeWindow ( float fov,
float nearDist,
float farDist,
int width,
int height )
pure virtual

Update the size of the window. Recalculates the perspective-projection matrix with the given parameters.

Implemented in Ult::OpenGLRenderer.

◆ ResizeWindowOrtho()

virtual void Ult::RenderInterface::ResizeWindowOrtho ( int left,
int right,
int bottom,
int top,
float nearDist,
float farDist )
pure virtual

Update the size of the window. Recalculates the projection matrix as an orthographic projection using the given parameters.

Implemented in Ult::OpenGLRenderer.

◆ RotateMatrix()

virtual void Ult::RenderInterface::RotateMatrix ( float angle,
float x,
float y,
float z )
pure virtual

Applies a rotation about the given axis to the current matrix.

Parameters
angleRotation angle in degrees.
x,y,zAxis of rotation.

Implemented in Ult::OpenGLRenderer.

◆ SetAlphaFunc()

virtual void Ult::RenderInterface::SetAlphaFunc ( AlphaState state,
float val )
pure virtual

Sets the type of alpha blending to use during render.

Implemented in Ult::OpenGLRenderer.

◆ SetClearColor()

virtual void Ult::RenderInterface::SetClearColor ( int r,
int g,
int b,
int a )
pure virtual

Sets the background color of the window upon StartRendering.

Implemented in Ult::OpenGLRenderer.

◆ SetMatrix()

virtual void Ult::RenderInterface::SetMatrix ( const float * matrix)
pure virtual

Copy the input matrix (as 16 floats) to the current matrix type.

Implemented in Ult::OpenGLRenderer.

◆ SetShaderParameter1f()

virtual void Ult::RenderInterface::SetShaderParameter1f ( ParameterHandle param,
float val )
pure virtual

Set a shader uniform float to the given value.

Implemented in Ult::OpenGLRenderer.

◆ SetShaderParameter1i()

virtual void Ult::RenderInterface::SetShaderParameter1i ( ParameterHandle param,
float val )
pure virtual

Set a shader uniform int to the given value.

Implemented in Ult::OpenGLRenderer.

◆ SetShaderParameter2f()

virtual void Ult::RenderInterface::SetShaderParameter2f ( ParameterHandle param,
float x,
float y )
pure virtual

Set a shader uniform vec2 to the given values.

Implemented in Ult::OpenGLRenderer.

◆ SetShaderParameter3f()

virtual void Ult::RenderInterface::SetShaderParameter3f ( ParameterHandle param,
float x,
float y,
float z )
pure virtual

Set a shader uniform vec3 to the given values.

Implemented in Ult::OpenGLRenderer.

◆ SetShaderParameter4f()

virtual void Ult::RenderInterface::SetShaderParameter4f ( ParameterHandle param,
float x,
float y,
float z,
float w )
pure virtual

Set a shader uniform vec4 to the given values.

Implemented in Ult::OpenGLRenderer.

◆ SetupShaderParameter()

virtual void Ult::RenderInterface::SetupShaderParameter ( const char * pname,
ShaderHandle shader,
ParameterHandle * param )
pure virtual

Store a handle to the shader uniform given by pname in the input shader into param. If the uniform isn't found, it prints an error message and does nothing.

Implemented in Ult::OpenGLRenderer.

◆ SetView()

virtual void Ult::RenderInterface::SetView ( float posX,
float posY,
float posZ,
float lookX,
float lookY,
float lookZ,
float upX,
float upY,
float upZ )
pure virtual

Sets the camera/view/lookat matrix from the given parameters.

Implemented in Ult::OpenGLRenderer.

◆ SetViewport()

virtual void Ult::RenderInterface::SetViewport ( int x,
int y,
int width,
int height )
pure virtual

Sets the window viewport - position and size of the rendering area.

Implemented in Ult::OpenGLRenderer.

◆ Shutdown()

virtual void Ult::RenderInterface::Shutdown ( )
pure virtual

Deinits the render system. Does not free the render params window.

Implemented in Ult::OpenGLRenderer.

◆ StartRendering()

virtual void Ult::RenderInterface::StartRendering ( bool color,
bool depth,
bool stencil )
pure virtual

Clears the corresponding buffers if its boolean is set to true (color buffer, depth buffer, stencil buffer).

Implemented in Ult::OpenGLRenderer.

◆ SwitchMatrixType()

virtual bool Ult::RenderInterface::SwitchMatrixType ( MatrixType type)
pure virtual

Change the currently used matrix to the input type.

Implemented in Ult::OpenGLRenderer.

◆ TranslateMatrix()

virtual void Ult::RenderInterface::TranslateMatrix ( float x,
float y,
float z )
pure virtual

Applies a translation of x,y,z to the current matrix.

Implemented in Ult::OpenGLRenderer.

Member Data Documentation

◆ mAlpha

int Ult::RenderInterface::mAlpha
protected

◆ mBlue

int Ult::RenderInterface::mBlue
protected

◆ mCgContext

CGcontext Ult::RenderInterface::mCgContext
protected

◆ mCubeMapSupport

bool Ult::RenderInterface::mCubeMapSupport
protected

◆ mGreen

int Ult::RenderInterface::mGreen
protected

◆ mMultiTexSupport

bool Ult::RenderInterface::mMultiTexSupport
protected

◆ mParams

RenderParams Ult::RenderInterface::mParams
protected

◆ mPsProfile

CGprofile Ult::RenderInterface::mPsProfile
protected

◆ mRed

int Ult::RenderInterface::mRed
protected

◆ mVsProfile

CGprofile Ult::RenderInterface::mVsProfile
protected

The documentation for this class was generated from the following files: