69,373
社区成员
发帖
与我相关
我的任务
分享
#ifndef OPENSERVER_H_INCLUDED
#define OPENSERVER_H_INCLUDED
void OpenSrve(void);
#endif // OPENSERVER_H_INCLUDED
#include<Winsock2.h>
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
#include"ComInterface.h"
#include"ReceiveMessage.h"
void OpenSrv(void)
{
int iPort = DEFAULT_PORT;
WSADATA wsaData;
struct sockaddr_in ser;
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
{
printf("Failed to load Winsock.\n");
return;
}
sSocket = socket(AF_INET, SOCK_DGRAM, 0);
if(sSocket == INVALID_SOCKET)
{
printf("socket()Failed:%d\n", WSAGetLastError());
return;
}
ser.sin_family = AF_INET;
ser.sin_port = htons(iPort);
ser.sin_addr.s_addr = htonl(INADDR_ANY);
if(bind(sSocket, (sockaddr*)&ser, sizeof(ser)) == SOCKET_ERROR)
{
printf("bind()Failed:%d\n", WSAGetLastError());
return;
}
else
{
printf("------------------------------\n");
printf("Server waiting\n");
printf("------------------------------\n");
}
_beginthread(RecvMsg, 1024 * 1024, (void*)sSocket);
}
#include "oglx.h"
#include <Winsock2.h>
#include <process.h>
#include "GL/glut.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sdy_events.h"
#include "specific.h"
#include "ComInterface.h"
#include "OpenServer.h"
#include "SendMessage.h"
int main(int argc, char *argv[])
{
/* Step 1: Initialize the GLUT library and negotiate a session with the
window system */
OpenSrv();
glutInit(&argc, argv);
/* Step 2: Set the initial display mode, which is used when creating
top-level windows, subwindows, and overlays to determine the
OpenGL display mode for the to-be-created window or overlay */
glutInitDisplayMode(GLUT_ALPHA | GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
/* Step 3: Set the initial window size in pixels */
glutInitWindowSize(getW(), getH());
/* Step 4: Create a top-level window. The name will be provided to the window
system as the window's name. Implicitly, the current window is set
to the newly created window. Each created window has a unique associated
OpenGL context. State changes to a window's associated OpenGL context
can be done immediately after the window is created. */
glutCreateWindow(getSpecName());
/* Step 5: Initialize all OGLX states and variables */
oglx_init();
/* Step 6: Initialize the SCADE Suite and/or Display application */
init_scene();
/* Step 7: Define the GLUT callbacks for display, window, keyboard,
mouse, etc. management */
glutDisplayFunc(display_callback);
glutReshapeFunc(reshape_callback);
glutKeyboardFunc(keyboard_callback);
glutMouseFunc(mouse);
glutPassiveMotionFunc(mousePassiveMotion);
glutMotionFunc(mouseMotion);
timer_callback(0);
//while(1)
//{
// distance+=distance;
//}
//
/* On Windows only, disable vertical synchronization (V-Sync) to avoid limiting FPS */
#ifdef _WIN32
{
typedef BOOL(APIENTRY * PFNWGLSWAPINTERVALFARPROC) (int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0);
}
}
#endif
/* Final Step: Enter the GLUT event processing loop. Once called, this
routine will never return. It will call as necessary any callbacks
that have been registered. */
glutMainLoop();
return 0;
}