Skip to content

Commit 31e29a3

Browse files
committed
Merge branch 'ElmarRoberto-ICG_GL' into ICG_GL
2 parents 2e10b25 + ad8a9d5 commit 31e29a3

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

include/framebufferinfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
//ContextInfo.h
77
namespace ijengine{
88

9-
struct FramebufferInfo{
9+
class FramebufferInfo{
1010

11+
public:
1112
unsigned int flags;
1213
int rbuffer = 5;
1314
int gbuffer = 5;
@@ -33,7 +34,7 @@ namespace ijengine{
3334
bbuffer = b_buffer_size;
3435
depthsize = depth_size;
3536
doublebuffersize = double_buffer_size;
36-
}
37+
}
3738

3839
//(optional)implement copy constructor and assignment operator
3940
};

include/sdl3Dvideo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace ijengine {
1010
public:
1111
SDL3DVideo();
1212
~SDL3DVideo();
13+
void setAttribute();
1314

1415
Window * create_window(int w, int h);
1516
};

src/sdl3Dvideo.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#include "sdl3Dvideo.h"
22
#include "sdl2window.h"
3+
#include "framebufferinfo.h"
34

45
#include <SDL2/SDL.h>
56

67
namespace ijengine {
78

9+
FramebufferInfo framebufferinfo;
10+
811
SDL3DVideo::SDL3DVideo()
912
{
1013
if (SDL_WasInit(SDL_INIT_VIDEO) == 0 and SDL_InitSubSystem(SDL_INIT_VIDEO))
@@ -17,16 +20,27 @@ namespace ijengine {
1720
SDL_QuitSubSystem(SDL_INIT_VIDEO);
1821
}
1922

23+
void SDL3DVideo::setAttribute() {
24+
25+
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, framebufferinfo.rbuffer);
26+
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, framebufferinfo.gbuffer);
27+
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, framebufferinfo.bbuffer);
28+
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, framebufferinfo.depthsize);
29+
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, framebufferinfo.doublebuffersize);
30+
}
31+
2032
Window *
2133
SDL3DVideo::create_window(int w, int h)
2234
{
2335
SDL_Window *window;
2436
SDL_Renderer *renderer;
2537

38+
this->setAttribute();
39+
2640
if (SDL_CreateWindowAndRenderer(w, h, SDL_WINDOW_OPENGL, &window, &renderer))
2741
return nullptr;
2842
SDL_GL_CreateContext(window);
2943
return new SDL2Window(window, renderer);
3044
}
31-
45+
3246
}

0 commit comments

Comments
 (0)