kode / kinc Goto Github PK
View Code? Open in Web Editor NEWModern low level game library and hardware abstraction.
Home Page: http://kinc.tech
License: zlib License
Modern low level game library and hardware abstraction.
Home Page: http://kinc.tech
License: zlib License
Tested using BlocksFromHeaven and OSX, OpenGL started to spit out error code 1286. Everything still appears to work fine, but it's problematic when debugging OpenGL code. Will have a look in coming days but if anyone is aware of this please report.
Images drawn with Graphics2::drawImage do not appear when a rotation transformation is applied. drawScaledSubImage
does however apply rotations.
It looks like drawImage is Simd optimized.
Videos played back with video.play(true) on macos result in this error repeatedly:
AVD error: Perf capability check failed: 0xe00002be
Which eventually compounds and crashes out the execution. It happens at the very moment the video reaches the end and doesn't loop properly.
When starting an application on android there's a chance for all sounds to seemingly play at half speed, sounding very stuttery. It usually stops after the application has been restarted.
Test it with this repository: https://github.com/jefvel/kha-tests/tree/audio-test
Build, run, and touch the screen for sounds. It should make a single click noise. Close it completely and start up again. From time to time it will sound like two clicks, or straight up crash on startup.
Would you like to wrap any pointer data members with the class template “std::unique_ptr”?
In android-studio:
Gradle '<project name>' project refresh failed
Error:Cause: org.gradle.api.internal.ExtensibleDynamicObject
< project name > being the name of the project.
A gist example.
An image showing a horizontal line rotated by PI/4.
One side of the line's width seems to drift with changes to the angle.
currently i look myself to implement this feautures in kore (but i don't know if i can it):
do we need more?
(*0) nearly finished for opengl and (*1) + android/ios, als no tests for ios
(*1) nearly finished for win/linux/mac, not tested for linux/mac and i can't make a test for mac.
And i have also no idea if the code can work for the mac.
Please include support for array textures and associated (cube/array) samplers within shaders.
Folder structured like:
- cpp
-libs
-Kore
-MyProject <---- contains korefile.js
call
node ../libs/Kore/make
error:
Error: ENOENT: no such file or directory, open 'E:\Programming\CPP\MyProject \Kore\korefile.js''
Backends/System/iOS/Sources/Kore/Display.cpp
Backends/System/iOS/Sources/Kore/Display_2.cpp
These cause duplicate symbol errors when linking an iOS project. It seems to work if you comment out the stub methods in Display.cpp, but I wanted to check what the story was with these two files first to be sure.
C:\Dev\Projetos\Kha\Invasion\build\android-native-build\Invasion\app\src\main\jni\SDKs\Kha\Kore\Backends\OpenGL2\Sources\Kore\RenderTargetImpl.cpp
Error:(78, 31) error: 'GL_DEPTH24_STENCIL8' was not declared in this scope
Error:(89, 31) error: 'GL_DEPTH32F_STENCIL8' was not declared in this scope
Error:(102, 45) error: 'GL_DEPTH_STENCIL_ATTACHMENT' was not declared in this scope
I am attempting to build the Shader-Kore and Texture-Kore samples for (old) hardware that doesn't support DX11 or OpenGL 3.3.
The samples are updated to use Kore 5c9362c (latest at time of writing) but otherwise unmodified.
I get the compilation errors shown below when building for DX9.
I'm adding support for the FireTv remote (gamepad support will probably come later, don't have acess to one yet) and have a question.
The remote (and some variants of the amazon gamepad) feature 'MENU', REWIND', 'PLAY / PAUSE', 'FAST FORWARD' buttons. As my usecase is to treat them like a gamepad, should i only forward them to kha.Input.GamePad.button or create new special keys in kha.input.Key as well (kha.input.Key.REWIND, ...) while i'm on it?
Updated to latest Kha/Kore, I get a crash at startup with the message : "No display attached?"
Program received signal SIGSEGV, Segmentation fault.
At /home/memilian/dev/lib/Kha/Kore/Backends/System/Linux/Sources/Kore/System.cpp:186
When you open an app in android it shows the bottom bar
With the current implementation if you call System.windowWidth() or System.windowHeight() at the start of the app and the bar is still showing, it will substract to the resolution the bottom bar area.
I made another implementation that just returns the full screen resolution of the phone, but dont know if its more a hack than a solution.
#157
#158
(Backends/Windows/Sources/Kore/Thread.cpp)
Calling Kore::createAndRunThread while the thread limit is already reached leads to hard to debug errors. (Different breaking points for 32/64 bit Debug/Release at at first glance unrelated places.)
The issue is that the thread index is increased without regard to MAX_THREADS. A check and error message would be nice.
Furthermore it is not clear to us how one should free a thread. The index doesn't seem to be decreased anywhere.
As I can see user can not detect actual color format, Image::Format only have RGBA32 value. So when making texture.lock() it is impossible to write data with right color format.
Conversion from RGBA to BGRA is hardcoded in texture constructor. May be we should also convert colors in Texture::unlock()?
PS Also it's possible to take care of pitch. Currently user can use texture->stride() but at least Kha in image.unlock() does not do this.
I get these errors when building an empty Kha project for Android native:
D:\projects\kha-tests\Kha\Kore\Backends\OpenGL2\Sources\Kore\OpenGL.cpp
Error:(871, 2) error: use of undeclared identifier 'glGenQueries'
Error:(876, 2) error: use of undeclared identifier 'glDeleteQueries'; did you mean 'glDeleteBuffers'?
Error:(880, 15) error: use of undeclared identifier 'GL_SAMPLES_PASSED'
Error:(883, 13) error: use of undeclared identifier 'GL_SAMPLES_PASSED'
Error:(888, 38) error: use of undeclared identifier 'GL_QUERY_RESULT_AVAILABLE'
Error:(893, 38) error: use of undeclared identifier 'GL_QUERY_RESULT'
It works to build if I comment the lines out.
In https://github.com/Kode/Kore/blob/master/Backends/OpenGL2/Sources/Kore/TextureImpl.cpp#L59
GL_R8 is not defined for Raspberry Pi and Android and both are OpenGL ES.
Using OpenGL@Windows:
glDisableVertexAttribArray(offset + index); (line 167) in VertexBufferImpl::setVertexAttributes results in opengl errors. After removing the line everything works fine, but I'm not sure if this is the right "fix". ;-)
A gist example of the issue.
Seems to be a problem somewhere within ColoredShaderPainter ::drawTriBuffer and ::drawBuffer.
See this : armory3d/armory2d#4
The issue seems to be caused by the fact that the window resizing for d3d11 is not present. Am I wrong in thinking so ?
Using a 360-Gamepad and kha->kore->windows:
Left analog stick is switched vertically compared to kha->html5.
Left and right trigger are not working.
Maybe more, aside from that I testet only the face buttons (which are working).
If the title Test
is passed to System.init
in the window options, the window will have a title TestTest
. The supplied title is being doubled.
To reproduce:
Main.hx
:
package;
import kha.System;
class Main {
public static function main() {
System.init({title: "Test", width: 1024, height: 768}, function () {
new Project();
});
}
}
Project.hx
:
package;
import kha.Framebuffer;
import kha.Scheduler;
import kha.System;
import kha.Color;
class Project {
public function new() {
System.notifyOnRender(render);
Scheduler.addTimeTask(update, 0, 1 / 60);
}
function update(): Void {
}
function render(framebuffer: Framebuffer): Void {
var g = framebuffer.g2;
g.begin(true, Color.Cyan);
g.color = Color.Purple;
g.fillRect(20, 20, 400, 400);
g.end();
}
}
See the D3D11 error in https://gist.github.com/grayhaze/3b550a53280745dd694be64b4c187a74
Here is the log, my pc setup is archlinux, gcc 8.1.1+20180531-1.
by the way, android seems have the same problem with clang, ndk r17.
g++ -O2 -I./ -I../Sources/include -I../../../Kha/Backends/Kore/khacpp/include -I../../../Kha/Backends/Kore/khacpp/project/thirdparty/pcre-7.8 -I../../../Kha/Backends/Kore/khacpp/project/thirdparty/zlib-1.2.3 -I../../../Kha/Backends/Kore/khacpp/project/libs/nekoapi -I../../../Kha/Backends/Kore/khacpp/project/thirdparty/mbedtls-2.2.1/include -I../../../Kha/Kore/Sources -I../../../Kha/Kore/Backends/System/Linux/Sources -I../../../Kha/Kore/Backends/System/POSIX/Sources -I../../../Kha/Kore/Backends/Graphics5/Vulkan/Sources -I../../../Kha/Kore/Backends/Graphics4/G4onG5/Sources -I../../../Kha/Kore/Backends/Audio3/A3onA2/Sources -DKORE_MULTITHREADED_AUDIO -DHX_LINUX -DHXCPP_API_LEVEL=330 -DSTATIC_LINK -DPCRE_STATIC -DHXCPP_SET_PROP -DHXCPP_VISIT_ALLOCS -DKORE -DROTATE90 -DKORE_G1 -DKORE_G2 -DKORE_G3 -DKORE_A1 -DKORE_A2 -DKORE_LINUX -DKORE_VULKAN -DVK_USE_PLATFORM_XCB_KHR -DKORE_POSIX -DKORE_G4 -DKORE_G5 -DKORE_G4ONG5 -DKORE_A3 -c ../../../Kha/Kore/Backends/Graphics4/G4onG5/Sources/Kore/G4.cpp -o g4.o -static-libgcc -static-libstdc++ -pthread -lasound -ldl -lvulkan -lxcb In file included from ../../../Kha/Kore/Backends/Graphics5/Vulkan/Sources/Kore/CommandList5Impl.h:3, from ../../../Kha/Kore/Sources/Kore/Graphics5/CommandList.h:3, from ../../../Kha/Kore/Backends/Graphics4/G4onG5/Sources/Kore/G4.cpp:10: ../../../Kha/Kore/Backends/Graphics5/Vulkan/Sources/Kore/vulkan_mini.h:3:28: error: conflicting declaration ‘typedef long long unsigned int uint64_t’ typedef unsigned long long uint64_t; ^~~~~~~~ In file included from /usr/include/stdint.h:37, from /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/include/stdint.h:9, from ../../../Kha/Kore/Backends/Graphics5/Vulkan/Sources/vulkan/vk_platform.h:84, from ../../../Kha/Kore/Backends/Graphics5/Vulkan/Sources/vulkan/vulkan.h:31, from ../../../Kha/Kore/Backends/Graphics5/Vulkan/Sources/Kore/Texture5Impl.h:4, from ../../../Kha/Kore/Sources/Kore/Graphics5/Texture.h:4, from ../../../Kha/Kore/Sources/Kore/Graphics5/Shader.h:3, from ../../../Kha/Kore/Sources/Kore/Graphics5/Graphics.h:5, from ../../../Kha/Kore/Backends/Graphics4/G4onG5/Sources/Kore/TextureImpl.h:4, from ../../../Kha/Kore/Sources/Kore/Graphics4/Texture.h:4, from ../../../Kha/Kore/Sources/Kore/Graphics4/Shader.h:3, from ../../../Kha/Kore/Sources/Kore/Graphics4/Graphics.h:3, from ../../../Kha/Kore/Backends/Graphics4/G4onG5/Sources/Kore/G4.h:3, from ../../../Kha/Kore/Backends/Graphics4/G4onG5/Sources/Kore/G4.cpp:3: /usr/include/bits/stdint-uintn.h:27:20: note: previous declaration as ‘typedef __uint64_t uint64_t’ typedef __uint64_t uint64_t; ^~~~~~~~
matrices dont get transpose when set using setFloats directX 11
On macOS, if you start krom
on an invalid directory (i.e. not something with a proper krom.js
from a previous build), it will crash 100% of the time:
Process: Krom [79402]
Path: /Users/USER/Downloads/*/Krom.app/Contents/MacOS/Krom
Identifier: com.ktxsoftware.Krom
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: bash [79374]
Responsible: Krom [79402]
User ID: 502
Date/Time: 2018-07-28 18:30:09.346 +0200
OS Version: Mac OS X 10.13.6 (17G65)
Report Version: 12
Bridge OS Version: 3.0 (14Y664)
Anonymous UUID: 75C7B990-F9F4-1764-0843-B6519F7CAD0C
Sleep/Wake UUID: A2760634-A85D-4C12-A9CB-18C2924BA10E
Time Awake Since Boot: 69000 seconds
Time Since Wake: 6600 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000068
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
VM Regions Near 0x68:
-->
__TEXT 00000001086d2000-0000000108745000 [ 460K] r-x/rwx SM=COW /Users/USER/Downloads/*/Krom.app/Contents/MacOS/Krom
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_c.dylib 0x00007fff736ebced flockfile + 18
1 libsystem_c.dylib 0x00007fff736ee0b6 fseek + 55
2 com.ktxsoftware.Krom 0x0000000108723bf4 0x1086d2000 + 334836
3 com.ktxsoftware.Krom 0x00000001086d6489 0x1086d2000 + 17545
4 com.ktxsoftware.Krom 0x00000001086f760f 0x1086d2000 + 153103
5 com.apple.Foundation 0x00007fff4d92a5a0 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 1123
6 com.apple.Foundation 0x00007fff4d92a0bf -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 131
7 com.ktxsoftware.Krom 0x00000001086f75b0 0x1086d2000 + 153008
8 libdyld.dylib 0x00007fff73661015 start + 1
Thread 1:
0 libsystem_kernel.dylib 0x00007fff737b228a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff73979009 _pthread_wqthread + 1035
2 libsystem_pthread.dylib 0x00007fff73978be9 start_wqthread + 13
Thread 2:
0 libsystem_pthread.dylib 0x00007fff73978bdc start_wqthread + 0
1 com.apple.CoreFoundation 0x00007fff4bb6d2da 0x7fff4b79b000 + 4006618
Thread 3:
0 libsystem_pthread.dylib 0x00007fff73978bdc start_wqthread + 0
1 ??? 0x0000700001dc3b50 0 + 123145333521232
Thread 4:
0 libsystem_pthread.dylib 0x00007fff73978bdc start_wqthread + 0
1 ??? 0x007865646e496d65 0 + 33888479226719589
Thread 5:
0 libsystem_pthread.dylib 0x00007fff73978bdc start_wqthread + 0
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x00007fffac1753c8 rbx: 0x0000000000000000 rcx: 0x00007fffac1753c8 rdx: 0x0000000000000000
rdi: 0x0000000000000000 rsi: 0x00007fff736ece66 rbp: 0x00007ffee752d620 rsp: 0x00007ffee752d610
r8: 0x00007fffac154048 r9: 0x0000000000000040 r10: 0x00007ffee752da90 r11: 0x00007fff736ee07f
r12: 0x0000000000000002 r13: 0x00007f7ef943d430 r14: 0x0000000000000002 r15: 0x0000000000000000
rip: 0x00007fff736ebced rfl: 0x0000000000010202 cr2: 0x0000000000000068
Logical CPU: 3
Error Code: 0x00000004
Trap Number: 14
I'm running across this:
[General] *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
And I believe it's coming from Video::load line 89:
AVAssetTrack* audioTrack = [[asset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
My video does NOT have an audio asset, as many of mine don't.
ColorVertexData vertex attributes do not appear to work on Direct3D11.
The effect is as if the shader receives vec4(0,0,0,0) for the attribute value (not confirmed if this is what is actually happening).
Reproduction: modify the Texture-Kore sample to add a ColorVertexData "col" attribute to pass a colour value to tint the texture. On DX11 the resulting display is black. On OpenGL on the same machine the output texture is tinted red as expected.
Shader.cpp (extract):
int kore(int argc, char** argv) {
...
Graphics4::VertexStructure structure;
structure.add("pos", Graphics4::Float3VertexData);
structure.add("tex", Graphics4::Float2VertexData);
structure.add("col", Graphics4::ColorVertexData);
pipeline = new Graphics4::PipelineState;
pipeline->inputLayout[0] = &structure;
pipeline->inputLayout[1] = nullptr;
pipeline->vertexShader = vertexShader;
pipeline->fragmentShader = fragmentShader;
pipeline->compile();
texunit = pipeline->getTextureUnit("texsampler");
offset = pipeline->getConstantLocation("mvp");
uint32_t col = 0xff0000ff;
float colf = *((float*)&col);
vertices = new Graphics4::VertexBuffer(3, structure);
float* v = vertices->lock();
*v++ = -1.0f; *v++ = -1.0f; *v++ = 0.5f; *v++ = 0.0f; *v++ = 1.0f; *v++ = colf;
*v++ = 1.0f; *v++ = -1.0f; *v++ = 0.5f; *v++ = 1.0f; *v++ = 1.0f; *v++ = colf;
*v++ = -1.0f; *v++ = 1.0f; *v++ = 0.5f; *v++ = 0.0f; *v++ = 0.0f; *v++ = colf;
vertices->unlock();
...
}
texture.vert.glsl
#version 450
in vec3 pos;
in vec2 tex;
in vec4 col;
out vec2 texcoord;
out vec4 colo;
uniform mat3 mvp;
void main() {
gl_Position = vec4(mvp * vec3(pos.x, pos.y, 0.5), 1.0);
texcoord = tex;
colo = col / 255.0;
}
texture.frag.glsl:
#version 450
in vec2 texcoord;
in vec4 colo;
out vec4 FragColor;
uniform sampler2D texsampler;
void main() {
vec4 color = texture(texsampler, texcoord);
FragColor = vec4(color.r, color.g, color.b, 1.0) * colo;
}
I found out that this lines are allocating a lot of memory triggering the garbage collector like every second.
iOS 11 removed the system()
call (see HaxeFoundation/hxcpp#649), which causes Kha to not compile with the latest iOS.
Fix should be to update hxcpp, but I don't know how to do so in Kore.
Unresolved symbols in OpenGL.cpp: glGenQueries, glBeginQuery etc.
I think this is because by default target android api is android-15 and these function are defined in OpenGL ES 3.0, which is supported only in android-18+.
unlock() on a VertexBuffer backed by OpenGL submits the entire buffer via glBufferData even if the buffer was lock()-ed with start and count parameters.
(Just a reminder ticket for now; probably has nothing to do with my current linux sound issue as i don't unload sounds yet)
Looking through the Kore/Sources/Kore/Audio/Sound.cpp i noticed the following:
This will leak the memory for left + right for mono sounds.
Sound::Sound(const char* filename) : myVolume(1), size(0), data(0), left(0), right(0) {
...
left = new s16[size / 2];
right = new s16[size / 2];
if (format.channels == 1) {
left = (s16*)data; // DK just allocated left and right are gone now
right = (s16*)data // DK just allocated left and right are gone now
}
else {
split((s16*)data, size, left, right);
}
...
}
This will explode b/c it tries to delete data 3x for mono sounds.
Sound::~Sound() {
delete[] data;
delete[] left; // DK will explode for mono sound, as left just points to (already deleted) data
delete[] right; // DK will explode for mono sound, as right just points to (already deleted) data
data = nullptr;
left = nullptr;
right = nullptr;
}
In developing a "flexible 2D renderer" - a rendering layer for 2D games that can cope with arbitrary geometry (sprites, text, polygons), shaders with various vertex structures, doing at least some draw call batching, and taking as much boilerplate work off the caller as possible - i've run in to some things in the Graphics4 API that make it difficult.
Observations only based on limited development of the renderer.
I may just need to rethink my approach and assumptions!
eg: if the user instructs the renderer to set a texture, how does the renderer know if this is actually changing anything? TextureUnit and Texture instances can't be compared easily. I think.
These are the ones I've run in to so far. There may be other state objects to consider.
Could be possible to have a --init option to create the korefile.js with a basic source project, like in Kha?
float t = max(1,0);
results in
Severity Code Description Project File Line Suppression State
Error 2 compilation errors. No code generated. Exercise5 C:\Users\tborowski\Desktop\tmp\Exercise5\build\CUSTOMBUILD 1
Error 0:39: 'max' : no matching overloaded function found Exercise5 C:\Users\tborowski\Desktop\tmp\Exercise5\build\CUSTOMBUILD 1
Error 0:39: '' : syntax error Exercise5 C:\Users\tborowski\Desktop\tmp\Exercise5\build\CUSTOMBUILD 1
Existing Image::at is only useful for integer formats.
I get this in logcat about every tenth start (android-native, OS 4.4.3) with this, for example: https://gist.github.com/RblSb/72b009f819575212a503ee9c976ba7f4
F/libc ( 5985): Fatal signal 11 (SIGSEGV) at 0x00000007 (code=1), thread 5999 (txsoftware.kore)
E/ActivityManager( 739): App crashed! Process: com.ktxsoftware.kore
E/InputDispatcher( 739): channel '42d07a80 com.ktxsoftware.kore.KoreActivity (s)' ~ Channel is unrecoverably broken and will be disposed!```
Getting error while compiling android native app in android studio
/app/src/main/jni/Kha/Kore/Sources/Kore/Application.cpp
Error:(28, 17) error: too few arguments to function 'void Kore::Graphics::init(int, int, int)'
Information:(3) (Unknown) In file included
Error:(32, 20) error: too few arguments to function 'void Kore::Graphics::destroy(int)'
Graphics::destroy();
In the current implementation, buffer size (via start and count) is specified at VertexBuffer->lock() time. In certain situations these values cannot be determined in advance and the whole buffer must be "locked". This results in VertexBuffer->unlock() submitting the whole buffer to the back end.
This issue is to investigate if it is possible, for a performance optimisation, to extend unlock() to accept size and count parameters and so perform partial submits of the buffer data.
If a texture unit tex is defined but not accessed in the shader, Graphics::setTextureAddressing(tex, U, Repeat); fails.
I guess this is the same as #31
I could fix it by using the following code, but i'm not sure where to best place the glGet
call, so it's not called everytime setVertexAttributes
runs as i guess once at startup somewhere would be enough?
int maxVertexAttribArrays = 0;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribArrays);
for (int index = actualIndex; index < maxVertexAttribArrays; ++index)
...
On my machine when I run project, lock machine and unlock it back, game keeps updating, but rendering do not work. This is for Direct3D 9 and simple kha project on Windows 10. Also tested with Direct3D 11 and OpenGL and there was no such problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.