Compare commits
No commits in common. "f9aef71a946688f3b20d3e4f67162afd3bebf053" and "4ccba24017262c300083f7c0f6b46cf12a662612" have entirely different histories.
f9aef71a94
...
4ccba24017
|
@ -2,7 +2,7 @@
|
||||||
image.ppm
|
image.ppm
|
||||||
|
|
||||||
# binary
|
# binary
|
||||||
snoopy
|
flark
|
||||||
|
|
||||||
# CMake
|
# CMake
|
||||||
# https://github.com/github/gitignore/blob/master/CMake.gitignore
|
# https://github.com/github/gitignore/blob/master/CMake.gitignore
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
project(snoopy)
|
project(flark)
|
||||||
|
|
||||||
file(GLOB snoopy_src
|
file(GLOB flark_src
|
||||||
"src/*.h"
|
"src/*.h"
|
||||||
"src/*.cpp"
|
"src/*.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(snoopy ${snoopy_src})
|
add_executable(flark ${flark_src})
|
||||||
|
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,9 +1,11 @@
|
||||||
# snoopy
|
# Flark
|
||||||
|
|
||||||
Networked fantasy telescope
|
Ray tracing rendering experiments
|
||||||
|
|
||||||
Originally based on https://raytracing.github.io/
|
https://raytracing.github.io/
|
||||||
|
|
||||||
Original repository at https://github.com/ktyldev/flark
|
Produced PPM images can be converted to PNG with `imagemagick`:
|
||||||
|
|
||||||
https://www.linuxhowtos.org/C_C++/socket.htm
|
```
|
||||||
|
convert image.ppm image.png
|
||||||
|
```
|
||||||
|
|
61
src/main.cpp
61
src/main.cpp
|
@ -8,13 +8,6 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
const double ASPECT_RATIO = 16.0 / 9.0;
|
const double ASPECT_RATIO = 16.0 / 9.0;
|
||||||
const int WIDTH = 1920;
|
const int WIDTH = 1920;
|
||||||
const int HEIGHT = static_cast<int>(WIDTH / ASPECT_RATIO);
|
const int HEIGHT = static_cast<int>(WIDTH / ASPECT_RATIO);
|
||||||
|
@ -119,62 +112,8 @@ hittable_list random_scene()
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(const char* message)
|
|
||||||
{
|
|
||||||
perror(message);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wait_for_client()
|
|
||||||
{
|
|
||||||
int sockfd, newsockfd;
|
|
||||||
struct sockaddr_in serv_addr, cli_addr;
|
|
||||||
socklen_t clilen;
|
|
||||||
|
|
||||||
// open socket and await connection from client
|
|
||||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
if (sockfd < 0)
|
|
||||||
{
|
|
||||||
error("ERROR creating socket");
|
|
||||||
}
|
|
||||||
|
|
||||||
bzero((char*)&serv_addr, sizeof(serv_addr));
|
|
||||||
|
|
||||||
// we successfully created the socket, configure it for binding
|
|
||||||
serv_addr.sin_family = AF_INET;
|
|
||||||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
|
||||||
serv_addr.sin_port = htons(64999); // convert number from host to network byte order
|
|
||||||
|
|
||||||
// bind the socket
|
|
||||||
if (bind(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0)
|
|
||||||
{
|
|
||||||
error("ERROR binding socket");
|
|
||||||
}
|
|
||||||
|
|
||||||
// successfully bound socket, start listening for connections
|
|
||||||
listen(sockfd, 5);
|
|
||||||
clilen = sizeof(cli_addr);
|
|
||||||
|
|
||||||
newsockfd = accept(sockfd, (struct sockaddr*)&cli_addr, &clilen);
|
|
||||||
if (newsockfd < 0)
|
|
||||||
{
|
|
||||||
error("ERROR accepting client");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("got a connection!\n");
|
|
||||||
|
|
||||||
// close sockets we opened
|
|
||||||
close(newsockfd);
|
|
||||||
close(sockfd);
|
|
||||||
|
|
||||||
// once connection is acquired, exit
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
wait_for_client();
|
|
||||||
|
|
||||||
std::cout << "P3\n" << WIDTH << ' ' << HEIGHT << "\n255\n";
|
std::cout << "P3\n" << WIDTH << ' ' << HEIGHT << "\n255\n";
|
||||||
|
|
||||||
hittable_list world = random_scene();
|
hittable_list world = random_scene();
|
||||||
|
|
21
telescope.md
21
telescope.md
|
@ -1,21 +0,0 @@
|
||||||
fantasy telescope idea
|
|
||||||
|
|
||||||
use rti1w as a base
|
|
||||||
|
|
||||||
* [ ] move rendering out of main.cpp
|
|
||||||
* [x] server waits for connection
|
|
||||||
* [x] client establishes connection
|
|
||||||
* [ ] client sends receiving port to server
|
|
||||||
* [ ] client application sends command to send image
|
|
||||||
* [ ] server receives imaging command
|
|
||||||
* [ ] server renders image
|
|
||||||
* [ ] server sends image data stream to client
|
|
||||||
* [ ] client application receives image
|
|
||||||
* [ ] client requests resend of lost packets
|
|
||||||
* [ ] client displays image
|
|
||||||
* [ ] client saves image to file
|
|
||||||
* [ ] server sends telemetry to client (what telemetry?)
|
|
||||||
* [ ] server compresses image before sending to client
|
|
||||||
* [ ] client specifies image parameters
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue