Skip to content

Commit

Permalink
xrRender_GL: fix gl render
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg authored and Xottab-DUTY committed Jul 24, 2018
1 parent 1390342 commit 68c032b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
26 changes: 14 additions & 12 deletions src/Layers/xrRenderGL/glHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,12 @@ void CHW::CreateDevice(SDL_Window *hWnd, bool move_window)

R_ASSERT(m_hWnd);

// Get the device context
Uint32 pixelFormat = SDL_GetWindowPixelFormat(m_hWnd);
if (SDL_PIXELFORMAT_UNKNOWN == pixelFormat)
{
Msg("Could not get pixel format: %s", SDL_GetError());
return;
}

//TODO Choose the closest pixel format

//TODO Apply the pixel format to the device context
//Choose the closest pixel format
SDL_DisplayMode mode;
SDL_GetWindowDisplayMode(m_hWnd, &mode);
mode.format = SDL_PIXELFORMAT_RGBA8888;
// Apply the pixel format to the device context
SDL_SetWindowDisplayMode(m_hWnd, &mode);

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

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);

// Initialize OpenGL Extension Wrangler
if (glewInit() != GLEW_OK)
{
Expand Down Expand Up @@ -176,6 +175,8 @@ void CHW::updateWindowProps(SDL_Window* m_sdlWnd)
}
else
{
SDL_SetWindowPosition(m_sdlWnd, 0, 0);
SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]);
SDL_ShowWindow(m_sdlWnd);
}

Expand Down Expand Up @@ -299,5 +300,6 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT
HRESULT CHW::Present(UINT /*SyncInterval*/, UINT /*Flags*/)
{
RImplementation.Target->phase_flip();
return SwapBuffers(m_hDC) ? S_OK : E_FAIL;
SDL_GL_SwapWindow(m_hWnd);
return S_OK;
}
5 changes: 0 additions & 5 deletions src/Layers/xrRenderPC_GL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
#include "SDL_opengl.h"
#include <GL/glu.h>
#include "SDL_opengl_glext.h"
#if defined(WINDOWS)
#include <gl/wglext.h>
#elif defined(LINUX)
#include <GL/glxext.h>
#endif

#include "Layers/xrRender/xrD3DDefs.h"
#include "Layers/xrRender/Debug/dxPixEventWrapper.h"
Expand Down

0 comments on commit 68c032b

Please sign in to comment.