Skip to content

Commit 05489f1

Browse files
committed
fix building with msvc & reduce warnings
1 parent abbdb2d commit 05489f1

4 files changed

Lines changed: 32 additions & 31 deletions

File tree

examples/shaders/shaders_basic_lighting.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ int main(void)
4848

4949
// Define the camera to look into our 3d world
5050
raylib::Camera camera;
51-
camera.position = (Vector3){ 2.0f, 4.0f, 6.0f }; // Camera position
52-
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
53-
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
51+
camera.position = Vector3{ 2.0f, 4.0f, 6.0f }; // Camera position
52+
camera.target = Vector3{ 0.0f, 0.5f, 0.0f }; // Camera looking at point
53+
camera.up = Vector3{ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
5454
camera.fovy = 45.0f; // Camera field-of-view Y
5555
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
5656

@@ -70,10 +70,10 @@ int main(void)
7070

7171
// Create lights
7272
std::array<Light, MAX_LIGHTS> lights = {
73-
CreateLight(LIGHT_POINT, (Vector3) {-2, 1, -2}, Vector3Zero(), YELLOW, shader),
74-
CreateLight(LIGHT_POINT, (Vector3) {2, 1, 2}, Vector3Zero(), RED, shader),
75-
CreateLight(LIGHT_POINT, (Vector3) {-2, 1, 2}, Vector3Zero(), GREEN, shader),
76-
CreateLight(LIGHT_POINT, (Vector3) {2, 1, -2}, Vector3Zero(), BLUE, shader),
73+
CreateLight(LIGHT_POINT, Vector3 {-2, 1, -2}, Vector3Zero(), YELLOW, shader),
74+
CreateLight(LIGHT_POINT, Vector3 {2, 1, 2}, Vector3Zero(), RED, shader),
75+
CreateLight(LIGHT_POINT, Vector3 {-2, 1, 2}, Vector3Zero(), GREEN, shader),
76+
CreateLight(LIGHT_POINT, Vector3 {2, 1, -2}, Vector3Zero(), BLUE, shader),
7777
};
7878

7979
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@@ -110,7 +110,7 @@ int main(void)
110110

111111
BeginShaderMode(shader);
112112

113-
DrawPlane(Vector3Zero(), (Vector2) { 10.0, 10.0 }, WHITE);
113+
DrawPlane(Vector3Zero(), Vector2 { 10.0, 10.0 }, WHITE);
114114
DrawCube(Vector3Zero(), 2.0, 4.0, 2.0, WHITE);
115115

116116
EndShaderMode();

examples/shaders/shaders_basic_pbr.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ int main()
8888

8989
// Define the camera to look into our 3d world
9090
raylib::Camera camera;
91-
camera.position = (Vector3){ 2.0f, 2.0f, 6.0f }; // Camera position
92-
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
93-
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
91+
camera.position = Vector3{ 2.0f, 2.0f, 6.0f }; // Camera position
92+
camera.target = Vector3{ 0.0f, 0.5f, 0.0f }; // Camera looking at point
93+
camera.up = Vector3{ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
9494
camera.fovy = 45.0f; // Camera field-of-view Y
9595
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
9696

@@ -117,8 +117,8 @@ int main()
117117

118118
// Setup ambient color and intensity parameters
119119
float ambientIntensity = 0.02f;
120-
raylib::Color ambientColor = (Color){ 26, 32, 135, 255 };
121-
raylib::Vector3 ambientColorNormalized = (Vector3){ ambientColor.r/255.0f, ambientColor.g/255.0f, ambientColor.b/255.0f };
120+
raylib::Color ambientColor = Color{ 26, 32, 135, 255 };
121+
raylib::Vector3 ambientColorNormalized = Vector3{ ambientColor.r/255.0f, ambientColor.g/255.0f, ambientColor.b/255.0f };
122122
shader.SetValue(shader.GetLocation("ambientColor"), &ambientColorNormalized, SHADER_UNIFORM_VEC3);
123123
shader.SetValue(shader.GetLocation("ambient"), &ambientIntensity, SHADER_UNIFORM_FLOAT);
124124

@@ -142,7 +142,7 @@ int main()
142142
car.materials[0].maps[MATERIAL_MAP_METALNESS].value = 0.0f;
143143
car.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value = 0.0f;
144144
car.materials[0].maps[MATERIAL_MAP_OCCLUSION].value = 1.0f;
145-
car.materials[0].maps[MATERIAL_MAP_EMISSION].color = (Color){ 255, 162, 0, 255 };
145+
car.materials[0].maps[MATERIAL_MAP_EMISSION].color = Color{ 255, 162, 0, 255 };
146146

147147
// Setup materials[0].maps default textures
148148
car.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("resources/old_car_d.png");
@@ -172,15 +172,15 @@ int main()
172172

173173
// Models texture tiling parameter can be stored in the Material struct if required (CURRENTLY NOT USED)
174174
// NOTE: Material.params[4] are available for generic parameters storage (float)
175-
Vector2 carTextureTiling = (Vector2){ 0.5f, 0.5f };
176-
Vector2 floorTextureTiling = (Vector2){ 0.5f, 0.5f };
175+
Vector2 carTextureTiling = Vector2{ 0.5f, 0.5f };
176+
Vector2 floorTextureTiling = Vector2{ 0.5f, 0.5f };
177177

178178
// Create some lights
179179
std::array<Light, MAX_LIGHTS> lights = {
180-
CreateLight(0, LightType::POINT, (Vector3) {-1.0f, 1.0f, -2.0f}, (Vector3) {0.0f, 0.0f, 0.0f}, YELLOW, 4.0f, shader),
181-
CreateLight(1, LightType::POINT, (Vector3){ 2.0f, 1.0f, 1.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, GREEN, 3.3f, shader),
182-
CreateLight(2, LightType::POINT, (Vector3){ -2.0f, 1.0f, 1.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, RED, 8.3f, shader),
183-
CreateLight(3, LightType::POINT, (Vector3){ 1.0f, 1.0f, -2.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, BLUE, 2.0f, shader),
180+
CreateLight(0, LightType::POINT, Vector3{-1.0f, 1.0f, -2.0f}, Vector3{0.0f, 0.0f, 0.0f}, YELLOW, 4.0f, shader),
181+
CreateLight(1, LightType::POINT, Vector3{ 2.0f, 1.0f, 1.0f }, Vector3{ 0.0f, 0.0f, 0.0f }, GREEN, 3.3f, shader),
182+
CreateLight(2, LightType::POINT, Vector3{ -2.0f, 1.0f, 1.0f }, Vector3{ 0.0f, 0.0f, 0.0f }, RED, 8.3f, shader),
183+
CreateLight(3, LightType::POINT, Vector3{ 1.0f, 1.0f, -2.0f }, Vector3{ 0.0f, 0.0f, 0.0f }, BLUE, 2.0f, shader),
184184
};
185185

186186
// Setup material texture maps usage in shader
@@ -228,7 +228,7 @@ int main()
228228
raylib::Vector4 floorEmissiveColor = ColorNormalize(floor.materials[0].maps[MATERIAL_MAP_EMISSION].color);
229229
SetShaderValue(shader, emissiveColorLoc, &floorEmissiveColor, SHADER_UNIFORM_VEC4);
230230

231-
DrawModel(floor, (Vector3){ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE); // Draw floor model
231+
DrawModel(floor, Vector3{ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE); // Draw floor model
232232

233233
// Set old car model texture tiling, emissive color and emissive intensity parameters on shader
234234
SetShaderValue(shader, textureTilingLoc, &carTextureTiling, SHADER_UNIFORM_VEC2);
@@ -237,15 +237,15 @@ int main()
237237
float emissiveIntensity = 0.01f;
238238
SetShaderValue(shader, emissiveIntensityLoc, &emissiveIntensity, SHADER_UNIFORM_FLOAT);
239239

240-
car.Draw((Vector3){ 0.0f, 0.0f, 0.0f }, 0.005f, WHITE); // Draw car model
240+
car.Draw(Vector3{ 0.0f, 0.0f, 0.0f }, 0.005f, WHITE); // Draw car model
241241

242242
// Draw spheres to show the lights positions
243243
for (const auto& light : lights)
244244
{
245-
Color lightColor = (Color){ static_cast<unsigned char>(light.color[0]*255),
246-
static_cast<unsigned char>(light.color[1]*255),
247-
static_cast<unsigned char>(light.color[2]*255),
248-
static_cast<unsigned char>(light.color[3]*255) };
245+
Color lightColor = Color{ static_cast<unsigned char>(light.color[0]*255),
246+
static_cast<unsigned char>(light.color[1]*255),
247+
static_cast<unsigned char>(light.color[2]*255),
248+
static_cast<unsigned char>(light.color[3]*255) };
249249

250250
if (light.enabled) DrawSphereEx(light.position, 0.2f, 8, 8, lightColor);
251251
else DrawSphereWires(light.position, 0.2f, 8, 8, ColorAlpha(lightColor, 0.3f));
@@ -267,12 +267,12 @@ int main()
267267
//--------------------------------------------------------------------------------------
268268
// Unbind (disconnect) shader from car.material[0]
269269
// to avoid UnloadMaterial() trying to unload it automatically
270-
car.materials[0].shader = (Shader){ 0 };
270+
car.materials[0].shader = Shader{ 0 };
271271
UnloadMaterial(car.materials[0]);
272272
car.materials[0].maps = NULL;
273273
//UnloadModel(car);
274274

275-
floor.materials[0].shader = (Shader){ 0 };
275+
floor.materials[0].shader = Shader{ 0 };
276276
UnloadMaterial(floor.materials[0]);
277277
floor.materials[0].maps = NULL;
278278
//UnloadModel(floor);

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(CTEST_CUSTOM_TESTS_IGNORE pkg-config--static)
66
# Executable
77
add_executable(raylib_cpp_test raylib_cpp_test.cpp)
88
if (MSVC)
9-
target_compile_options(raylib_cpp_test PRIVATE /Wall /W4)
9+
target_compile_options(raylib_cpp_test PRIVATE /W4)
1010
else()
1111
target_compile_options(raylib_cpp_test PRIVATE -Wall -Wextra -Wconversion -Wsign-conversion -Weffc++)
1212
endif()

tests/raylib-assert.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ extern "C" {
7878
#endif
7979

8080
// Variadic Arguments
81-
#define RAYLIB_ASSERT_CAT( A, B ) A ## B
82-
#define RAYLIB_ASSERT_SELECT( NAME, NUM ) RAYLIB_ASSERT_CAT( NAME ## _, NUM )
81+
#define RAYLIB_ASSERT_CAT(a, b) RAYLIB_ASSERT_CAT_I(a, b)
82+
#define RAYLIB_ASSERT_CAT_I(a, b) a##b
83+
#define RAYLIB_ASSERT_SELECT(name, num) RAYLIB_ASSERT_CAT(name##_, num)
8384
#define RAYLIB_ASSERT_GET_COUNT( _1, _2, _3, _4, _5, _6, _7, RAYLIB_ASSERT_COUNT, ... ) RAYLIB_ASSERT_COUNT
8485
#define RAYLIB_ASSERT_VA_SIZE( ... ) RAYLIB_ASSERT_GET_COUNT( __VA_ARGS__, 7, 6, 5, 4, 3, 2, 1 )
8586
#define RAYLIB_ASSERT_VA_SELECT( NAME, ... ) RAYLIB_ASSERT_SELECT( NAME, RAYLIB_ASSERT_VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)

0 commit comments

Comments
 (0)