mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
#19197 Create basic visual studio
This commit is contained in:
parent
d769699cbe
commit
83abc571f1
10 changed files with 96 additions and 16 deletions
|
@ -19,7 +19,7 @@ endif (APPLE)
|
|||
|
||||
if (WIN32)
|
||||
set(GLUT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glut)
|
||||
set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0\n#include <GL/glew.h>\n#include <GL/freeglut_std.h>\n#include <GL/freeglut_ext.h>")
|
||||
set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0\n#include <GL/glew.h>\n#include <GL/wglew.h>\n#include <GL/freeglut_std.h>\n#include <GL/freeglut_ext.h>")
|
||||
endif (WIN32)
|
||||
|
||||
# create the InterfaceConfig.h file based on GL_HEADERS above
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
// Created by Philip on 12/31/12.
|
||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _timeval_
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <iostream> // to load voxels from file
|
||||
|
|
|
@ -166,7 +166,7 @@ double elapsedTime;
|
|||
|
||||
// Particles
|
||||
|
||||
char texture_filename[] = "images/int-texture256-v4.png";
|
||||
char texture_filename[] = "resources/images/int-texture256-v4.png";
|
||||
unsigned int texture_width = 256;
|
||||
unsigned int texture_height = 256;
|
||||
|
||||
|
@ -562,6 +562,7 @@ void display(void)
|
|||
char val[20];
|
||||
sprintf(val, "%d,%d", target_x, target_y);
|
||||
drawtext(target_x, target_y-20, 0.08, 0, 1.0, 0, val, 0, 1, 0);
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
if (display_head_mouse && !display_head && stats_on)
|
||||
{
|
||||
|
@ -571,6 +572,7 @@ void display(void)
|
|||
glBegin(GL_POINTS);
|
||||
glVertex2f(head_mouse_x, head_mouse_y);
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
// Spot bouncing back and forth on bottom of screen
|
||||
if (0)
|
||||
|
@ -583,7 +585,7 @@ void display(void)
|
|||
glEnd();
|
||||
render_test_spot += render_test_direction*50;
|
||||
if ((render_test_spot > WIDTH-100) || (render_test_spot < 100)) render_test_direction *= -1.0;
|
||||
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -687,8 +689,9 @@ void specialkey(int k, int x, int y)
|
|||
if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) myHead.setDriveKeys(RIGHT, 1);
|
||||
else myHead.setDriveKeys(ROT_RIGHT, 1);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
audio.setWalkingState(true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -903,16 +906,16 @@ int main(int argc, char** argv)
|
|||
#ifndef _WIN32
|
||||
agentList.audioMixerSocketUpdate = &audioMixerUpdate;
|
||||
#endif
|
||||
|
||||
// start the thread which checks for silent agents
|
||||
agentList.startSilentAgentRemovalThread();
|
||||
agentList.startDomainServerCheckInThread();
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA WsaData;
|
||||
int wsaresult = WSAStartup( MAKEWORD(2,2), &WsaData );
|
||||
#endif
|
||||
|
||||
// start the thread which checks for silent agents
|
||||
agentList.startSilentAgentRemovalThread();
|
||||
agentList.startDomainServerCheckInThread();
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
glutInitWindowSize(WIDTH, HEIGHT);
|
||||
|
|
|
@ -9,6 +9,15 @@ file(GLOB HIFI_SHARED_SRCS src/*.h src/*.cpp)
|
|||
add_library(HifiShared ${HIFI_SHARED_SRCS})
|
||||
set(HIFI_SHARED_LIBRARY HifiShared)
|
||||
|
||||
set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
|
||||
if (WIN32)
|
||||
# include headers for external libraries and InterfaceConfig.
|
||||
include_directories(
|
||||
${EXTERNAL_ROOT_DIR}
|
||||
)
|
||||
endif (WIN32)
|
||||
|
||||
# link required libraries on UNIX
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_package(Threads REQUIRED)
|
||||
|
|
|
@ -296,6 +296,18 @@ void AgentList::stopSilentAgentRemovalThread() {
|
|||
pthread_join(removeSilentAgentsThread, NULL);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void usleep(int waitTime){
|
||||
__int64 time1 = 0, time2 = 0, sysFreq = 0;
|
||||
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&time1);
|
||||
QueryPerformanceFrequency((LARGE_INTEGER *)&sysFreq);
|
||||
do{
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&time2);
|
||||
}while( (time2-time1) <waitTime);
|
||||
}
|
||||
#endif
|
||||
|
||||
void *checkInWithDomainServer(void *args) {
|
||||
|
||||
AgentList *parentAgentList = (AgentList *)args;
|
||||
|
@ -333,6 +345,7 @@ void *checkInWithDomainServer(void *args) {
|
|||
if (usecToSleep > 0) {
|
||||
usleep(usecToSleep);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pthread_exit(0);
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
#ifdef _WIN32
|
||||
#define WINSOCK_API_LINKAGE
|
||||
#include <winsock2.h>
|
||||
#ifndef _timeval_
|
||||
#define _timeval_
|
||||
|
||||
#endif
|
||||
typedef SSIZE_T ssize_t;
|
||||
typedef ULONG32 in_addr_t;
|
||||
typedef USHORT in_port_t;
|
||||
|
|
|
@ -10,7 +10,7 @@ int gettimeofday( timeval* p_tv, timezone* p_tz )
|
|||
int tt = timeGetTime();
|
||||
|
||||
p_tv->tv_sec = tt / 1000;
|
||||
p_tv->tv_sec = tt % 1000 *1000;
|
||||
p_tv->tv_usec = tt % 1000 *1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
#define __Systime__
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _WINSOCK2API_
|
||||
#define _timeval_
|
||||
#endif
|
||||
#ifndef _timeval_
|
||||
#define _timeval_
|
||||
/*
|
||||
* Structure returned by gettimeofday(2) system call,
|
||||
* and used in other calls.
|
||||
* and used in other calls.
|
||||
*/
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
|
|
|
@ -72,8 +72,9 @@ int getLocalAddress() {
|
|||
|
||||
int family;
|
||||
int localAddress = 0;
|
||||
|
||||
getifaddrs(&ifAddrStruct);
|
||||
|
||||
#ifndef _WIN32
|
||||
getifaddrs(&ifAddrStruct);
|
||||
|
||||
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
family = ifa->ifa_addr->sa_family;
|
||||
|
@ -83,11 +84,22 @@ int getLocalAddress() {
|
|||
}
|
||||
|
||||
freeifaddrs(ifAddrStruct);
|
||||
#else
|
||||
// Get the local hostname
|
||||
char szHostName[255];
|
||||
gethostname(szHostName, 255);
|
||||
struct hostent *host_entry;
|
||||
host_entry=gethostbyname(szHostName);
|
||||
char * szLocalIP;
|
||||
szLocalIP = inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
|
||||
localAddress = inet_addr(szLocalIP);
|
||||
#endif
|
||||
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
UDPSocket::UDPSocket(int listeningPort) {
|
||||
init();
|
||||
// create the socket
|
||||
handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
||||
|
@ -126,6 +138,38 @@ UDPSocket::~UDPSocket() {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool UDPSocket::init() {
|
||||
#ifdef _WIN32
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
|
||||
wVersionRequested = MAKEWORD( 2, 2 );
|
||||
|
||||
err = WSAStartup( wVersionRequested, &wsaData );
|
||||
if ( err != 0 ) {
|
||||
/* Tell the user that we could not find a usable */
|
||||
/* WinSock DLL. */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Confirm that the WinSock DLL supports 2.2.*/
|
||||
/* Note that if the DLL supports versions later */
|
||||
/* than 2.2 in addition to 2.2, it will still return */
|
||||
/* 2.2 in wVersion since that is the version we */
|
||||
/* requested. */
|
||||
|
||||
if ( LOBYTE( wsaData.wVersion ) != 2 ||
|
||||
HIBYTE( wsaData.wVersion ) != 2 ) {
|
||||
/* Tell the user that we could not find a usable */
|
||||
/* WinSock DLL. */
|
||||
WSACleanup( );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
// Receive data on this socket with retrieving address of sender
|
||||
bool UDPSocket::receive(void *receivedData, ssize_t *receivedBytes) {
|
||||
|
||||
|
@ -135,8 +179,11 @@ bool UDPSocket::receive(void *receivedData, ssize_t *receivedBytes) {
|
|||
// Receive data on this socket with the address of the sender
|
||||
bool UDPSocket::receive(sockaddr *recvAddress, void *receivedData, ssize_t *receivedBytes) {
|
||||
|
||||
#ifdef _WIN32
|
||||
int addressSize = sizeof(*recvAddress);
|
||||
#else
|
||||
socklen_t addressSize = sizeof(&recvAddress);
|
||||
|
||||
#endif
|
||||
*receivedBytes = recvfrom(handle, static_cast<char*>(receivedData), MAX_BUFFER_LENGTH_BYTES,
|
||||
0, recvAddress, &addressSize);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class UDPSocket {
|
|||
public:
|
||||
UDPSocket(int listening_port);
|
||||
~UDPSocket();
|
||||
bool init();
|
||||
int send(sockaddr *destAddress, const void *data, size_t byteLength);
|
||||
int send(char *destAddress, int destPort, const void *data, size_t byteLength);
|
||||
bool receive(void *receivedData, ssize_t *receivedBytes);
|
||||
|
|
Loading…
Reference in a new issue