Fix merge conflict and add check for unix and not apple for glx

Merge branch 'development-gg' into gladdev

# Conflicts:
#	Tools/CMake/libraries/glad.cmake
This commit is contained in:
Jeff Hutchinson 2016-11-02 21:55:24 -04:00
commit 0296e6d3fd
728 changed files with 83679 additions and 66879 deletions

View file

@ -27,26 +27,9 @@
void GFXGLCardProfiler::init()
{
mChipSet = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
// get the major and minor parts of the GL version. These are defined to be
// in the order "[major].[minor] [other]|[major].[minor].[release] [other] in the spec
const char *versionStart = reinterpret_cast<const char*>(glGetString(GL_VERSION));
const char *versionEnd = versionStart;
// get the text for the version "x.x.xxxx "
for( S32 tok = 0; tok < 2; ++tok )
{
char *text = dStrdup( versionEnd );
dStrtok(text, ". ");
versionEnd += dStrlen( text ) + 1;
dFree( text );
}
mRendererString = "GL";
mRendererString += String::SpanToString(versionStart, versionEnd - 1);
mRendererString = "OpenGL";
mCardDescription = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
mVideoMemory = static_cast<GFXGLDevice*>(GFX)->getTotalVideoMemory();
Parent::init();
@ -85,7 +68,8 @@ void GFXGLCardProfiler::setupCardCapabilities()
setCapability("GL_ARB_copy_image", gglHasExtension(ARB_copy_image));
// Check for vertex attrib binding
setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
}
bool GFXGLCardProfiler::_queryCardCap(const String& query, U32& foundResult)

View file

