Math supporting Clang Vector Extension

This commit is contained in:
Jon Daniel 2024-11-13 17:30:27 +01:00
commit fee3054638
6 changed files with 1080 additions and 1837 deletions

View file

@ -102,15 +102,15 @@ int main()
for (int i = 0; i < numPoints; i++)
{
Vector3 pos = {
.x = mesh.vertices[i*3 + 0],
.y = mesh.vertices[i*3 + 1],
.z = mesh.vertices[i*3 + 2],
mesh.vertices[i*3 + 0],
mesh.vertices[i*3 + 1],
mesh.vertices[i*3 + 2],
};
Color color = {
.r = mesh.colors[i*4 + 0],
.g = mesh.colors[i*4 + 1],
.b = mesh.colors[i*4 + 2],
.a = mesh.colors[i*4 + 3],
mesh.colors[i*4 + 0],
mesh.colors[i*4 + 1],
mesh.colors[i*4 + 2],
mesh.colors[i*4 + 3],
};
DrawPoint3D(pos, color);
@ -159,9 +159,9 @@ Mesh GenMeshPoints(int numPoints)
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
for (int i = 0; i < numPoints; i++)
{
float theta = PI*rand()/RAND_MAX;
float phi = 2.0f*PI*rand()/RAND_MAX;
float r = 10.0f*rand()/RAND_MAX;
float theta = PI*rand()/(float)RAND_MAX;
float phi = 2.0f*PI*rand()/(float)RAND_MAX;
float r = 10.0f*rand()/(float)RAND_MAX;
mesh.vertices[i*3 + 0] = r*sin(theta)*cos(phi);
mesh.vertices[i*3 + 1] = r*sin(theta)*sin(phi);

View file

@ -155,9 +155,9 @@ int main(void)
for (int i = 0; i < MAX_CUBES; i++)
{
cubePositions[i] = (Vector3){
.x = (float)(rand()%10) - 5,
.y = (float)(rand()%5),
.z = (float)(rand()%10) - 5,
(float)(rand()%10) - 5,
(float)(rand()%5),
(float)(rand()%10) - 5,
};
cubeRotations[i] = (float)(rand()%360);

View file

@ -114,7 +114,7 @@ int main(void)
modelA.transform = MatrixMultiply(modelA.transform, MatrixRotateZ(0.012f));
// Update the light shader with the camera view position
SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], &camera.position.x, SHADER_UNIFORM_VEC3);
SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], (float*)&camera.position, SHADER_UNIFORM_VEC3);
//----------------------------------------------------------------------------------
// Draw

View file

@ -68,7 +68,7 @@ int main(void)
marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
Vector2 screenCenter = {.x = screenWidth/2.0f, .y = screenHeight/2.0f};
Vector2 screenCenter = { screenWidth/2.0f, screenHeight/2.0f};
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
// Use Customized function to create writable depth texture buffer

View file

@ -135,7 +135,7 @@ int main(void)
spots[i].inner = 28.0f * (i + 1);
spots[i].radius = 48.0f * (i + 1);
SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].positionLoc, (float*)&spots[i].position, SHADER_UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, SHADER_UNIFORM_FLOAT);
SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, SHADER_UNIFORM_FLOAT);
}
@ -173,7 +173,7 @@ int main(void)
if (spots[i].position.y > (screenHeight - 64)) spots[i].speed.y = -spots[i].speed.y;
}
SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].positionLoc, (float*)&spots[i].position, SHADER_UNIFORM_VEC2);
}
// Draw

View file

@ -3722,7 +3722,7 @@ int GuiColorPicker(Rectangle bounds, const char *text, Color *color)
// NOTE: this conversion can cause low hue-resolution, if the r, g and b value are very similar, which causes the hue bar to shift around when only the GuiColorPanel is used.
Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
GuiColorBarHue(boundsHue, NULL, &hsv.x);
GuiColorBarHue(boundsHue, NULL, (float*)&hsv);
//color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
Vector3 rgb = ConvertHSVtoRGB(hsv);
@ -3756,7 +3756,7 @@ int GuiColorPickerHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
const Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
GuiColorBarHue(boundsHue, NULL, &colorHsv->x);
GuiColorBarHue(boundsHue, NULL, (float*)&colorHsv);
return result;
}
@ -5718,4 +5718,4 @@ static int GetCodepointNext(const char *text, int *codepointSize)
}
#endif // RAYGUI_STANDALONE
#endif // RAYGUI_IMPLEMENTATION
#endif // RAYGUI_IMPLEMENTATION