<commit_before>/*
    Copyright (C) 2002 by <NAME>
                          <NAME>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __IVIDEO_RNDBUF_H__
#define __IVIDEO_RNDBUF_H__

/** \file 
 * Render buffer interface
 */
 
/**
 * \addtogroup gfx3d
 * @{ */

#include "csutil/strset.h"

#include "ivideo/render3d.h"
#include "iengine/material.h"

class csVector3;
class csVector2;
class csColor;

struct iLightingInfo;
struct iTextureHandle;


/**
 * Where the buffer is placed
 * CS_BUF_INDEX is special and only to be used by indexbuffers
 */
typedef enum _CS_RENDERBUFFER_TYPE
{
  CS_BUF_DYNAMIC,
  CS_BUF_STATIC,
  CS_BUF_INDEX
} CS_RENDERBUFFER_TYPE;


SCF_VERSION (iRenderBuffer, 0, 0, 2);

/**
 * This is a general buffer to be used by the renderer. It can ONLY be
 * created by the VB manager
 */
struct iRenderBuffer : public iBase
{
  /**
   * Type of lock
   * CS_BUF_LOCK_NORMAL: Just get a point to the buffer, nothing special
   * CS_BUF_LOCK_DISCARD: Get a buffer to use just this frame/rendering
   * CS_BUF_LOCK_RENDER: Special lock only to be used by renderer
   */
  typedef enum _CS_BUFFER_LOCK_TYPE
  {
    CS_BUF_LOCK_NOLOCK,
    CS_BUF_LOCK_NORMAL,
    CS_BUF_LOCK_DISCARD,
    CS_BUF_LOCK_RENDER
  } CS_BUFFER_LOCK_TYPE;

  /**
   * Lock the buffer to allow writing and give us a pointer to the data
   * The pointer will be NULL if there was some error
   */
  virtual void* Lock(CS_BUFFER_LOCK_TYPE lockType) = 0;

  /// Releases the buffer. After this all writing to the buffer is illegal
  virtual void Release() = 0;


  /// Get type of buffer (where it's located)
  virtual CS_RENDERBUFFER_TYPE GetBufferType() = 0;

  /// Get the size of the buffer (in bytes)
  virtual int GetSize() = 0;

};

SCF_VERSION (iRenderBufferManager, 0, 0, 2);

struct iRenderBufferManager : public iBase
{
  /// Allocate a buffer of the specified type and return it

  virtual csPtr<iRenderBuffer> GetBuffer(int buffersize, CS_RENDERBUFFER_TYPE type) = 0;

};


SCF_VERSION (iStreamSource, 0, 0, 1);

struct iStreamSource : public iBase
{
  /// Get a named buffer
  virtual iRenderBuffer* GetBuffer (csStringID name) = 0;
};

class csRenderMesh
{
public:
  /// Type of mesh
  typedef enum
  {
    MESHTYPE_TRIANGLES,
    MESHTYPE_QUADS,
    MESHTYPE_TRIANGLESTRIP,
    MESHTYPE_TRIANGLEFAN,
    MESHTYPE_POINT,
    MESHTYPE_LINES,
    MESHTYPE_LINESTRIP
  } meshtype;

private: 
  meshtype type;
  unsigned int indexstart, indexend;
  csRef<iStreamSource> streamsource;
  csRef<iMaterialWrapper> matwrap;
  const char *defaultvertices;
  const char *defaulttexcoords;
  const char *defaultnormals;
  const char *defaultindices;

public:

  csRenderMesh () 
  {
    defaultvertices = "vertices";
    defaulttexcoords = "texture coordinates";
    defaultnormals = "normals";
    defaultindices = "indices";
  }

  /// Special attributes. Please don't change, it's used as flags
  typedef enum<commit_msg>* Fixed bug with mixmode not being set<commit_after>/*
    Copyright (C) 2002 by <NAME>
                          <NAME>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __IVIDEO_RNDBUF_H__
#define __IVIDEO_RNDBUF_H__

/** \file 
 * Render buffer interface
 */
 
/**
 * \addtogroup gfx3d
 * @{ */

#include "csutil/strset.h"

#include "ivideo/render3d.h"
#include "iengine/material.h"

class csVector3;
class csVector2;
class csColor;

struct iLightingInfo;
struct iTextureHandle;


/**
 * Where the buffer is placed
 * CS_BUF_INDEX is special and only to be used by indexbuffers
 */
typedef enum _CS_RENDERBUFFER_TYPE
{
  CS_BUF_DYNAMIC,
  CS_BUF_STATIC,
  CS_BUF_INDEX
} CS_RENDERBUFFER_TYPE;


SCF_VERSION (iRenderBuffer, 0, 0, 2);

/**
 * This is a general buffer to be used by the renderer. It can ONLY be
 * created by the VB manager
 */
struct iRenderBuffer : public iBase
{
  /**
   * Type of lock
   * CS_BUF_LOCK_NORMAL: Just get a point to the buffer, nothing special
   * CS_BUF_LOCK_DISCARD: Get a buffer to use just this frame/rendering
   * CS_BUF_LOCK_RENDER: Special lock only to be used by renderer
   */
  typedef enum _CS_BUFFER_LOCK_TYPE
  {
    CS_BUF_LOCK_NOLOCK,
    CS_BUF_LOCK_NORMAL,
    CS_BUF_LOCK_DISCARD,
    CS_BUF_LOCK_RENDER
  } CS_BUFFER_LOCK_TYPE;

  /**
   * Lock the buffer to allow writing and give us a pointer to the data
   * The pointer will be NULL if there was some error
   */
  virtual void* Lock(CS_BUFFER_LOCK_TYPE lockType) = 0;

  /// Releases the buffer. After this all writing to the buffer is illegal
  virtual void Release() = 0;


  /// Get type of buffer (where it's located)
  virtual CS_RENDERBUFFER_TYPE GetBufferType() = 0;

  /// Get the size of the buffer (in bytes)
  virtual int GetSize() = 0;

};

SCF_VERSION (iRenderBufferManager, 0, 0, 2);

struct iRenderBufferManager : public iBase
{
  /// Allocate a buffer of the specified type and return it

  virtual csPtr<iRenderBuffer> GetBuffer(int buffersize, CS_RENDERBUFFER_TYPE type) = 0;

};


SCF_VERSION (iStreamSource, 0, 0, 1);

struct iStreamSource : public iBase
{
  /// Get a named buffer
  virtual iRenderBuffer* GetBuffer (csStringID name) = 0;
};

class csRenderMesh
{
public:
  /// Type of mesh
  typedef enum
  {
    MESHTYPE_TRIANGLES,
    MESHTYPE_QUADS,
    MESHTYPE_TRIANGLESTRIP,
    MESHTYPE_TRIANGLEFAN,
    MESHTYPE_POINT,
    MESHTYPE_LINES,
    MESHTYPE_LINESTRIP
  } meshtype;

private: 
  meshtype type;
  unsigned int indexstart, indexend;
  csRef<iStreamSource> streamsource;
  csRef<iMaterialWrapper> matwrap;
  const char *defaultvertices;
  const char *defaulttexcoords;
  const char *defaultnormals;
  const char *defaultindices;

public:

  csRenderMesh () 
  {
    defaultvertices = "vertices";
    defaulttexcoords = "texture coordinates";
    defaultnormals = "normals";
    defaultindices = "indices";
    mixmode = CS_FX_COPY;
  }

  /// Special attributes. Please don't change, it's used as flags
  typedef enum
{'fraction_non_alphanumeric': 0.07173344348065537, 'fraction_numerical': 0.008811785763458625, 'mean_word_length': 3.4756623536660505, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3479115', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2313, 'n_words': 830}