Skip to content

Commit d443d20

Browse files
committed
xrRender_GL: fix gl render
1 parent eef7590 commit d443d20

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/Layers/xrRenderGL/glHW.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window)
4848

4949
R_ASSERT(m_hWnd);
5050

51-
// Get the device context
52-
Uint32 pixelFormat = SDL_GetWindowPixelFormat(m_hWnd);
53-
if (SDL_PIXELFORMAT_UNKNOWN == pixelFormat)
54-
{
55-
Msg("Could not get pixel format: %s", SDL_GetError());
56-
return;
57-
}
58-
59-
//TODO Choose the closest pixel format
60-
61-
//TODO Apply the pixel format to the device context
51+
//Choose the closest pixel format
52+
SDL_DisplayMode mode;
53+
SDL_GetWindowDisplayMode(m_hWnd, &mode);
54+
mode.format = SDL_PIXELFORMAT_RGBA8888;
55+
// Apply the pixel format to the device context
56+
SDL_SetWindowDisplayMode(m_hWnd, &mode);
6257

6358
// Create the context
6459
m_hRC = SDL_GL_CreateContext(m_hWnd);
@@ -77,6 +72,10 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window)
7772
return;
7873
}
7974

75+
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
76+
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
77+
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
78+
8079
// Initialize OpenGL Extension Wrangler
8180
if (glewInit() != GLEW_OK)
8281
{
@@ -176,6 +175,8 @@ void CHW::updateWindowProps(SDL_Window* m_sdlWnd)
176175
}
177176
else
178177
{
178+
SDL_SetWindowPosition(m_sdlWnd, 0, 0);
179+
SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]);
179180
SDL_ShowWindow(m_sdlWnd);
180181
}
181182

@@ -299,5 +300,6 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT
299300
HRESULT CHW::Present(UINT /*SyncInterval*/, UINT /*Flags*/)
300301
{
301302
RImplementation.Target->phase_flip();
302-
return SwapBuffers(m_hDC) ? S_OK : E_FAIL;
303+
SDL_GL_SwapWindow(m_hWnd);
304+
return S_OK;
303305
}

src/Layers/xrRenderPC_GL/stdafx.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
#include "SDL_opengl.h"
1414
#include <GL/glu.h>
1515
#include "SDL_opengl_glext.h"
16-
#if defined(WINDOWS)
17-
#include <gl/wglext.h>
18-
#elif defined(LINUX)
19-
#include <GL/glxext.h>
20-
#endif
2116

2217
#include "Layers/xrRender/xrD3DDefs.h"
2318
#include "Layers/xrRender/Debug/dxPixEventWrapper.h"

0 commit comments

Comments
 (0)