Skip to content
Snippets Groups Projects
Commit 54f25c8f authored by Eidolon's avatar Eidolon
Browse files

Add resizeable vertex array data structure.

This will be used for the vertex array buckets when building the
render lists for each FSurfaceInfo being used by the hardware
renderer. Generally, we will replace DrawPolygon calls with
operations to fill these resizeable arrays, one for each
FSurfaceInfo. After the initial BSP node draw call, we will go
through the buckets calling DrawPolygon on each one.
parent d1d05fad
No related branches found
No related tags found
No related merge requests found
......@@ -338,6 +338,7 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_trick.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_vertarray.c
)
set (SRB2_HWRENDER_HEADERS
......@@ -350,6 +351,7 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_vertarray.h
)
set(SRB2_R_OPENGL_SOURCES
......
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Resizeable vertex array implementation
#include "hw_vertarray.h"
#include "../z_zone.h"
#define RESIZE_FACTOR 2
void HWR_InitVertexArray(FVertexArray * varray, unsigned int initialSize)
{
varray->size = initialSize;
varray->used = 0;
varray->buffer = Z_Malloc(varray->size * sizeof(FOutVector), PU_STATIC, varray);
}
void HWR_FreeVertexArray(FVertexArray * varray)
{
Z_Free(varray->buffer);
}
void HWR_InsertVertexArray(FVertexArray * varray, int numElements, FOutVector * elements)
{
int i = 0;
if (varray->used + numElements >= varray->size)
{
varray->size *= RESIZE_FACTOR;
varray->buffer = Z_Realloc(varray->buffer, varray->size * sizeof(FOutVector), PU_STATIC, varray);
}
for (i = 0; i < numElements; i++)
{
varray->buffer[i + varray->used] = elements[i];
}
varray->used += numElements;
}
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Resizeable vertex array
#ifndef __HWR_VERTARRAY_H__
#define __HWR_VERTARRAY_H__
#include "hw_defs.h"
typedef struct
{
FOutVector * buffer;
unsigned int used;
unsigned int size;
} FVertexArray;
void HWR_InitVertexArray(FVertexArray * varray, unsigned int initialSize);
void HWR_FreeVertexArray(FVertexArray * varray);
void HWR_InsertVertexArray(FVertexArray * varray, int numElements, FOutVector * elements);
#endif // __HWR_VERTARRAY_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment