Stardew Engine
Loading...
Searching...
No Matches
DrawContext.c File Reference
#include "DrawContext.h"
#include <string.h>
#include <glad/glad.h>
#include <cglm/cglm.h>
#include "ObjectPool.h"
#include "Widget.h"
#include "DynArray.h"
#include "AssertLib.h"
#include "PlatformDefs.h"
#include "Game2DLayer.h"
#include "Log.h"
Include dependency graph for DrawContext.c:

Data Structures

struct  IndexedVertexBuffer
 
struct  VertexBuffer
 
struct  Shader
 

Enumerations

enum  ShaderType { ST_Vertex , ST_Fragment , ST_Program , ST_NUM }
 

Functions

 OBJECT_POOL (struct VertexBuffer)
 
void WorldspaceVertexBufferData (HUIVertexBuffer hBuf, Worldspace2DVert *src, size_t size, VertIndexT *indices, u32 numIndices)
 
void DrawWorldspaceVertexBuffer (H2DWorldspaceVertexBuffer hBuf, size_t indexCount, mat4 view)
 
void DestroyWorldspaceVertexBuffer (H2DWorldspaceVertexBuffer hBuf)
 
DrawContext Dr_InitDrawContext ()
 
void Dr_OnScreenDimsChange (DrawContext *pCtx, int newW, int newH)
 

Variables

const char * uiVert
 
const char * uiFrag
 
const char * worldspaceVert
 
const char * worldspaceFrag
 
struct Shader gUIShader = {0,0,0}
 
struct Shader gWorldspace2DShader = { 0,0,0 }
 
mat4 gScreenspaceOrtho
 

Enumeration Type Documentation

◆ ShaderType

enum ShaderType
Enumerator
ST_Vertex 
ST_Fragment 
ST_Program 
ST_NUM 

Function Documentation

◆ DestroyWorldspaceVertexBuffer()

void DestroyWorldspaceVertexBuffer ( H2DWorldspaceVertexBuffer  hBuf)

◆ Dr_InitDrawContext()

DrawContext Dr_InitDrawContext ( )

◆ Dr_OnScreenDimsChange()

void Dr_OnScreenDimsChange ( DrawContext pCtx,
int  newW,
int  newH 
)

◆ DrawWorldspaceVertexBuffer()

void DrawWorldspaceVertexBuffer ( H2DWorldspaceVertexBuffer  hBuf,
size_t  indexCount,
mat4  view 
)

◆ OBJECT_POOL()

OBJECT_POOL ( struct VertexBuffer  )

◆ WorldspaceVertexBufferData()

void WorldspaceVertexBufferData ( HUIVertexBuffer  hBuf,
Worldspace2DVert src,
size_t  size,
VertIndexT indices,
u32  numIndices 
)

Variable Documentation

◆ gScreenspaceOrtho

mat4 gScreenspaceOrtho

◆ gUIShader

struct Shader gUIShader = {0,0,0}

◆ gWorldspace2DShader

struct Shader gWorldspace2DShader = { 0,0,0 }

◆ uiFrag

const char* uiFrag
Initial value:
=
"#version 330 core\n"
"out vec4 FragColor;\n"
"in vec4 Colour;\n"
"in vec2 UV;\n"
"uniform sampler2D ourTexture;\n"
"void main()\n"
"{\n"
"FragColor = texture(ourTexture, UV) * Colour;\n"
"}\n"

◆ uiVert

const char* uiVert
Initial value:
=
"#version 330 core\n"
"layout (location = 0) in vec2 aPos;\n"
"layout (location = 1) in vec2 aUv;\n"
"layout (location = 2) in vec4 aColour;\n"
"out vec2 UV;\n"
"out vec4 Colour;\n"
"uniform mat4 screenToClipMatrix;\n"
"void main()\n"
"{\n"
"gl_Position = screenToClipMatrix * vec4(aPos, 0.0, 1.0);\n"
"UV = aUv;\n"
"Colour = aColour;"
"}\n"

◆ worldspaceFrag

const char* worldspaceFrag
Initial value:
=
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 FragColor;\n"
"in vec2 UV;\n"
"uniform sampler2D ourTexture;\n"
"void main()\n"
"{\n"
"FragColor = texture(ourTexture, UV);\n"
"}\n"

◆ worldspaceVert

const char* worldspaceVert
Initial value:
=
"#version 300 es\n"
"in vec2 aPos;\n"
"in vec2 aUv;\n"
"out vec2 UV;\n"
"uniform mat4 vp;\n"
"void main()\n"
"{\n"
"gl_Position = vp * vec4(aPos, 0.0, 1.0);\n"
"UV = aUv;\n"
"}\n"