93 lines
2.0 KiB
D
93 lines
2.0 KiB
D
import std.stdio;
|
|
import derelict.sdl2.sdl;
|
|
import derelict.opengl3.gl3;
|
|
import glamour.vao;
|
|
import glamour.vbo;
|
|
|
|
static import logo;
|
|
import mode;
|
|
|
|
immutable int N_GENTEX = 6;
|
|
immutable int N_CORPORATION = 11;
|
|
|
|
class ScreenSaver
|
|
{
|
|
protected int m_width;
|
|
protected int m_height;
|
|
protected SDL_Window * m_window;
|
|
protected SDL_GLContext m_context;
|
|
|
|
this(int width, int height)
|
|
{
|
|
m_width = width;
|
|
m_height = height;
|
|
|
|
DerelictSDL2.load();
|
|
|
|
DerelictGL3.load();
|
|
|
|
if (SDL_Init(SDL_INIT_EVERYTHING))
|
|
{
|
|
writeln("Failed to initialize SDL!");
|
|
return;
|
|
}
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
|
|
|
|
m_window = SDL_CreateWindow("Gentex ScreenSaver",
|
|
0,
|
|
0,
|
|
m_width,
|
|
m_height,
|
|
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
|
|
|
|
m_context = SDL_GL_CreateContext(m_window);
|
|
|
|
if (m_window == null)
|
|
{
|
|
writeln("Failed to create SDL window!");
|
|
return;
|
|
}
|
|
|
|
DerelictGL3.reload();
|
|
|
|
SDL_ShowCursor(0);
|
|
|
|
logo.init();
|
|
}
|
|
|
|
public void run(Mode modes[])
|
|
{
|
|
modes[0].init(this);
|
|
|
|
SDL_Event event;
|
|
for (;;)
|
|
{
|
|
if (SDL_PollEvent(&event))
|
|
{
|
|
if ((event.type == SDL_QUIT) || (event.type == SDL_KEYDOWN))
|
|
break;
|
|
}
|
|
modes[0].display(this, SDL_GetTicks());
|
|
SDL_GL_SwapWindow(m_window);
|
|
}
|
|
|
|
SDL_GL_DeleteContext(m_context);
|
|
|
|
SDL_DestroyWindow(m_window);
|
|
|
|
SDL_Quit();
|
|
}
|
|
|
|
public int get_width()
|
|
{
|
|
return m_width;
|
|
}
|
|
|
|
public int get_height()
|
|
{
|
|
return m_height;
|
|
}
|
|
}
|