@ -103,27 +103,6 @@ void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLs
Con::printf("AMDOPENGL: %s", message);
}
// >>>> OPENGL INTEL WORKAROUND @todo OPENGL INTEL remove
PFNGLBINDFRAMEBUFFERPROC __openglBindFramebuffer = NULL;
void STDCALL _t3d_glBindFramebuffer(GLenum target, GLuint framebuffer)
{
if( target == GL_FRAMEBUFFER )
{
if( GFXGL->getOpenglCache()->getCacheBinded( GL_DRAW_FRAMEBUFFER ) == framebuffer
&& GFXGL->getOpenglCache()->getCacheBinded( GL_READ_FRAMEBUFFER ) == framebuffer )
return;
}
else if( GFXGL->getOpenglCache()->getCacheBinded( target ) == framebuffer )
return;
__openglBindFramebuffer(target, framebuffer);
GFXGL->getOpenglCache()->setCacheBinded( target, framebuffer);
}
// <<<< OPENGL INTEL WORKAROUND
void GFXGLDevice::initGLState()
{
// We don't currently need to sync device state with a known good place because we are
@ -157,14 +136,11 @@ void GFXGLDevice::initGLState()
String vendorStr = (const char*)glGetString( GL_VENDOR );
if( vendorStr.find("NVIDIA", 0, String::NoCase | String::Left) != String::NPos)
mUseGlMap = false;
if( vendorStr.find("INTEL", 0, String::NoCase | String::Left ) != String::NPos)
{
// @todo OPENGL INTEL - This is a workaround for a warning spam or even crashes with actual framebuffer code, remove when implemented TGL layer.
__openglBindFramebuffer = glBindFramebuffer;
glBindFramebuffer = &_t3d_glBindFramebuffer;
}
// Workaround for all Mac's, has a problem using glMap* with volatile buffers
#ifdef TORQUE_OS_MAC
mUseGlMap = false;
#endif
#if TORQUE_DEBUG
if( gglHasExtension(ARB_debug_output) )
@ -200,8 +176,10 @@ void GFXGLDevice::initGLState()
GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
mAdapterIndex(adapterIndex),
mNeedUpdateVertexAttrib(false),
mCurrentPB(NULL),
mDrawInstancesCount(0),
mCurrentShader( NULL ),
m_mCurrentWorld(true),
m_mCurrentView(true),
mContext(NULL),
@ -211,8 +189,6 @@ GFXGLDevice::GFXGLDevice(U32 adapterIndex) :
mMaxFFTextures(2),
mMaxTRColors(1),
mClip(0, 0, 0, 0),
mCurrentShader( NULL ),
mNeedUpdateVertexAttrib(false),
mWindowRT(NULL),
mUseGlMap(true)
{

View file

@ -1,343 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// Don't include Apple's GL header
#define __gl_h_
// Include our GL header before Apple headers.
#include "gfx/gl/ggl/ggl.h"
#include "platform/tmm_off.h"
#include <Cocoa/Cocoa.h>
#include <OpenGL/OpenGL.h>
#include "gfx/gl/gfxGLDevice.h"
#include "platform/tmm_on.h"
#include "gfx/gl/gfxGLTextureTarget.h"
#include "gfx/gl/gfxGLCardProfiler.h"
#include "gfx/gl/gfxGLAppleFence.h"
#include "gfx/gl/gfxGLWindowTarget.h"
#include "platformMac/macGLUtils.h"
#include "windowManager/mac/macWindow.h"
extern void loadGLCore();
extern void loadGLExtensions(void* context);
static String _getRendererForDisplay(CGDirectDisplayID display)
{
Vector<NSOpenGLPixelFormatAttribute> attributes = _createStandardPixelFormatAttributesForDisplay(display);
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes.address()];
AssertFatal(fmt, "_getRendererForDisplay - Unable to create a pixel format object");
NSOpenGLContext* ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
AssertFatal(ctx, "_getRendererForDisplay - Unable to create an OpenGL context");
// Save the current context, just in case
NSOpenGLContext* currCtx = [NSOpenGLContext currentContext];
[ctx makeCurrentContext];
// CodeReview [ags 12/19/07] This is a hack. We should call loadGLCore somewhere else, before we reach here.
// On Macs we can safely assume access to the OpenGL framework at anytime, perhaps this should go in main()?
loadGLCore();
// get the renderer string
String ret((const char*)glGetString(GL_RENDERER));
// Restore our old context, release the context and pixel format.
[currCtx makeCurrentContext];
[ctx release];
[fmt release];
return ret;
}
static void _createInitialContextAndFormat(void* &ctx, void* &fmt)
{
AssertFatal(!fmt && !ctx, "_createInitialContextAndFormat - Already created initial context and format");
fmt = _createStandardPixelFormat();
AssertFatal(fmt, "_createInitialContextAndFormat - Unable to create an OpenGL pixel format");
ctx = [[NSOpenGLContext alloc] initWithFormat: (NSOpenGLPixelFormat*)fmt shareContext: nil];
AssertFatal(ctx, "_createInitialContextAndFormat - Unable to create an OpenGL context");
}
static NSOpenGLContext* _createContextForWindow(PlatformWindow *window, void* &context, void* &pixelFormat)
{
NSOpenGLView* view = (NSOpenGLView*)window->getPlatformDrawable();
AssertFatal([view isKindOfClass:[NSOpenGLView class]], avar("_createContextForWindow - Supplied a %s instead of a NSOpenGLView", [[view className] UTF8String]));
NSOpenGLContext* ctx = NULL;
if(!context || !pixelFormat)
{
// Create the initial opengl context that the device and the first window will hold.
_createInitialContextAndFormat(context, pixelFormat);
ctx = (NSOpenGLContext*)context;
}
else
{
// Create a context which shares its resources with the device's initial context
ctx = [[NSOpenGLContext alloc] initWithFormat: (NSOpenGLPixelFormat*)pixelFormat shareContext: (NSOpenGLContext*)context];
AssertFatal(ctx, "Unable to create a shared OpenGL context");
}
[view setPixelFormat: (NSOpenGLPixelFormat*)pixelFormat];
[view setOpenGLContext: ctx];
return ctx;
}
void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
{
if(mInitialized)
return;
NSOpenGLContext* ctx = _createContextForWindow(window, mContext, mPixelFormat);
[ctx makeCurrentContext];
loadGLCore();
loadGLExtensions(ctx);
initGLState();
mInitialized = true;
deviceInited();
}
void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
{
GFXAdapter *toAdd;
Vector<GFXVideoMode> videoModes;
CGDirectDisplayID display = CGMainDisplayID();
// Enumerate all available resolutions:
NSArray* modeArray = (NSArray*)CGDisplayAvailableModes(display);
GFXVideoMode vmAdd;
NSEnumerator* enumerator = [modeArray objectEnumerator];
NSDictionary* mode;
while((mode = [enumerator nextObject]))
{
vmAdd.resolution.x = [[mode valueForKey:@"Width"] intValue];
vmAdd.resolution.y = [[mode valueForKey:@"Height"] intValue];
vmAdd.bitDepth = [[mode valueForKey:@"BitsPerPixel"] intValue];
vmAdd.refreshRate = [[mode valueForKey:@"RefreshRate"] intValue];
vmAdd.fullScreen = false;
// skip if mode claims to be 8bpp
if( vmAdd.bitDepth == 8 )
continue;
// Only add this resolution if it is not already in the list:
bool alreadyInList = false;
for(Vector<GFXVideoMode>::iterator i = videoModes.begin(); i != videoModes.end(); i++)
{
if(vmAdd == *i)
{
alreadyInList = true;
break;
}
}
if( !alreadyInList )
{
videoModes.push_back( vmAdd );
}
}
// Get number of displays
CGDisplayCount dispCnt;
CGGetActiveDisplayList(0, NULL, &dispCnt);
// Take advantage of GNU-C
CGDirectDisplayID displays[dispCnt];
CGGetActiveDisplayList(dispCnt, displays, &dispCnt);
for(U32 i = 0; i < dispCnt; i++)
{
toAdd = new GFXAdapter();
toAdd->mType = OpenGL;
toAdd->mIndex = (U32)displays[i];
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
String renderer = _getRendererForDisplay(displays[i]);
AssertFatal(dStrlen(renderer.c_str()) < GFXAdapter::MaxAdapterNameLen, "GFXGLDevice::enumerateAdapter - renderer name too long, increae the size of GFXAdapter::MaxAdapterNameLen (or use String!)");
dStrncpy(toAdd->mName, renderer.c_str(), GFXAdapter::MaxAdapterNameLen);
adapterList.push_back(toAdd);
for (S32 j = videoModes.size() - 1 ; j >= 0 ; j--)
toAdd->mAvailableModes.push_back(videoModes[j]);
}
}
void GFXGLDevice::enumerateVideoModes()
{
mVideoModes.clear();
CGDirectDisplayID display = CGMainDisplayID();
// Enumerate all available resolutions:
NSArray* modeArray = (NSArray*)CGDisplayAvailableModes(display);
GFXVideoMode toAdd;
NSEnumerator* enumerator = [modeArray objectEnumerator];
NSDictionary* mode;
while((mode = [enumerator nextObject]))
{
toAdd.resolution.x = [[mode valueForKey:@"Width"] intValue];
toAdd.resolution.y = [[mode valueForKey:@"Height"] intValue];
toAdd.bitDepth = [[mode valueForKey:@"BitsPerPixel"] intValue];
toAdd.refreshRate = [[mode valueForKey:@"RefreshRate"] intValue];
toAdd.fullScreen = false;
// skip if mode claims to be 8bpp
if( toAdd.bitDepth == 8 )
continue;
// Only add this resolution if it is not already in the list:
bool alreadyInList = false;
for(Vector<GFXVideoMode>::iterator i = mVideoModes.begin(); i != mVideoModes.end(); i++)
{
if(toAdd == *i)
{
alreadyInList = true;
break;
}
}
if( !alreadyInList )
{
mVideoModes.push_back( toAdd );
}
}
}
bool GFXGLDevice::beginSceneInternal()
{
// Nothing to do here for GL.
mCanCurrentlyRender = true;
return true;
}
U32 GFXGLDevice::getTotalVideoMemory()
{
// Convert our adapterIndex (i.e. our CGDirectDisplayID) into an OpenGL display mask
GLuint display = CGDisplayIDToOpenGLDisplayMask((CGDirectDisplayID)mAdapterIndex);
CGLRendererInfoObj rend;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
GLint nrend;
#else
long int nrend;
#endif
CGLQueryRendererInfo(display, &rend, &nrend);
if(!nrend)
return 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
GLint vidMem;
#else
long int vidMem;
#endif
CGLDescribeRenderer(rend, 0, kCGLRPVideoMemory, &vidMem);
CGLDestroyRendererInfo(rend);
// convert bytes to MB
vidMem /= (1024 * 1024);
return vidMem;
}
//-----------------------------------------------------------------------------
GFXWindowTarget *GFXGLDevice::allocWindowTarget(PlatformWindow *window)
{
void *ctx = NULL;
// Init if needed, or create a new context
if(!mInitialized)
init(window->getVideoMode(), window);
else
ctx = _createContextForWindow(window, mContext, mPixelFormat);
// Allocate the wintarget and create a new context.
GFXGLWindowTarget *gwt = new GFXGLWindowTarget(window, this);
gwt->mContext = ctx ? ctx : mContext;
// And return...
return gwt;
}
GFXFence* GFXGLDevice::_createPlatformSpecificFence()
{
if(!mCardProfiler->queryProfile("GL::APPLE::suppFence"))
return NULL;
return new GFXGLAppleFence(this);
}
void GFXGLWindowTarget::_WindowPresent()
{
GFX->updateStates();
mFullscreenContext ? [(NSOpenGLContext*)mFullscreenContext flushBuffer] : [(NSOpenGLContext*)mContext flushBuffer];
return true;
}
void GFXGLWindowTarget::_teardownCurrentMode()
{
GFX->setActiveRenderTarget(this);
static_cast<GFXGLDevice*>(mDevice)->zombify();
if(mFullscreenContext)
{
[NSOpenGLContext clearCurrentContext];
[(NSOpenGLContext*)mFullscreenContext clearDrawable];
}
}
void GFXGLWindowTarget::_setupNewMode()
{
if(mWindow->getVideoMode().fullScreen && !mFullscreenContext)
{
// We have to create a fullscreen context.
Vector<NSOpenGLPixelFormatAttribute> attributes = _beginPixelFormatAttributesForDisplay(static_cast<MacWindow*>(mWindow)->getDisplay());
_addColorAlphaDepthStencilAttributes(attributes, 24, 8, 24, 8);
_addFullscreenAttributes(attributes);
_endAttributeList(attributes);
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes.address()];
mFullscreenContext = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
[fmt release];
[(NSOpenGLContext*)mFullscreenContext setFullScreen];
[(NSOpenGLContext*)mFullscreenContext makeCurrentContext];
// Restore resources in new context
static_cast<GFXGLDevice*>(mDevice)->resurrect();
GFX->updateStates(true);
}
else if(!mWindow->getVideoMode().fullScreen && mFullscreenContext)
{
[(NSOpenGLContext*)mFullscreenContext release];
mFullscreenContext = NULL;
[(NSOpenGLContext*)mContext makeCurrentContext];
GFX->clear(GFXClearTarget | GFXClearZBuffer | GFXClearStencil, ColorI(0, 0, 0), 1.0f, 0);
static_cast<GFXGLDevice*>(mDevice)->resurrect();
GFX->updateStates(true);
}
}

