mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] initial parameter implementation
This commit is contained in:
parent
34e67b1b57
commit
4731b13a03
@ -51,7 +51,22 @@ struct AppState
|
||||
struct KVMGFXHeader * shm;
|
||||
};
|
||||
|
||||
struct AppParams
|
||||
{
|
||||
bool borderless;
|
||||
const char * ivshmemSocket;
|
||||
bool useBufferStorage;
|
||||
bool useSpice;
|
||||
};
|
||||
|
||||
struct AppState state;
|
||||
struct AppParams params =
|
||||
{
|
||||
.borderless = true,
|
||||
.ivshmemSocket = "/tmp/ivshmem_socket",
|
||||
.useBufferStorage = true,
|
||||
.useSpice = true
|
||||
};
|
||||
|
||||
inline bool areFormatsSame(const struct KVMGFXHeader s1, const struct KVMGFXHeader s2)
|
||||
{
|
||||
@ -365,15 +380,24 @@ int eventThread(void * arg)
|
||||
while(state.running)
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
if (!SDL_WaitEventTimeout(&event, 1000))
|
||||
{
|
||||
const char * err = SDL_GetError();
|
||||
if (err[0] != '\0')
|
||||
{
|
||||
DEBUG_ERROR("SDL Error: %s", err);
|
||||
state.running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type == SDL_QUIT)
|
||||
{
|
||||
state.running = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!state.started)
|
||||
if (!state.started || !params.useSpice)
|
||||
continue;
|
||||
|
||||
switch(event.type)
|
||||
@ -500,8 +524,6 @@ int eventThread(void * arg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -517,7 +539,14 @@ int main(int argc, char * argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
state.window = SDL_CreateWindow("KVM-GFX Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 100, 100, SDL_WINDOW_BORDERLESS);
|
||||
state.window = SDL_CreateWindow(
|
||||
"KVM-GFX Test",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
100, 100,
|
||||
params.borderless ? SDL_WINDOW_BORDERLESS : 0
|
||||
);
|
||||
|
||||
if (!state.window)
|
||||
{
|
||||
DEBUG_ERROR("failed to create window");
|
||||
@ -534,12 +563,15 @@ int main(int argc, char * argv[])
|
||||
state.renderer = SDL_CreateRenderer(state.window, -1,
|
||||
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
|
||||
if (params.useBufferStorage)
|
||||
{
|
||||
const GLubyte * extensions = glGetString(GL_EXTENSIONS);
|
||||
if (gluCheckExtension((const GLubyte *)"GL_ARB_buffer_storage", extensions))
|
||||
{
|
||||
DEBUG_INFO("Using GL_ARB_buffer_storage");
|
||||
state.hasBufferStorage = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!state.renderer)
|
||||
{
|
||||
@ -554,7 +586,7 @@ int main(int argc, char * argv[])
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (!ivshmem_connect("/tmp/ivshmem_socket"))
|
||||
if (!ivshmem_connect(params.ivshmemSocket))
|
||||
{
|
||||
DEBUG_ERROR("failed to connect to the ivshmem server");
|
||||
break;
|
||||
@ -574,6 +606,8 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
state.shm->hostID = ivshmem_get_id();
|
||||
|
||||
if (params.useSpice)
|
||||
{
|
||||
if (!spice_connect("127.0.0.1", 5900, ""))
|
||||
{
|
||||
DEBUG_ERROR("Failed to connect to spice server");
|
||||
@ -593,6 +627,7 @@ int main(int argc, char * argv[])
|
||||
DEBUG_ERROR("spice create thread failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(t_event = SDL_CreateThread(eventThread, "eventThread", NULL)))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user