BindBC SDL working
This commit is contained in:
commit
d15cb42475
14 files changed
+4510
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import std.stdio;
|
||||
import bindbc.sdl;
|
||||
|
||||
enum int WIDTH = 800;
|
||||
enum int HEIGHT = 600;
|
||||
|
||||
void init()
|
||||
{
|
||||
// glActiveTexture(GL_TEXTURE0);
|
||||
// glEnable(GL_BLEND);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
// glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
// glClearColor (1.0, 0.7, 0.0, 0.0);
|
||||
// glViewport(0, 0, WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
void display(SDL_Window * window)
|
||||
{
|
||||
// glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING))
|
||||
{
|
||||
stderr.writeln("Failed to initialize SDL!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_Window * window = SDL_CreateWindow("d-bindbc-sdl-glad",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
SDL_WINDOW_OPENGL);
|
||||
|
||||
if (window == null)
|
||||
{
|
||||
stderr.writeln("Failed to create SDL window!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_GLContext context = SDL_GL_CreateContext(window);
|
||||
|
||||
// if (!gladLoadGl())
|
||||
// {
|
||||
// stderr.writeln("Failed to load OpenGL");
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
init();
|
||||
SDL_Event event;
|
||||
for (;;)
|
||||
{
|
||||
if (SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_QUIT)
|
||||
break;
|
||||
else if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
if (event.key.keysym.scancode == SDL_SCANCODE_ESCAPE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
display(window);
|
||||
}
|
||||
|
||||
SDL_GL_DeleteContext(context);
|
||||
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user