Skip to content

Instantly share code, notes, and snippets.

@Platin21
Created December 17, 2017 00:34
Show Gist options
  • Save Platin21/e6dbbcfc418eb33251792965bbeb9ee1 to your computer and use it in GitHub Desktop.
Save Platin21/e6dbbcfc418eb33251792965bbeb9ee1 to your computer and use it in GitHub Desktop.
Spirit Graphics
//==@ 3d Spirit! @==\\
enum spType;
enum spDrawType;
enum spStatus;
struct spContext;
spContext spCreateContext();
//
void spViewSize(spI64 width,spI64 height);
void spViewSizeWith_spWindow(spWindow win);
void spViewSizeWith_spPixelBuffer(spPixelBuffer pxBuffer);
void spDrawCurrentspSurface();
void spSetDrawType(spDrawType); // default spTriangle
//void spGetLogString(spContext& ctx); @info(armin): potential bad design!
//void spGetErrorCode(spContext& ctx);
struct spWindow;
struct spPixelBuffer;
struct spSurface;
void spCreateSurfaceWith_spWindow(spWindow win,spContext& ctx);
void spCreateSurfaceWith_spPixelBuffer(spBuffer buffer,spContext& ctx);
void spChangeSurfaceWith_spPixelBuffer(spBuffer& buffer,spContext& ctx);
void spChangeSurfaceWith_spWindow(spWindow win,spContext& ctx);
spStatus spSwapSurfaceTo(spSurface& surface,spContext& ctx);
///
struct spBufferIdx;
struct spBufferReturnType(spStatus,spBufferIdx);
spBufferReturnType spCreateBuffer(spType ofType,spI64 withCount,spContext& ctx);
spStatus spChange_spBufferIdx(BufferIdx bufferIdx);
///
///
struct spShader;
struct spShaderReturnType(spStatus,spShader);
spShaderReturnType spCreate_spShader(spString withSourceCode,spContext& ctx); //@info(armin): shader format???
spStatus spUse_spShader(spShader sh);
///
struct spVertex4;
void spPush_Vertex(spF32 x, spF32 y, spF32 z, spF32 w,spContext& ctx);
void spPush_spVertex(spVertex4 v,spContext ctx);
///
struct spInt32Vertex;
void spPush_Int32Vertex(spInt32 x,spInt32 y, spInt32 z,spInt32 w,spContext& ctx);
void spPush_spInt32Vertex(spInt32Vertex vertex,spContext& ctx);
///
struct spQuad;
spPush_Quad(spVertex4 a1,spVertex4 a2,spVertex a3,spVertex a4, spContext ctx);
spPush_spQuad(spQuad quad, spContext ctx);
int main(void)
{
spWindow win = spWindow();
spContext* ctx = spCreateContext();
spCreateSurfaceWith_spWindow(win,ctx);
spViewSizeWith_spWindow(win);
spBufferIdx vertexBuffer = spCreateBuffer(SP_VERTEX,4,ctx).buffer;
spBufferIdx colorBuffer = spCreateBuffer(SP_VERTEX,4,ctx).buffer;
spShader sh = spCreate_spShader(NULL,ctx).shader;
while(true)
{
spUse_spShader(sh);
spChange_spBufferIdx(vertexBuffer);
spPush_Quad(...,ctx);
spPush_Quad(...,ctx);
spPush_Quad(...,ctx);
spPush_Quad(...,ctx);
spChange_spBufferIdx(colorBuffer);
spPush_Quad(...,ctx);
spPush_Quad(...,ctx);
spPush_Quad(...,ctx);
spPush_Quad(...,ctx);
spDraw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment