View previous topic :: View next topic |
Author |
Message |
bioinfornatics
Joined: 22 Jun 2010 Posts: 90
|
Posted: Wed Dec 14, 2011 3:37 am Post subject: SDL |
|
|
Hi, derelictSDL do not bind some new SDL method like: SDL_GLContext, SDL_WindowID
Thanks if you could add this
Code: | module gui.application;
import std.string;
import std.conv;
import std.exception;
import derelict.sdl.sdl;
class Application{
private:
SDL_GLContext _context;
SDL_Event _events;
SDL_WindowID _window;
string _title;
size_t _height;
size_t _width;
bool _isInit;
public:
this( string title, size_t width, size_t height ){
_title = title;
_width = width;
_height= height;
_isInit = false;
DerelictSDL.load();
DerelictGL.load();
// Initialize SDL
if(SDL_Init(SDL_INIT_VIDEO) < 0){
string error = to!string( SDL_GetError() );
SDL_Quit();
throw new Exception("Error in SDL initialization: %s" .format( error ) );
isInit = false;
}
else{
// OpenGL Version
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
// Double Buffer
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
// Create main window
_window = SDL_CreateWindow( _title.toStrinZ(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _width, _height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL );
_context = SDL_GL_CreateContext( _window );
_isInit = true;
}
}
void run(){
if( !isInit )
throw new Exception("OpenGL and/or SDL are not initialized!");
bool isRunning = true;
while( isRunning ){
// Manage Event
SDL_WaitEvent( &_events );
if( _events.window.event == SDL_WINDOWEVENT_CLOSE)
isRunning = false;
// Clean window
glClear(GL_COLOR_BUFFER_BIT);
// TODO
SDL_GL_SwapWindow( -window );
}
}
@property:
bool isInitialized(){
return _isInit;
}
size_t height(){
return _height;
}
void height( size_t height ){
_height = height;
}
string title(){
return _title;
}
void title( string text ){
_title = text;
}
size_t width(){
return _width;
}
void width( size_t width ){
_width = width;
}
}
|
|
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Wed Dec 14, 2011 5:38 am Post subject: |
|
|
DerelictSDL is for the SDL 1.2 series. For SDL 1.3, the future SDL 2, there will be a DerelictSDL2 package. I started work on it some time ago, but the 1.3 API was not stable then. So I decided to hold off until SDL 2 is nearer to release. Given that it's relatively stable now, I may look into putting the binding together sooner. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
bioinfornatics
Joined: 22 Jun 2010 Posts: 90
|
Posted: Wed Dec 14, 2011 9:12 am Post subject: |
|
|
oh nice |
|
Back to top |
|
|
mutable
Joined: 22 Jun 2010 Posts: 87
|
Posted: Sun Jan 01, 2012 5:10 pm Post subject: |
|
|
I have ported SDL 1.3 Beta with a friend of mine. If you or anyone else is interessted on this, he or she can write me here.
But for the sake of completeness i must say, that it is different to handle as derelict. The handling is very similar to the "original" C SDL. |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Sun Jan 01, 2012 10:29 pm Post subject: |
|
|
mutable wrote: | I have ported SDL 1.3 Beta with a friend of mine. If you or anyone else is interessted on this, he or she can write me here.
But for the sake of completeness i must say, that it is different to handle as derelict. The handling is very similar to the "original" C SDL. |
DerelictSDL is exactly the same as the C API. It's a direct one-to-one binding. Do you mean yours is a static binding and not a dynamic one (i.e. one that requires loading, like Derelict). _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
mutable
Joined: 22 Jun 2010 Posts: 87
|
Posted: Mon Jan 02, 2012 4:01 am Post subject: |
|
|
Correct, that was what i mean. |
|
Back to top |
|
|
ParticlePeter
Joined: 19 Nov 2011 Posts: 49 Location: Germany
|
Posted: Fri Jan 13, 2012 5:05 am Post subject: |
|
|
Hi,
@Mutable, I would like to try out your Bata Binding. Where can I get it ? THX. _________________ Cheers, searching for the Pivot of my Soul, PP |
|
Back to top |
|
|
|