存档在 ‘未分类’ 分类

关于前几日网站无法访问的说明

2020年10月8日

前几日由于服务器MariaDB Server(10.1.6)崩溃,造成了网站Wordpress无法访问。

独立的GLSL编译工具

2020年9月5日

由于使用SPIRV-Cross以及glslang的源代码版本有太多的编译配置选项,很烦,所以我制作了一个动态链接库版的GLSL到SPV编译器。

Github仓库

下载链接

使用代码大致如下:

namespace glsl_compiler
{
enum class DescriptorType //等同VkDescriptorType
{
SAMPLER = 0,
COMBINED_IMAGE_SAMPLER = 1,
SAMPLED_IMAGE = 2,
STORAGE_IMAGE = 3,
UNIFORM_TEXEL_BUFFER = 4,
STORAGE_TEXEL_BUFFER = 5,
UNIFORM_BUFFER = 6,
STORAGE_BUFFER = 7,
UNIFORM_BUFFER_DYNAMIC = 8,
STORAGE_BUFFER_DYNAMIC = 9,
INPUT_ATTACHMENT = 10,

BEGIN_RANGE=SAMPLER,
END_RANGE=INPUT_ATTACHMENT,
RANGE_SIZE=(END_RANGE-BEGIN_RANGE)+1
};

enum class VertexAttribBaseType
{
Bool=0,
Int,
UInt,
Float,
Double,
};//enum class VertexAttribBaseType

struct ShaderStage
{
char name[128];
uint8_t location;
uint32_t basetype; //对应enum class VertexAttribBaseType
uint32_t vec_size;
};//

struct ShaderStageData
{
uint32_t count;
ShaderStage *items;
};

struct ShaderResource
{
char name[128];

uint8_t set;
uint8_t binding;
};

struct ShaderResourceData
{
uint32_t count;
ShaderResource *items;
};

struct SPVData
{
bool result;
char *log;
char *debug_log;

uint32_t *spv_data;
uint32_t spv_length;

ShaderStageData input,output;
ShaderResourceData resource[size_t(DescriptorType::RANGE_SIZE)];
};

struct GLSLCompilerInterface
{
bool (*Init)(); ///<初始化
void (*Close)(); ///<关闭

uint32_t (*GetType)(const char *ext_name); ///<根据扩展名获取SHADER类型
SPVData * (*Compile)(const uint32_t type,const char *source); ///<编译glsl

void (*Free)(SPVData *); ///<释放数据
};
}//namespace glsl_shader

使用方法:

  1. 加载动态链接库
  2. 从动态链接库获取GetInterface函数
  3. 用GetInterface函数得到一个GLSLCompilerInterface指针(以下简称GSI)
  4. 调用GSI::Init函数
  5. 自行加载glsl的文本,并保证为ansi或utf8字符集
  6. 截取glsl文件扩展名(不包括.),或自行传递一个字符串给GSI::GetType函数,以获取shader类型。
    shader文件扩展名规则同glslangValidator

    • vert 顶点
    • tesc 镶嵌控制
    • tese 镶嵌评估
    • geom 几何
    • frag 片断
    • comp 计算
    • task 任务
    • mesh 网格
  7. 调用GSI::Compile函数,并同时传递shader类型以及shader文本字符串
  8. 根据得到的SPVData::result来判断是否成功
    • result为false表示失败,在log/debug_log中包含返回的错误信息
    • result为true表示成功,在spv_data,spv_length中包含编译好的spv数据
  9. 自行处理spv数据
  10. 调用GSI::Free释放SPVData指针

文本显示,一个看起来很简单的功能

2020年8月4日

现所有主要开源仓库一览

2020年4月5日
  • 现今主力开发的超轻量级渲染引擎
    • https://github.com/hyzboy/ULRE
  • 曾经的旧主力引擎
    • https://github.com/hyzboy/CMGameEngine
  •  曾经短暂编写PHP网站时总结的小型PHP工具库
    • https://github.com/hyzboy/CMPHP
  • 修改的仅支持OpenGL Core的GLEW
    • https://github.com/hyzboy/GLEWCore

2D/3D抛物线

2019年5月23日

#include<iostream>

using namespace std;
using uint=unsigned int;

struct vec2
{
float x,y;
};

struct vec3
{
float x,y,z;
};

/**
* 算出指定数量的抛物线高度值
* @param count 结果数量
* @param start 起始时间量,一般为-1
* @param end 结束时间量,一般为+1
*/
float *Parabolic(const uint count,const float time_start=-1,const float time_end=1)
{
if(count<=0)return(nullptr);

float *result=new float[count];

float rate;
float cur=time_start;
float total_time=time_end-time_start;

for(uint i=0;i<count;i++)
{
rate=float(i)/float(count);

cur=time_start+rate*total_time;

result[i]=1-cur*cur;

cout<<“height[“<<i<<“] “<<result[i]<<endl;
}

return result;
}

/**
* 画2D抛物线
* @param start 起始点
* @param end 结束点
* @param up 单位向上量
* @param height 高度值
* @param count 数量
*/
void Put2D(const vec2 &start,const vec2 &end,const vec2 &up,const float *height,const uint count)
{
vec2 total;
vec2 pos;
float rate;

total.x=end.x-start.x;
total.y=end.y-start.y;

cout<<“from “<<start.x<<“,”<<start.y<<” to “<<end.x<<“,”<<end.y<<endl;

for(uint i=0;i<count;i++)
{
rate=float(i)/float(count);

pos.x=start.x+rate*total.x;
pos.y=start.y+rate*total.y;

pos.x+=height[i]*up.x;
pos.y+=height[i]*up.y;

cout<<i<<“: “<<pos.x<<“,”<<pos.y<<endl;
}
}

/**
* 画3D抛物线
* @param start 起始点
* @param end 结束点
* @param up 单位向上量
* @param height 高度值
* @param count 数量
*/
void Put3D(const vec3 &start,const vec3 &end,const vec3 &up,const float *height,const uint count)
{
vec3 total;
vec3 pos;
float rate;

total.x=end.x-start.x;
total.y=end.y-start.y;
total.z=end.z-start.z;

cout<<“from “<<start.x<<“,”<<start.y<<“,”<<start.z<<” to “<<end.x<<“,”<<end.y<<“,”<<end.z<<endl;

for(uint i=0;i<count;i++)
{
rate=float(i)/float(count);

pos.x=start.x+rate*total.x;
pos.y=start.y+rate*total.y;
pos.z=start.z+rate*total.z;

pos.x+=height[i]*up.x;
pos.y+=height[i]*up.y;
pos.z+=height[i]*up.z;

cout<<i<<“: “<<pos.x<<“,”<<pos.y<<“,”<<pos.z<<endl;
}
}

void Test2D(float *height,const uint count)
{
vec2 start,end,up;

start.x=0;
start.y=0;

end.x=100;
end.y=0;

up.x=0;
up.y=100;

Put2D(start,end,up,height,count);
}

void Test3D(float *height,const uint count)
{
vec3 start,end,up;

start.x=0;
start.y=0;
start.z=0;

end.x=100;
end.y=0;
end.z=100;

up.x=0;
up.y=100;
up.z=0;

Put3D(start,end,up,height,count);
}

void main()
{
constexpr uint count=10;

float *height=Parabolic(count);

Test2D(height,count);
Test3D(height,count);

delete[] height;
}

重新支持C++Builder

2018年11月5日

Turbo C/C++、Borland C++、C++Builder曾经是我唯一的开发工具。在很久的一段时间里,我一直使用的是盗版,后来Borland公司的一位员工劝说我要使用正版。我同意了,我努力去做了,我也真的做到了。

只不过世事难料的是,因为我的全正版化计划,我放弃了我最爱的C++Builder。原因很有意思也很简单:我买不到正版从2002年开始,我寻找一切可以购买C++Builder正版的方式,但都一无所获。一开始告诉我在中国不卖个人版和专业版,只卖企业版。于是我准备好了3万块钱去买一套企业版,结果告诉我不卖给个人。我成立了一家空壳公司去买,答复我不卖给只有2个人的小公司。拉了几个朋友都弄成公司员工,最后告诉我至少要5套起卖。当时我就差点去丰联广场拉横幅抗议了,我突然醒悟:为什么我要花这么大的力气去给人送钱呢?

于是我放弃了使用C++Builder,转向Microsoft C/C++。为什么是Microsoft C/C++而不是Visual C++呢?因为我不想花钱,但又想是正版。Visual C++ IDE是收费的,但微软提供了免费且可商用的Windows SDK,其中便包含了Visual C++底层所调用的Microsoft C/C++ Compiler。于是我所有的工程就变成了使用CMAKE生成工程文件,再通过MSBuild编译链接。整个过程全程正版、合法、免费。

我曾经说过,在我可以得到正版的C++Builder前,我不会考虑再度支持C++Builder。只是没想到这个时间隔的是这么久。如今C++Builder推出了免费且可有限商用的Community版,这确实是一份正版授权,履行承诺的时刻来了。

 

新的strchr/strrchr/ClipFilename/ClipLastPathname函数

2018年8月22日

参见范例Example.DataType.StrCharTest

str: “hello,world!”
strchr(str,’,’) return “,world!”
strrchr(str,strlen(str),’,’) return “,world!”
strchr(str,”el”,2) return “ello,world!”
strrchr(str,strlen(str),”el”,2) return “ld!”
strrchr(str,strlen(str),3,’l’) return “lo,world!”
strrchr(str,strlen(str),3,”el”,2) return “lo,world!”
ClipFilename(“C:\1.txt”) return “1.txt”
ClipLastPathname(“C:\1\2”) return “2”
ClipLastPathname(“C:\1\2\”) return “2”
ClipLastPathname(“C:\1\2\\”) return “2”

新的HASH算法SHA1LE

2018年7月27日

SHA1LE算法是我们自定义的一种SHA1算法变种,它的计算方法与SHA1一致,改动如下:

  1. 去掉了因BigEndian设计造成的LittleEndian处理器需要做大小头转换的部分
  2. 可自定义起始因子
  3. 可动态修改扰乱因子

我们开通云服务了

2018年7月18日
  • 官方网站 cloud.hyzgame.com
  •  云服务器
    • 北京节点,最低CNY48/月
    • 香港节点,最低CNY69/月
  • 服务器租赁/托管
    • 北京水立方BGP机房
    • 广州双线机房
    • 广州电信机房
    • 广州联通机房
    • 1U/2U规格
  • Symantec SSL证书办理
    • OVSSL/EV SSL
    • 单域名/多域名
    • 1-3年有效期

 

新日志系统

2018年7月17日

日志系统一直是SDK的重中之中,在DOS时代,单机无法调试图形界面程序的情况下。日志系统是调试信息来源的重要途径。

从单纯的文本文件输出,到 控制台、文件等 等 的多端输出,从单线程到多线程,我们的日志系统经历了一次次的更新与换代。

现在,我们又将迎来全新一代的日志系统。

  1. 多线程日志获取
  2. 多线程日志输出
  3. 多端输出(本地文件、远端服务器)
  4. 详细分类信息(时间,线程,文件,模块)
  5. 多语种模板化支持
  6. 性能、内存等信息自动输出
  7. 可视化图形报表与日志分析查看工具
  8. 等等许多其它改进
鄂ICP备09027626号