View file

@ -58,7 +58,7 @@ public:
glGenQueries(1, &mQueryId);
}
GLTimer() : mName(NULL), mQueryId(0), mData(NULL)
GLTimer() : mName(NULL), mData(NULL), mQueryId(0)
{
}

View file

@ -32,6 +32,8 @@
#include "gfx/gfxStructs.h"
#include "console/console.h"
#define CHECK_AARG(pos, name) static StringTableEntry attr_##name = StringTable->insert(#name); if (argName == attr_##name) { glBindAttribLocation(mProgram, pos, attr_##name); continue; }
class GFXGLShaderConstHandle : public GFXShaderConstHandle
{
@ -447,34 +449,62 @@ bool GFXGLShader::_init()
// If either shader was present and failed to compile, bail.
if(!compiledVertexShader || !compiledPixelShader)
return false;
//bind vertex attributes
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Position, "vPosition");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Normal, "vNormal");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Color, "vColor");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Tangent, "vTangent");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TangentW, "vTangentW");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_Binormal, "vBinormal");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord0, "vTexCoord0");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord1, "vTexCoord1");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord2, "vTexCoord2");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord3, "vTexCoord3");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord4, "vTexCoord4");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord5, "vTexCoord5");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord6, "vTexCoord6");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord7, "vTexCoord7");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord8, "vTexCoord8");
glBindAttribLocation(mProgram, Torque::GL_VertexAttrib_TexCoord9, "vTexCoord9");
//bind fragment out color
glBindFragDataLocation(mProgram, 0, "OUT_col");
glBindFragDataLocation(mProgram, 1, "OUT_col1");
glBindFragDataLocation(mProgram, 2, "OUT_col2");
glBindFragDataLocation(mProgram, 3, "OUT_col3");
// Link it!
glLinkProgram( mProgram );
GLint activeAttribs = 0;
glGetProgramiv(mProgram, GL_ACTIVE_ATTRIBUTES, &activeAttribs );
GLint maxLength;
glGetProgramiv(mProgram, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxLength);
FrameTemp<GLchar> tempData(maxLength+1);
*tempData.address() = '\0';
// Check atributes
for (U32 i=0; i<activeAttribs; i++)
{
GLint size;
GLenum type;
glGetActiveAttrib(mProgram, i, maxLength + 1, NULL, &size, &type, tempData.address());
StringTableEntry argName = StringTable->insert(tempData.address());
CHECK_AARG(Torque::GL_VertexAttrib_Position, vPosition);
CHECK_AARG(Torque::GL_VertexAttrib_Normal, vNormal);
CHECK_AARG(Torque::GL_VertexAttrib_Color, vColor);
CHECK_AARG(Torque::GL_VertexAttrib_Tangent, vTangent);
CHECK_AARG(Torque::GL_VertexAttrib_TangentW, vTangentW);
CHECK_AARG(Torque::GL_VertexAttrib_Binormal, vBinormal);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord0, vTexCoord0);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord1, vTexCoord1);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord2, vTexCoord2);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord3, vTexCoord3);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord4, vTexCoord4);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord5, vTexCoord5);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord6, vTexCoord6);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord7, vTexCoord7);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord8, vTexCoord8);
CHECK_AARG(Torque::GL_VertexAttrib_TexCoord9, vTexCoord9);
}
//always have OUT_col
glBindFragDataLocation(mProgram, 0, "OUT_col");
// Check OUT_colN
for(U32 i=1;i<4;i++)
{
char buffer[10];
dSprintf(buffer, sizeof(buffer), "OUT_col%u",i);
GLint location = glGetFragDataLocation(mProgram, buffer);
if(location>0)
glBindFragDataLocation(mProgram, i, buffer);
}
// Link it again!
glLinkProgram( mProgram );
GLint linkStatus;
glGetProgramiv( mProgram, GL_LINK_STATUS, &linkStatus );
@ -486,23 +516,24 @@ bool GFXGLShader::_init()
FrameAllocatorMarker fam;
char* log = (char*)fam.alloc( logLength );
glGetProgramInfoLog( mProgram, logLength, NULL, log );
if ( linkStatus == GL_FALSE )
{
if ( smLogErrors )
{
Con::errorf( "GFXGLShader::init - Error linking shader!" );
Con::errorf( "Program %s / %s: %s",
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
Con::errorf( "Program %s / %s: %s",
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
}
}
else if ( smLogWarnings )
{
Con::warnf( "Program %s / %s: %s",
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
Con::warnf( "Program %s / %s: %s",
mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str(), log);
}
}
// If we failed to link, bail.
if ( linkStatus == GL_FALSE )
return false;

View file

@ -196,7 +196,7 @@ void _GFXGLTextureTargetFBOImpl::applyState()
{
// Certain drivers have issues with depth only FBOs. That and the next two asserts assume we have a color target.
AssertFatal(hasColor, "GFXGLTextureTarget::applyState() - Cannot set DepthStencil target without Color0 target!");
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthStecil->getBinding(), depthStecil->getHandle(), depthStecil->getMipLevel());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, depthStecil->getBinding(), depthStecil->getHandle(), depthStecil->getMipLevel());
}
else
{

View file

@ -41,10 +41,11 @@ GFXGLVertexBuffer::GFXGLVertexBuffer( GFXDevice *device,
const GFXVertexFormat *vertexFormat,
U32 vertexSize,
GFXBufferType bufferType )
: GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType ),
mZombieCache(NULL),
: GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType ),
mBufferOffset(0),
mBufferVertexOffset(0)
mBufferVertexOffset(0),
mZombieCache(NULL)
{
if( mBufferType == GFXBufferTypeVolatile )
{

View file

@ -118,11 +118,14 @@ inline void GFXGLWindowTarget::_setupAttachments()
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color->getHandle(), 0);
mBackBufferDepthTex.set(dstSize.x, dstSize.y, GFXFormatD24S8, &BackBufferDepthProfile, "backBuffer");
GFXGLTextureObject *depth = static_cast<GFXGLTextureObject*>(mBackBufferDepthTex.getPointer());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth->getHandle(), 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depth->getHandle(), 0);
}
void GFXGLWindowTarget::makeActive()
{
//make the rendering context active on this window
_makeContextCurrent();
if(mBackBufferFBO)
{
glBindFramebuffer( GL_FRAMEBUFFER, mBackBufferFBO);

View file

@ -64,6 +64,8 @@ private:
void _setupNewMode();
void _setupAttachments();
void _WindowPresent();
//set this windows context to be current
void _makeContextCurrent();
};
#endif

View file

@ -157,12 +157,12 @@ void GFXGLDevice::enumerateVideoModes()
void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
{
AssertFatal(window, "GFXGLDevice::init - no window specified, can't init device without a window!");
PlatformWindowSDL* x11Window = dynamic_cast<PlatformWindowSDL*>(window);
AssertFatal(x11Window, "Window is not a valid PlatformWindowSDL object");
PlatformWindowSDL* sdlWindow = dynamic_cast<PlatformWindowSDL*>(window);
AssertFatal(sdlWindow, "Window is not a valid PlatformWindowSDL object");
// Create OpenGL context
mContext = PlatformGL::CreateContextGL( x11Window );
PlatformGL::MakeCurrentGL( x11Window, mContext );
mContext = PlatformGL::CreateContextGL( sdlWindow );
PlatformGL::MakeCurrentGL( sdlWindow, mContext );
loadGLCore();
loadGLExtensions(mContext);
@ -228,4 +228,9 @@ void GFXGLWindowTarget::_setupNewMode()
{
}
void GFXGLWindowTarget::_makeContextCurrent()
{
PlatformGL::MakeCurrentGL(mWindow, mContext);
}
#endif

View file

@ -363,3 +363,16 @@ void GFXGLWindowTarget::_teardownCurrentMode()
void GFXGLWindowTarget::_setupNewMode()
{
}
void GFXGLWindowTarget::_makeContextCurrent()
{
HWND hwnd = GETHWND(getWindow());
HDC hdc = GetDC(hwnd);
if (!wglMakeCurrent(hdc, (HGLRC)mContext))
{
//HRESULT if needed for debug
//HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
AssertFatal(false, "GFXGLWindowTarget::_makeContextCurrent() - cannot make our context current.");
}
}