-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdl_main.cpp
More file actions
54 lines (42 loc) · 1.62 KB
/
sdl_main.cpp
File metadata and controls
54 lines (42 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <vlCore/VisualizationLibrary.hpp>
#include <vlSDL/SDLWindow.hpp>
#include <vlCore/Colors.hpp>
#include "MainWindow.h"
using namespace vl;
int main( int argc, char* args[] ) {
/* init Visualization Library */
VisualizationLibrary::init();
/* setup the OpenGL context format */
OpenGLContextFormat format;
format.setDoubleBuffer( true );
format.setRGBABits( 8, 8, 8, 0 );
format.setDepthBufferBits( 24 );
format.setStencilBufferBits( 8 );
format.setFullscreen( false );
//format.setMultisampleSamples(16);
//format.setMultisample(true);
/* create the applet to be run */
MainWindow* w = new MainWindow;
vl::ref<vl::Applet> applet = w;
applet->initialize();
/* create a native SDL window */
ref<vlSDL::SDLWindow> sdl_window = new vlSDL::SDLWindow;
/* bind the applet so it receives all the GUI events related to the OpenGLContext */
sdl_window->addEventListener( applet.get() );
/* target the window so we can render on it */
applet->rendering()->as<Rendering>()->renderer()->setFramebuffer( sdl_window->framebuffer() );
/* Initialize the OpenGL context and window properties */
int x = 0;
int y = 0;
int width = 1024;
int height = 768;
sdl_window->initSDLWindow( "Planet rendering using Visualization Library", format, x, y, width, height );
/* run SDL message loop */
vlSDL::messageLoop();
/* deallocate the window with all the OpenGL resources before shutting down Visualization Library */
sdl_window = NULL;
/* shutdown Visualization Library */
VisualizationLibrary::shutdown();
return 0;
}
// Have fun!