mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
intigrate bgfx(not done yet)
This commit is contained in:
parent
4e26f5f2e7
commit
43b0122249
3
3rd/bgfx/.gitignore
vendored
Normal file
3
3rd/bgfx/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
bgfx
|
||||
bimg
|
||||
bx
|
15
3rd/bgfx/README.md
Normal file
15
3rd/bgfx/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# bgfx
|
||||
|
||||
使用bgfx需要手工去下列软件包:
|
||||
|
||||
* bx:https://github.com/bkaradzic/bx.git
|
||||
* bimg:https://github.com/bkaradzic/bimg.git
|
||||
* bgfx: https://github.com/bkaradzic/bgfx.git
|
||||
|
||||
```
|
||||
git clone https://github.com/bkaradzic/bx.git
|
||||
git clone https://github.com/bkaradzic/bimg.git
|
||||
git clone https://github.com/bkaradzic/bgfx.git
|
||||
|
||||
```
|
||||
|
70
3rd/bgfx/SConscript
Normal file
70
3rd/bgfx/SConscript
Normal file
@ -0,0 +1,70 @@
|
||||
import os
|
||||
import platform
|
||||
BgCppPath=[]
|
||||
BgSources=[]
|
||||
env=DefaultEnvironment().Clone()
|
||||
OS_NAME=platform.system()
|
||||
LIB_DIR=os.environ['LIB_DIR'];
|
||||
CCFLAGS=os.environ['CCFLAGS'];
|
||||
|
||||
BgCppPath=['bx/3rdparty',
|
||||
'bx/include',
|
||||
'bimg/include',
|
||||
'bgfx/3rdparty',
|
||||
'bgfx/3rdparty/khronos',
|
||||
'bgfx/include']
|
||||
BgSources=[
|
||||
'bx/src/allocator.cpp',
|
||||
'bx/src/bx.cpp',
|
||||
'bx/src/commandline.cpp',
|
||||
'bx/src/crtnone.cpp',
|
||||
'bx/src/debug.cpp',
|
||||
'bx/src/dtoa.cpp',
|
||||
'bx/src/easing.cpp',
|
||||
'bx/src/file.cpp',
|
||||
'bx/src/filepath.cpp',
|
||||
'bx/src/hash.cpp',
|
||||
'bx/src/math.cpp',
|
||||
'bx/src/mutex.cpp',
|
||||
'bx/src/os.cpp',
|
||||
'bx/src/process.cpp',
|
||||
'bx/src/semaphore.cpp',
|
||||
'bx/src/settings.cpp',
|
||||
'bx/src/string.cpp',
|
||||
'bx/src/sort.cpp',
|
||||
'bx/src/thread.cpp',
|
||||
'bx/src/timer.cpp',
|
||||
'bx/src/url.cpp',
|
||||
'bimg/src/image.cpp',
|
||||
'bimg/src/image_gnf.cpp',
|
||||
'bgfx/src/bgfx.cpp',
|
||||
'bgfx/src/debug_renderdoc.cpp',
|
||||
'bgfx/src/dxgi.cpp',
|
||||
'bgfx/src/glcontext_egl.cpp',
|
||||
'bgfx/src/glcontext_glx.cpp',
|
||||
'bgfx/src/glcontext_wgl.cpp',
|
||||
'bgfx/src/nvapi.cpp',
|
||||
'bgfx/src/renderer_d3d11.cpp',
|
||||
'bgfx/src/renderer_d3d12.cpp',
|
||||
'bgfx/src/renderer_d3d9.cpp',
|
||||
'bgfx/src/renderer_gl.cpp',
|
||||
'bgfx/src/renderer_gnm.cpp',
|
||||
'bgfx/src/renderer_noop.cpp',
|
||||
'bgfx/src/renderer_vk.cpp',
|
||||
'bgfx/src/shader.cpp',
|
||||
'bgfx/src/shader_dx9bc.cpp',
|
||||
'bgfx/src/shader_dxbc.cpp',
|
||||
'bgfx/src/shader_spirv.cpp',
|
||||
'bgfx/src/topology.cpp',
|
||||
'bgfx/src/vertexdecl.cpp'
|
||||
]
|
||||
|
||||
if OS_NAME == 'Windows':
|
||||
BgCppPath= BgCppPath + ['bx/include/compat/msvc','bgfx/3rdparty/dxsdk/include']
|
||||
elif OS_NAME == 'Darwin':
|
||||
CCFLAGS = CCFLAGS + '-std=c++11 ';
|
||||
BgCppPath= BgCppPath + ['bx/include/compat/osx']
|
||||
BgSources= BgSources + ['bgfx/src/renderer_mtl.mm']
|
||||
|
||||
env.Library(os.path.join(LIB_DIR, 'bgfx'), BgSources, CPPPATH = BgCppPath,CCFLAGS = CCFLAGS)
|
||||
|
@ -1,8 +1,14 @@
|
||||
import os
|
||||
import platform
|
||||
|
||||
def joinPath(root, subdir):
|
||||
return os.path.normpath(os.path.join(root, subdir))
|
||||
env=DefaultEnvironment().Clone()
|
||||
LIB_DIR=os.environ['LIB_DIR'];
|
||||
BIN_DIR=os.environ['BIN_DIR'];
|
||||
CCFLAGS=os.environ['CCFLAGS'];
|
||||
TK_3RD_ROOT=os.environ['TK_3RD_ROOT'];
|
||||
OS_NAME=platform.system()
|
||||
|
||||
env.Library(os.path.join(LIB_DIR, 'nanovg'), Glob('base/*.c'))
|
||||
|
||||
@ -23,6 +29,20 @@ elif NANOVG_BACKEND == 'AGGE':
|
||||
env.Program(os.path.join(BIN_DIR, 'agge_fill'), Glob('demos/agge_fill.c'));
|
||||
env.Program(os.path.join(BIN_DIR, 'agge_draw_image'), Glob('demos/agge_draw_image.c'));
|
||||
elif NANOVG_BACKEND == 'BGFX':
|
||||
print("not supported yet");
|
||||
CPPPATH = [
|
||||
joinPath(TK_3RD_ROOT, 'nanovg/base'),
|
||||
joinPath(TK_3RD_ROOT, 'bgfx/bx/include'),
|
||||
joinPath(TK_3RD_ROOT, 'bgfx/bgfx/include'),
|
||||
joinPath(TK_3RD_ROOT, 'SDL/include')]
|
||||
if OS_NAME == 'Darwin':
|
||||
CCFLAGS = CCFLAGS + ' -std=c++11 '
|
||||
elif OS_NAME == 'Windows':
|
||||
CPPPATH = CPPPATH + [joinPath(TK_3RD_ROOT, 'bgfx/bx/include/compat/msvc')];
|
||||
env.Library(os.path.join(LIB_DIR, 'nanovg-bgfx'), Glob('bgfx/*.cpp'), CPPPATH = CPPPATH, CCFLAGS = CCFLAGS)
|
||||
|
||||
env['LIBS'] = ['nanovg-bgfx', 'bgfx', 'nanovg'] + env['LIBS']
|
||||
env.Program(os.path.join(BIN_DIR, 'bgfx_sdl_fill'), Glob('demos/bgfx_sdl_fill.c'));
|
||||
env.Program(os.path.join(BIN_DIR, 'bgfx_sdl_stroke'), Glob('demos/bgfx_sdl_stroke.c'));
|
||||
env.Program(os.path.join(BIN_DIR, 'bgfx_sdl_draw_image'), Glob('demos/bgfx_sdl_draw_image.c'));
|
||||
env.Program(os.path.join(BIN_DIR, 'bgfx_sdl_draw_text'), Glob('demos/bgfx_sdl_draw_text.c'));
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <math.h>
|
||||
#include "nanovg.h"
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#define FONTSTASH_IMPLEMENTATION
|
||||
@ -30,7 +30,7 @@
|
||||
#else
|
||||
#include <string.h>
|
||||
#define printf(...)
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4100) // unreferenced formal parameter
|
||||
@ -290,9 +290,9 @@ static NVGstate* nvg__getState(NVGcontext* ctx)
|
||||
|
||||
NVGcontext* nvgCreateInternal(NVGparams* params)
|
||||
{
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
FONSparams fontParams;
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext));
|
||||
int i;
|
||||
if (ctx == NULL) goto error;
|
||||
@ -317,7 +317,7 @@ NVGcontext* nvgCreateInternal(NVGparams* params)
|
||||
|
||||
if (ctx->params.renderCreate(ctx->params.userPtr) == 0) goto error;
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
// Init font rendering
|
||||
memset(&fontParams, 0, sizeof(fontParams));
|
||||
fontParams.width = NVG_INIT_FONTIMAGE_SIZE;
|
||||
@ -335,7 +335,7 @@ NVGcontext* nvgCreateInternal(NVGparams* params)
|
||||
ctx->fontImages[0] = ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_ALPHA, fontParams.width, fontParams.height, 0, NULL);
|
||||
if (ctx->fontImages[0] == 0) goto error;
|
||||
ctx->fontImageIdx = 0;
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
return ctx;
|
||||
|
||||
@ -356,7 +356,7 @@ void nvgDeleteInternal(NVGcontext* ctx)
|
||||
if (ctx->commands != NULL) free(ctx->commands);
|
||||
if (ctx->cache != NULL) nvg__deletePathCache(ctx->cache);
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
if (ctx->fs)
|
||||
fonsDeleteInternal(ctx->fs);
|
||||
|
||||
@ -368,7 +368,7 @@ void nvgDeleteInternal(NVGcontext* ctx)
|
||||
}
|
||||
#else
|
||||
(void)i;
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
if (ctx->params.renderDelete != NULL)
|
||||
ctx->params.renderDelete(ctx->params.userPtr);
|
||||
@ -801,7 +801,7 @@ void nvgFillPaint(NVGcontext* ctx, NVGpaint paint)
|
||||
nvgTransformMultiply(state->fill.xform, state->xform);
|
||||
}
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags)
|
||||
{
|
||||
int w, h, n, image;
|
||||
@ -840,7 +840,7 @@ int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data)
|
||||
{
|
||||
@ -1448,7 +1448,7 @@ static int nvg__curveDivs(float r, float arc, float tol)
|
||||
return nvg__maxi(2, (int)ceilf(arc / da));
|
||||
}
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
static void nvg__chooseBevel(int bevel, NVGpoint* p0, NVGpoint* p1, float w,
|
||||
float* x0, float* y0, float* x1, float* y1)
|
||||
{
|
||||
@ -2177,7 +2177,7 @@ static int nvg__expandFill(NVGcontext* ctx, float w, int lineJoin, float miterLi
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
// Draw
|
||||
void nvgBeginPath(NVGcontext* ctx)
|
||||
@ -2411,7 +2411,7 @@ void nvgCircle(NVGcontext* ctx, float cx, float cy, float r)
|
||||
nvgEllipse(ctx, cx,cy, r,r);
|
||||
}
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
void nvgDebugDumpPathCache(NVGcontext* ctx)
|
||||
{
|
||||
const NVGpath* path;
|
||||
@ -2433,7 +2433,7 @@ void nvgDebugDumpPathCache(NVGcontext* ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
void nvgFill(NVGcontext* ctx)
|
||||
{
|
||||
@ -2505,7 +2505,7 @@ void nvgStroke(NVGcontext* ctx)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_NANOVG_GL
|
||||
#ifdef WITH_NANOVG_GPU
|
||||
// Add fonts
|
||||
int nvgCreateFont(NVGcontext* ctx, const char* name, const char* path)
|
||||
{
|
||||
@ -3173,7 +3173,7 @@ float nvgTextBounds(NVGcontext* ctx, float x, float y, const char* string, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif/*WITH_NANOVG_GL*/
|
||||
#endif/*WITH_NANOVG_GPU*/
|
||||
|
||||
NVGparams* nvgGetParams(NVGcontext* ctx) {
|
||||
return &(ctx->params);
|
||||
|
@ -621,8 +621,7 @@ enum NVGtexture {
|
||||
NVG_TEXTURE_BGRA = 0x04,
|
||||
NVG_TEXTURE_RGB = 0x08,
|
||||
NVG_TEXTURE_BGR = 0x16,
|
||||
NVG_TEXTURE_RGB565 = 0x32,
|
||||
NVG_TEXTURE_BGR565 = 0x64
|
||||
NVG_TEXTURE_BGR565 = 0x32
|
||||
};
|
||||
|
||||
struct NVGscissor {
|
||||
|
@ -1 +0,0 @@
|
||||
todo
|
1760
3rd/nanovg/bgfx/fontstash.h
Normal file
1760
3rd/nanovg/bgfx/fontstash.h
Normal file
File diff suppressed because it is too large
Load Diff
1028
3rd/nanovg/bgfx/fs_nanovg_fill.bin.h
Normal file
1028
3rd/nanovg/bgfx/fs_nanovg_fill.bin.h
Normal file
File diff suppressed because it is too large
Load Diff
94
3rd/nanovg/bgfx/fs_nanovg_fill.sc
Normal file
94
3rd/nanovg/bgfx/fs_nanovg_fill.sc
Normal file
@ -0,0 +1,94 @@
|
||||
$input v_position, v_texcoord0
|
||||
|
||||
#include "../common.sh"
|
||||
|
||||
#define EDGE_AA 1
|
||||
|
||||
uniform mat3 u_scissorMat;
|
||||
uniform mat3 u_paintMat;
|
||||
uniform vec4 u_innerCol;
|
||||
uniform vec4 u_outerCol;
|
||||
uniform vec4 u_scissorExtScale;
|
||||
uniform vec4 u_extentRadius;
|
||||
uniform vec4 u_params;
|
||||
|
||||
SAMPLER2D(s_tex, 0);
|
||||
|
||||
#define u_scissorExt (u_scissorExtScale.xy)
|
||||
#define u_scissorScale (u_scissorExtScale.zw)
|
||||
#define u_extent (u_extentRadius.xy)
|
||||
#define u_radius (u_extentRadius.z)
|
||||
#define u_feather (u_params.x)
|
||||
#define u_strokeMult (u_params.y)
|
||||
#define u_texType (u_params.z)
|
||||
#define u_type (u_params.w)
|
||||
|
||||
float sdroundrect(vec2 pt, vec2 ext, float rad)
|
||||
{
|
||||
vec2 ext2 = ext - vec2(rad,rad);
|
||||
vec2 d = abs(pt) - ext2;
|
||||
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0) ) - rad;
|
||||
}
|
||||
|
||||
// Scissoring
|
||||
float scissorMask(vec2 p)
|
||||
{
|
||||
vec2 sc = abs(mul(u_scissorMat, vec3(p, 1.0) ).xy) - u_scissorExt;
|
||||
sc = vec2(0.5, 0.5) - sc * u_scissorScale;
|
||||
return clamp(sc.x, 0.0, 1.0) * clamp(sc.y, 0.0, 1.0);
|
||||
}
|
||||
|
||||
// Stroke - from [0..1] to clipped pyramid, where the slope is 1px.
|
||||
float strokeMask(vec2 _texcoord)
|
||||
{
|
||||
#if EDGE_AA
|
||||
return min(1.0, (1.0 - abs(_texcoord.x*2.0 - 1.0) )*u_strokeMult) * min(1.0, _texcoord.y);
|
||||
#else
|
||||
return 1.0;
|
||||
#endif // EDGE_AA
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 result;
|
||||
float scissor = scissorMask(v_position);
|
||||
float strokeAlpha = strokeMask(v_texcoord0);
|
||||
|
||||
if (u_type == 0.0) // Gradient
|
||||
{
|
||||
// Calculate gradient color using box gradient
|
||||
vec2 pt = mul(u_paintMat, vec3(v_position, 1.0) ).xy;
|
||||
float d = clamp( (sdroundrect(pt, u_extent, u_radius) + u_feather*0.5) / u_feather, 0.0, 1.0);
|
||||
vec4 color = mix(u_innerCol, u_outerCol, d);
|
||||
// Combine alpha
|
||||
color *= strokeAlpha * scissor;
|
||||
result = color;
|
||||
}
|
||||
else if (u_type == 1.0) // Image
|
||||
{
|
||||
// Calculate color from texture
|
||||
vec2 pt = mul(u_paintMat, vec3(v_position, 1.0) ).xy / u_extent;
|
||||
vec4 color = texture2D(s_tex, pt);
|
||||
if (u_texType == 1.0) color = vec4(color.xyz * color.w, color.w);
|
||||
if (u_texType == 2.0) color = color.xxxx;
|
||||
// Apply color tint and alpha
|
||||
color *= u_innerCol;
|
||||
// Combine alpha
|
||||
color *= strokeAlpha * scissor;
|
||||
result = color;
|
||||
}
|
||||
else if (u_type == 2.0) // Stencil fill
|
||||
{
|
||||
result = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
else if (u_type == 3.0) // Textured tris
|
||||
{
|
||||
vec4 color = texture2D(s_tex, v_texcoord0.xy);
|
||||
if (u_texType == 1.0) color = vec4(color.xyz * color.w, color.w);
|
||||
if (u_texType == 2.0) color = color.xxxx;
|
||||
color *= scissor;
|
||||
result = color * u_innerCol;
|
||||
}
|
||||
|
||||
gl_FragColor = result;
|
||||
}
|
1351
3rd/nanovg/bgfx/nanovg_bgfx.cpp
Normal file
1351
3rd/nanovg/bgfx/nanovg_bgfx.cpp
Normal file
File diff suppressed because it is too large
Load Diff
44
3rd/nanovg/bgfx/nanovg_bgfx.h
Normal file
44
3rd/nanovg/bgfx/nanovg_bgfx.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2011-2018 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
#ifndef NANOVG_BGFX_H_HEADER_GUARD
|
||||
#define NANOVG_BGFX_H_HEADER_GUARD
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nanovg.h"
|
||||
#include <SDL.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926f
|
||||
#endif /*M_PI*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///sdl entry
|
||||
NVGcontext* nvgCreateBGFX(int32_t _edgeaa, uint16_t _viewId,uint32_t _width, uint32_t _height, SDL_Window* _window);
|
||||
|
||||
///
|
||||
void nvgDeleteBGFX(NVGcontext* _ctx);
|
||||
|
||||
uint32_t renderBGFXFrame(int32_t _msecs);
|
||||
|
||||
void setBGFXViewRect(uint16_t _viewId, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
|
||||
|
||||
void touchBGFX(uint16_t _viewId);
|
||||
|
||||
uint32_t frameBGFX(bool _capture);
|
||||
|
||||
void resetBGFX(uint32_t _width, uint32_t _height, uint32_t _flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NANOVG_BGFX_H_HEADER_GUARD
|
61
3rd/nanovg/bgfx/nanovg_bgfxEx.h
Normal file
61
3rd/nanovg/bgfx/nanovg_bgfxEx.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef NANOVG_BGFXEX_H_HEADER_GUARD
|
||||
#define NANOVG_BGFXEX_H_HEADER_GUARD
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
namespace bx { struct AllocatorI; }
|
||||
|
||||
typedef struct NVGcontext NVGcontext;
|
||||
|
||||
struct NVGLUframebuffer_bgfx
|
||||
{
|
||||
NVGcontext* ctx;
|
||||
bgfx::FrameBufferHandle handle;
|
||||
int image;
|
||||
bgfx::ViewId viewId;
|
||||
};
|
||||
|
||||
///
|
||||
NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _allocator);
|
||||
///
|
||||
void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId);
|
||||
|
||||
///
|
||||
uint16_t nvgGetViewId(struct NVGcontext* _ctx);
|
||||
|
||||
// Helper functions to create bgfx framebuffer to render to.
|
||||
// Example:
|
||||
// float scale = 2;
|
||||
// NVGLUframebuffer* fb = nvgluCreateFramebuffer(ctx, 100 * scale, 100 * scale, 0);
|
||||
// nvgluSetViewFramebuffer(VIEW_ID, fb);
|
||||
// nvgluBindFramebuffer(fb);
|
||||
// nvgBeginFrame(ctx, 100, 100, scale);
|
||||
// // renders anything offscreen
|
||||
// nvgEndFrame(ctx);
|
||||
// nvgluBindFramebuffer(NULL);
|
||||
//
|
||||
// // Pastes the framebuffer rendering.
|
||||
// nvgBeginFrame(ctx, 1024, 768, scale);
|
||||
// NVGpaint paint = nvgImagePattern(ctx, 0, 0, 100, 100, 0, fb->image, 1);
|
||||
// nvgBeginPath(ctx);
|
||||
// nvgRect(ctx, 0, 0, 100, 100);
|
||||
// nvgFillPaint(ctx, paint);
|
||||
// nvgFill(ctx);
|
||||
// nvgEndFrame(ctx);
|
||||
|
||||
///
|
||||
NVGLUframebuffer_bgfx* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags, bgfx::ViewId _viewId);
|
||||
|
||||
///
|
||||
NVGLUframebuffer_bgfx* nvgluCreateFramebuffer(NVGcontext* _ctx, int32_t _width, int32_t _height, int32_t _imageFlags);
|
||||
|
||||
///
|
||||
void nvgluBindFramebuffer(NVGLUframebuffer_bgfx* _framebuffer);
|
||||
|
||||
///
|
||||
void nvgluDeleteFramebuffer(NVGLUframebuffer_bgfx* _framebuffer);
|
||||
|
||||
///
|
||||
void nvgluSetViewFramebuffer(bgfx::ViewId _viewId, NVGLUframebuffer_bgfx* _framebuffer);
|
||||
|
||||
#endif
|
5
3rd/nanovg/bgfx/varying.def.sc
Normal file
5
3rd/nanovg/bgfx/varying.def.sc
Normal file
@ -0,0 +1,5 @@
|
||||
vec2 v_position : TEXCOORD0 = vec2(0.0, 0.0);
|
||||
vec2 v_texcoord0 : TEXCOORD1 = vec2(0.0, 0.0);
|
||||
|
||||
vec2 a_position : POSITION;
|
||||
vec2 a_texcoord0 : TEXCOORD0;
|
265
3rd/nanovg/bgfx/vs_nanovg_fill.bin.h
Normal file
265
3rd/nanovg/bgfx/vs_nanovg_fill.bin.h
Normal file
@ -0,0 +1,265 @@
|
||||
static const uint8_t vs_nanovg_fill_glsl[541] =
|
||||
{
|
||||
0x56, 0x53, 0x48, 0x05, 0xcf, 0xda, 0x1b, 0x94, 0x02, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
|
||||
0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x75, 0x5f, 0x68, 0x61, // wSize.......u_ha
|
||||
0x6c, 0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0xeb, 0x01, 0x00, // lfTexel.........
|
||||
0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // .attribute highp
|
||||
0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // vec2 a_position
|
||||
0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, // ;.attribute high
|
||||
0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, // p vec2 a_texcoor
|
||||
0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, // d0;.varying high
|
||||
0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, // p vec2 v_positio
|
||||
0x6e, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // n;.varying highp
|
||||
0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // vec2 v_texcoord
|
||||
0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // 0;.uniform highp
|
||||
0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, // vec4 u_viewSize
|
||||
0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, // ;.uniform highp
|
||||
0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x68, 0x61, 0x6c, 0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, // vec4 u_halfTexel
|
||||
0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, // ;.void main ().{
|
||||
0x0a, 0x20, 0x20, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, // . v_position =
|
||||
0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, // a_position;. v_
|
||||
0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x61, 0x5f, 0x74, // texcoord0 = (a_t
|
||||
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x75, 0x5f, 0x68, 0x61, 0x6c, // excoord0 + u_hal
|
||||
0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x2e, 0x78, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x69, // fTexel.xy);. hi
|
||||
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // ghp vec4 tmpvar_
|
||||
0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x7a, 0x77, // 1;. tmpvar_1.zw
|
||||
0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, // = vec2(0.0, 1.0
|
||||
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x20, // );. tmpvar_1.x
|
||||
0x3d, 0x20, 0x28, 0x28, 0x28, 0x32, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, // = (((2.0 * a_pos
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x29, 0x20, 0x2f, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, // ition.x) / u_vie
|
||||
0x77, 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x29, 0x20, 0x2d, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, // wSize.x) - 1.0);
|
||||
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x79, 0x20, 0x3d, 0x20, // . tmpvar_1.y =
|
||||
0x28, 0x31, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x32, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x61, // (1.0 - ((2.0 * a
|
||||
0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x79, 0x29, 0x20, 0x2f, 0x20, 0x75, // _position.y) / u
|
||||
0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x79, 0x29, 0x29, 0x3b, 0x0a, 0x20, // _viewSize.y));.
|
||||
0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, // gl_Position = t
|
||||
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // mpvar_1;.}...
|
||||
};
|
||||
static const uint8_t vs_nanovg_fill_spv[1481] =
|
||||
{
|
||||
0x56, 0x53, 0x48, 0x05, 0xcf, 0xda, 0x1b, 0x94, 0x02, 0x00, 0x0b, 0x75, 0x5f, 0x68, 0x61, 0x6c, // VSH........u_hal
|
||||
0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x02, 0x01, 0x10, 0x00, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, // fTexel.......u_v
|
||||
0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x90, 0x05, 0x00, // iewSize.........
|
||||
0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x08, 0x00, 0xb1, 0x00, 0x00, // ...#............
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, // ................
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, // .....GLSL.std.45
|
||||
0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // 0...............
|
||||
0x00, 0x0f, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, // .............mai
|
||||
0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, // n....G...J...S..
|
||||
0x00, 0x57, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, // .W...Z..........
|
||||
0x00, 0xf4, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, // .............mai
|
||||
0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, // n............$Gl
|
||||
0x6f, 0x62, 0x61, 0x6c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // obal............
|
||||
0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x06, 0x00, 0x06, // .u_viewSize.....
|
||||
0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x68, 0x61, 0x6c, 0x66, 0x54, // .........u_halfT
|
||||
0x65, 0x78, 0x65, 0x6c, 0x00, 0x05, 0x00, 0x03, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // exel............
|
||||
0x00, 0x05, 0x00, 0x05, 0x00, 0x47, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // .....G...a_posit
|
||||
0x69, 0x6f, 0x6e, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x74, // ion......J...a_t
|
||||
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x53, 0x00, 0x00, // excoord0.....S..
|
||||
0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, // .@entryPointOutp
|
||||
0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, // ut.gl_Position..
|
||||
0x00, 0x05, 0x00, 0x0a, 0x00, 0x57, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, // .....W...@entryP
|
||||
0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x5f, 0x70, 0x6f, 0x73, // ointOutput.v_pos
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x5a, 0x00, 0x00, // ition........Z..
|
||||
0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, // .@entryPointOutp
|
||||
0x75, 0x74, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x00, // ut.v_texcoord0..
|
||||
0x00, 0x48, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .H...........#..
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....H..........
|
||||
0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, // .#.......G......
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .....G......."..
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...G......
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...J......
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, // .....G...S......
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...W......
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G...Z......
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, // .............!..
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, // ................
|
||||
0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // . ..............
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // ................
|
||||
0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ............. ..
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, // .....+..........
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, // .....+..........
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, // ................
|
||||
0x00, 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ..........
|
||||
0x00, 0x1c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....;..........
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ..........
|
||||
0x00, 0x09, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, // .....+.......%..
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, // .....+.......&..
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // ....@....'... ..
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .....+...'...(..
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ..... ...-......
|
||||
0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, // .....+.......1..
|
||||
0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, // ....?+...'...3..
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ..... ...F......
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, // .....;...F...G..
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, // .....;...F...J..
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...R......
|
||||
0x00, 0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, // .....;...R...S..
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... ...V......
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, // .....;...V...W..
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, // .....;...V...Z..
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, // ................
|
||||
0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .6..............
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .............=..
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, // .....H...G...=..
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, // .....K...J...A..
|
||||
0x00, 0x1f, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, // .....v..........
|
||||
0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, // .=.......w...v..
|
||||
0x00, 0x4f, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, // .O.......x...w..
|
||||
0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, // .w..............
|
||||
0x00, 0x07, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, // .....y...K...x..
|
||||
0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, // .Q.......|...H..
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, // .............}..
|
||||
0x00, 0x26, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x2d, 0x00, 0x00, // .&...|...A...-..
|
||||
0x00, 0x7e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .~.......%...(..
|
||||
0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, // .=...........~..
|
||||
0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, // .............}..
|
||||
0x00, 0x7f, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, // ................
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, // .....1...Q......
|
||||
0x00, 0x83, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, // .....H..........
|
||||
0x00, 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, // .........&......
|
||||
0x00, 0x41, 0x00, 0x06, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .A...-..........
|
||||
0x00, 0x25, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, // .%...3...=......
|
||||
0x00, 0x86, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, // ................
|
||||
0x00, 0x87, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, // .............P..
|
||||
0x00, 0x09, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, // ................
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, // .....1..........
|
||||
0x00, 0x8d, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, // .........1...R..
|
||||
0x00, 0x09, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, // ................
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x53, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, // .....>...S......
|
||||
0x00, 0x3e, 0x00, 0x03, 0x00, 0x57, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, // .>...W...H...>..
|
||||
0x00, 0x5a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, // .Z...y.......8..
|
||||
0x00, 0x00, 0x02, 0x01, 0x00, 0x10, 0x00, 0x20, 0x00, // ....... .
|
||||
};
|
||||
static const uint8_t vs_nanovg_fill_dx9[426] =
|
||||
{
|
||||
0x56, 0x53, 0x48, 0x05, 0xcf, 0xda, 0x1b, 0x94, 0x02, 0x00, 0x0b, 0x75, 0x5f, 0x68, 0x61, 0x6c, // VSH........u_hal
|
||||
0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x02, 0x01, 0x01, 0x00, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, // fTexel.......u_v
|
||||
0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x78, 0x01, 0x00, // iewSize......x..
|
||||
0x00, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x28, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, // .......(.CTAB...
|
||||
0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, // .r..............
|
||||
0x00, 0x00, 0x91, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, // .....k...D......
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, // .....P.......`..
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........P......
|
||||
0x00, 0x75, 0x5f, 0x68, 0x61, 0x6c, 0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x00, 0x01, 0x00, 0x03, // .u_halfTexel....
|
||||
0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, // .............u_v
|
||||
0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, // iewSize.vs_3_0.M
|
||||
0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, // icrosoft (R) HLS
|
||||
0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, // L Shader Compile
|
||||
0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x00, 0xab, 0xab, 0x51, 0x00, 0x00, 0x05, 0x02, 0x00, 0x0f, // r 10.1...Q......
|
||||
0xa0, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........?.......
|
||||
0x00, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, // ................
|
||||
0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ................
|
||||
0x80, 0x00, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, // ................
|
||||
0xe0, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x01, 0x80, 0x02, 0x00, 0x03, 0xe0, 0x02, 0x00, 0x00, // ................
|
||||
0x03, 0x02, 0x00, 0x03, 0xe0, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0xe4, 0x90, 0x06, 0x00, 0x00, // ................
|
||||
0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, // ................
|
||||
0x80, 0x00, 0x00, 0xd0, 0x90, 0x00, 0x00, 0xd0, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, // ................
|
||||
0xe0, 0x00, 0x00, 0x55, 0x80, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xa0, 0x06, 0x00, 0x00, // ...U............
|
||||
0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x55, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, // .......U........
|
||||
0xe0, 0x00, 0x00, 0xaa, 0x80, 0x00, 0x00, 0x00, 0x81, 0x02, 0x00, 0x55, 0xa0, 0x01, 0x00, 0x00, // ...........U....
|
||||
0x02, 0x00, 0x00, 0x0c, 0xe0, 0x02, 0x00, 0x64, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x03, // .......d........
|
||||
0xe0, 0x00, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // ..........
|
||||
};
|
||||
static const uint8_t vs_nanovg_fill_dx11[579] =
|
||||
{
|
||||
0x56, 0x53, 0x48, 0x05, 0xcf, 0xda, 0x1b, 0x94, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
|
||||
0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1c, 0x02, 0x00, 0x00, 0x44, // wSize..........D
|
||||
0x58, 0x42, 0x43, 0x99, 0x64, 0x1c, 0x9f, 0xec, 0x38, 0xd9, 0xd2, 0x91, 0x86, 0xde, 0x66, 0x7d, // XBC.d...8.....f}
|
||||
0x52, 0x06, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, // R..............,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x4c, // ...........ISGNL
|
||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, // ...........8....
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ................
|
||||
0x03, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...A............
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, // ...........POSIT
|
||||
0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0x4f, // ION.TEXCOORD...O
|
||||
0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, // SGNh...........P
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x5c, // ................
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, // ................
|
||||
0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, // .......SV_POSITI
|
||||
0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0xab, 0x53, // ON.TEXCOORD....S
|
||||
0x48, 0x44, 0x52, 0x24, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x49, 0x00, 0x00, 0x00, 0x59, // HDR$...@...I...Y
|
||||
0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, // ...F. ........._
|
||||
0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, // ...2......._...2
|
||||
0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, // .......g.... ...
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x01, // .......e...2 ...
|
||||
0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xc2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68, // ...e.... ......h
|
||||
0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x00, // ...........2....
|
||||
0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, // ...F.......F....
|
||||
0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, // .......2.......F
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .......F. ......
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x12, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, // ........ .......
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, // ........@.......
|
||||
0x00, 0x00, 0x08, 0x22, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, // ..." ..........A
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x36, // ........@.....?6
|
||||
0x00, 0x00, 0x08, 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, // .... .......@...
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x36, // ..............?6
|
||||
0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, // ...2 ......F....
|
||||
0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xc2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, // ...6.... .......
|
||||
0x14, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x01, 0x00, 0x10, // .......>........
|
||||
0x00, 0x10, 0x00, // ...
|
||||
};
|
||||
static const uint8_t vs_nanovg_fill_mtl[904] =
|
||||
{
|
||||
0x56, 0x53, 0x48, 0x05, 0xcf, 0xda, 0x1b, 0x94, 0x02, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
|
||||
0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x75, 0x5f, 0x68, 0x61, // wSize.......u_ha
|
||||
0x6c, 0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x56, 0x03, 0x00, // lfTexel......V..
|
||||
0x00, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, // .using namespace
|
||||
0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, // metal;.struct x
|
||||
0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, // latMtlShaderInpu
|
||||
0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x61, 0x5f, 0x70, // t {. float2 a_p
|
||||
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, // osition [[attrib
|
||||
0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, // ute(0)]];. floa
|
||||
0x74, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x5b, // t2 a_texcoord0 [
|
||||
0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, // [attribute(1)]];
|
||||
0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // .};.struct xlatM
|
||||
0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, // tlShaderOutput {
|
||||
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, // . float4 gl_Pos
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // ition [[position
|
||||
0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x76, 0x5f, 0x70, // ]];. float2 v_p
|
||||
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // osition;. float
|
||||
0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x7d, // 2 v_texcoord0;.}
|
||||
0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // ;.struct xlatMtl
|
||||
0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, // ShaderUniform {.
|
||||
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, // float4 u_viewS
|
||||
0x69, 0x7a, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, // ize;. float4 u_
|
||||
0x68, 0x61, 0x6c, 0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, // halfTexel;.};.ve
|
||||
0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, // rtex xlatMtlShad
|
||||
0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // erOutput xlatMtl
|
||||
0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // Main (xlatMtlSha
|
||||
0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, // derInput _mtl_i
|
||||
0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, // [[stage_in]], co
|
||||
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // nstant xlatMtlSh
|
||||
0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, // aderUniform& _mt
|
||||
0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, // l_u [[buffer(0)]
|
||||
0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // ]).{. xlatMtlSh
|
||||
0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // aderOutput _mtl_
|
||||
0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x70, 0x6f, // o;. _mtl_o.v_po
|
||||
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, // sition = _mtl_i.
|
||||
0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, // a_position;. _m
|
||||
0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // tl_o.v_texcoord0
|
||||
0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x74, 0x65, 0x78, // = (_mtl_i.a_tex
|
||||
0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, // coord0 + _mtl_u.
|
||||
0x75, 0x5f, 0x68, 0x61, 0x6c, 0x66, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x2e, 0x78, 0x79, 0x29, 0x3b, // u_halfTexel.xy);
|
||||
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // . float4 tmpvar
|
||||
0x5f, 0x31, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // _1 = 0;. tmpvar
|
||||
0x5f, 0x31, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x30, // _1.zw = float2(0
|
||||
0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // .0, 1.0);. tmpv
|
||||
0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, 0x32, 0x2e, 0x30, 0x20, // ar_1.x = (((2.0
|
||||
0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // * _mtl_i.a_posit
|
||||
0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x29, 0x20, 0x2f, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, // ion.x) / _mtl_u.
|
||||
0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x29, 0x20, 0x2d, 0x20, // u_viewSize.x) -
|
||||
0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // 1.0);. tmpvar_1
|
||||
0x2e, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x31, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x32, 0x2e, // .y = (1.0 - ((2.
|
||||
0x30, 0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, // 0 * _mtl_i.a_pos
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x79, 0x29, 0x20, 0x2f, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // ition.y) / _mtl_
|
||||
0x75, 0x2e, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x79, 0x29, 0x29, // u.u_viewSize.y))
|
||||
0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // ;. _mtl_o.gl_Po
|
||||
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // sition = tmpvar_
|
||||
0x31, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // 1;. return _mtl
|
||||
0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // _o;.}...
|
||||
};
|
||||
extern const uint8_t* vs_nanovg_fill_pssl;
|
||||
extern const uint32_t vs_nanovg_fill_pssl_size;
|
23
3rd/nanovg/bgfx/vs_nanovg_fill.sc
Normal file
23
3rd/nanovg/bgfx/vs_nanovg_fill.sc
Normal file
@ -0,0 +1,23 @@
|
||||
$input a_position, a_texcoord0
|
||||
$output v_position, v_texcoord0
|
||||
|
||||
#include "../common.sh"
|
||||
|
||||
#define NEED_HALF_TEXEL (BGFX_SHADER_LANGUAGE_HLSL < 4)
|
||||
|
||||
uniform vec4 u_viewSize;
|
||||
|
||||
#if NEED_HALF_TEXEL
|
||||
uniform vec4 u_halfTexel;
|
||||
#endif // NEED_HALF_TEXEL
|
||||
|
||||
void main()
|
||||
{
|
||||
#if !NEED_HALF_TEXEL
|
||||
const vec4 u_halfTexel = vec4_splat(0.0);
|
||||
#endif // !NEED_HALF_TEXEL
|
||||
|
||||
v_position = a_position;
|
||||
v_texcoord0 = a_texcoord0+u_halfTexel.xy;
|
||||
gl_Position = vec4(2.0*v_position.x/u_viewSize.x - 1.0, 1.0 - 2.0*v_position.y/u_viewSize.y, 0.0, 1.0);
|
||||
}
|
60
3rd/nanovg/demos/bgfx_sdl_draw_image.c
Normal file
60
3rd/nanovg/demos/bgfx_sdl_draw_image.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include "bgfx/nanovg_bgfx.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "../stb/stb_image.h"
|
||||
#include "draw_image.inc"
|
||||
#include "get_sdl_window.inc"
|
||||
|
||||
|
||||
static void run_test(int w, int h)
|
||||
{
|
||||
bool exit = false;
|
||||
SDL_Event event;
|
||||
SDL_WindowEvent wev;
|
||||
NVGcontext* vg = nvgCreateBGFX(1, 0, w, h, CreateSDLWindow(w, h));
|
||||
while (!exit)
|
||||
{
|
||||
setBGFXViewRect(0, 0, 0, w, h);
|
||||
touchBGFX(0);
|
||||
do_draw(vg, w, h);
|
||||
frameBGFX(false);
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
exit = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
wev = event.window;
|
||||
switch (wev.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
w = wev.data1;
|
||||
h = wev.data2;
|
||||
resetBGFX(w, h, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nvgDeleteBGFX(vg);
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
||||
#else
|
||||
int main(void) {
|
||||
#endif
|
||||
run_test(400, 400);
|
||||
return 0;
|
||||
}
|
58
3rd/nanovg/demos/bgfx_sdl_draw_text.c
Normal file
58
3rd/nanovg/demos/bgfx_sdl_draw_text.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include "bgfx/nanovg_bgfx.h"
|
||||
#include "draw_text.inc"
|
||||
#include "get_sdl_window.inc"
|
||||
|
||||
static void run_test(int w, int h)
|
||||
{
|
||||
bool exit = false;
|
||||
SDL_Event event;
|
||||
SDL_WindowEvent wev;
|
||||
NVGcontext* vg = nvgCreateBGFX(1, 0, w, h, CreateSDLWindow(w, h));
|
||||
nvgCreateFont(vg, "default", "default.ttf");
|
||||
nvgFontFace(vg, "default");
|
||||
while (!exit)
|
||||
{
|
||||
setBGFXViewRect(0, 0, 0, w, h);
|
||||
touchBGFX(0);
|
||||
do_draw_text(vg, w, h);
|
||||
frameBGFX(false);
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
exit = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
wev = event.window;
|
||||
switch (wev.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
w = wev.data1;
|
||||
h = wev.data2;
|
||||
resetBGFX(w, h, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nvgDeleteBGFX(vg);
|
||||
}
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
||||
#else
|
||||
int main(void) {
|
||||
#endif
|
||||
run_test(400, 400);
|
||||
return 0;
|
||||
}
|
57
3rd/nanovg/demos/bgfx_sdl_fill.c
Normal file
57
3rd/nanovg/demos/bgfx_sdl_fill.c
Normal file
@ -0,0 +1,57 @@
|
||||
#include "bgfx/nanovg_bgfx.h"
|
||||
#include "fill.inc"
|
||||
#include "get_sdl_window.inc"
|
||||
|
||||
static void run_test(int w, int h)
|
||||
{
|
||||
bool exit = false;
|
||||
SDL_Event event;
|
||||
SDL_WindowEvent wev;
|
||||
NVGcontext* vg = nvgCreateBGFX(1, 0, w, h, CreateSDLWindow(w, h));
|
||||
while (!exit)
|
||||
{
|
||||
setBGFXViewRect(0, 0, 0, w, h);
|
||||
touchBGFX(0);
|
||||
do_fill(vg, w, h);
|
||||
frameBGFX(false);
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
exit = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
wev = event.window;
|
||||
switch (wev.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
w = wev.data1;
|
||||
h = wev.data2;
|
||||
resetBGFX(w, h, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nvgDeleteBGFX(vg);
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
||||
#else
|
||||
int main(void) {
|
||||
#endif
|
||||
run_test(400, 400);
|
||||
return 0;
|
||||
}
|
56
3rd/nanovg/demos/bgfx_sdl_stroke.c
Normal file
56
3rd/nanovg/demos/bgfx_sdl_stroke.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include "bgfx/nanovg_bgfx.h"
|
||||
#include "stroke.inc"
|
||||
#include "get_sdl_window.inc"
|
||||
|
||||
static void run_test(int w, int h)
|
||||
{
|
||||
bool exit = false;
|
||||
SDL_Event event;
|
||||
SDL_WindowEvent wev;
|
||||
NVGcontext* vg = nvgCreateBGFX(1, 0, w, h, CreateSDLWindow(w, h));
|
||||
while (!exit)
|
||||
{
|
||||
setBGFXViewRect(0, 0, 0, (uint16_t)w, (uint16_t)h);
|
||||
touchBGFX(0);
|
||||
do_stroke(vg, w, h);
|
||||
frameBGFX(false);
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
exit = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
wev = event.window;
|
||||
switch (wev.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
w = wev.data1;
|
||||
h = wev.data2;
|
||||
resetBGFX(w, h, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nvgDeleteBGFX(vg);
|
||||
}
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
||||
#else
|
||||
int main(void) {
|
||||
#endif
|
||||
run_test(400, 400);
|
||||
return 0;
|
||||
}
|
@ -27,7 +27,7 @@ static void do_draw(NVGcontext* vg, int32_t w, int32_t h) {
|
||||
int32_t iw = 0;
|
||||
int32_t ih = 0;
|
||||
int32_t comp = 4;
|
||||
int img = load_image(vg, "demos/assets/raw/images/x2/rgb.png", &comp, &iw, &ih);
|
||||
int img = load_image(vg, "../demos/assets/raw/images/x2/rgb.png", &comp, &iw, &ih);
|
||||
|
||||
nvgBeginFrame(vg, w, h, 1);
|
||||
|
||||
@ -37,7 +37,7 @@ static void do_draw(NVGcontext* vg, int32_t w, int32_t h) {
|
||||
draw_image(vg, imgPaint, 0, 0, iw, ih, 10, 100, iw*2, ih*2);
|
||||
|
||||
|
||||
int img2 = load_image(vg, "demos/assets/raw/images/x2/rgba.png", &comp, &iw, &ih);
|
||||
int img2 = load_image(vg, "../demos/assets/raw/images/x2/rgba.png", &comp, &iw, &ih);
|
||||
NVGpaint imgPaint2 = nvgImagePattern(vg, 0, 0, iw, ih, 0, img2, 1);
|
||||
|
||||
nvgTranslate(vg, 100, 100);
|
||||
|
17
3rd/nanovg/demos/draw_text.inc
Normal file
17
3rd/nanovg/demos/draw_text.inc
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
static void do_draw_text(NVGcontext* vg, int32_t w, int32_t h) {
|
||||
|
||||
const char* text = "Hello AWTK";
|
||||
nvgBeginFrame(vg, w, h, 1);
|
||||
nvgFillColor(vg, nvgRGBA(255, 0, 0, 255));
|
||||
nvgSave(vg);
|
||||
nvgFontSize(vg, 20);
|
||||
nvgTextAlign(vg, NVG_ALIGN_LEFT|NVG_ALIGN_TOP);
|
||||
//nvgFontBlur(vg,2);
|
||||
nvgFillColor(vg, nvgRGBA(0, 255, 0, 255));
|
||||
nvgText(vg, 20, 20, text, NULL);
|
||||
nvgRestore(vg);
|
||||
|
||||
nvgEndFrame(vg);
|
||||
}
|
||||
|
13
3rd/nanovg/demos/get_sdl_window.inc
Normal file
13
3rd/nanovg/demos/get_sdl_window.inc
Normal file
@ -0,0 +1,13 @@
|
||||
static SDL_Window* CreateSDLWindow(int w, int h){
|
||||
SDL_Init(0 | SDL_INIT_GAMECONTROLLER);
|
||||
static SDL_Window* sdl_window = NULL;
|
||||
sdl_window = SDL_CreateWindow("bgfx"
|
||||
, SDL_WINDOWPOS_UNDEFINED
|
||||
, SDL_WINDOWPOS_UNDEFINED
|
||||
, w
|
||||
, h
|
||||
, SDL_WINDOW_SHOWN
|
||||
| SDL_WINDOW_RESIZABLE
|
||||
);
|
||||
return sdl_window;
|
||||
}
|
@ -36,3 +36,14 @@ for f in GL_FILES:
|
||||
src=os.path.join('src', f);
|
||||
dst=os.path.join('gl', f);
|
||||
copyFile(src, dst)
|
||||
|
||||
|
||||
SRC_ROOT_DIR=joinPath(os.getcwd(), '../../../3rd/bgfx-awtk/nanovg/');
|
||||
BGFX_FILES=['fs_nanovg_fill.sc', 'nanovg_bgfxEx.h', 'vs_nanovg_fill.sc',
|
||||
'fontstash.h','nanovg_bgfx.cpp','varying.def.sc',
|
||||
'fs_nanovg_fill.bin.h','nanovg_bgfx.h','vs_nanovg_fill.bin.h'];
|
||||
|
||||
for f in BGFX_FILES:
|
||||
src=os.path.join('bgfx', f);
|
||||
dst=os.path.join('bgfx', f);
|
||||
copyFile(src, dst)
|
||||
|
89
SConstruct
89
SConstruct
@ -6,12 +6,12 @@ def joinPath(root, subdir):
|
||||
|
||||
OS_NAME=platform.system()
|
||||
TK_ROOT = os.path.normpath(os.getcwd())
|
||||
BIN_DIR=joinPath(TK_ROOT, 'bin')
|
||||
LIB_DIR=joinPath(TK_ROOT, 'lib')
|
||||
TK_SRC = joinPath(TK_ROOT, 'src')
|
||||
TK_3RD_ROOT = joinPath(TK_ROOT, '3rd')
|
||||
TK_TOOLS_ROOT = joinPath(TK_ROOT, 'tools')
|
||||
GTEST_ROOT = joinPath(TK_ROOT, '3rd/gtest/googletest')
|
||||
BIN_DIR=joinPath(TK_ROOT, 'bin')
|
||||
LIB_DIR=joinPath(TK_ROOT, 'lib')
|
||||
|
||||
if OS_NAME == 'Windows':
|
||||
TK_ROOT=TK_ROOT.replace('\\', '\\\\');
|
||||
@ -19,38 +19,35 @@ if OS_NAME == 'Windows':
|
||||
#INPUT_ENGINE='null'
|
||||
INPUT_ENGINE='pinyin'
|
||||
|
||||
LCD='SDL'
|
||||
LCD='GL'
|
||||
|
||||
VGCANVAS='NANOVG'
|
||||
NANOVG_BACKEND='GL3'
|
||||
#NANOVG_BACKEND='GLES2'
|
||||
#NANOVG_BACKEND='GLES3'
|
||||
#NANOVG_BACKEND='AGG'
|
||||
#NANOVG_BACKEND='AGGE'
|
||||
#NANOVG_BACKEND='BGFX'
|
||||
#NANOVG_BACKEND='GL3'
|
||||
#NANOVG_BACKEND='GLES'
|
||||
#NANOVG_BACKEND='AGG'
|
||||
NANOVG_BACKEND='AGGE'
|
||||
|
||||
#FRAME_BUFFER_FORMAT='bgr888'
|
||||
FRAME_BUFFER_FORMAT='bgr565'
|
||||
FRAME_BUFFER_FORMAT='bgra8888'
|
||||
|
||||
COMMON_CCFLAGS=' -DTK_ROOT=\\\"'+TK_ROOT+'\\\" -DHAS_STD_MALLOC -DWITH_SDL -DWITH_FS_RES -DHAS_STDIO -DWITH_DESKTOP_STYLE '
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DSTBTT_STATIC -DSTB_IMAGE_STATIC -DWITH_STB_IMAGE -DWITH_STB_FONT -DWITH_VGCANVAS -DWITH_UNICODE_BREAK '
|
||||
FRAME_BUFFER_FORMAT=''
|
||||
if NANOVG_BACKEND == 'AGGE' or NANOVG_BACKEND == 'AGG':
|
||||
LCD='SDL_FB'
|
||||
FRAME_BUFFER_FORMAT='bgr565'
|
||||
#FRAME_BUFFER_FORMAT='bgra8888'
|
||||
else:
|
||||
LCD='SDL_GPU'
|
||||
|
||||
NANOVG_BACKEND_LIBS=[];
|
||||
NANOVG_BACKEND_PROJS=[];
|
||||
COMMON_CCFLAGS=' -DTK_ROOT=\\\"'+TK_ROOT+'\\\" -DHAS_STD_MALLOC -DWITH_SDL -DWITH_FS_RES -DHAS_STDIO -DWITH_DESKTOP_STYLE '
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DSTBTT_STATIC -DSTB_IMAGE_STATIC -DWITH_STB_IMAGE -DWITH_STB_FONT -DWITH_VGCANVAS -DWITH_UNICODE_BREAK '
|
||||
|
||||
if LCD == 'GL':
|
||||
NANOVG_BACKEND='GL'
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GL -DWITH_VGCANVAS_LCD'
|
||||
if LCD == 'SDL_GPU':
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GPU -DWITH_VGCANVAS_LCD'
|
||||
else:
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_BITMAP_BGRA -DWITH_NANOVG_SOFT '
|
||||
if FRAME_BUFFER_FORMAT=='bgra8888':
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DWITH_FB_BGRA8888=1 ';
|
||||
elif FRAME_BUFFER_FORMAT=='bgr888':
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DWITH_FB_BGR888=1 ';
|
||||
else:
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DWITH_FB_BGR565=1 ';
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DWITH_FB_BGR565=1 -DWITH_BITMAP_BGR565';
|
||||
|
||||
if NANOVG_BACKEND == 'AGG':
|
||||
NANOVG_BACKEND_LIBS=['nanovg-agg', 'agg'];
|
||||
@ -59,23 +56,17 @@ if NANOVG_BACKEND == 'AGG':
|
||||
elif NANOVG_BACKEND == 'AGGE':
|
||||
NANOVG_BACKEND_LIBS=['nanovg-agge', 'agge'];
|
||||
NANOVG_BACKEND_PROJS=['3rd/agge/SConscript'];
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_AGGE -DWITH_BITMAP_BGR565 '
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_AGGE '
|
||||
elif NANOVG_BACKEND == 'BGFX':
|
||||
NANOVG_BACKEND_LIBS=['nanovg-bgfx','bgfx'];
|
||||
NANOVG_BACKEND_PROJS=['3rd/bgfx/SConscript'];
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_BGFX '
|
||||
elif NANOVG_BACKEND == 'GLES':
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GLES '
|
||||
elif NANOVG_BACKEND == 'GLES2':
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GLES2 -DWITH_NANOVG_GL '
|
||||
elif NANOVG_BACKEND == 'GLES3':
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GLES3 -DWITH_NANOVG_GL '
|
||||
else:
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GL3 '
|
||||
|
||||
os.environ['LCD'] = LCD
|
||||
os.environ['VGCANVAS'] = VGCANVAS
|
||||
os.environ['BIN_DIR'] = BIN_DIR;
|
||||
os.environ['LIB_DIR'] = LIB_DIR;
|
||||
os.environ['TK_ROOT'] = TK_ROOT;
|
||||
os.environ['GTEST_ROOT'] = GTEST_ROOT;
|
||||
os.environ['INPUT_ENGINE'] = INPUT_ENGINE;
|
||||
os.environ['NANOVG_BACKEND'] = NANOVG_BACKEND;
|
||||
os.environ['FRAME_BUFFER_FORMAT'] = FRAME_BUFFER_FORMAT;
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_GL3 -DWITH_NANOVG_GL '
|
||||
|
||||
OS_LIBS=[]
|
||||
OS_LIBPATH=[]
|
||||
@ -88,9 +79,9 @@ OS_PROJECTS=[]
|
||||
|
||||
if OS_NAME == 'Darwin':
|
||||
OS_LIBS = ['stdc++', 'pthread', 'm', 'dl']
|
||||
OS_LINKFLAGS='-framework OpenGL'
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -D__APPLE__ -DHAS_PTHREAD -DMACOS -DENABLE_MEM_LEAK_CHECK1 '
|
||||
COMMON_CCFLAGS=COMMON_CCFLAGS+' -DENABLE_CURSOR '
|
||||
OS_LINKFLAGS='-framework Cocoa -framework QuartzCore -framework OpenGL -weak_framework Metal -weak_framework MetalKit'
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -D__APPLE__ -DHAS_PTHREAD -DMACOS -DENABLE_MEM_LEAK_CHECK '
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -DBGFX_CONFIG_RENDERER_METAL=1 '
|
||||
|
||||
elif OS_NAME == 'Linux':
|
||||
OS_LIBS = ['GL', 'gtk-3','gdk-3','Xext', 'X11', 'sndio','stdc++', 'pthread', 'm', 'dl']
|
||||
@ -102,9 +93,11 @@ elif OS_NAME == 'Linux':
|
||||
OS_PROJECTS=['3rd/SDL/SConscript']
|
||||
|
||||
elif OS_NAME == 'Windows':
|
||||
OS_LIBS=['gdi32', 'user32','winmm.lib','imm32.lib','version.lib','shell32.lib','ole32.lib','Oleaut32.lib','Advapi32.lib']
|
||||
OS_LIBS=['gdi32', 'user32','winmm.lib','imm32.lib','version.lib','shell32.lib','ole32.lib','Oleaut32.lib','Advapi32.lib','DelayImp.lib','psapi.lib']
|
||||
OS_FLAGS='-DWIN32 -D_WIN32 -DWINDOWS /EHsc -D_CONSOLE /DEBUG /Od /FS /Z7 '
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DSDL_REAL_API -DSDL_HAPTIC_DISABLED -DSDL_SENSOR_DISABLED -DSDL_JOYSTICK_DISABLED '
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + '-D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D_HAS_EXCEPTIONS=0 -D_HAS_ITERATOR_DEBUGGING=0 -D_ITERATOR_DEBUG_LEVEL=0 -D_SCL_SECURE=0'
|
||||
COMMON_CCFLAGS = COMMON_CCFLAGS + '-D_SECURE_SCL=0 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_WIN64'
|
||||
OS_LINKFLAGS='/MACHINE:X64 /DEBUG'
|
||||
OS_SUBSYSTEM_CONSOLE='/SUBSYSTEM:CONSOLE '
|
||||
OS_SUBSYSTEM_WINDOWS='/SUBSYSTEM:WINDOWS '
|
||||
@ -119,12 +112,16 @@ CPPPATH=[TK_ROOT,
|
||||
TK_SRC,
|
||||
TK_3RD_ROOT,
|
||||
joinPath(TK_SRC, 'ext_widgets'),
|
||||
joinPath(TK_3RD_ROOT, 'bgfx/bgfx/include'),
|
||||
joinPath(TK_3RD_ROOT, 'bgfx/bx/include'),
|
||||
joinPath(TK_3RD_ROOT, 'bgfx/bimg/include'),
|
||||
joinPath(TK_3RD_ROOT, 'agge'),
|
||||
joinPath(TK_3RD_ROOT, 'agg/include'),
|
||||
joinPath(TK_3RD_ROOT, 'nanovg'),
|
||||
joinPath(TK_3RD_ROOT, 'nanovg/base'),
|
||||
joinPath(TK_3RD_ROOT, 'nanovg/gl'),
|
||||
joinPath(TK_3RD_ROOT, 'nanovg/base'),
|
||||
joinPath(TK_3RD_ROOT, 'nanovg/agge'),
|
||||
joinPath(TK_3RD_ROOT, 'nanovg/bgfx'),
|
||||
joinPath(TK_3RD_ROOT, 'SDL/src'),
|
||||
joinPath(TK_3RD_ROOT, 'SDL/include'),
|
||||
joinPath(TK_3RD_ROOT, 'agge/src'),
|
||||
@ -142,6 +139,18 @@ DefaultEnvironment(CCFLAGS = CCFLAGS,
|
||||
OS_SUBSYSTEM_WINDOWS=OS_SUBSYSTEM_WINDOWS
|
||||
)
|
||||
|
||||
os.environ['LCD'] = LCD
|
||||
os.environ['BIN_DIR'] = BIN_DIR;
|
||||
os.environ['LIB_DIR'] = LIB_DIR;
|
||||
os.environ['TK_ROOT'] = TK_ROOT;
|
||||
os.environ['CCFLAGS'] = CCFLAGS;
|
||||
os.environ['VGCANVAS'] = VGCANVAS
|
||||
os.environ['GTEST_ROOT'] = GTEST_ROOT;
|
||||
os.environ['TK_3RD_ROOT'] = TK_3RD_ROOT;
|
||||
os.environ['INPUT_ENGINE'] = INPUT_ENGINE;
|
||||
os.environ['NANOVG_BACKEND'] = NANOVG_BACKEND;
|
||||
os.environ['FRAME_BUFFER_FORMAT'] = FRAME_BUFFER_FORMAT;
|
||||
|
||||
SConscriptFiles=NANOVG_BACKEND_PROJS + [
|
||||
'3rd/nanovg/SConscript',
|
||||
'3rd/glad/SConscript',
|
||||
|
@ -3,6 +3,7 @@ import copy
|
||||
|
||||
BIN_DIR=os.environ['BIN_DIR'];
|
||||
LIB_DIR=os.environ['LIB_DIR'];
|
||||
NANOVG_BACKEND=os.environ['NANOVG_BACKEND'];
|
||||
|
||||
sources=Glob('base/*.c') +\
|
||||
Glob('ui_loader/*.c') + \
|
||||
@ -19,20 +20,28 @@ sources=Glob('base/*.c') +\
|
||||
['awtk.c'];
|
||||
|
||||
sources += ['main_loop/main_loop_simple.c'];
|
||||
if os.environ['LCD'] == 'GL':
|
||||
sources += ['window_animators/window_animator_opengl.c'];
|
||||
sources += ['lcd/lcd_nanovg.c', 'main_loop/main_loop_nanovg.c'];
|
||||
elif os.environ['LCD'] == 'SDL':
|
||||
if os.environ['LCD'] == 'SDL_GPU':
|
||||
sources += ['window_animators/window_animator_gpu.c'];
|
||||
sources += ['lcd/lcd_nanovg.c', 'main_loop/main_loop_sdl_gpu.c'];
|
||||
elif os.environ['LCD'] == 'SDL_FB':
|
||||
sources += ['window_animators/window_animator_fb.c'];
|
||||
sources += ['lcd/lcd_sdl2.c', 'main_loop/main_loop_sdl2.c']
|
||||
sources += ['lcd/lcd_sdl2.c', 'main_loop/main_loop_sdl_fb.c']
|
||||
else:
|
||||
sources += ['window_animators/window_animator_fb.c'];
|
||||
|
||||
sources += [
|
||||
'vgcanvas/vgcanvas_nanovg.c',
|
||||
'input_methods/input_method_creator.c'
|
||||
] + Glob('lcd/lcd_mem_*.c') ;
|
||||
|
||||
if NANOVG_BACKEND == 'BGFX':
|
||||
sources +=['vgcanvas/vgcanvas_nanovg_bgfx.c'];
|
||||
elif NANOVG_BACKEND == 'AGG':
|
||||
sources +=['vgcanvas/vgcanvas_nanovg_soft.c'];
|
||||
elif NANOVG_BACKEND == 'AGGE':
|
||||
sources +=['vgcanvas/vgcanvas_nanovg_soft.c'];
|
||||
else:
|
||||
sources +=['vgcanvas/vgcanvas_nanovg_gl.c'];
|
||||
|
||||
if os.environ['INPUT_ENGINE'] == 'null':
|
||||
sources += Glob('input_engines/input_engine_null.c')
|
||||
else:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* File: main_loop_sdl2.c
|
||||
* File: main_loop_sdl_fb.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: sdl2 implemented main_loop interface
|
||||
*
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "main_loop/main_loop_simple.h"
|
||||
#include "main_loop/main_loop_sdl2.h"
|
||||
#include "main_loop/main_loop_sdl_fb.h"
|
||||
#include "base/window_manager.h"
|
||||
#include "base/font_manager.h"
|
||||
#include "lcd/lcd_sdl2.h"
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#include "sdl2_common.inc"
|
||||
|
||||
static ret_t main_loop_sdl2_destroy(main_loop_t* l) {
|
||||
static ret_t main_loop_sdl_fb_destroy(main_loop_t* l) {
|
||||
const char* errMsg = SDL_GetError();
|
||||
main_loop_simple_t* loop = (main_loop_simple_t*)l;
|
||||
|
||||
@ -57,7 +57,7 @@ static ret_t main_loop_sdl2_destroy(main_loop_t* l) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t main_loop_sdl2_create_window(main_loop_simple_t* l) {
|
||||
static ret_t main_loop_sdl_fb_create_window(main_loop_simple_t* l) {
|
||||
int x = SDL_WINDOWPOS_UNDEFINED;
|
||||
int y = SDL_WINDOWPOS_UNDEFINED;
|
||||
int flags = SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED;
|
||||
@ -77,10 +77,10 @@ static ret_t main_loop_sdl2_create_window(main_loop_simple_t* l) {
|
||||
main_loop_t* main_loop_init(int w, int h) {
|
||||
main_loop_simple_t* loop = main_loop_simple_init(w, h);
|
||||
|
||||
loop->base.destroy = main_loop_sdl2_destroy;
|
||||
loop->dispatch_input = main_loop_sdl2_dispatch;
|
||||
loop->base.destroy = main_loop_sdl_fb_destroy;
|
||||
loop->dispatch_input = main_loop_sdl_fb_dispatch;
|
||||
|
||||
main_loop_sdl2_create_window(loop);
|
||||
main_loop_sdl_fb_create_window(loop);
|
||||
SDL_StopTextInput();
|
||||
|
||||
return (main_loop_t*)loop;
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* File: main_loop_sdl2.h
|
||||
* File: main_loop_sdl_fb.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: sdl2 implemented main_loop interface
|
||||
*
|
||||
@ -19,8 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_MAIN_LOOP_SDL2_H
|
||||
#define TK_MAIN_LOOP_SDL2_H
|
||||
#ifndef TK_MAIN_LOOP_SDL_FB_H
|
||||
#define TK_MAIN_LOOP_SDL_FB_H
|
||||
|
||||
#include "base/main_loop.h"
|
||||
|
||||
@ -30,4 +30,4 @@ main_loop_t* main_loop_init(int w, int h);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_MAIN_LOOP_SDL2_H*/
|
||||
#endif /*TK_MAIN_LOOP_SDL_FB_H*/
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* File: main_loop_nanovg.c
|
||||
* File: main_loop_sdl_gpu.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: nanovg implemented main_loop interface
|
||||
*
|
||||
@ -19,23 +19,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include <SDL.h>
|
||||
#include "lcd/lcd_nanovg.h"
|
||||
#include "main_loop/main_loop_nanovg.h"
|
||||
#include "main_loop/main_loop_sdl_gpu.h"
|
||||
#include "main_loop/main_loop_simple.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
#include <SDL_opengl_glext.h>
|
||||
|
||||
#define LOOP_SDL_WINDOW(loop) ((SDL_Window*)(((main_loop_simple_t*)loop)->user1))
|
||||
#define LOOP_SDL_GLCONTEXT(loop) ((SDL_Window*)(((main_loop_simple_t*)loop)->user2))
|
||||
#define LOOP_SDL_WINDOW_SET(loop, v) (((main_loop_simple_t*)loop)->user1 = v)
|
||||
#define LOOP_SDL_GLCONTEXT_SET(loop, v) (((main_loop_simple_t*)loop)->user2 = v)
|
||||
|
||||
#include "sdl2_common.inc"
|
||||
|
||||
static ret_t main_loop_nanovg_destroy(main_loop_t* l) {
|
||||
static ret_t main_loop_sdl_gpu_destroy(main_loop_t* l) {
|
||||
const char* errMsg = SDL_GetError();
|
||||
main_loop_simple_t* loop = (main_loop_simple_t*)l;
|
||||
|
||||
@ -45,7 +39,6 @@ static ret_t main_loop_nanovg_destroy(main_loop_t* l) {
|
||||
|
||||
if (LOOP_SDL_WINDOW(loop)) {
|
||||
SDL_DestroyWindow(LOOP_SDL_WINDOW(loop));
|
||||
SDL_GL_DeleteContext(LOOP_SDL_GLCONTEXT(loop));
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
@ -54,11 +47,11 @@ static ret_t main_loop_nanovg_destroy(main_loop_t* l) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t main_loop_nanovg_create_window(main_loop_simple_t* l) {
|
||||
static ret_t main_loop_sdl_gpu_create_window(main_loop_simple_t* l) {
|
||||
int32_t x = SDL_WINDOWPOS_UNDEFINED;
|
||||
int32_t y = SDL_WINDOWPOS_UNDEFINED;
|
||||
uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
const char* title = system_info()->app_name;
|
||||
uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
if (title == NULL) {
|
||||
title = "AWTK Simulator";
|
||||
@ -74,32 +67,9 @@ static ret_t main_loop_nanovg_create_window(main_loop_simple_t* l) {
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||
|
||||
#ifdef WITH_NANOVG_GL2
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#elif defined(WITH_NANOVG_GL3)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
#endif
|
||||
|
||||
LOOP_SDL_WINDOW_SET(l, SDL_CreateWindow(title, x, y, l->w, l->h, flags));
|
||||
return_value_if_fail(LOOP_SDL_WINDOW(l) != NULL, RET_FAIL);
|
||||
|
||||
LOOP_SDL_GLCONTEXT_SET(l, SDL_GL_CreateContext(LOOP_SDL_WINDOW(l)));
|
||||
SDL_GL_MakeCurrent(LOOP_SDL_WINDOW(l), LOOP_SDL_GLCONTEXT(l));
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
|
||||
gladLoadGL();
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
canvas_init(&(l->base.canvas), lcd_nanovg_init(LOOP_SDL_WINDOW(l)), font_manager());
|
||||
|
||||
return RET_OK;
|
||||
@ -108,10 +78,10 @@ static ret_t main_loop_nanovg_create_window(main_loop_simple_t* l) {
|
||||
main_loop_t* main_loop_init(int w, int h) {
|
||||
main_loop_simple_t* loop = main_loop_simple_init(w, h);
|
||||
|
||||
loop->base.destroy = main_loop_nanovg_destroy;
|
||||
loop->base.destroy = main_loop_sdl_gpu_destroy;
|
||||
loop->dispatch_input = main_loop_sdl2_dispatch;
|
||||
|
||||
main_loop_nanovg_create_window(loop);
|
||||
main_loop_sdl_gpu_create_window(loop);
|
||||
SDL_StopTextInput();
|
||||
|
||||
return (main_loop_t*)loop;
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* File: main_loop_nanovg.h
|
||||
* File: main_loop_sdl_gpu.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: nanovg implemented main_loop interface
|
||||
*
|
||||
@ -19,8 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_MAIN_LOOP_NANOVG_H
|
||||
#define TK_MAIN_LOOP_NANOVG_H
|
||||
#ifndef TK_MAIN_LOOP_SDL_GPU_H
|
||||
#define TK_MAIN_LOOP_SDL_GPU_H
|
||||
|
||||
#include "base/main_loop.h"
|
||||
|
||||
@ -30,4 +30,4 @@ main_loop_t* main_loop_init(int w, int h);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_MAIN_LOOP_NANOVG_H*/
|
||||
#endif /*TK_MAIN_LOOP_SDL_GPU_H*/
|
11
src/vgcanvas/README.md
Normal file
11
src/vgcanvas/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 矢量图绘图接口的实现
|
||||
|
||||
目前有4类实现:
|
||||
|
||||
* vgcanvas\_nanovg\_soft 软件实现(**适合普通嵌入式平台**)。软件实现又有agg和agge两种实现。
|
||||
|
||||
* vgcanvas\_nanovg\_gl OpenGL实现。OpenGL实现又有OpenGL3、OpenGLES2和OpenGLES3三种实现。
|
||||
|
||||
* vgcanvas\_nanovg\_bfgx 基于bgfx的实现。bgfx可以使用平台特有的加速接口。如DirectX和Metal等。
|
||||
|
||||
* vgcanvas\_null 空实现。极低端平台不支持矢量图绘图函数,使用本实现。
|
42
src/vgcanvas/texture.inc
Normal file
42
src/vgcanvas/texture.inc
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
static ret_t nanovg_on_bitmap_destroy(bitmap_t* img) {
|
||||
int32_t id = (char*)(img->specific) - (char*)NULL;
|
||||
NVGcontext* vg = (NVGcontext*)(img->specific_ctx);
|
||||
|
||||
if (vg != NULL && id >= 0) {
|
||||
nvgDeleteImage(vg, id);
|
||||
}
|
||||
img->specific = NULL;
|
||||
img->specific_ctx = NULL;
|
||||
img->specific_destroy = NULL;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static int vgcanvas_nanovg_ensure_image(vgcanvas_nanovg_t* canvas, bitmap_t* img) {
|
||||
int32_t i = 0;
|
||||
if (img->flags & BITMAP_FLAG_TEXTURE) {
|
||||
i = (char*)(img->specific) - (char*)NULL;
|
||||
|
||||
if (img->flags & BITMAP_FLAG_CHANGED) {
|
||||
img->flags &= (~(BITMAP_FLAG_CHANGED));
|
||||
nvgUpdateImage(canvas->vg, i, img->data);
|
||||
log_debug("nvgUpdateImage %d\n", i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
i = nvgCreateImageRGBA(canvas->vg, img->w, img->h, NVG_IMAGE_NEAREST, img->data);
|
||||
|
||||
if (i >= 0) {
|
||||
img->flags |= BITMAP_FLAG_TEXTURE;
|
||||
img->specific = (char*)NULL + i;
|
||||
img->specific_ctx = canvas->vg;
|
||||
img->specific_destroy = nanovg_on_bitmap_destroy;
|
||||
image_manager_update_specific(image_manager(), img);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -1,72 +1,10 @@
|
||||
/**
|
||||
* File: vgcanvas.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: vector graphics canvas base on nanovg
|
||||
*
|
||||
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program 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
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-14 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
#define NANOVG_GL3_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#if defined(WITH_NANOVG_GLES2)
|
||||
#define NANOVG_GLES2_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#if defined(WITH_NANOVG_GLES3)
|
||||
#define NANOVG_GLES3_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#include "base/utf8.h"
|
||||
#include "nanovg.h"
|
||||
#include "base/mem.h"
|
||||
#include "base/utf8.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "base/assets_manager.h"
|
||||
|
||||
#include "nanovg.h"
|
||||
|
||||
#ifdef WITH_NANOVG_AGGE
|
||||
#include "agge/nanovg_agge.h"
|
||||
#elif defined(WITH_NANOVG_AGG)
|
||||
#include "agg/nanovg_agg.h"
|
||||
#else /*OpenGL*/
|
||||
#include "glad/glad.h"
|
||||
#include "nanovg_gl.h"
|
||||
#include "nanovg_gl_utils.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
#include <SDL_opengl_glext.h>
|
||||
#endif /*WITH_NANOVG_AGGE*/
|
||||
|
||||
typedef struct _vgcanvas_nanovg_t {
|
||||
vgcanvas_t base;
|
||||
|
||||
int font_id;
|
||||
NVGcontext* vg;
|
||||
uint32_t text_align_v;
|
||||
uint32_t text_align_h;
|
||||
#if defined(WITH_NANOVG_GL)
|
||||
SDL_Window* sdl_window;
|
||||
#endif /*WITH_NANOVG_GL*/
|
||||
} vgcanvas_nanovg_t;
|
||||
|
||||
static int vgcanvas_nanovg_ensure_image(vgcanvas_nanovg_t* canvas, bitmap_t* img);
|
||||
|
||||
static ret_t vgcanvas_nanovg_reset(vgcanvas_t* vgcanvas) {
|
||||
(void)vgcanvas;
|
||||
|
||||
@ -374,22 +312,6 @@ static float_t vgcanvas_nanovg_measure_text(vgcanvas_t* vgcanvas, const char* te
|
||||
return nvgTextBounds(vg, 0, 0, text, text + strlen(text), bounds);
|
||||
}
|
||||
|
||||
#if defined(WITH_NANOVG_GL)
|
||||
static ret_t nanovg_on_bitmap_destroy(bitmap_t* img) {
|
||||
int32_t id = (char*)(img->specific) - (char*)NULL;
|
||||
NVGcontext* vg = (NVGcontext*)(img->specific_ctx);
|
||||
|
||||
if (vg != NULL && id >= 0) {
|
||||
nvgDeleteImage(vg, id);
|
||||
}
|
||||
img->specific = NULL;
|
||||
img->specific_ctx = NULL;
|
||||
img->specific_destroy = NULL;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
#endif /*WITH_NANOVG_GL*/
|
||||
|
||||
static ret_t vgcanvas_nanovg_draw_image(vgcanvas_t* vgcanvas, bitmap_t* img, float_t sx, float_t sy,
|
||||
float_t sw, float_t sh, float_t dx, float_t dy, float_t dw,
|
||||
float_t dh) {
|
||||
@ -514,268 +436,6 @@ static ret_t vgcanvas_nanovg_restore(vgcanvas_t* vgcanvas) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
#if defined(WITH_NANOVG_SOFT)
|
||||
static enum NVGtexture bitmap_format_to_nanovg(bitmap_format_t format) {
|
||||
enum NVGtexture f = NVG_TEXTURE_BGRA;
|
||||
|
||||
switch (format) {
|
||||
case BITMAP_FMT_RGBA8888: {
|
||||
f = NVG_TEXTURE_RGBA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGRA8888: {
|
||||
f = NVG_TEXTURE_BGRA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR888: {
|
||||
f = NVG_TEXTURE_BGR;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB888: {
|
||||
f = NVG_TEXTURE_RGB;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR565: {
|
||||
f = NVG_TEXTURE_BGR565;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB565: {
|
||||
f = NVG_TEXTURE_RGB565;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert(!"not supported format");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_create_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_bind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_unbind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vgcanvas, uint32_t w, uint32_t h, uint32_t stride,
|
||||
bitmap_format_t format, void* data) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
vgcanvas->w = w;
|
||||
vgcanvas->h = h;
|
||||
vgcanvas->buff = (uint32_t*)data;
|
||||
nvgReinitAgge(vg, w, h, stride, bitmap_format_to_nanovg(format), data);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rect) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgBeginFrame(vg, vgcanvas->w, vgcanvas->h, vgcanvas->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_end_frame(vgcanvas_t* vgcanvas) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static int vgcanvas_nanovg_ensure_image(vgcanvas_nanovg_t* canvas, bitmap_t* img) {
|
||||
int32_t i = 0;
|
||||
int32_t f = 0;
|
||||
if (img->flags & BITMAP_FLAG_TEXTURE) {
|
||||
i = (char*)(img->specific) - (char*)NULL;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
switch (img->format) {
|
||||
case BITMAP_FMT_RGBA8888: {
|
||||
f = NVG_TEXTURE_RGBA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGRA8888: {
|
||||
f = NVG_TEXTURE_BGRA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR565: {
|
||||
f = NVG_TEXTURE_BGR565;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB888: {
|
||||
f = NVG_TEXTURE_RGB;
|
||||
break;
|
||||
}
|
||||
default: { assert(!"not supported format"); }
|
||||
}
|
||||
|
||||
i = nvgCreateImageRaw(canvas->vg, img->w, img->h, f, NVG_IMAGE_NEAREST, img->data);
|
||||
|
||||
if (i >= 0) {
|
||||
img->flags |= BITMAP_FLAG_TEXTURE;
|
||||
img->specific = (char*)NULL + i;
|
||||
image_manager_update_specific(image_manager(), img);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#else
|
||||
static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vg, uint32_t w, uint32_t h, uint32_t stride,
|
||||
bitmap_format_t format, void* data) {
|
||||
(void)vg;
|
||||
(void)w;
|
||||
(void)h;
|
||||
(void)format;
|
||||
(void)data;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rect) {
|
||||
int ww = 0;
|
||||
int wh = 0;
|
||||
int fw = 0;
|
||||
int fh = 0;
|
||||
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
SDL_Window* sdl_window = canvas->sdl_window;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
SDL_GetWindowSize(sdl_window, &ww, &wh);
|
||||
SDL_GL_GetDrawableSize(sdl_window, &fw, &fh);
|
||||
|
||||
glViewport(0, 0, fw, fh);
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
nvgBeginFrame(vg, ww, wh, vgcanvas->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_end_frame(vgcanvas_t* vgcanvas) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
SDL_Window* sdl_window = canvas->sdl_window;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
SDL_GL_SwapWindow(sdl_window);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_create_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGLUframebuffer* handle = NULL;
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
|
||||
handle = nvgluCreateFramebuffer(vg, (int)(vgcanvas->w * vgcanvas->ratio),
|
||||
(int)(vgcanvas->h * vgcanvas->ratio), 0);
|
||||
return_value_if_fail(handle != NULL, RET_FAIL);
|
||||
|
||||
fbo->w = vgcanvas->w;
|
||||
fbo->h = vgcanvas->h;
|
||||
fbo->handle = handle;
|
||||
fbo->id = handle->image;
|
||||
fbo->ratio = vgcanvas->ratio;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGLUframebuffer* handle = (NVGLUframebuffer*)fbo->handle;
|
||||
nvgluDeleteFramebuffer(handle);
|
||||
(void)vgcanvas;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_bind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
NVGLUframebuffer* handle = (NVGLUframebuffer*)fbo->handle;
|
||||
|
||||
nvgluBindFramebuffer(handle);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glViewport(0, 0, fbo->w * fbo->ratio, fbo->h * fbo->ratio);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
nvgBeginFrame(vg, fbo->w, fbo->h, fbo->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_unbind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
nvgluBindFramebuffer(NULL);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static int vgcanvas_nanovg_ensure_image(vgcanvas_nanovg_t* canvas, bitmap_t* img) {
|
||||
int32_t i = 0;
|
||||
if (img->flags & BITMAP_FLAG_TEXTURE) {
|
||||
i = (char*)(img->specific) - (char*)NULL;
|
||||
|
||||
if (img->flags & BITMAP_FLAG_CHANGED) {
|
||||
img->flags &= (~(BITMAP_FLAG_CHANGED));
|
||||
nvgUpdateImage(canvas->vg, i, img->data);
|
||||
log_debug("nvgUpdateImage %d\n", i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
i = nvgCreateImageRGBA(canvas->vg, img->w, img->h, NVG_IMAGE_NEAREST, img->data);
|
||||
|
||||
if (i >= 0) {
|
||||
img->flags |= BITMAP_FLAG_TEXTURE;
|
||||
img->specific = (char*)NULL + i;
|
||||
img->specific_ctx = canvas->vg;
|
||||
img->specific_destroy = nanovg_on_bitmap_destroy;
|
||||
image_manager_update_specific(image_manager(), img);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endif /*WITH_NANOVG_AGGE*/
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy(vgcanvas_t* vgcanvas) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
nvgDeleteGL3(vg);
|
||||
#elif defined(WITH_NANOVG_GLES2)
|
||||
nvgDeleteGLES2(vg);
|
||||
#elif defined(WITH_NANOVG_GLES3)
|
||||
nvgDeleteGLES3(vg);
|
||||
#elif defined(WITH_NANOVG_AGGE)
|
||||
nvgDeleteAGGE(vg);
|
||||
#elif defined(WITH_NANOVG_AGG)
|
||||
nvgDeleteAGG(vg);
|
||||
#endif
|
||||
TKMEM_FREE(vgcanvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static const vgcanvas_vtable_t vt = {vgcanvas_nanovg_reinit,
|
||||
vgcanvas_nanovg_begin_frame,
|
||||
vgcanvas_nanovg_reset,
|
||||
@ -825,60 +485,3 @@ static const vgcanvas_vtable_t vt = {vgcanvas_nanovg_reinit,
|
||||
vgcanvas_nanovg_unbind_fbo,
|
||||
vgcanvas_nanovg_destroy};
|
||||
|
||||
#if defined(WITH_NANOVG_SOFT)
|
||||
vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format,
|
||||
void* data) {
|
||||
enum NVGtexture f = bitmap_format_to_nanovg(format);
|
||||
vgcanvas_nanovg_t* nanovg = (vgcanvas_nanovg_t*)TKMEM_ZALLOC(vgcanvas_nanovg_t);
|
||||
return_value_if_fail(nanovg != NULL, NULL);
|
||||
|
||||
nanovg->base.w = w;
|
||||
nanovg->base.h = h;
|
||||
nanovg->base.vt = &vt;
|
||||
nanovg->base.ratio = 1;
|
||||
nanovg->base.buff = (uint32_t*)data;
|
||||
#if defined(WITH_NANOVG_AGG)
|
||||
nanovg->vg = nvgCreateAGG(w, h, stride, f, (uint8_t*)data);
|
||||
#elif defined(WITH_NANOVG_AGGE)
|
||||
nanovg->vg = nvgCreateAGGE(w, h, stride, f, (uint8_t*)data);
|
||||
#else
|
||||
#error "not supported"
|
||||
#endif
|
||||
|
||||
return &(nanovg->base);
|
||||
}
|
||||
#else /*OpenGL*/
|
||||
vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format,
|
||||
void* sdl_window) {
|
||||
int ww = 0;
|
||||
int wh = 0;
|
||||
int fw = 0;
|
||||
int fh = 0;
|
||||
vgcanvas_nanovg_t* nanovg = (vgcanvas_nanovg_t*)TKMEM_ZALLOC(vgcanvas_nanovg_t);
|
||||
return_value_if_fail(nanovg != NULL, NULL);
|
||||
|
||||
(void)format;
|
||||
|
||||
SDL_GetWindowSize((SDL_Window*)sdl_window, &ww, &wh);
|
||||
SDL_GL_GetDrawableSize((SDL_Window*)sdl_window, &fw, &fh);
|
||||
|
||||
nanovg->base.w = w;
|
||||
nanovg->base.h = h;
|
||||
nanovg->base.vt = &vt;
|
||||
nanovg->base.ratio = (float)fw / (float)ww;
|
||||
nanovg->sdl_window = (SDL_Window*)sdl_window;
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
nanovg->vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
#elif defined(WITH_NANOVG_GLES2)
|
||||
nanovg->vg = nvgCreateGLES2(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
#elif defined(WITH_NANOVG_GLES3)
|
||||
nanovg->vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
#endif
|
||||
|
||||
if (nanovg->vg == NULL) {
|
||||
assert(!"OpenGL is not supported!");
|
||||
}
|
||||
|
||||
return &(nanovg->base);
|
||||
}
|
||||
#endif
|
62
src/vgcanvas/vgcanvas_nanovg_bgfx.c
Normal file
62
src/vgcanvas/vgcanvas_nanovg_bgfx.c
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* File: vgcanvas_nanovg_bgfx.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: vector graphics canvas base on nanovg-bgfx
|
||||
*
|
||||
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program 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
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-14 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nanovg.h"
|
||||
#include "base/mem.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "bgfx/nanovg_bgfx.h"
|
||||
#include "base/image_manager.h"
|
||||
|
||||
typedef struct _vgcanvas_nanovg_t {
|
||||
vgcanvas_t base;
|
||||
|
||||
int font_id;
|
||||
NVGcontext* vg;
|
||||
uint32_t text_align_v;
|
||||
uint32_t text_align_h;
|
||||
SDL_Window* sdl_window;
|
||||
} vgcanvas_nanovg_t;
|
||||
|
||||
#include "texture.inc"
|
||||
#include "vgcanvas_nanovg_bgfx.inc"
|
||||
#include "vgcanvas_nanovg.inc"
|
||||
|
||||
vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format,
|
||||
void* sdl_window) {
|
||||
vgcanvas_nanovg_t* nanovg = (vgcanvas_nanovg_t*)TKMEM_ZALLOC(vgcanvas_nanovg_t);
|
||||
return_value_if_fail(nanovg != NULL, NULL);
|
||||
|
||||
(void)format;
|
||||
(void)stride;
|
||||
|
||||
nanovg->base.w = w;
|
||||
nanovg->base.h = h;
|
||||
nanovg->base.vt = &vt;
|
||||
nanovg->base.ratio = 1;
|
||||
nanovg->sdl_window = (SDL_Window*)sdl_window;
|
||||
nanovg->vg = nvgCreateBGFX(1, 0, w, h, nanovg->sdl_window);
|
||||
|
||||
if (nanovg->vg == NULL) {
|
||||
assert(!"BGFX is not supported!");
|
||||
}
|
||||
|
||||
return &(nanovg->base);
|
||||
}
|
52
src/vgcanvas/vgcanvas_nanovg_bgfx.inc
Normal file
52
src/vgcanvas/vgcanvas_nanovg_bgfx.inc
Normal file
@ -0,0 +1,52 @@
|
||||
static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vg, uint32_t w, uint32_t h, uint32_t stride,
|
||||
bitmap_format_t format, void* data) {
|
||||
(void)vg;
|
||||
(void)w;
|
||||
(void)h;
|
||||
(void)format;
|
||||
(void)data;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rect) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
|
||||
nvgBeginFrame(canvas->vg, vgcanvas->w, vgcanvas->h, vgcanvas->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_end_frame(vgcanvas_t* vgcanvas) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_create_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_bind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_unbind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy(vgcanvas_t* vgcanvas) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
|
||||
nvgDeleteBGFX(vg);
|
||||
TKMEM_FREE(vgcanvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
126
src/vgcanvas/vgcanvas_nanovg_gl.c
Normal file
126
src/vgcanvas/vgcanvas_nanovg_gl.c
Normal file
@ -0,0 +1,126 @@
|
||||
/**
|
||||
* File: vgcanvas_nanovg_gl.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: vector graphics canvas base on nanovg-gl
|
||||
*
|
||||
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program 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
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-14 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
#define NANOVG_GL3_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#if defined(WITH_NANOVG_GLES2)
|
||||
#define NANOVG_GLES2_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#if defined(WITH_NANOVG_GLES3)
|
||||
#define NANOVG_GLES3_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include "nanovg.h"
|
||||
#include "base/utf8.h"
|
||||
#include "base/mem.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "base/assets_manager.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include "nanovg_gl.h"
|
||||
#include <SDL_opengl.h>
|
||||
#include <SDL_opengl_glext.h>
|
||||
#include "nanovg_gl_utils.h"
|
||||
|
||||
typedef struct _vgcanvas_nanovg_t {
|
||||
vgcanvas_t base;
|
||||
|
||||
int font_id;
|
||||
NVGcontext* vg;
|
||||
uint32_t text_align_v;
|
||||
uint32_t text_align_h;
|
||||
|
||||
SDL_Window* sdl_window;
|
||||
SDL_GLContext context;
|
||||
} vgcanvas_nanovg_t;
|
||||
|
||||
#include "texture.inc"
|
||||
#include "vgcanvas_nanovg_gl.inc"
|
||||
#include "vgcanvas_nanovg.inc"
|
||||
|
||||
static ret_t vgcanvas_init_gl(vgcanvas_nanovg_t* nanovg, SDL_Window* win) {
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||
|
||||
#ifdef WITH_NANOVG_GL2
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#elif defined(WITH_NANOVG_GL3)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
#endif
|
||||
|
||||
nanovg->context = SDL_GL_CreateContext(win);
|
||||
SDL_GL_MakeCurrent(win, nanovg->context);
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
|
||||
gladLoadGL();
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format,
|
||||
void* sdl_window) {
|
||||
int ww = 0;
|
||||
int wh = 0;
|
||||
int fw = 0;
|
||||
int fh = 0;
|
||||
vgcanvas_nanovg_t* nanovg = (vgcanvas_nanovg_t*)TKMEM_ZALLOC(vgcanvas_nanovg_t);
|
||||
return_value_if_fail(nanovg != NULL, NULL);
|
||||
|
||||
(void)format;
|
||||
|
||||
SDL_GetWindowSize((SDL_Window*)sdl_window, &ww, &wh);
|
||||
SDL_GL_GetDrawableSize((SDL_Window*)sdl_window, &fw, &fh);
|
||||
|
||||
nanovg->base.w = w;
|
||||
nanovg->base.h = h;
|
||||
nanovg->base.vt = &vt;
|
||||
nanovg->base.ratio = (float)fw / (float)ww;
|
||||
nanovg->sdl_window = (SDL_Window*)sdl_window;
|
||||
vgcanvas_init_gl(nanovg, nanovg->sdl_window);
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
nanovg->vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
#elif defined(WITH_NANOVG_GLES2)
|
||||
nanovg->vg = nvgCreateGLES2(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
#elif defined(WITH_NANOVG_GLES3)
|
||||
nanovg->vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
|
||||
#endif
|
||||
|
||||
if (nanovg->vg == NULL) {
|
||||
assert(!"OpenGL is not supported!");
|
||||
}
|
||||
|
||||
return &(nanovg->base);
|
||||
}
|
110
src/vgcanvas/vgcanvas_nanovg_gl.inc
Normal file
110
src/vgcanvas/vgcanvas_nanovg_gl.inc
Normal file
@ -0,0 +1,110 @@
|
||||
#include "glad/glad.h"
|
||||
#include <SDL_opengl.h>
|
||||
#include <SDL_opengl_glext.h>
|
||||
|
||||
static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vg, uint32_t w, uint32_t h, uint32_t stride,
|
||||
bitmap_format_t format, void* data) {
|
||||
(void)vg;
|
||||
(void)w;
|
||||
(void)h;
|
||||
(void)format;
|
||||
(void)data;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rect) {
|
||||
int ww = 0;
|
||||
int wh = 0;
|
||||
int fw = 0;
|
||||
int fh = 0;
|
||||
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
SDL_Window* sdl_window = canvas->sdl_window;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
SDL_GetWindowSize(sdl_window, &ww, &wh);
|
||||
SDL_GL_GetDrawableSize(sdl_window, &fw, &fh);
|
||||
|
||||
glViewport(0, 0, fw, fh);
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
nvgBeginFrame(vg, ww, wh, vgcanvas->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_end_frame(vgcanvas_t* vgcanvas) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
SDL_Window* sdl_window = canvas->sdl_window;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
SDL_GL_SwapWindow(sdl_window);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_create_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGLUframebuffer* handle = NULL;
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
|
||||
handle = nvgluCreateFramebuffer(vg, (int)(vgcanvas->w * vgcanvas->ratio),
|
||||
(int)(vgcanvas->h * vgcanvas->ratio), 0);
|
||||
return_value_if_fail(handle != NULL, RET_FAIL);
|
||||
|
||||
fbo->w = vgcanvas->w;
|
||||
fbo->h = vgcanvas->h;
|
||||
fbo->handle = handle;
|
||||
fbo->id = handle->image;
|
||||
fbo->ratio = vgcanvas->ratio;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGLUframebuffer* handle = (NVGLUframebuffer*)fbo->handle;
|
||||
nvgluDeleteFramebuffer(handle);
|
||||
(void)vgcanvas;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_bind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
NVGLUframebuffer* handle = (NVGLUframebuffer*)fbo->handle;
|
||||
|
||||
nvgluBindFramebuffer(handle);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glViewport(0, 0, fbo->w * fbo->ratio, fbo->h * fbo->ratio);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
nvgBeginFrame(vg, fbo->w, fbo->h, fbo->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_unbind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
nvgluBindFramebuffer(NULL);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy(vgcanvas_t* vgcanvas) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
nvgDeleteGL3(vg);
|
||||
#elif defined(WITH_NANOVG_GLES2)
|
||||
nvgDeleteGLES2(vg);
|
||||
#elif defined(WITH_NANOVG_GLES3)
|
||||
nvgDeleteGLES3(vg);
|
||||
#endif
|
||||
SDL_GL_DeleteContext(((vgcanvas_nanovg_t*)vgcanvas)->context);
|
||||
|
||||
TKMEM_FREE(vgcanvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
68
src/vgcanvas/vgcanvas_nanovg_soft.c
Normal file
68
src/vgcanvas/vgcanvas_nanovg_soft.c
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* File: vgcanvas_nanovg_soft.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: vector graphics canvas base on nanovg-soft
|
||||
*
|
||||
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program 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
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-04-14 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "nanovg.h"
|
||||
#include "base/utf8.h"
|
||||
#include "base/mem.h"
|
||||
#include "base/vgcanvas.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "base/assets_manager.h"
|
||||
|
||||
#ifdef WITH_NANOVG_AGGE
|
||||
#include "agge/nanovg_agge.h"
|
||||
#elif defined(WITH_NANOVG_AGG)
|
||||
#include "agg/nanovg_agg.h"
|
||||
#endif/*WITH_NANOVG_AGGE|WITH_NANOVG_AGG*/
|
||||
|
||||
typedef struct _vgcanvas_nanovg_t {
|
||||
vgcanvas_t base;
|
||||
|
||||
int font_id;
|
||||
NVGcontext* vg;
|
||||
uint32_t text_align_v;
|
||||
uint32_t text_align_h;
|
||||
} vgcanvas_nanovg_t;
|
||||
|
||||
#include "vgcanvas_nanovg_soft.inc"
|
||||
#include "vgcanvas_nanovg.inc"
|
||||
|
||||
vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format,
|
||||
void* data) {
|
||||
enum NVGtexture f = bitmap_format_to_nanovg(format);
|
||||
vgcanvas_nanovg_t* nanovg = (vgcanvas_nanovg_t*)TKMEM_ZALLOC(vgcanvas_nanovg_t);
|
||||
return_value_if_fail(nanovg != NULL, NULL);
|
||||
|
||||
nanovg->base.w = w;
|
||||
nanovg->base.h = h;
|
||||
nanovg->base.vt = &vt;
|
||||
nanovg->base.ratio = 1;
|
||||
nanovg->base.buff = (uint32_t*)data;
|
||||
#if defined(WITH_NANOVG_AGG)
|
||||
nanovg->vg = nvgCreateAGG(w, h, stride, f, (uint8_t*)data);
|
||||
#elif defined(WITH_NANOVG_AGGE)
|
||||
nanovg->vg = nvgCreateAGGE(w, h, stride, f, (uint8_t*)data);
|
||||
#else
|
||||
assert(!"not support backend");
|
||||
#endif
|
||||
|
||||
return &(nanovg->base);
|
||||
}
|
142
src/vgcanvas/vgcanvas_nanovg_soft.inc
Normal file
142
src/vgcanvas/vgcanvas_nanovg_soft.inc
Normal file
@ -0,0 +1,142 @@
|
||||
|
||||
static enum NVGtexture bitmap_format_to_nanovg(bitmap_format_t format) {
|
||||
enum NVGtexture f = NVG_TEXTURE_BGRA;
|
||||
|
||||
switch (format) {
|
||||
case BITMAP_FMT_RGBA8888: {
|
||||
f = NVG_TEXTURE_RGBA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGRA8888: {
|
||||
f = NVG_TEXTURE_BGRA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR888: {
|
||||
f = NVG_TEXTURE_BGR;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB888: {
|
||||
f = NVG_TEXTURE_RGB;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR565: {
|
||||
f = NVG_TEXTURE_BGR565;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB565: {
|
||||
f = NVG_TEXTURE_RGB565;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert(!"not supported format");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_create_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_bind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_unbind_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) {
|
||||
return RET_NOT_IMPL;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_reinit(vgcanvas_t* vgcanvas, uint32_t w, uint32_t h, uint32_t stride,
|
||||
bitmap_format_t format, void* data) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
vgcanvas->w = w;
|
||||
vgcanvas->h = h;
|
||||
vgcanvas->buff = (uint32_t*)data;
|
||||
nvgReinitAgge(vg, w, h, stride, bitmap_format_to_nanovg(format), data);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, rect_t* dirty_rect) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgBeginFrame(vg, vgcanvas->w, vgcanvas->h, vgcanvas->ratio);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_end_frame(vgcanvas_t* vgcanvas) {
|
||||
vgcanvas_nanovg_t* canvas = (vgcanvas_nanovg_t*)vgcanvas;
|
||||
NVGcontext* vg = canvas->vg;
|
||||
|
||||
nvgEndFrame(vg);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static int vgcanvas_nanovg_ensure_image(vgcanvas_nanovg_t* canvas, bitmap_t* img) {
|
||||
int32_t i = 0;
|
||||
int32_t f = 0;
|
||||
if (img->flags & BITMAP_FLAG_TEXTURE) {
|
||||
i = (char*)(img->specific) - (char*)NULL;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
switch (img->format) {
|
||||
case BITMAP_FMT_RGBA8888: {
|
||||
f = NVG_TEXTURE_RGBA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGRA8888: {
|
||||
f = NVG_TEXTURE_BGRA;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_BGR565: {
|
||||
f = NVG_TEXTURE_BGR565;
|
||||
break;
|
||||
}
|
||||
case BITMAP_FMT_RGB888: {
|
||||
f = NVG_TEXTURE_RGB;
|
||||
break;
|
||||
}
|
||||
default: { assert(!"not supported format"); }
|
||||
}
|
||||
|
||||
i = nvgCreateImageRaw(canvas->vg, img->w, img->h, f, NVG_IMAGE_NEAREST, img->data);
|
||||
|
||||
if (i >= 0) {
|
||||
img->flags |= BITMAP_FLAG_TEXTURE;
|
||||
img->specific = (char*)NULL + i;
|
||||
image_manager_update_specific(image_manager(), img);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static ret_t vgcanvas_nanovg_destroy(vgcanvas_t* vgcanvas) {
|
||||
NVGcontext* vg = ((vgcanvas_nanovg_t*)vgcanvas)->vg;
|
||||
#if defined(WITH_NANOVG_GL3)
|
||||
nvgDeleteGL3(vg);
|
||||
#elif defined(WITH_NANOVG_GLES2)
|
||||
nvgDeleteGLES2(vg);
|
||||
#elif defined(WITH_NANOVG_GLES3)
|
||||
nvgDeleteGLES3(vg);
|
||||
#elif defined(WITH_NANOVG_AGGE)
|
||||
nvgDeleteAGGE(vg);
|
||||
#elif defined(WITH_NANOVG_AGG)
|
||||
nvgDeleteAGG(vg);
|
||||
#endif
|
||||
TKMEM_FREE(vgcanvas);
|
||||
|
||||
return RET_OK;
|
||||
}
|
Loading…
Reference in New Issue
Block a user