mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-06 18:06:28 +00:00
Merge branch 'master' of https://github.com/raysan5/raylib
This commit is contained in:
@@ -17,7 +17,7 @@ out vec4 finalColor;
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
// NOTE: The texel is actually the a GRAYSCALE index color
|
||||
// NOTE: The texel is actually the GRAYSCALE index color
|
||||
vec4 texelColor = texture(texture0, fragTexCoord)*fragColor;
|
||||
|
||||
// Convert the (normalized) texel color RED component (GB would work, too)
|
||||
|
@@ -115,9 +115,9 @@ int main(void)
|
||||
// without crossing perimeter, points must be in anticlockwise order
|
||||
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
|
||||
{
|
||||
rlSetTexture(texture.id);
|
||||
rlBegin(RL_TRIANGLES);
|
||||
|
||||
rlSetTexture(texture.id);
|
||||
|
||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
||||
|
||||
|
@@ -49,7 +49,7 @@
|
||||
#include <android_native_app_glue.h> // Required for: android_app struct and activity management
|
||||
#include <android/window.h> // Required for: AWINDOW_FLAG_FULLSCREEN definition and others
|
||||
//#include <android/sensor.h> // Required for: Android sensors functions (accelerometer, gyroscope, light...)
|
||||
#include <jni.h> // Required for: JNIEnv and JavaVM [Used in OpenURL()]
|
||||
#include <jni.h> // Required for: JNIEnv and JavaVM [Used in OpenURL() and GetCurrentMonitor()]
|
||||
|
||||
#include <EGL/egl.h> // Native platform windowing system interface
|
||||
|
||||
@@ -446,8 +446,32 @@ int GetMonitorCount(void)
|
||||
// Get current monitor where window is placed
|
||||
int GetCurrentMonitor(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform");
|
||||
return 0;
|
||||
int displayId = -1;
|
||||
JNIEnv* env = NULL;
|
||||
JavaVM* vm = platform.app->activity->vm;
|
||||
(*vm)->AttachCurrentThread(vm, &env, NULL);
|
||||
|
||||
jobject activity = platform.app->activity->clazz;
|
||||
jclass activityClass = (*env)->GetObjectClass(env, activity);
|
||||
|
||||
jmethodID getDisplayMethod = (*env)->GetMethodID(env, activityClass, "getDisplay", "()Landroid/view/Display;");
|
||||
|
||||
jobject display = (*env)->CallObjectMethod(env, activity, getDisplayMethod);
|
||||
|
||||
if (display == NULL) {
|
||||
TRACELOG(LOG_ERROR, "GetCurrentMonitor() couldn't get the display object");
|
||||
} else {
|
||||
jclass displayClass = (*env)->FindClass(env, "android/view/Display");
|
||||
jmethodID getDisplayIdMethod = (*env)->GetMethodID(env, displayClass, "getDisplayId", "()I");
|
||||
displayId = (int) (*env)->CallIntMethod(env, display, getDisplayIdMethod);
|
||||
(*env)->DeleteLocalRef(env, displayClass);
|
||||
}
|
||||
|
||||
(*env)->DeleteLocalRef(env, activityClass);
|
||||
(*env)->DeleteLocalRef(env, display);
|
||||
|
||||
(*vm)->DetachCurrentThread(vm);
|
||||
return displayId;
|
||||
}
|
||||
|
||||
// Get selected monitor position
|
||||
|
11
src/rlgl.h
11
src/rlgl.h
@@ -1067,6 +1067,7 @@ typedef struct rlglData {
|
||||
Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop
|
||||
int stackCounter; // Matrix stack counter
|
||||
|
||||
unsigned int currentTextureId; // Current texture id to be used on glBegin
|
||||
unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)
|
||||
unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default)
|
||||
unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program)
|
||||
@@ -1485,8 +1486,8 @@ void rlBegin(int mode)
|
||||
if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
|
||||
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.currentTextureId;
|
||||
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1651,6 +1652,7 @@ void rlSetTexture(unsigned int id)
|
||||
{
|
||||
rlDrawRenderBatch(RLGL.currentBatch);
|
||||
}
|
||||
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -1658,6 +1660,7 @@ void rlSetTexture(unsigned int id)
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
rlEnableTexture(id);
|
||||
#else
|
||||
RLGL.State.currentTextureId = id;
|
||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id)
|
||||
{
|
||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
|
||||
@@ -1676,6 +1679,9 @@ void rlSetTexture(unsigned int id)
|
||||
RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;
|
||||
|
||||
RLGL.currentBatch->drawCounter++;
|
||||
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 2].mode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2257,6 +2263,7 @@ void rlglInit(int width, int height)
|
||||
// Init default white texture
|
||||
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
|
||||
RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
|
||||
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
|
||||
|
||||
if (RLGL.State.defaultTextureId != 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId);
|
||||
else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load default texture");
|
||||
|
@@ -4261,9 +4261,10 @@ static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform
|
||||
continue;
|
||||
}
|
||||
transforms[i].rotation = QuaternionMultiply(transforms[bones[i].parent].rotation, transforms[i].rotation);
|
||||
transforms[i].scale = Vector3Multiply(transforms[i].scale, transforms[bones[i].parent].scale);
|
||||
transforms[i].translation = Vector3Multiply(transforms[i].translation, transforms[bones[i].parent].scale);
|
||||
transforms[i].translation = Vector3RotateByQuaternion(transforms[i].translation, transforms[bones[i].parent].rotation);
|
||||
transforms[i].translation = Vector3Add(transforms[i].translation, transforms[bones[i].parent].translation);
|
||||
transforms[i].scale = Vector3Multiply(transforms[i].scale, transforms[bones[i].parent].scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6238,6 +6239,20 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
|
||||
*animCount = (int)data->animations_count;
|
||||
animations = (ModelAnimation *)RL_CALLOC(data->animations_count, sizeof(ModelAnimation));
|
||||
|
||||
Transform worldTransform;
|
||||
{
|
||||
cgltf_float cgltf_worldTransform[16];
|
||||
cgltf_node* node = skin.joints[0];
|
||||
cgltf_node_transform_world(node->parent, cgltf_worldTransform);
|
||||
Matrix worldMatrix = {
|
||||
cgltf_worldTransform[0], cgltf_worldTransform[4], cgltf_worldTransform[8], cgltf_worldTransform[12],
|
||||
cgltf_worldTransform[1], cgltf_worldTransform[5], cgltf_worldTransform[9], cgltf_worldTransform[13],
|
||||
cgltf_worldTransform[2], cgltf_worldTransform[6], cgltf_worldTransform[10], cgltf_worldTransform[14],
|
||||
cgltf_worldTransform[3], cgltf_worldTransform[7], cgltf_worldTransform[11], cgltf_worldTransform[15]
|
||||
};
|
||||
MatrixDecompose(worldMatrix, &(worldTransform.translation), &(worldTransform.rotation), &(worldTransform.scale));
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < data->animations_count; i++)
|
||||
{
|
||||
animations[i].bones = LoadBoneInfoGLTF(skin, &animations[i].boneCount);
|
||||
@@ -6356,6 +6371,13 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
|
||||
};
|
||||
}
|
||||
|
||||
Transform* root = &animations[i].framePoses[j][0];
|
||||
root->rotation = QuaternionMultiply(worldTransform.rotation, root->rotation);
|
||||
root->scale = Vector3Multiply(root->scale, worldTransform.scale);
|
||||
root->translation = Vector3Multiply(root->translation, worldTransform.scale);
|
||||
root->translation = Vector3RotateByQuaternion(root->translation, worldTransform.rotation);
|
||||
root->translation = Vector3Add(root->translation, worldTransform.translation);
|
||||
|
||||
BuildPoseFromParentJoints(animations[i].bones, animations[i].boneCount, animations[i].framePoses[j]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user