Compare commits
No commits in common. "main" and "main" have entirely different histories.
@ -1,268 +1,268 @@
|
||||
/*
|
||||
* Platform-specific and custom entropy polling functions
|
||||
*
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_C)
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
#include <string.h>
|
||||
#include "mbedtls/timing.h"
|
||||
#endif
|
||||
#if defined(MBEDTLS_HAVEGE_C)
|
||||
#include "mbedtls/havege.h"
|
||||
#endif
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#include "mbedtls/platform.h"
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
|
||||
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
|
||||
!defined(__APPLE__) && !defined(_WIN32)
|
||||
#error "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
|
||||
#if !defined(_WIN32_WINNT)
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
|
||||
int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len,
|
||||
size_t *olen )
|
||||
{
|
||||
HCRYPTPROV provider;
|
||||
((void) data);
|
||||
*olen = 0;
|
||||
|
||||
if( CryptAcquireContext( &provider, NULL, NULL,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) == FALSE )
|
||||
{
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
}
|
||||
|
||||
if( CryptGenRandom( provider, (DWORD) len, output ) == FALSE )
|
||||
{
|
||||
CryptReleaseContext( provider, 0 );
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
}
|
||||
|
||||
CryptReleaseContext( provider, 0 );
|
||||
*olen = len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#else /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
|
||||
/*
|
||||
* Test for Linux getrandom() support.
|
||||
* Since there is no wrapper in the libc yet, use the generic syscall wrapper
|
||||
* available in GNU libc and compatible libc's (eg uClibc).
|
||||
*/
|
||||
#if defined(__linux__) && defined(__GLIBC__)
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#if defined(SYS_getrandom)
|
||||
#define HAVE_GETRANDOM
|
||||
|
||||
static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags )
|
||||
{
|
||||
/* MemSan cannot understand that the syscall writes to the buffer */
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
memset( buf, 0, buflen );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return( syscall( SYS_getrandom, buf, buflen, flags ) );
|
||||
}
|
||||
|
||||
#include <sys/utsname.h>
|
||||
/* Check if version is at least 3.17.0 */
|
||||
static int check_version_3_17_plus( void )
|
||||
{
|
||||
int minor;
|
||||
struct utsname un;
|
||||
const char *ver;
|
||||
|
||||
/* Get version information */
|
||||
uname(&un);
|
||||
ver = un.release;
|
||||
|
||||
/* Check major version; assume a single digit */
|
||||
if( ver[0] < '3' || ver[0] > '9' || ver [1] != '.' )
|
||||
return( -1 );
|
||||
|
||||
if( ver[0] - '0' > 3 )
|
||||
return( 0 );
|
||||
|
||||
/* Ok, so now we know major == 3, check minor.
|
||||
* Assume 1 or 2 digits. */
|
||||
if( ver[2] < '0' || ver[2] > '9' )
|
||||
return( -1 );
|
||||
|
||||
minor = ver[2] - '0';
|
||||
|
||||
if( ver[3] >= '0' && ver[3] <= '9' )
|
||||
minor = 10 * minor + ver[3] - '0';
|
||||
else if( ver [3] != '.' )
|
||||
return( -1 );
|
||||
|
||||
if( minor < 17 )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
static int has_getrandom = -1;
|
||||
#endif /* SYS_getrandom */
|
||||
#endif /* __linux__ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int mbedtls_platform_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
FILE *file;
|
||||
size_t read_len;
|
||||
((void) data);
|
||||
|
||||
#if defined(HAVE_GETRANDOM)
|
||||
if( has_getrandom == -1 )
|
||||
has_getrandom = ( check_version_3_17_plus() == 0 );
|
||||
|
||||
if( has_getrandom )
|
||||
{
|
||||
int ret;
|
||||
|
||||
if( ( ret = getrandom_wrapper( output, len, 0 ) ) < 0 )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
*olen = ret;
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* HAVE_GETRANDOM */
|
||||
|
||||
*olen = 0;
|
||||
|
||||
file = fopen( "/dev/urandom", "rb" );
|
||||
if( file == NULL )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
read_len = fread( output, 1, len, file );
|
||||
if( read_len != len )
|
||||
{
|
||||
fclose( file );
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
}
|
||||
|
||||
fclose( file );
|
||||
*olen = len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
#endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */
|
||||
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
int mbedtls_null_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
((void) data);
|
||||
((void) output);
|
||||
*olen = 0;
|
||||
|
||||
if( len < sizeof(unsigned char) )
|
||||
return( 0 );
|
||||
|
||||
*olen = sizeof(unsigned char);
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
int mbedtls_hardclock_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
unsigned long timer = mbedtls_timing_hardclock();
|
||||
((void) data);
|
||||
*olen = 0;
|
||||
|
||||
if( len < sizeof(unsigned long) )
|
||||
return( 0 );
|
||||
|
||||
memcpy( output, &timer, sizeof(unsigned long) );
|
||||
*olen = sizeof(unsigned long);
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_TIMING_C */
|
||||
|
||||
#if defined(MBEDTLS_HAVEGE_C)
|
||||
int mbedtls_havege_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
mbedtls_havege_state *hs = (mbedtls_havege_state *) data;
|
||||
*olen = 0;
|
||||
|
||||
if( mbedtls_havege_random( hs, output, len ) != 0 )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
*olen = len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_HAVEGE_C */
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
int mbedtls_nv_seed_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
|
||||
size_t use_len = MBEDTLS_ENTROPY_BLOCK_SIZE;
|
||||
((void) data);
|
||||
|
||||
memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
|
||||
|
||||
if( mbedtls_nv_seed_read( buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) < 0 )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
if( len < use_len )
|
||||
use_len = len;
|
||||
|
||||
memcpy( output, buf, use_len );
|
||||
*olen = use_len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
||||
|
||||
#endif /* MBEDTLS_ENTROPY_C */
|
||||
/*
|
||||
* Platform-specific and custom entropy polling functions
|
||||
*
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_C)
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
#include <string.h>
|
||||
#include "mbedtls/timing.h"
|
||||
#endif
|
||||
#if defined(MBEDTLS_HAVEGE_C)
|
||||
#include "mbedtls/havege.h"
|
||||
#endif
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#include "mbedtls/platform.h"
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
|
||||
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
|
||||
!defined(__APPLE__) && !defined(_WIN32)
|
||||
#error "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
|
||||
#if !defined(_WIN32_WINNT)
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
|
||||
int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len,
|
||||
size_t *olen )
|
||||
{
|
||||
HCRYPTPROV provider;
|
||||
((void) data);
|
||||
*olen = 0;
|
||||
|
||||
if( CryptAcquireContext( &provider, NULL, NULL,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) == FALSE )
|
||||
{
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
}
|
||||
|
||||
if( CryptGenRandom( provider, (DWORD) len, output ) == FALSE )
|
||||
{
|
||||
CryptReleaseContext( provider, 0 );
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
}
|
||||
|
||||
CryptReleaseContext( provider, 0 );
|
||||
*olen = len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#else /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
|
||||
/*
|
||||
* Test for Linux getrandom() support.
|
||||
* Since there is no wrapper in the libc yet, use the generic syscall wrapper
|
||||
* available in GNU libc and compatible libc's (eg uClibc).
|
||||
*/
|
||||
#if defined(__linux__) && defined(__GLIBC__)
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#if defined(SYS_getrandom)
|
||||
#define HAVE_GETRANDOM
|
||||
|
||||
static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags )
|
||||
{
|
||||
/* MemSan cannot understand that the syscall writes to the buffer */
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
memset( buf, 0, buflen );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return( syscall( SYS_getrandom, buf, buflen, flags ) );
|
||||
}
|
||||
|
||||
#include <sys/utsname.h>
|
||||
/* Check if version is at least 3.17.0 */
|
||||
static int check_version_3_17_plus( void )
|
||||
{
|
||||
int minor;
|
||||
struct utsname un;
|
||||
const char *ver;
|
||||
|
||||
/* Get version information */
|
||||
uname(&un);
|
||||
ver = un.release;
|
||||
|
||||
/* Check major version; assume a single digit */
|
||||
if( ver[0] < '3' || ver[0] > '9' || ver [1] != '.' )
|
||||
return( -1 );
|
||||
|
||||
if( ver[0] - '0' > 3 )
|
||||
return( 0 );
|
||||
|
||||
/* Ok, so now we know major == 3, check minor.
|
||||
* Assume 1 or 2 digits. */
|
||||
if( ver[2] < '0' || ver[2] > '9' )
|
||||
return( -1 );
|
||||
|
||||
minor = ver[2] - '0';
|
||||
|
||||
if( ver[3] >= '0' && ver[3] <= '9' )
|
||||
minor = 10 * minor + ver[3] - '0';
|
||||
else if( ver [3] != '.' )
|
||||
return( -1 );
|
||||
|
||||
if( minor < 17 )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
static int has_getrandom = -1;
|
||||
#endif /* SYS_getrandom */
|
||||
#endif /* __linux__ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int mbedtls_platform_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
FILE *file;
|
||||
size_t read_len;
|
||||
((void) data);
|
||||
|
||||
#if defined(HAVE_GETRANDOM)
|
||||
if( has_getrandom == -1 )
|
||||
has_getrandom = ( check_version_3_17_plus() == 0 );
|
||||
|
||||
if( has_getrandom )
|
||||
{
|
||||
int ret;
|
||||
|
||||
if( ( ret = getrandom_wrapper( output, len, 0 ) ) < 0 )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
*olen = ret;
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* HAVE_GETRANDOM */
|
||||
|
||||
*olen = 0;
|
||||
|
||||
file = fopen( "/dev/urandom", "rb" );
|
||||
if( file == NULL )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
read_len = fread( output, 1, len, file );
|
||||
if( read_len != len )
|
||||
{
|
||||
fclose( file );
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
}
|
||||
|
||||
fclose( file );
|
||||
*olen = len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
#endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */
|
||||
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
int mbedtls_null_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
((void) data);
|
||||
((void) output);
|
||||
*olen = 0;
|
||||
|
||||
if( len < sizeof(unsigned char) )
|
||||
return( 0 );
|
||||
|
||||
*olen = sizeof(unsigned char);
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
int mbedtls_hardclock_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
unsigned long timer = mbedtls_timing_hardclock();
|
||||
((void) data);
|
||||
*olen = 0;
|
||||
|
||||
if( len < sizeof(unsigned long) )
|
||||
return( 0 );
|
||||
|
||||
memcpy( output, &timer, sizeof(unsigned long) );
|
||||
*olen = sizeof(unsigned long);
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_TIMING_C */
|
||||
|
||||
#if defined(MBEDTLS_HAVEGE_C)
|
||||
int mbedtls_havege_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
mbedtls_havege_state *hs = (mbedtls_havege_state *) data;
|
||||
*olen = 0;
|
||||
|
||||
if( mbedtls_havege_random( hs, output, len ) != 0 )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
*olen = len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_HAVEGE_C */
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
int mbedtls_nv_seed_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
|
||||
size_t use_len = MBEDTLS_ENTROPY_BLOCK_SIZE;
|
||||
((void) data);
|
||||
|
||||
memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
|
||||
|
||||
if( mbedtls_nv_seed_read( buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) < 0 )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
if( len < use_len )
|
||||
use_len = len;
|
||||
|
||||
memcpy( output, buf, use_len );
|
||||
*olen = use_len;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
||||
|
||||
#endif /* MBEDTLS_ENTROPY_C */
|
||||
|
@ -1,38 +1,179 @@
|
||||
#include <kinc/graphics4/compute.h>
|
||||
#include <kinc/compute/compute.h>
|
||||
#include <kinc/graphics4/texture.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
vbyte *hl_kinc_g4_compute_create_shader(vbyte *data, int length) {
|
||||
kinc_g4_compute_shader *shader = (kinc_g4_compute_shader *)malloc(sizeof(kinc_g4_compute_shader));
|
||||
kinc_g4_compute_shader_init(shader, data, length);
|
||||
vbyte *hl_kinc_compute_create_shader(vbyte *data, int length) {
|
||||
kinc_compute_shader_t *shader = (kinc_compute_shader_t *)malloc(sizeof(kinc_compute_shader_t));
|
||||
kinc_compute_shader_init(shader, data, length);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
void hl_kinc_g4_compute_delete_shader(vbyte *shader) {
|
||||
kinc_g4_compute_shader *sh = (kinc_g4_compute_shader *)shader;
|
||||
kinc_g4_compute_shader_destroy(sh);
|
||||
void hl_kinc_compute_delete_shader(vbyte *shader) {
|
||||
kinc_compute_shader_t *sh = (kinc_compute_shader_t *)shader;
|
||||
kinc_compute_shader_destroy(sh);
|
||||
free(sh);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_g4_compute_get_constantlocation(vbyte *shader, vbyte *name) {
|
||||
kinc_g4_compute_shader *sh = (kinc_g4_compute_shader *)shader;
|
||||
kinc_g4_constant_location_t *location = (kinc_g4_constant_location_t *)malloc(sizeof(kinc_g4_constant_location_t));
|
||||
*location = kinc_g4_compute_shader_get_constant_location(sh, (char *)name), sizeof(kinc_g4_constant_location_t);
|
||||
vbyte *hl_kinc_compute_get_constantlocation(vbyte *shader, vbyte *name) {
|
||||
kinc_compute_shader_t *sh = (kinc_compute_shader_t *)shader;
|
||||
kinc_compute_constant_location_t *location = (kinc_compute_constant_location_t *)malloc(sizeof(kinc_compute_constant_location_t));
|
||||
*location = kinc_compute_shader_get_constant_location(sh, (char *)name), sizeof(kinc_compute_constant_location_t);
|
||||
return (vbyte *)location;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_g4_compute_get_textureunit(vbyte *shader, vbyte *name) {
|
||||
kinc_g4_compute_shader *sh = (kinc_g4_compute_shader *)shader;
|
||||
kinc_g4_texture_unit_t *unit = (kinc_g4_texture_unit_t *)malloc(sizeof(kinc_g4_texture_unit_t));
|
||||
*unit = kinc_g4_compute_shader_get_texture_unit(sh, (char *)name), sizeof(kinc_g4_texture_unit_t);
|
||||
vbyte *hl_kinc_compute_get_textureunit(vbyte *shader, vbyte *name) {
|
||||
kinc_compute_shader_t *sh = (kinc_compute_shader_t *)shader;
|
||||
kinc_compute_texture_unit_t *unit = (kinc_compute_texture_unit_t *)malloc(sizeof(kinc_compute_texture_unit_t));
|
||||
*unit = kinc_compute_shader_get_texture_unit(sh, (char *)name), sizeof(kinc_compute_texture_unit_t);
|
||||
return (vbyte *)unit;
|
||||
}
|
||||
|
||||
void hl_kinc_g4_set_compute_shader(vbyte *shader) {
|
||||
kinc_g4_set_compute_shader((kinc_g4_compute_shader *)shader);
|
||||
void hl_kinc_compute_set_bool(vbyte *location, bool value) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_bool(*loc, value);
|
||||
}
|
||||
|
||||
void hl_kinc_g4_compute(int x, int y, int z) {
|
||||
kinc_g4_compute(x, y, z);
|
||||
void hl_kinc_compute_set_int(vbyte *location, int value) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_int(*loc, value);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_float(vbyte *location, float value) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_float(*loc, value);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_float2(vbyte *location, float value1, float value2) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_float2(*loc, value1, value2);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_float3(vbyte *location, float value1, float value2, float value3) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_float3(*loc, value1, value2, value3);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_float4(vbyte *location, float value1, float value2, float value3, float value4) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_float4(*loc, value1, value2, value3, value4);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_floats(vbyte *location, vbyte *values, int count) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_compute_set_floats(*loc, (float *)values, count);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_matrix(vbyte *location, float _00, float _10, float _20, float _30, float _01, float _11, float _21, float _31, float _02, float _12,
|
||||
float _22, float _32, float _03, float _13, float _23, float _33) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_matrix4x4_t value;
|
||||
kinc_matrix4x4_set(&value, 0, 0, _00);
|
||||
kinc_matrix4x4_set(&value, 0, 1, _01);
|
||||
kinc_matrix4x4_set(&value, 0, 2, _02);
|
||||
kinc_matrix4x4_set(&value, 0, 3, _03);
|
||||
kinc_matrix4x4_set(&value, 1, 0, _10);
|
||||
kinc_matrix4x4_set(&value, 1, 1, _11);
|
||||
kinc_matrix4x4_set(&value, 1, 2, _12);
|
||||
kinc_matrix4x4_set(&value, 1, 3, _13);
|
||||
kinc_matrix4x4_set(&value, 2, 0, _20);
|
||||
kinc_matrix4x4_set(&value, 2, 1, _21);
|
||||
kinc_matrix4x4_set(&value, 2, 2, _22);
|
||||
kinc_matrix4x4_set(&value, 2, 3, _23);
|
||||
kinc_matrix4x4_set(&value, 3, 0, _30);
|
||||
kinc_matrix4x4_set(&value, 3, 1, _31);
|
||||
kinc_matrix4x4_set(&value, 3, 2, _32);
|
||||
kinc_matrix4x4_set(&value, 3, 3, _33);
|
||||
kinc_compute_set_matrix4(*loc, &value);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_matrix3(vbyte *location, float _00, float _10, float _20, float _01, float _11, float _21, float _02, float _12, float _22) {
|
||||
kinc_compute_constant_location_t *loc = (kinc_compute_constant_location_t *)location;
|
||||
kinc_matrix3x3_t value;
|
||||
kinc_matrix3x3_set(&value, 0, 0, _00);
|
||||
kinc_matrix3x3_set(&value, 0, 1, _01);
|
||||
kinc_matrix3x3_set(&value, 0, 2, _02);
|
||||
kinc_matrix3x3_set(&value, 1, 0, _10);
|
||||
kinc_matrix3x3_set(&value, 1, 1, _11);
|
||||
kinc_matrix3x3_set(&value, 1, 2, _12);
|
||||
kinc_matrix3x3_set(&value, 2, 0, _20);
|
||||
kinc_matrix3x3_set(&value, 2, 1, _21);
|
||||
kinc_matrix3x3_set(&value, 2, 2, _22);
|
||||
kinc_compute_set_matrix3(*loc, &value);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_texture(vbyte *unit, vbyte *texture, int access) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_texture_t *tex = (kinc_g4_texture_t *)texture;
|
||||
kinc_compute_set_texture(*u, tex, (kinc_compute_access_t)access);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_target(vbyte *unit, vbyte *renderTarget, int access) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_render_target_t *rt = (kinc_g4_render_target_t *)renderTarget;
|
||||
kinc_compute_set_render_target(*u, rt, (kinc_compute_access_t)access);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_sampled_texture(vbyte *unit, vbyte *texture) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_texture_t *tex = (kinc_g4_texture_t *)texture;
|
||||
kinc_compute_set_sampled_texture(*u, tex);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_sampled_target(vbyte *unit, vbyte *renderTarget) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_render_target_t *rt = (kinc_g4_render_target_t *)renderTarget;
|
||||
kinc_compute_set_sampled_render_target(*u, rt);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_sampled_depth_target(vbyte *unit, vbyte *renderTarget) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_render_target_t *rt = (kinc_g4_render_target_t *)renderTarget;
|
||||
kinc_compute_set_sampled_depth_from_render_target(*u, rt);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_sampled_cubemap_texture(vbyte *unit, vbyte *texture) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_texture_t *tex = (kinc_g4_texture_t *)texture;
|
||||
kinc_compute_set_sampled_texture(*u, tex);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_sampled_cubemap_target(vbyte *unit, vbyte *renderTarget) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_render_target_t *rt = (kinc_g4_render_target_t *)renderTarget;
|
||||
kinc_compute_set_sampled_render_target(*u, rt);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_sampled_cubemap_depth_target(vbyte *unit, vbyte *renderTarget) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_g4_render_target_t *rt = (kinc_g4_render_target_t *)renderTarget;
|
||||
kinc_compute_set_sampled_depth_from_render_target(*u, rt);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_texture_parameters(vbyte *unit, int uAddressing, int vAddressing, int minificationFilter, int magnificationFilter, int mipmapFilter) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_compute_set_texture_addressing(*u, KINC_G4_TEXTURE_DIRECTION_U, (kinc_g4_texture_addressing_t)uAddressing);
|
||||
kinc_compute_set_texture_addressing(*u, KINC_G4_TEXTURE_DIRECTION_V, (kinc_g4_texture_addressing_t)vAddressing);
|
||||
kinc_compute_set_texture_minification_filter(*u, (kinc_g4_texture_filter_t)minificationFilter);
|
||||
kinc_compute_set_texture_magnification_filter(*u, (kinc_g4_texture_filter_t)magnificationFilter);
|
||||
kinc_compute_set_texture_mipmap_filter(*u, (kinc_g4_mipmap_filter_t)mipmapFilter);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_texture3d_parameters(vbyte *unit, int uAddressing, int vAddressing, int wAddressing, int minificationFilter, int magnificationFilter,
|
||||
int mipmapFilter) {
|
||||
kinc_compute_texture_unit_t *u = (kinc_compute_texture_unit_t *)unit;
|
||||
kinc_compute_set_texture3d_addressing(*u, KINC_G4_TEXTURE_DIRECTION_U, (kinc_g4_texture_addressing_t)uAddressing);
|
||||
kinc_compute_set_texture3d_addressing(*u, KINC_G4_TEXTURE_DIRECTION_V, (kinc_g4_texture_addressing_t)vAddressing);
|
||||
kinc_compute_set_texture3d_addressing(*u, KINC_G4_TEXTURE_DIRECTION_W, (kinc_g4_texture_addressing_t)wAddressing);
|
||||
kinc_compute_set_texture3d_minification_filter(*u, (kinc_g4_texture_filter_t)minificationFilter);
|
||||
kinc_compute_set_texture3d_magnification_filter(*u, (kinc_g4_texture_filter_t)magnificationFilter);
|
||||
kinc_compute_set_texture3d_mipmap_filter(*u, (kinc_g4_mipmap_filter_t)mipmapFilter);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_set_shader(vbyte *shader) {
|
||||
kinc_compute_set_shader((kinc_compute_shader_t *)shader);
|
||||
}
|
||||
|
||||
void hl_kinc_compute_compute(int x, int y, int z) {
|
||||
kinc_compute(x, y, z);
|
||||
}
|
||||
|
@ -1,129 +1,127 @@
|
||||
#include <kinc/audio2/audio.h>
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
#include <kinc/io/filereader.h>
|
||||
#include <kinc/log.h>
|
||||
#include <kinc/system.h>
|
||||
#include <kinc/window.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
void frame();
|
||||
|
||||
static bool visible = true;
|
||||
static bool paused = false;
|
||||
|
||||
typedef void (*FN_AUDIO_CALL_CALLBACK)(int);
|
||||
typedef float (*FN_AUDIO_READ_SAMPLE)(void);
|
||||
|
||||
void (*audioCallCallback)(int);
|
||||
float (*audioReadSample)(void);
|
||||
|
||||
static void update(void *data) {
|
||||
if (paused) {
|
||||
return;
|
||||
}
|
||||
|
||||
kinc_a2_update();
|
||||
|
||||
int windowCount = kinc_count_windows();
|
||||
|
||||
for (int windowIndex = 0; windowIndex < windowCount; ++windowIndex) {
|
||||
if (visible) {
|
||||
kinc_g4_begin(windowIndex);
|
||||
frame();
|
||||
kinc_g4_end(windowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!kinc_g4_swap_buffers()) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Graphics context lost.");
|
||||
}
|
||||
}
|
||||
|
||||
static bool mixThreadregistered = false;
|
||||
|
||||
static void mix(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata) {
|
||||
#ifdef KINC_MULTITHREADED_AUDIO
|
||||
if (!mixThreadregistered) {
|
||||
vdynamic *ret;
|
||||
hl_register_thread(&ret);
|
||||
mixThreadregistered = true;
|
||||
}
|
||||
hl_blocking(true);
|
||||
#endif
|
||||
|
||||
audioCallCallback(samples);
|
||||
|
||||
for (uint32_t i = 0; i < samples; i += 2) {
|
||||
float left_value = audioReadSample();
|
||||
float right_value = audioReadSample();
|
||||
*(float *)&buffer->channels[0][buffer->write_location] = left_value;
|
||||
*(float *)&buffer->channels[1][buffer->write_location] = right_value;
|
||||
buffer->write_location += 1;
|
||||
if (buffer->write_location >= buffer->data_size) {
|
||||
buffer->write_location = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef KINC_MULTITHREADED_AUDIO
|
||||
hl_blocking(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void hl_init_kore(vbyte *title, int width, int height, int samplesPerPixel, bool vSync, int windowMode, int windowFeatures) {
|
||||
kinc_log(KINC_LOG_LEVEL_INFO, "Starting KincHL");
|
||||
|
||||
kinc_window_options_t win;
|
||||
kinc_window_options_set_defaults(&win);
|
||||
win.title = (char *)title;
|
||||
win.width = width;
|
||||
win.height = height;
|
||||
win.x = -1;
|
||||
win.y = -1;
|
||||
win.mode = (kinc_window_mode_t)windowMode;
|
||||
win.window_features = windowFeatures;
|
||||
kinc_framebuffer_options_t frame;
|
||||
kinc_framebuffer_options_set_defaults(&frame);
|
||||
frame.vertical_sync = vSync;
|
||||
frame.samples_per_pixel = samplesPerPixel;
|
||||
kinc_init((char *)title, width, height, &win, &frame);
|
||||
|
||||
kinc_set_update_callback(update, NULL);
|
||||
}
|
||||
|
||||
void hl_kinc_init_audio(vclosure *callCallback, vclosure *readSample, int *outSamplesPerSecond) {
|
||||
audioCallCallback = *((FN_AUDIO_CALL_CALLBACK *)(&callCallback->fun));
|
||||
audioReadSample = *((FN_AUDIO_READ_SAMPLE *)(&readSample->fun));
|
||||
kinc_a2_set_callback(mix, NULL);
|
||||
kinc_a2_init();
|
||||
*outSamplesPerSecond = kinc_a2_samples_per_second();
|
||||
}
|
||||
|
||||
void hl_run_kore(void) {
|
||||
kinc_start();
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_file_contents(vbyte *name, int *size) {
|
||||
int len;
|
||||
int p = 0;
|
||||
vbyte *content;
|
||||
kinc_file_reader_t file;
|
||||
if (!kinc_file_reader_open(&file, (char *)name, KINC_FILE_TYPE_ASSET)) {
|
||||
return NULL;
|
||||
}
|
||||
hl_blocking(true);
|
||||
len = (int)kinc_file_reader_size(&file);
|
||||
if (size) {
|
||||
*size = len;
|
||||
}
|
||||
hl_blocking(false);
|
||||
content = (vbyte *)hl_gc_alloc_noptr(size ? len : len + 1);
|
||||
hl_blocking(true);
|
||||
if (!size) {
|
||||
content[len] = 0; // final 0 for UTF8
|
||||
}
|
||||
kinc_file_reader_read(&file, content, len);
|
||||
kinc_file_reader_close(&file);
|
||||
hl_blocking(false);
|
||||
return content;
|
||||
}
|
||||
#include <kinc/audio2/audio.h>
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
#include <kinc/io/filereader.h>
|
||||
#include <kinc/log.h>
|
||||
#include <kinc/system.h>
|
||||
#include <kinc/window.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
void frame();
|
||||
|
||||
static bool visible = true;
|
||||
static bool paused = false;
|
||||
|
||||
typedef void (*FN_AUDIO_CALL_CALLBACK)(int);
|
||||
typedef float (*FN_AUDIO_READ_SAMPLE)(void);
|
||||
|
||||
void (*audioCallCallback)(int);
|
||||
float (*audioReadSample)(void);
|
||||
|
||||
static void update(void *data) {
|
||||
if (paused) {
|
||||
return;
|
||||
}
|
||||
|
||||
kinc_a2_update();
|
||||
|
||||
int windowCount = kinc_count_windows();
|
||||
|
||||
for (int windowIndex = 0; windowIndex < windowCount; ++windowIndex) {
|
||||
if (visible) {
|
||||
kinc_g4_begin(windowIndex);
|
||||
frame();
|
||||
kinc_g4_end(windowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!kinc_g4_swap_buffers()) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Graphics context lost.");
|
||||
}
|
||||
}
|
||||
|
||||
static bool mixThreadregistered = false;
|
||||
|
||||
static void mix(kinc_a2_buffer_t *buffer, int samples) {
|
||||
#ifdef KORE_MULTITHREADED_AUDIO
|
||||
if (!mixThreadregistered) {
|
||||
vdynamic *ret;
|
||||
hl_register_thread(&ret);
|
||||
mixThreadregistered = true;
|
||||
}
|
||||
hl_blocking(true);
|
||||
#endif
|
||||
|
||||
audioCallCallback(samples);
|
||||
|
||||
for (int i = 0; i < samples; ++i) {
|
||||
float value = audioReadSample();
|
||||
*(float *)&buffer->data[buffer->write_location] = value;
|
||||
buffer->write_location += 4;
|
||||
if (buffer->write_location >= buffer->data_size) {
|
||||
buffer->write_location = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef KORE_MULTITHREADED_AUDIO
|
||||
hl_blocking(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void hl_init_kore(vbyte *title, int width, int height, int samplesPerPixel, bool vSync, int windowMode, int windowFeatures) {
|
||||
kinc_log(KINC_LOG_LEVEL_INFO, "Starting KincHL");
|
||||
|
||||
kinc_window_options_t win;
|
||||
kinc_window_options_set_defaults(&win);
|
||||
win.title = (char *)title;
|
||||
win.width = width;
|
||||
win.height = height;
|
||||
win.x = -1;
|
||||
win.y = -1;
|
||||
win.mode = (kinc_window_mode_t)windowMode;
|
||||
win.window_features = windowFeatures;
|
||||
kinc_framebuffer_options_t frame;
|
||||
kinc_framebuffer_options_set_defaults(&frame);
|
||||
frame.vertical_sync = vSync;
|
||||
frame.samples_per_pixel = samplesPerPixel;
|
||||
kinc_init((char *)title, width, height, &win, &frame);
|
||||
|
||||
kinc_set_update_callback(update, NULL);
|
||||
}
|
||||
|
||||
void hl_kinc_init_audio(vclosure *callCallback, vclosure *readSample, int *outSamplesPerSecond) {
|
||||
audioCallCallback = *((FN_AUDIO_CALL_CALLBACK *)(&callCallback->fun));
|
||||
audioReadSample = *((FN_AUDIO_READ_SAMPLE *)(&readSample->fun));
|
||||
kinc_a2_set_callback(mix);
|
||||
kinc_a2_init();
|
||||
*outSamplesPerSecond = kinc_a2_samples_per_second;
|
||||
}
|
||||
|
||||
void hl_run_kore(void) {
|
||||
kinc_start();
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_file_contents(vbyte *name, int *size) {
|
||||
int len;
|
||||
int p = 0;
|
||||
vbyte *content;
|
||||
kinc_file_reader_t file;
|
||||
if (!kinc_file_reader_open(&file, (char *)name, KINC_FILE_TYPE_ASSET)) {
|
||||
return NULL;
|
||||
}
|
||||
hl_blocking(true);
|
||||
len = (int)kinc_file_reader_size(&file);
|
||||
if (size) {
|
||||
*size = len;
|
||||
}
|
||||
hl_blocking(false);
|
||||
content = (vbyte *)hl_gc_alloc_noptr(size ? len : len + 1);
|
||||
hl_blocking(true);
|
||||
if (!size) {
|
||||
content[len] = 0; // final 0 for UTF8
|
||||
}
|
||||
kinc_file_reader_read(&file, content, len);
|
||||
kinc_file_reader_close(&file);
|
||||
hl_blocking(false);
|
||||
return content;
|
||||
}
|
||||
|
@ -1,265 +1,265 @@
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
#include <kinc/graphics4/pipeline.h>
|
||||
#include <kinc/graphics4/shader.h>
|
||||
#include <kinc/graphics4/vertexstructure.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
static kinc_g4_compare_mode_t convertCompareMode(int mode) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
return KINC_G4_COMPARE_ALWAYS;
|
||||
case 1:
|
||||
return KINC_G4_COMPARE_NEVER;
|
||||
case 2:
|
||||
return KINC_G4_COMPARE_EQUAL;
|
||||
case 3:
|
||||
return KINC_G4_COMPARE_NOT_EQUAL;
|
||||
case 4:
|
||||
return KINC_G4_COMPARE_LESS;
|
||||
case 5:
|
||||
return KINC_G4_COMPARE_LESS_EQUAL;
|
||||
case 6:
|
||||
return KINC_G4_COMPARE_GREATER;
|
||||
case 7:
|
||||
default:
|
||||
return KINC_G4_COMPARE_GREATER_EQUAL;
|
||||
}
|
||||
}
|
||||
|
||||
static kinc_g4_stencil_action_t convertStencilAction(int action) {
|
||||
switch (action) {
|
||||
case 0:
|
||||
return KINC_G4_STENCIL_KEEP;
|
||||
case 1:
|
||||
return KINC_G4_STENCIL_ZERO;
|
||||
case 2:
|
||||
return KINC_G4_STENCIL_REPLACE;
|
||||
case 3:
|
||||
return KINC_G4_STENCIL_INCREMENT;
|
||||
case 4:
|
||||
return KINC_G4_STENCIL_INCREMENT_WRAP;
|
||||
case 5:
|
||||
return KINC_G4_STENCIL_DECREMENT;
|
||||
case 6:
|
||||
return KINC_G4_STENCIL_DECREMENT_WRAP;
|
||||
case 7:
|
||||
default:
|
||||
return KINC_G4_STENCIL_INVERT;
|
||||
}
|
||||
}
|
||||
|
||||
static kinc_g4_render_target_format_t convertColorAttachment(int format) {
|
||||
switch (format) {
|
||||
case 0:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_32BIT;
|
||||
case 1:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_8BIT_RED;
|
||||
case 2:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_128BIT_FLOAT;
|
||||
case 3:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_16BIT_DEPTH;
|
||||
case 4:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_64BIT_FLOAT;
|
||||
case 5:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_32BIT_RED_FLOAT;
|
||||
case 6:
|
||||
default:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_16BIT_RED_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_vertexshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_VERTEX);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_fragmentshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_FRAGMENT);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_geometryshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_GEOMETRY);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_tesscontrolshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_TESSELLATION_CONTROL);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_tessevalshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_TESSELLATION_EVALUATION);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_vertexshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_VERTEX);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_fragmentshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_FRAGMENT);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_geometryshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_GEOMETRY);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_tesscontrolshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_TESSELLATION_CONTROL);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_tessevalshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_TESSELLATION_EVALUATION);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_pipeline() {
|
||||
kinc_g4_pipeline_t *pipeline = (kinc_g4_pipeline_t *)malloc(sizeof(kinc_g4_pipeline_t));
|
||||
kinc_g4_pipeline_init(pipeline);
|
||||
return (vbyte *)pipeline;
|
||||
}
|
||||
|
||||
void hl_kinc_delete_pipeline(vbyte *pipeline) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_pipeline_destroy(pipe);
|
||||
free(pipe);
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_vertex_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->vertex_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_fragment_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->fragment_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_geometry_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->geometry_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_tesscontrol_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->tessellation_control_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_tesseval_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->tessellation_evaluation_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_compile(vbyte *pipeline, vbyte *structure0, vbyte *structure1, vbyte *structure2, vbyte *structure3) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
pipe->input_layout[0] = (kinc_g4_vertex_structure_t *)structure0;
|
||||
pipe->input_layout[1] = (kinc_g4_vertex_structure_t *)structure1;
|
||||
pipe->input_layout[2] = (kinc_g4_vertex_structure_t *)structure2;
|
||||
pipe->input_layout[3] = (kinc_g4_vertex_structure_t *)structure3;
|
||||
pipe->input_layout[4] = NULL;
|
||||
kinc_g4_pipeline_compile(pipe);
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_states(vbyte *pipeline, int cullMode, int depthMode, int stencilFrontMode, int stencilFrontBothPass, int stencilFrontDepthFail,
|
||||
int stencilFrontFail, int stencilBackMode, int stencilBackBothPass, int stencilBackDepthFail, int stencilBackFail,
|
||||
int blendSource, int blendDestination, int alphaBlendSource, int alphaBlendDestination, bool depthWrite,
|
||||
int stencilReferenceValue, int stencilReadMask, int stencilWriteMask, bool colorWriteMaskRed, bool colorWriteMaskGreen,
|
||||
bool colorWriteMaskBlue, bool colorWriteMaskAlpha, int colorAttachmentCount, int colorAttachment0, int colorAttachment1,
|
||||
int colorAttachment2, int colorAttachment3, int colorAttachment4, int colorAttachment5, int colorAttachment6,
|
||||
int colorAttachment7, int depthAttachmentBits, int stencilAttachmentBits, bool conservativeRasterization) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
|
||||
switch (cullMode) {
|
||||
case 0:
|
||||
pipe->cull_mode = KINC_G4_CULL_CLOCKWISE;
|
||||
break;
|
||||
case 1:
|
||||
pipe->cull_mode = KINC_G4_CULL_COUNTER_CLOCKWISE;
|
||||
break;
|
||||
case 2:
|
||||
pipe->cull_mode = KINC_G4_CULL_NOTHING;
|
||||
break;
|
||||
}
|
||||
|
||||
pipe->depth_mode = convertCompareMode(depthMode);
|
||||
pipe->depth_write = depthWrite;
|
||||
|
||||
pipe->stencil_front_mode = convertCompareMode(stencilFrontMode);
|
||||
pipe->stencil_front_both_pass = convertStencilAction(stencilFrontBothPass);
|
||||
pipe->stencil_front_depth_fail = convertStencilAction(stencilFrontDepthFail);
|
||||
pipe->stencil_front_fail = convertStencilAction(stencilFrontFail);
|
||||
|
||||
pipe->stencil_back_mode = convertCompareMode(stencilBackMode);
|
||||
pipe->stencil_back_both_pass = convertStencilAction(stencilBackBothPass);
|
||||
pipe->stencil_back_depth_fail = convertStencilAction(stencilBackDepthFail);
|
||||
pipe->stencil_back_fail = convertStencilAction(stencilBackFail);
|
||||
|
||||
pipe->stencil_reference_value = stencilReferenceValue;
|
||||
pipe->stencil_read_mask = stencilReadMask;
|
||||
pipe->stencil_write_mask = stencilWriteMask;
|
||||
|
||||
pipe->blend_source = (kinc_g4_blending_factor_t)blendSource;
|
||||
pipe->blend_destination = (kinc_g4_blending_factor_t)blendDestination;
|
||||
pipe->alpha_blend_source = (kinc_g4_blending_factor_t)alphaBlendSource;
|
||||
pipe->alpha_blend_destination = (kinc_g4_blending_factor_t)alphaBlendDestination;
|
||||
|
||||
pipe->color_write_mask_red[0] = colorWriteMaskRed;
|
||||
pipe->color_write_mask_green[0] = colorWriteMaskGreen;
|
||||
pipe->color_write_mask_blue[0] = colorWriteMaskBlue;
|
||||
pipe->color_write_mask_alpha[0] = colorWriteMaskAlpha;
|
||||
|
||||
pipe->color_attachment_count = colorAttachmentCount;
|
||||
pipe->color_attachment[0] = convertColorAttachment(colorAttachment0);
|
||||
pipe->color_attachment[1] = convertColorAttachment(colorAttachment1);
|
||||
pipe->color_attachment[2] = convertColorAttachment(colorAttachment2);
|
||||
pipe->color_attachment[3] = convertColorAttachment(colorAttachment3);
|
||||
pipe->color_attachment[4] = convertColorAttachment(colorAttachment4);
|
||||
pipe->color_attachment[5] = convertColorAttachment(colorAttachment5);
|
||||
pipe->color_attachment[6] = convertColorAttachment(colorAttachment6);
|
||||
pipe->color_attachment[7] = convertColorAttachment(colorAttachment7);
|
||||
|
||||
pipe->depth_attachment_bits = depthAttachmentBits;
|
||||
pipe->stencil_attachment_bits = stencilAttachmentBits;
|
||||
|
||||
pipe->conservative_rasterization = conservativeRasterization;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set(vbyte *pipeline) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_set_pipeline(pipe);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_pipeline_get_constantlocation(vbyte *pipeline, vbyte *name) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_constant_location_t *location = (kinc_g4_constant_location_t *)malloc(sizeof(kinc_g4_constant_location_t));
|
||||
*location = kinc_g4_pipeline_get_constant_location(pipe, (char *)name);
|
||||
return (vbyte *)location;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_pipeline_get_textureunit(vbyte *pipeline, vbyte *name) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_texture_unit_t *unit = (kinc_g4_texture_unit_t *)malloc(sizeof(kinc_g4_texture_unit_t));
|
||||
*unit = kinc_g4_pipeline_get_texture_unit(pipe, (char *)name);
|
||||
return (vbyte *)unit;
|
||||
}
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
#include <kinc/graphics4/pipeline.h>
|
||||
#include <kinc/graphics4/shader.h>
|
||||
#include <kinc/graphics4/vertexstructure.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
static kinc_g4_compare_mode_t convertCompareMode(int mode) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
return KINC_G4_COMPARE_ALWAYS;
|
||||
case 1:
|
||||
return KINC_G4_COMPARE_NEVER;
|
||||
case 2:
|
||||
return KINC_G4_COMPARE_EQUAL;
|
||||
case 3:
|
||||
return KINC_G4_COMPARE_NOT_EQUAL;
|
||||
case 4:
|
||||
return KINC_G4_COMPARE_LESS;
|
||||
case 5:
|
||||
return KINC_G4_COMPARE_LESS_EQUAL;
|
||||
case 6:
|
||||
return KINC_G4_COMPARE_GREATER;
|
||||
case 7:
|
||||
default:
|
||||
return KINC_G4_COMPARE_GREATER_EQUAL;
|
||||
}
|
||||
}
|
||||
|
||||
static kinc_g4_stencil_action_t convertStencilAction(int action) {
|
||||
switch (action) {
|
||||
case 0:
|
||||
return KINC_G4_STENCIL_KEEP;
|
||||
case 1:
|
||||
return KINC_G4_STENCIL_ZERO;
|
||||
case 2:
|
||||
return KINC_G4_STENCIL_REPLACE;
|
||||
case 3:
|
||||
return KINC_G4_STENCIL_INCREMENT;
|
||||
case 4:
|
||||
return KINC_G4_STENCIL_INCREMENT_WRAP;
|
||||
case 5:
|
||||
return KINC_G4_STENCIL_DECREMENT;
|
||||
case 6:
|
||||
return KINC_G4_STENCIL_DECREMENT_WRAP;
|
||||
case 7:
|
||||
default:
|
||||
return KINC_G4_STENCIL_INVERT;
|
||||
}
|
||||
}
|
||||
|
||||
static kinc_g4_render_target_format_t convertColorAttachment(int format) {
|
||||
switch (format) {
|
||||
case 0:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_32BIT;
|
||||
case 1:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_8BIT_RED;
|
||||
case 2:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_128BIT_FLOAT;
|
||||
case 3:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_16BIT_DEPTH;
|
||||
case 4:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_64BIT_FLOAT;
|
||||
case 5:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_32BIT_RED_FLOAT;
|
||||
case 6:
|
||||
default:
|
||||
return KINC_G4_RENDER_TARGET_FORMAT_16BIT_RED_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_vertexshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_VERTEX);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_fragmentshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_FRAGMENT);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_geometryshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_GEOMETRY);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_tesscontrolshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_TESSELLATION_CONTROL);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_tessevalshader(vbyte *data, int length) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init(shader, data, length, KINC_G4_SHADER_TYPE_TESSELLATION_EVALUATION);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_vertexshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_VERTEX);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_fragmentshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_FRAGMENT);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_geometryshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_GEOMETRY);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_tesscontrolshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_TESSELLATION_CONTROL);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_tessevalshader_from_source(vbyte *source) {
|
||||
kinc_g4_shader_t *shader = (kinc_g4_shader_t *)malloc(sizeof(kinc_g4_shader_t));
|
||||
kinc_g4_shader_init_from_source(shader, (char *)source, KINC_G4_SHADER_TYPE_TESSELLATION_EVALUATION);
|
||||
return (vbyte *)shader;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_create_pipeline() {
|
||||
kinc_g4_pipeline_t *pipeline = (kinc_g4_pipeline_t *)malloc(sizeof(kinc_g4_pipeline_t));
|
||||
kinc_g4_pipeline_init(pipeline);
|
||||
return (vbyte *)pipeline;
|
||||
}
|
||||
|
||||
void hl_kinc_delete_pipeline(vbyte *pipeline) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_pipeline_destroy(pipe);
|
||||
free(pipe);
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_vertex_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->vertex_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_fragment_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->fragment_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_geometry_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->geometry_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_tesscontrol_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->tessellation_control_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_tesseval_shader(vbyte *pipeline, vbyte *shader) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_shader_t *sh = (kinc_g4_shader_t *)shader;
|
||||
pipe->tessellation_evaluation_shader = sh;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_compile(vbyte *pipeline, vbyte *structure0, vbyte *structure1, vbyte *structure2, vbyte *structure3) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
pipe->input_layout[0] = (kinc_g4_vertex_structure_t *)structure0;
|
||||
pipe->input_layout[1] = (kinc_g4_vertex_structure_t *)structure1;
|
||||
pipe->input_layout[2] = (kinc_g4_vertex_structure_t *)structure2;
|
||||
pipe->input_layout[3] = (kinc_g4_vertex_structure_t *)structure3;
|
||||
pipe->input_layout[4] = NULL;
|
||||
kinc_g4_pipeline_compile(pipe);
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set_states(vbyte *pipeline, int cullMode, int depthMode, int stencilFrontMode, int stencilFrontBothPass, int stencilFrontDepthFail,
|
||||
int stencilFrontFail, int stencilBackMode, int stencilBackBothPass, int stencilBackDepthFail, int stencilBackFail,
|
||||
int blendSource, int blendDestination, int alphaBlendSource, int alphaBlendDestination, bool depthWrite,
|
||||
int stencilReferenceValue, int stencilReadMask, int stencilWriteMask, bool colorWriteMaskRed, bool colorWriteMaskGreen,
|
||||
bool colorWriteMaskBlue, bool colorWriteMaskAlpha, int colorAttachmentCount, int colorAttachment0, int colorAttachment1,
|
||||
int colorAttachment2, int colorAttachment3, int colorAttachment4, int colorAttachment5, int colorAttachment6,
|
||||
int colorAttachment7, int depthAttachmentBits, int stencilAttachmentBits, bool conservativeRasterization) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
|
||||
switch (cullMode) {
|
||||
case 0:
|
||||
pipe->cull_mode = KINC_G4_CULL_CLOCKWISE;
|
||||
break;
|
||||
case 1:
|
||||
pipe->cull_mode = KINC_G4_CULL_COUNTER_CLOCKWISE;
|
||||
break;
|
||||
case 2:
|
||||
pipe->cull_mode = KINC_G4_CULL_NOTHING;
|
||||
break;
|
||||
}
|
||||
|
||||
pipe->depth_mode = convertCompareMode(depthMode);
|
||||
pipe->depth_write = depthWrite;
|
||||
|
||||
pipe->stencil_front_mode = convertCompareMode(stencilFrontMode);
|
||||
pipe->stencil_front_both_pass = convertStencilAction(stencilFrontBothPass);
|
||||
pipe->stencil_front_depth_fail = convertStencilAction(stencilFrontDepthFail);
|
||||
pipe->stencil_front_fail = convertStencilAction(stencilFrontFail);
|
||||
|
||||
pipe->stencil_back_mode = convertCompareMode(stencilBackMode);
|
||||
pipe->stencil_back_both_pass = convertStencilAction(stencilBackBothPass);
|
||||
pipe->stencil_back_depth_fail = convertStencilAction(stencilBackDepthFail);
|
||||
pipe->stencil_back_fail = convertStencilAction(stencilBackFail);
|
||||
|
||||
pipe->stencil_reference_value = stencilReferenceValue;
|
||||
pipe->stencil_read_mask = stencilReadMask;
|
||||
pipe->stencil_write_mask = stencilWriteMask;
|
||||
|
||||
pipe->blend_source = (kinc_g4_blending_factor_t)blendSource;
|
||||
pipe->blend_destination = (kinc_g4_blending_factor_t)blendDestination;
|
||||
pipe->alpha_blend_source = (kinc_g4_blending_factor_t)alphaBlendSource;
|
||||
pipe->alpha_blend_destination = (kinc_g4_blending_factor_t)alphaBlendDestination;
|
||||
|
||||
pipe->color_write_mask_red[0] = colorWriteMaskRed;
|
||||
pipe->color_write_mask_green[0] = colorWriteMaskGreen;
|
||||
pipe->color_write_mask_blue[0] = colorWriteMaskBlue;
|
||||
pipe->color_write_mask_alpha[0] = colorWriteMaskAlpha;
|
||||
|
||||
pipe->color_attachment_count = colorAttachmentCount;
|
||||
pipe->color_attachment[0] = convertColorAttachment(colorAttachment0);
|
||||
pipe->color_attachment[1] = convertColorAttachment(colorAttachment1);
|
||||
pipe->color_attachment[2] = convertColorAttachment(colorAttachment2);
|
||||
pipe->color_attachment[3] = convertColorAttachment(colorAttachment3);
|
||||
pipe->color_attachment[4] = convertColorAttachment(colorAttachment4);
|
||||
pipe->color_attachment[5] = convertColorAttachment(colorAttachment5);
|
||||
pipe->color_attachment[6] = convertColorAttachment(colorAttachment6);
|
||||
pipe->color_attachment[7] = convertColorAttachment(colorAttachment7);
|
||||
|
||||
pipe->depth_attachment_bits = depthAttachmentBits;
|
||||
pipe->stencil_attachment_bits = stencilAttachmentBits;
|
||||
|
||||
pipe->conservative_rasterization = conservativeRasterization;
|
||||
}
|
||||
|
||||
void hl_kinc_pipeline_set(vbyte *pipeline) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_set_pipeline(pipe);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_pipeline_get_constantlocation(vbyte *pipeline, vbyte *name) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_constant_location_t *location = (kinc_g4_constant_location_t *)malloc(sizeof(kinc_g4_constant_location_t));
|
||||
*location = kinc_g4_pipeline_get_constant_location(pipe, (char *)name);
|
||||
return (vbyte *)location;
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_pipeline_get_textureunit(vbyte *pipeline, vbyte *name) {
|
||||
kinc_g4_pipeline_t *pipe = (kinc_g4_pipeline_t *)pipeline;
|
||||
kinc_g4_texture_unit_t *unit = (kinc_g4_texture_unit_t *)malloc(sizeof(kinc_g4_texture_unit_t));
|
||||
*unit = kinc_g4_pipeline_get_texture_unit(pipe, (char *)name);
|
||||
return (vbyte *)unit;
|
||||
}
|
||||
|
@ -1,201 +1,201 @@
|
||||
#include <kinc/input/acceleration.h>
|
||||
#include <kinc/input/gamepad.h>
|
||||
#include <kinc/input/keyboard.h>
|
||||
#include <kinc/input/mouse.h>
|
||||
#include <kinc/input/pen.h>
|
||||
#include <kinc/input/rotation.h>
|
||||
#include <kinc/input/surface.h>
|
||||
#include <kinc/log.h>
|
||||
#include <kinc/system.h>
|
||||
#include <kinc/video.h>
|
||||
#include <kinc/window.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
void hl_kinc_log(vbyte *v) {
|
||||
kinc_log(KINC_LOG_LEVEL_INFO, (char *)v);
|
||||
}
|
||||
|
||||
double hl_kinc_get_time(void) {
|
||||
return kinc_time();
|
||||
}
|
||||
|
||||
int hl_kinc_get_window_width(int window) {
|
||||
return kinc_window_width(window);
|
||||
}
|
||||
|
||||
int hl_kinc_get_window_height(int window) {
|
||||
return kinc_window_height(window);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_system_id(void) {
|
||||
return (vbyte *)kinc_system_id();
|
||||
}
|
||||
|
||||
void hl_kinc_vibrate(int ms) {
|
||||
kinc_vibrate(ms);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_language(void) {
|
||||
return (vbyte *)kinc_language();
|
||||
}
|
||||
|
||||
void hl_kinc_request_shutdown(void) {
|
||||
kinc_stop();
|
||||
}
|
||||
|
||||
void hl_kinc_mouse_lock(int windowId) {
|
||||
kinc_mouse_lock(windowId);
|
||||
}
|
||||
|
||||
void hl_kinc_mouse_unlock(void) {
|
||||
kinc_mouse_unlock();
|
||||
}
|
||||
|
||||
bool hl_kinc_can_lock_mouse(void) {
|
||||
return kinc_mouse_can_lock();
|
||||
}
|
||||
|
||||
bool hl_kinc_is_mouse_locked(void) {
|
||||
return kinc_mouse_is_locked();
|
||||
}
|
||||
|
||||
void hl_kinc_show_mouse(bool show) {
|
||||
if (show) {
|
||||
kinc_mouse_show();
|
||||
}
|
||||
else {
|
||||
kinc_mouse_hide();
|
||||
}
|
||||
}
|
||||
|
||||
bool hl_kinc_system_is_fullscreen(void) {
|
||||
return false; // kinc_is_fullscreen();
|
||||
}
|
||||
|
||||
void hl_kinc_system_request_fullscreen(void) {
|
||||
// kinc_change_resolution(display_width(), display_height(), true);
|
||||
}
|
||||
|
||||
void hl_kinc_system_exit_fullscreen(int previousWidth, int previousHeight) {
|
||||
// kinc_change_resolution(previousWidth, previousHeight, false);
|
||||
}
|
||||
|
||||
void hl_kinc_system_change_resolution(int width, int height) {
|
||||
// kinc_change_resolution(width, height, false);
|
||||
}
|
||||
|
||||
void hl_kinc_system_set_keepscreenon(bool on) {
|
||||
kinc_set_keep_screen_on(on);
|
||||
}
|
||||
|
||||
void hl_kinc_system_load_url(vbyte *url) {
|
||||
kinc_load_url((char *)url);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_gamepad_id(int index) {
|
||||
return (vbyte *)kinc_gamepad_product_name(index);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_gamepad_vendor(int index) {
|
||||
return (vbyte *)kinc_gamepad_vendor(index);
|
||||
}
|
||||
|
||||
bool hl_kinc_gamepad_connected(int index) {
|
||||
return kinc_gamepad_connected(index);
|
||||
}
|
||||
|
||||
typedef void (*FN_KEY_DOWN)(int, void *);
|
||||
typedef void (*FN_KEY_UP)(int, void *);
|
||||
typedef void (*FN_KEY_PRESS)(unsigned int, void *);
|
||||
|
||||
void hl_kinc_register_keyboard(vclosure *keyDown, vclosure *keyUp, vclosure *keyPress) {
|
||||
kinc_keyboard_set_key_down_callback(*((FN_KEY_DOWN *)(&keyDown->fun)), NULL);
|
||||
kinc_keyboard_set_key_up_callback(*((FN_KEY_UP *)(&keyUp->fun)), NULL);
|
||||
kinc_keyboard_set_key_press_callback(*((FN_KEY_PRESS *)(&keyPress->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_MOUSE_DOWN)(int, int, int, int, void *);
|
||||
typedef void (*FN_MOUSE_UP)(int, int, int, int, void *);
|
||||
typedef void (*FN_MOUSE_MOVE)(int, int, int, int, int, void *);
|
||||
typedef void (*FN_MOUSE_WHEEL)(int, int, void *);
|
||||
|
||||
void hl_kinc_register_mouse(vclosure *mouseDown, vclosure *mouseUp, vclosure *mouseMove, vclosure *mouseWheel) {
|
||||
kinc_mouse_set_press_callback(*((FN_MOUSE_DOWN *)(&mouseDown->fun)), NULL);
|
||||
kinc_mouse_set_release_callback(*((FN_MOUSE_UP *)(&mouseUp->fun)), NULL);
|
||||
kinc_mouse_set_move_callback(*((FN_MOUSE_MOVE *)(&mouseMove->fun)), NULL);
|
||||
kinc_mouse_set_scroll_callback(*((FN_MOUSE_WHEEL *)(&mouseWheel->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_PEN_DOWN)(int, int, int, float);
|
||||
typedef void (*FN_PEN_UP)(int, int, int, float);
|
||||
typedef void (*FN_PEN_MOVE)(int, int, int, float);
|
||||
|
||||
void hl_kinc_register_pen(vclosure *penDown, vclosure *penUp, vclosure *penMove) {
|
||||
kinc_pen_set_press_callback(*((FN_PEN_DOWN *)(&penDown->fun)));
|
||||
kinc_pen_set_release_callback(*((FN_PEN_UP *)(&penUp->fun)));
|
||||
kinc_pen_set_move_callback(*((FN_PEN_MOVE *)(&penMove->fun)));
|
||||
}
|
||||
|
||||
typedef void (*FN_GAMEPAD_AXIS)(int, int, float, void *);
|
||||
typedef void (*FN_GAMEPAD_BUTTON)(int, int, float, void *);
|
||||
|
||||
void hl_kinc_register_gamepad(vclosure *gamepadAxis, vclosure *gamepadButton) {
|
||||
kinc_gamepad_set_axis_callback(*((FN_GAMEPAD_AXIS *)(&gamepadAxis->fun)), NULL);
|
||||
kinc_gamepad_set_button_callback(*((FN_GAMEPAD_BUTTON *)(&gamepadButton->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_TOUCH_START)(int, int, int);
|
||||
typedef void (*FN_TOUCH_END)(int, int, int);
|
||||
typedef void (*FN_TOUCH_MOVE)(int, int, int);
|
||||
|
||||
void hl_kinc_register_surface(vclosure *touchStart, vclosure *touchEnd, vclosure *touchMove) {
|
||||
kinc_surface_set_touch_start_callback(*((FN_TOUCH_START *)(&touchStart->fun)));
|
||||
kinc_surface_set_touch_end_callback(*((FN_TOUCH_END *)(&touchEnd->fun)));
|
||||
kinc_surface_set_move_callback(*((FN_TOUCH_MOVE *)(&touchMove->fun)));
|
||||
}
|
||||
|
||||
typedef void (*FN_SENSOR_ACCELEROMETER)(float, float, float);
|
||||
typedef void (*FN_SENSOR_GYROSCOPE)(float, float, float);
|
||||
|
||||
void hl_kinc_register_sensor(vclosure *accelerometerChanged, vclosure *gyroscopeChanged) {
|
||||
kinc_acceleration_set_callback(*((FN_SENSOR_ACCELEROMETER *)(&accelerometerChanged->fun)));
|
||||
kinc_rotation_set_callback(*((FN_SENSOR_GYROSCOPE *)(&gyroscopeChanged->fun)));
|
||||
}
|
||||
|
||||
// typedef void(*FN_CB_ORIENTATION)(int);
|
||||
typedef void (*FN_CB_FOREGROUND)(void *);
|
||||
typedef void (*FN_CB_RESUME)(void *);
|
||||
typedef void (*FN_CB_PAUSE)(void *);
|
||||
typedef void (*FN_CB_BACKGROUND)(void *);
|
||||
typedef void (*FN_CB_SHUTDOWN)(void *);
|
||||
|
||||
void hl_kinc_register_callbacks(vclosure *foreground, vclosure *resume, vclosure *pause, vclosure *background, vclosure *shutdown) {
|
||||
// kinc_set_orientation_callback(orientation);
|
||||
kinc_set_foreground_callback(*((FN_CB_FOREGROUND *)(&foreground->fun)), NULL);
|
||||
kinc_set_resume_callback(*((FN_CB_RESUME *)(&resume->fun)), NULL);
|
||||
kinc_set_pause_callback(*((FN_CB_PAUSE *)(&pause->fun)), NULL);
|
||||
kinc_set_background_callback(*((FN_CB_BACKGROUND *)(&background->fun)), NULL);
|
||||
kinc_set_shutdown_callback(*((FN_CB_SHUTDOWN *)(&shutdown->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_CB_DROPFILES)(wchar_t *);
|
||||
|
||||
void hl_kinc_register_dropfiles(vclosure *dropFiles) {
|
||||
// todo: string convert
|
||||
// kinc_set_drop_files_callback(*((FN_CB_DROPFILES*)(&dropFiles->fun)));
|
||||
}
|
||||
|
||||
typedef char *(*FN_CB_COPY)(void *);
|
||||
typedef char *(*FN_CB_CUT)(void *);
|
||||
typedef void (*FN_CB_PASTE)(char *, void *);
|
||||
|
||||
void hl_kinc_register_copycutpaste(vclosure *copy, vclosure *cut, vclosure *paste) {
|
||||
kinc_set_copy_callback(*((FN_CB_COPY *)(©->fun)), NULL);
|
||||
kinc_set_cut_callback(*((FN_CB_CUT *)(&cut->fun)), NULL);
|
||||
kinc_set_paste_callback(*((FN_CB_PASTE *)(&paste->fun)), NULL);
|
||||
}
|
||||
|
||||
const char *hl_kinc_video_format(void) {
|
||||
return kinc_video_formats()[0];
|
||||
}
|
||||
#include <kinc/input/acceleration.h>
|
||||
#include <kinc/input/gamepad.h>
|
||||
#include <kinc/input/keyboard.h>
|
||||
#include <kinc/input/mouse.h>
|
||||
#include <kinc/input/pen.h>
|
||||
#include <kinc/input/rotation.h>
|
||||
#include <kinc/input/surface.h>
|
||||
#include <kinc/log.h>
|
||||
#include <kinc/system.h>
|
||||
#include <kinc/video.h>
|
||||
#include <kinc/window.h>
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
void hl_kinc_log(vbyte *v) {
|
||||
kinc_log(KINC_LOG_LEVEL_INFO, (char *)v);
|
||||
}
|
||||
|
||||
double hl_kinc_get_time(void) {
|
||||
return kinc_time();
|
||||
}
|
||||
|
||||
int hl_kinc_get_window_width(int window) {
|
||||
return kinc_window_width(window);
|
||||
}
|
||||
|
||||
int hl_kinc_get_window_height(int window) {
|
||||
return kinc_window_height(window);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_system_id(void) {
|
||||
return (vbyte *)kinc_system_id();
|
||||
}
|
||||
|
||||
void hl_kinc_vibrate(int ms) {
|
||||
kinc_vibrate(ms);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_language(void) {
|
||||
return (vbyte *)kinc_language();
|
||||
}
|
||||
|
||||
void hl_kinc_request_shutdown(void) {
|
||||
kinc_stop();
|
||||
}
|
||||
|
||||
void hl_kinc_mouse_lock(int windowId) {
|
||||
kinc_mouse_lock(windowId);
|
||||
}
|
||||
|
||||
void hl_kinc_mouse_unlock(void) {
|
||||
kinc_mouse_unlock();
|
||||
}
|
||||
|
||||
bool hl_kinc_can_lock_mouse(void) {
|
||||
return kinc_mouse_can_lock();
|
||||
}
|
||||
|
||||
bool hl_kinc_is_mouse_locked(void) {
|
||||
return kinc_mouse_is_locked();
|
||||
}
|
||||
|
||||
void hl_kinc_show_mouse(bool show) {
|
||||
if (show) {
|
||||
kinc_mouse_show();
|
||||
}
|
||||
else {
|
||||
kinc_mouse_hide();
|
||||
}
|
||||
}
|
||||
|
||||
bool hl_kinc_system_is_fullscreen(void) {
|
||||
return false; // kinc_is_fullscreen();
|
||||
}
|
||||
|
||||
void hl_kinc_system_request_fullscreen(void) {
|
||||
// kinc_change_resolution(display_width(), display_height(), true);
|
||||
}
|
||||
|
||||
void hl_kinc_system_exit_fullscreen(int previousWidth, int previousHeight) {
|
||||
// kinc_change_resolution(previousWidth, previousHeight, false);
|
||||
}
|
||||
|
||||
void hl_kinc_system_change_resolution(int width, int height) {
|
||||
// kinc_change_resolution(width, height, false);
|
||||
}
|
||||
|
||||
void hl_kinc_system_set_keepscreenon(bool on) {
|
||||
kinc_set_keep_screen_on(on);
|
||||
}
|
||||
|
||||
void hl_kinc_system_load_url(vbyte *url) {
|
||||
kinc_load_url((char *)url);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_gamepad_id(int index) {
|
||||
return (vbyte*)kinc_gamepad_product_name(index);
|
||||
}
|
||||
|
||||
vbyte *hl_kinc_get_gamepad_vendor(int index) {
|
||||
return (vbyte*)kinc_gamepad_vendor(index);
|
||||
}
|
||||
|
||||
bool hl_kinc_gamepad_connected(int index) {
|
||||
return kinc_gamepad_connected(index);
|
||||
}
|
||||
|
||||
typedef void (*FN_KEY_DOWN)(int, void *);
|
||||
typedef void (*FN_KEY_UP)(int, void *);
|
||||
typedef void (*FN_KEY_PRESS)(unsigned int, void *);
|
||||
|
||||
void hl_kinc_register_keyboard(vclosure *keyDown, vclosure *keyUp, vclosure *keyPress) {
|
||||
kinc_keyboard_set_key_down_callback(*((FN_KEY_DOWN *)(&keyDown->fun)), NULL);
|
||||
kinc_keyboard_set_key_up_callback(*((FN_KEY_UP *)(&keyUp->fun)), NULL);
|
||||
kinc_keyboard_set_key_press_callback(*((FN_KEY_PRESS *)(&keyPress->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_MOUSE_DOWN)(int, int, int, int, void *);
|
||||
typedef void (*FN_MOUSE_UP)(int, int, int, int, void *);
|
||||
typedef void (*FN_MOUSE_MOVE)(int, int, int, int, int, void *);
|
||||
typedef void (*FN_MOUSE_WHEEL)(int, int, void *);
|
||||
|
||||
void hl_kinc_register_mouse(vclosure *mouseDown, vclosure *mouseUp, vclosure *mouseMove, vclosure *mouseWheel) {
|
||||
kinc_mouse_set_press_callback(*((FN_MOUSE_DOWN *)(&mouseDown->fun)), NULL);
|
||||
kinc_mouse_set_release_callback(*((FN_MOUSE_UP *)(&mouseUp->fun)), NULL);
|
||||
kinc_mouse_set_move_callback(*((FN_MOUSE_MOVE *)(&mouseMove->fun)), NULL);
|
||||
kinc_mouse_set_scroll_callback(*((FN_MOUSE_WHEEL *)(&mouseWheel->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_PEN_DOWN)(int, int, int, float);
|
||||
typedef void (*FN_PEN_UP)(int, int, int, float);
|
||||
typedef void (*FN_PEN_MOVE)(int, int, int, float);
|
||||
|
||||
void hl_kinc_register_pen(vclosure *penDown, vclosure *penUp, vclosure *penMove) {
|
||||
kinc_pen_set_press_callback(*((FN_PEN_DOWN *)(&penDown->fun)));
|
||||
kinc_pen_set_release_callback(*((FN_PEN_UP *)(&penUp->fun)));
|
||||
kinc_pen_set_move_callback(*((FN_PEN_MOVE *)(&penMove->fun)));
|
||||
}
|
||||
|
||||
typedef void (*FN_GAMEPAD_AXIS)(int, int, float);
|
||||
typedef void (*FN_GAMEPAD_BUTTON)(int, int, float);
|
||||
|
||||
void hl_kinc_register_gamepad(vclosure *gamepadAxis, vclosure *gamepadButton) {
|
||||
kinc_gamepad_set_axis_callback(*((FN_GAMEPAD_AXIS *)(&gamepadAxis->fun)));
|
||||
kinc_gamepad_set_button_callback(*((FN_GAMEPAD_BUTTON *)(&gamepadButton->fun)));
|
||||
}
|
||||
|
||||
typedef void (*FN_TOUCH_START)(int, int, int);
|
||||
typedef void (*FN_TOUCH_END)(int, int, int);
|
||||
typedef void (*FN_TOUCH_MOVE)(int, int, int);
|
||||
|
||||
void hl_kinc_register_surface(vclosure *touchStart, vclosure *touchEnd, vclosure *touchMove) {
|
||||
kinc_surface_set_touch_start_callback(*((FN_TOUCH_START *)(&touchStart->fun)));
|
||||
kinc_surface_set_touch_end_callback(*((FN_TOUCH_END *)(&touchEnd->fun)));
|
||||
kinc_surface_set_move_callback(*((FN_TOUCH_MOVE *)(&touchMove->fun)));
|
||||
}
|
||||
|
||||
typedef void (*FN_SENSOR_ACCELEROMETER)(float, float, float);
|
||||
typedef void (*FN_SENSOR_GYROSCOPE)(float, float, float);
|
||||
|
||||
void hl_kinc_register_sensor(vclosure *accelerometerChanged, vclosure *gyroscopeChanged) {
|
||||
kinc_acceleration_set_callback(*((FN_SENSOR_ACCELEROMETER *)(&accelerometerChanged->fun)));
|
||||
kinc_rotation_set_callback(*((FN_SENSOR_GYROSCOPE *)(&gyroscopeChanged->fun)));
|
||||
}
|
||||
|
||||
// typedef void(*FN_CB_ORIENTATION)(int);
|
||||
typedef void (*FN_CB_FOREGROUND)(void *);
|
||||
typedef void (*FN_CB_RESUME)(void *);
|
||||
typedef void (*FN_CB_PAUSE)(void *);
|
||||
typedef void (*FN_CB_BACKGROUND)(void *);
|
||||
typedef void (*FN_CB_SHUTDOWN)(void *);
|
||||
|
||||
void hl_kinc_register_callbacks(vclosure *foreground, vclosure *resume, vclosure *pause, vclosure *background, vclosure *shutdown) {
|
||||
// kinc_set_orientation_callback(orientation);
|
||||
kinc_set_foreground_callback(*((FN_CB_FOREGROUND *)(&foreground->fun)), NULL);
|
||||
kinc_set_resume_callback(*((FN_CB_RESUME *)(&resume->fun)), NULL);
|
||||
kinc_set_pause_callback(*((FN_CB_PAUSE *)(&pause->fun)), NULL);
|
||||
kinc_set_background_callback(*((FN_CB_BACKGROUND *)(&background->fun)), NULL);
|
||||
kinc_set_shutdown_callback(*((FN_CB_SHUTDOWN *)(&shutdown->fun)), NULL);
|
||||
}
|
||||
|
||||
typedef void (*FN_CB_DROPFILES)(wchar_t *);
|
||||
|
||||
void hl_kinc_register_dropfiles(vclosure *dropFiles) {
|
||||
// todo: string convert
|
||||
// kinc_set_drop_files_callback(*((FN_CB_DROPFILES*)(&dropFiles->fun)));
|
||||
}
|
||||
|
||||
typedef char *(*FN_CB_COPY)(void *);
|
||||
typedef char *(*FN_CB_CUT)(void *);
|
||||
typedef void (*FN_CB_PASTE)(char *, void *);
|
||||
|
||||
void hl_kinc_register_copycutpaste(vclosure *copy, vclosure *cut, vclosure *paste) {
|
||||
kinc_set_copy_callback(*((FN_CB_COPY *)(©->fun)), NULL);
|
||||
kinc_set_cut_callback(*((FN_CB_CUT *)(&cut->fun)), NULL);
|
||||
kinc_set_paste_callback(*((FN_CB_PASTE *)(&paste->fun)), NULL);
|
||||
}
|
||||
|
||||
const char *hl_kinc_video_format(void) {
|
||||
return kinc_video_formats()[0];
|
||||
}
|
||||
|
@ -140,4 +140,4 @@ void kinc_internal_gamepad_trigger_button(int gamepad, int button, float value)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -26,9 +26,10 @@ class GetBoneTransformNode extends LogicNode {
|
||||
// Get bone in armature
|
||||
var bone = anim.getBone(boneName);
|
||||
|
||||
return anim.getAbsWorldMat(anim.skeletonMats, bone);
|
||||
//return anim.getAbsMat(bone).clone().multmat(object.transform.world);
|
||||
|
||||
//return anim.getAbsWorldMat(bone);
|
||||
return anim.getAbsMat(bone).clone().multmat(object.transform.world);
|
||||
//return anim.getAbsWorldMat(bone);
|
||||
|
||||
#else
|
||||
return null;
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ class Inc {
|
||||
kha.compute.Compute.setSampledTexture(voxel_td4, rts.get("voxelsSDF").image);
|
||||
kha.compute.Compute.setTexture(voxel_te4, rts.get("voxels_specular").image, kha.compute.Access.Write);
|
||||
|
||||
//kha.compute.Compute.setSampledTexture(voxel_tf4, rts.get("gbuffer2").image);
|
||||
kha.compute.Compute.setSampledTexture(voxel_tf4, rts.get("gbuffer2").image);
|
||||
|
||||
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
|
||||
for (i in 0...Main.voxelgiClipmapCount) {
|
||||
|
@ -7,46 +7,48 @@ if lnx.is_reload(__name__):
|
||||
else:
|
||||
lnx.enable_reload(__name__)
|
||||
|
||||
#lnx.keymaps = []
|
||||
lnx.keymaps = []
|
||||
|
||||
|
||||
def register():
|
||||
wm = bpy.context.window_manager
|
||||
keyconfig = wm.keyconfigs.user
|
||||
|
||||
addon_keyconfig = wm.keyconfigs.addon
|
||||
|
||||
# Keyconfigs are not available in background mode. If the keyconfig
|
||||
# was not found despite running _not_ in background mode, a warning
|
||||
# is printed
|
||||
if keyconfig is None:
|
||||
if addon_keyconfig is None:
|
||||
if not bpy.app.background:
|
||||
log.warn("No keyconfig path found")
|
||||
return
|
||||
km = keyconfig.keymaps.get('Window')
|
||||
if km is None:
|
||||
log.warn("Window keymaps not available")
|
||||
return
|
||||
lnx_start = any(kmi.idname == props_ui.LeenkxPlayButton.bl_idname for kmi in km.keymap_items)
|
||||
if not lnx_start:
|
||||
kmw = keyconfig.keymaps.new(name='Window', space_type='EMPTY', region_type="WINDOW")
|
||||
kmw.keymap_items.new(props_ui.LeenkxPlayButton.bl_idname, type='F5', value='PRESS')
|
||||
kmw.keymap_items.new('tlm.build_lightmaps', type='F6', value='PRESS')
|
||||
kmw.keymap_items.new('tlm.clean_lightmaps', type='F7', value='PRESS')
|
||||
kmn = keyconfig.keymaps.new(name='Node Editor', space_type='NODE_EDITOR')
|
||||
kmn.keymap_items.new('lnx.add_call_group_node', 'G', 'PRESS', shift=True)
|
||||
kmn.keymap_items.new('lnx.add_group_tree_from_selected', 'G', 'PRESS', ctrl=True)
|
||||
kmn.keymap_items.new('lnx.edit_group_tree', 'TAB', 'PRESS')
|
||||
kmn.keymap_items.new('node.tree_path_parent', 'TAB', 'PRESS', ctrl=True)
|
||||
kmn.keymap_items.new('lnx.ungroup_group_tree', 'G', 'PRESS', alt=True)
|
||||
|
||||
|
||||
km = addon_keyconfig.keymaps.new(name='Window', space_type='EMPTY', region_type="WINDOW")
|
||||
km.keymap_items.new(props_ui.LeenkxPlayButton.bl_idname, type='F5', value='PRESS')
|
||||
km.keymap_items.new("tlm.build_lightmaps", type='F6', value='PRESS')
|
||||
km.keymap_items.new("tlm.clean_lightmaps", type='F7', value='PRESS')
|
||||
lnx.keymaps.append(km)
|
||||
|
||||
km = addon_keyconfig.keymaps.new(name='Node Editor', space_type='NODE_EDITOR')
|
||||
|
||||
# shift+G: Create a new node call group node
|
||||
km.keymap_items.new('lnx.add_call_group_node', 'G', 'PRESS', shift=True)
|
||||
|
||||
# ctrl+G: make node group from selected
|
||||
km.keymap_items.new('lnx.add_group_tree_from_selected', 'G', 'PRESS', ctrl=True)
|
||||
|
||||
# TAB: enter node groups depending on selection
|
||||
km.keymap_items.new('lnx.edit_group_tree', 'TAB', 'PRESS')
|
||||
|
||||
# ctrl+TAB: exit node groups depending on selectio
|
||||
km.keymap_items.new('node.tree_path_parent', 'TAB', 'PRESS', ctrl=True)
|
||||
|
||||
# alt+G: ungroup node tree
|
||||
km.keymap_items.new('lnx.ungroup_group_tree', 'G', 'PRESS', alt=True)
|
||||
lnx.keymaps.append(km)
|
||||
|
||||
|
||||
def unregister():
|
||||
kmw = bpy.context.window_manager.keyconfigs.user.keymaps.get('Window')
|
||||
kmw.keymap_items.remove(kmw.keymap_items[props_ui.LeenkxPlayButton.bl_idname])
|
||||
kmw.keymap_items.remove(kmw.keymap_items['tlm.build_lightmaps'])
|
||||
kmw.keymap_items.remove(kmw.keymap_items['tlm.clean_lightmaps'])
|
||||
kmn = bpy.context.window_manager.keyconfigs.user.keymaps.get('Node Editor')
|
||||
kmn.keymap_items.remove(kmn.keymap_items['lnx.add_call_group_node'])
|
||||
kmn.keymap_items.remove(kmn.keymap_items['lnx.add_group_tree_from_selected'])
|
||||
kmn.keymap_items.remove(kmn.keymap_items['lnx.edit_group_tree'])
|
||||
kmn.keymap_items.remove(kmn.keymap_items['node.tree_path_parent'])
|
||||
kmn.keymap_items.remove(kmn.keymap_items['lnx.ungroup_group_tree'])
|
||||
wm = bpy.context.window_manager
|
||||
for km in lnx.keymaps:
|
||||
wm.keyconfigs.addon.keymaps.remove(km)
|
||||
del lnx.keymaps[:]
|
||||
|
@ -139,10 +139,7 @@ if bpy.app.version > (4, 1, 0):
|
||||
subsurface_radius = c.parse_vector_input(node.inputs[9])
|
||||
subsurface_color = c.parse_vector_input(node.inputs[8])
|
||||
state.out_metallic = c.parse_value_input(node.inputs[1])
|
||||
if bpy.app.version > (4, 2, 4):
|
||||
state.out_specular = c.parse_value_input(node.inputs[13])
|
||||
else:
|
||||
state.out_specular = c.parse_value_input(node.inputs[12])
|
||||
state.out_specular = c.parse_value_input(node.inputs[12])
|
||||
state.out_roughness = c.parse_value_input(node.inputs[2])
|
||||
# Prevent black material when metal = 1.0 and roughness = 0.0
|
||||
try:
|
||||
|
@ -686,9 +686,9 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
if parse_opacity:
|
||||
frag.write('indirect = traceDiffuse(wposition, n, voxels, clipmaps).rgb * albedo * voxelgiDiff;')
|
||||
frag.write('if (roughness < 1.0 && specular > 0.0){')
|
||||
frag.add_uniform('sampler2D sveloc')
|
||||
frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
|
||||
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * specular * voxelgiRefl;}')
|
||||
#frag.add_uniform('sampler2D sveloc')
|
||||
#frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
|
||||
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), roughness, clipmaps, gl_FragCoord.xy).rgb * specular * voxelgiRefl;}')
|
||||
else:
|
||||
frag.add_uniform("sampler2D voxels_diffuse")
|
||||
frag.add_uniform("sampler2D voxels_specular")
|
||||
@ -779,10 +779,9 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
if '_MicroShadowing' in wrd.world_defs:
|
||||
frag.write(', occlusion')
|
||||
if '_SSRS' in wrd.world_defs:
|
||||
frag.add_uniform('sampler2D gbufferD', top=True)
|
||||
frag.add_uniform('mat4 invVP', '_inverseViewProjectionMatrix')
|
||||
frag.add_uniform('vec3 eye', '_cameraPosition')
|
||||
frag.write(', gbufferD, invVP, eye')
|
||||
frag.write(', gl_FragCoord.z, inVP, eye')
|
||||
frag.write(');')
|
||||
|
||||
if '_Clusters' in wrd.world_defs:
|
||||
@ -795,8 +794,8 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
|
||||
if '_VoxelRefract' in wrd.world_defs and parse_opacity:
|
||||
frag.write('if (opacity < 1.0) {')
|
||||
frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
|
||||
frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), ior, roughness, clipmaps, gl_FragCoord.xy,velocity).rgb;')
|
||||
#frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
|
||||
frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), ior, roughness, clipmaps, gl_FragCoord.xy).rgb;')
|
||||
frag.write(' indirect = mix(refraction, indirect, opacity) * voxelgiRefr;')
|
||||
frag.write(' direct = mix(refraction, direct, opacity) * voxelgiRefr;')
|
||||
frag.write('}')
|
||||
|
@ -264,7 +264,7 @@ class LnxOpenNodeHaxeSource(bpy.types.Operator):
|
||||
version = lnx.utils.get_last_commit()
|
||||
if version == '':
|
||||
version = 'main'
|
||||
webbrowser.open(f'https://dev.leenkx.com/LeenkxTeam/LNXSDK/src/branch/{version}/leenkx/Sources/leenkx/logicnode/{name}.hx')
|
||||
webbrowser.open(f'https://github.com/leenkx3d/leenkx/blob/{version}/leenkx/Sources/leenkx/logicnode/{name}.hx')
|
||||
return{'FINISHED'}
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@ class LnxOpenNodePythonSource(bpy.types.Operator):
|
||||
if version == '':
|
||||
version = 'main'
|
||||
rel_path = node.__module__.replace('.', '/')
|
||||
webbrowser.open(f'https://dev.leenkx.com/LeenkxTeam/LNXSDK/src/branch/{version}/leenkx/blender/{rel_path}.py')
|
||||
webbrowser.open(f'https://github.com/leenkx3d/leenkx/blob/{version}/leenkx/blender/{rel_path}.py')
|
||||
return{'FINISHED'}
|
||||
|
||||
|
||||
|
@ -216,7 +216,7 @@ def is_gapi_gl_es() -> bool:
|
||||
|
||||
def get_rp() -> lnx.props_renderpath.LnxRPListItem:
|
||||
wrd = bpy.data.worlds['Lnx']
|
||||
if not state.is_export and wrd.lnx_play_renderpath != '' and lnx.props_renderpath.LnxRPListItem.get_by_name(wrd.lnx_play_renderpath) is not None:
|
||||
if not state.is_export and wrd.lnx_play_renderpath != '':
|
||||
return lnx.props_renderpath.LnxRPListItem.get_by_name(wrd.lnx_play_renderpath)
|
||||
else:
|
||||
return wrd.lnx_rplist[wrd.lnx_rplist_index]
|
||||
|
@ -1,3 +1,3 @@
|
||||
// Keep this file so that the headers are included in the compilation
|
||||
#include "hl/aura/math/FFT.h"
|
||||
#include "hl/aura/math/fft.h"
|
||||
#include "hl/aura/types/complex_array.h"
|
||||
|
@ -2,27 +2,27 @@
|
||||
|
||||
#include <hl.h>
|
||||
|
||||
//#include <aura/types/_ComplexArray/HL_ComplexArrayImpl.h>
|
||||
#include <aura/types/_ComplexArray/HL_ComplexArrayImpl.h>
|
||||
|
||||
#include "hl/aura/aurahl.h"
|
||||
#include "common_c/math/fft.h"
|
||||
#include "common_c/types/complex_t.h"
|
||||
|
||||
//HL_PRIM void AURA_HL_FUNC(ditfft2)(aura__types___ComplexArray__HL_ComplexArrayImpl time_array, int t, aura__types___ComplexArray__HL_ComplexArrayImpl freq_array, int f, int n, int step, bool inverse) {
|
||||
// const aura_complex_t *times = (aura_complex_t*) time_array->self;
|
||||
// aura_complex_t *freqs = (aura_complex_t*) freq_array->self;
|
||||
HL_PRIM void AURA_HL_FUNC(ditfft2)(aura__types___ComplexArray__HL_ComplexArrayImpl time_array, int t, aura__types___ComplexArray__HL_ComplexArrayImpl freq_array, int f, int n, int step, bool inverse) {
|
||||
const aura_complex_t *times = (aura_complex_t*) time_array->self;
|
||||
aura_complex_t *freqs = (aura_complex_t*) freq_array->self;
|
||||
|
||||
/// aura_ditfft2(times, t, freqs, f, n, step, inverse);
|
||||
//}
|
||||
aura_ditfft2(times, t, freqs, f, n, step, inverse);
|
||||
}
|
||||
|
||||
//HL_PRIM void AURA_HL_FUNC(ditfft2_iterative)(aura__types___ComplexArray__HL_ComplexArrayImpl time_array, aura__types___ComplexArray__HL_ComplexArrayImpl freq_array, int n, bool inverse, aura__types___ComplexArray__HL_ComplexArrayImpl exp_rotation_step_table) {
|
||||
// const aura_complex_t *times = (aura_complex_t*) time_array->self;
|
||||
// aura_complex_t *freqs = (aura_complex_t*) freq_array->self;
|
||||
HL_PRIM void AURA_HL_FUNC(ditfft2_iterative)(aura__types___ComplexArray__HL_ComplexArrayImpl time_array, aura__types___ComplexArray__HL_ComplexArrayImpl freq_array, int n, bool inverse, aura__types___ComplexArray__HL_ComplexArrayImpl exp_rotation_step_table) {
|
||||
const aura_complex_t *times = (aura_complex_t*) time_array->self;
|
||||
aura_complex_t *freqs = (aura_complex_t*) freq_array->self;
|
||||
|
||||
// const aura_complex_t *exp_lut = (aura_complex_t*) exp_rotation_step_table->self;
|
||||
const aura_complex_t *exp_lut = (aura_complex_t*) exp_rotation_step_table->self;
|
||||
|
||||
// aura_ditfft2_iterative(times, freqs, n, inverse, exp_lut);
|
||||
//}
|
||||
aura_ditfft2_iterative(times, freqs, n, inverse, exp_lut);
|
||||
}
|
||||
|
||||
//DEFINE_PRIM(_VOID, ditfft2, _BYTES _I32 _BYTES _I32 _I32 _I32 _BOOL)
|
||||
//DEFINE_PRIM(_VOID, ditfft2_iterative, _BYTES _BYTES _I32 _BOOL _BYTES)
|
||||
DEFINE_PRIM(_VOID, ditfft2, _BYTES _I32 _BYTES _I32 _I32 _I32 _BOOL)
|
||||
DEFINE_PRIM(_VOID, ditfft2_iterative, _BYTES _BYTES _I32 _BOOL _BYTES)
|
||||
|
Loading…
x
Reference in New Issue
Block a user