Skip to content

Instantly share code, notes, and snippets.

////////////////////////////////////////////////////////////////////////////
#include "pch.h"
#include <string>
#include <stdexcept>
#include <cstdlib>
#include "GrowableArray.h"
#include "base64.h"
#include "PlistReader.h"
#include "PlistBuilder.h"
@mlfarrell
mlfarrell / dynrend.cpp
Last active November 15, 2023 00:18
dynamic rendering method
void RenderingCommandList::beginRendering(RenderTarget *target, uint32_t imageIndex)
{
VkClearValue &clearColorValue = target->getClearColorValue(), &clearDepthValue = target->getClearDepthValue();
VkRenderingAttachmentInfo attachmentInfo = {}, depthAttachmentInfo = {};
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
if(!target->getImages().empty())
{
attachmentInfo.imageView = target->getImages()[imageIndex]->getImageView();
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR;
//vs
#ifdef GL_ES
//precision mediump float;
#else
#define highp
#define lowp
#define mediump
#endif
//
// Full lighting shader template
// Verto Studio 3D
// Created by Mike Farrell
//
// Please read the shader section of the user-guide
// for more information on shader programming
// within Verto Studio
precision mediump float;
@mlfarrell
mlfarrell / BoneAnimSnippets.cpp
Created October 21, 2020 20:13
Skeletal animation
static const int currentAnimation = 0;
typedef unordered_map<aiString, const aiNodeAnim *> NodeAnimMap;
void EntityModel::boneAnimTransform(float timeInSeconds, vutil::GrowableArray *transforms, aiScene *aiSceneObj, const float16 *globalInverseTransform, bool loop)
{
const aiScene *scene = aiSceneObj;
mat4 identity = mat4Identity;
if(!nodeAnimMapPtr)
#include <iostream>
#include <fstream>
#include <utility>
using namespace std;
int main(int argc, char **argv)
{
auto loadSPIRV = [](const string &spirvPath) -> pair<uint8_t *, size_t> {
ifstream file(spirvPath, ios::ate | ios::binary);
//Bilboard shader
//draw sprites in 3D from any angle
const vec2 pos[6] = vec2[](
vec2(0, 0),
vec2(1, 0),
vec2(0, 1),
vec2(0, 1),
vec2(1, 0),
//Bilboard shader
//draw sprites in 3D from any angle
in vec4 position;
in vec2 texcoord0;
out vec2 varTexcoord;
out flat float varDistanceToCamera;
out flat float varAlpha;
out flat float textureCutoffT;
int Logger::Buffer::flushBuffer()
{
int num = (int)(pptr()-pbase());
/*if(cout.write(buffer, num) != num)
{
return EOF;
}*/
#if (defined WIN10_BUILD) || (defined WIN32)
#version 450
#define VGL_VULKAN
#extension GL_ARB_separate_shader_objects : enable
#ifdef GL_ES
precision highp float;
#else
#define highp
#define lowp