summaryrefslogtreecommitdiffhomepage
path: root/examples/network/network_resolve_host.c
diff options
context:
space:
mode:
authorRay <[email protected]>2020-02-19 18:16:20 +0100
committerRay <[email protected]>2020-02-19 18:16:20 +0100
commit19390eaf097f2f78b7af188ece92f73388381cb6 (patch)
treeb406a24b9c40951d7174d71422836e1b0b90059a /examples/network/network_resolve_host.c
parentfaff51214079955eb86dc972e1746ad728e6d5e3 (diff)
downloadraylib-19390eaf097f2f78b7af188ece92f73388381cb6.tar.gz
raylib-19390eaf097f2f78b7af188ece92f73388381cb6.zip
[rnet] Examples review -WIP-
Diffstat (limited to 'examples/network/network_resolve_host.c')
-rw-r--r--examples/network/network_resolve_host.c79
1 files changed, 42 insertions, 37 deletions
diff --git a/examples/network/network_resolve_host.c b/examples/network/network_resolve_host.c
index 45d6e4e9..9081f70e 100644
--- a/examples/network/network_resolve_host.c
+++ b/examples/network/network_resolve_host.c
@@ -1,44 +1,36 @@
/*******************************************************************************************
*
* raylib [network] example - Resolve Host
- *
- * Welcome to raylib!
- *
- * To test examples, just press F6 and execute raylib_compile_execute script
- * Note that compiled executable is placed in the same folder as .c file
- *
- * You can find all basic examples on C:\raylib\raylib\examples folder or
- * raylib official webpage: www.raylib.com
- *
- * Enjoy using raylib. :)
- *
- * This example has been created using raylib 2.0 (www.raylib.com)
- * raylib is licensed under an unmodified zlib/libpng license (View raylib.h
- *for details)
- *
- * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
- *
- ********************************************************************************************/
+*
+* This example has been created using raylib 3.0 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
-#include "raylib.h"
-#include "rnet.h"
+#include "raylib.h"
-char buffer[ADDRESS_IPV6_ADDRSTRLEN];
-uint16_t port = 0;
+#define RNET_IMPLEMENTATION
+#include "rnet.h"
-int main()
+int main(void)
{
- // Setup
- int screenWidth = 800;
- int screenHeight = 450;
- InitWindow(
- screenWidth, screenHeight, "raylib [network] example - ping pong");
- SetTargetFPS(60);
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+ InitWindow(screenWidth, screenHeight, "raylib [network] example - ping pong");
+
+ char buffer[ADDRESS_IPV6_ADDRSTRLEN];
+ uint16_t port = 0;
+
SetTraceLogLevel(LOG_DEBUG);
+
// Networking
- InitNetwork();
+ InitNetworkDevice();
AddressInformation* addr = AllocAddressList(1);
int count = ResolveHost(
@@ -58,23 +50,36 @@ int main()
if (count > 0)
{
GetAddressHostAndPort(addr[0], buffer, &port);
- TraceLog(LOG_INFO, "Resolved to ip %s::%d\n", buffer, port);
+ TraceLog(LOG_INFO, "Resolved to ip %s::%d", buffer, port);
}
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
// Main game loop
- while (!WindowShouldClose())
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
// Draw
+ //----------------------------------------------------------------------------------
BeginDrawing();
- // Clear
- ClearBackground(RAYWHITE);
+ ClearBackground(RAYWHITE);
+
+ DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
- // End draw
EndDrawing();
+ //----------------------------------------------------------------------------------
}
- // Cleanup
- CloseWindow();
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
return 0;
} \ No newline at end of file