Merge branch 'master' of github.com:bkaradzic/bgfx

This commit is contained in:
bkaradzic 2013-07-21 14:46:23 -07:00
commit 9852949a38
14 changed files with 502 additions and 76 deletions

View file

@ -0,0 +1,241 @@
/*
* Copyright 2011-2013 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bx/bx.h>
#if BX_PLATFORM_IOS
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/CAEAGLLayer.h>
#include <bgfxplatform.h>
#include <bx/uint32_t.h>
#include <bx/thread.h>
#include "entry_p.h"
#include "dbg.h"
extern int _main_(int _argc, char** _argv);
namespace bgfx
{
void renderFrame();
}
namespace entry
{
struct MainThreadEntry
{
int m_argc;
char** m_argv;
static int32_t threadFunc(void* _userData);
};
struct Context
{
Context()
{
const char* argv[1] = { "ios" };
m_mte.m_argc = 1;
m_mte.m_argv = const_cast<char**>(argv);
m_eventQueue.postSizeEvent(720, 1024);
m_thread.init(MainThreadEntry::threadFunc, &m_mte);
}
~Context()
{
m_thread.shutdown();
}
MainThreadEntry m_mte;
bx::Thread m_thread;
EventQueue m_eventQueue;
};
static Context* s_ctx;
int32_t MainThreadEntry::threadFunc(void* _userData)
{
MainThreadEntry* self = (MainThreadEntry*)_userData;
int32_t result = _main_(self->m_argc, self->m_argv);
return result;
}
const Event* poll()
{
return s_ctx->m_eventQueue.poll();
}
void release(const Event* _event)
{
s_ctx->m_eventQueue.release(_event);
}
void setWindowSize(uint32_t _width, uint32_t _height)
{
}
void toggleWindowFrame()
{
}
void setMouseLock(bool _lock)
{
}
} // namespace entry
using namespace entry;
@interface EAGLView : UIView
{
EAGLContext* m_context;
CADisplayLink* m_displayLink;
}
@property (nonatomic, retain) EAGLContext* m_context;
@end
@implementation EAGLView
@synthesize m_context;
+ (Class)layerClass
{
return [CAEAGLLayer class];
}
- (id)initWithFrame:(CGRect)rect
{
self = [super initWithFrame:rect];
if (nil == self)
{
return nil;
}
CAEAGLLayer* layer = (CAEAGLLayer*)self.layer;
layer.opaque = true;
layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys
: [NSNumber numberWithBool:false]
, kEAGLDrawablePropertyRetainedBacking
, kEAGLColorFormatRGBA8
, kEAGLDrawablePropertyColorFormat
, nil
];
m_context = [ [EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
BX_CHECK(NULL != m_context, "Failed to create kEAGLRenderingAPIOpenGLES2 context.");
[EAGLContext setCurrentContext:m_context];
bgfx::iosSetEaglContext(m_context, layer);
return self;
}
- (void)start
{
if (nil == m_displayLink)
{
m_displayLink = [self.window.screen displayLinkWithTarget:self selector:@selector(renderFrame)];
[m_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
}
- (void)stop
{
if (nil != m_displayLink)
{
[m_displayLink invalidate];
m_displayLink = nil;
}
}
- (void)renderFrame
{
bgfx::renderFrame();
}
@end
@interface AppDelegate : UIResponder<UIApplicationDelegate>
{
UIWindow* m_window;
EAGLView* m_view;
}
@property (nonatomic, retain) UIWindow* m_window;
@property (nonatomic, retain) EAGLView* m_view;
@end
@implementation AppDelegate
@synthesize m_window;
@synthesize m_view;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CGRect rect = [ [UIScreen mainScreen] bounds];
m_window = [ [UIWindow alloc] initWithFrame: rect];
m_view = [ [EAGLView alloc] initWithFrame: rect];
[m_window addSubview: m_view];
[m_window makeKeyAndVisible];
s_ctx = new Context;
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
[m_view stop];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[m_view start];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
[m_view stop];
}
- (void)dealloc
{
[m_window release];
[m_view release];
[super dealloc];
}
@end
int main(int _argc, char* _argv[])
{
NSAutoreleasePool* pool = [ [NSAutoreleasePool alloc] init];
int exitCode = UIApplicationMain(_argc, _argv, @"UIApplication", NSStringFromClass([AppDelegate class]) );
[pool release];
return exitCode;
}
#endif // BX_PLATFORM_IOS

View file

@ -37,7 +37,7 @@ extern int _main_(int _argc, char** _argv);
- (id)init { - (id)init {
self = [super init]; self = [super init];
if (self) { if (self) {
self->terminated = false; self->terminated = false;
} }
return self; return self;
} }
@ -77,7 +77,7 @@ extern int _main_(int _argc, char** _argv);
- (void)windowCreated:(NSWindow *)window { - (void)windowCreated:(NSWindow *)window {
assert(window); assert(window);
[window setDelegate:self]; [window setDelegate:self];
assert(self->windowCount < ~0u); assert(self->windowCount < ~0u);
@ -86,12 +86,12 @@ extern int _main_(int _argc, char** _argv);
- (BOOL)windowShouldClose:(NSWindow *)window { - (BOOL)windowShouldClose:(NSWindow *)window {
assert(window); assert(window);
[window setDelegate:nil]; [window setDelegate:nil];
assert(self->windowCount); assert(self->windowCount);
self->windowCount -= 1; self->windowCount -= 1;
if (self->windowCount == 0) { if (self->windowCount == 0) {
[NSApp terminate:self]; [NSApp terminate:self];
return false; return false;
@ -106,39 +106,39 @@ namespace entry
{ {
int m_argc; int m_argc;
char** m_argv; char** m_argv;
static int32_t threadFunc(void* _userData) static int32_t threadFunc(void* _userData)
{ {
MainThreadEntry* self = (MainThreadEntry*)_userData; MainThreadEntry* self = (MainThreadEntry*)_userData;
return _main_(self->m_argc, self->m_argv); return _main_(self->m_argc, self->m_argv);
} }
}; };
struct Context struct Context
{ {
Context() Context()
: m_exit(false) : m_exit(false)
{ {
} }
NSEvent* WaitEvent () { NSEvent* WaitEvent () {
return return
[NSApp [NSApp
nextEventMatchingMask:NSAnyEventMask nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture] // wait for event untilDate:[NSDate distantFuture] // wait for event
inMode:NSDefaultRunLoopMode inMode:NSDefaultRunLoopMode
dequeue:YES]; dequeue:YES];
} }
NSEvent* PeekEvent () { NSEvent* PeekEvent () {
return return
[NSApp [NSApp
nextEventMatchingMask:NSAnyEventMask nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast] // do not wait for event untilDate:[NSDate distantPast] // do not wait for event
inMode:NSDefaultRunLoopMode inMode:NSDefaultRunLoopMode
dequeue:YES]; dequeue:YES];
} }
bool DispatchEvent (NSEvent* event) { bool DispatchEvent (NSEvent* event) {
if (event) { if (event) {
[NSApp sendEvent:event]; [NSApp sendEvent:event];
@ -147,22 +147,22 @@ namespace entry
} }
return false; return false;
} }
int32_t main(int _argc, char** _argv) int32_t main(int _argc, char** _argv)
{ {
[NSApplication sharedApplication]; [NSApplication sharedApplication];
id dg = [bgfxApplicationDelegate sharedDelegate]; id dg = [bgfxApplicationDelegate sharedDelegate];
[NSApp setDelegate:dg]; [NSApp setDelegate:dg];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
[NSApp finishLaunching]; [NSApp finishLaunching];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName:NSApplicationWillFinishLaunchingNotification postNotificationName:NSApplicationWillFinishLaunchingNotification
object:NSApp]; object:NSApp];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName:NSApplicationDidFinishLaunchingNotification postNotificationName:NSApplicationDidFinishLaunchingNotification
object:NSApp]; object:NSApp];
id quitMenuItem = [NSMenuItem new]; id quitMenuItem = [NSMenuItem new];
[quitMenuItem [quitMenuItem
initWithTitle:@"Quit" initWithTitle:@"Quit"
@ -175,53 +175,52 @@ namespace entry
id menubar = [[NSMenu new] autorelease]; id menubar = [[NSMenu new] autorelease];
[menubar addItem:appMenuItem]; [menubar addItem:appMenuItem];
[NSApp setMainMenu:menubar]; [NSApp setMainMenu:menubar];
NSRect rect = NSMakeRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT); NSRect rect = NSMakeRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
NSWindow* window = [NSWindow alloc]; NSWindow* window = [NSWindow alloc];
[window [window
initWithContentRect:rect initWithContentRect:rect
styleMask:0 styleMask:0
|NSTitledWindowMask |NSTitledWindowMask
|NSClosableWindowMask |NSClosableWindowMask
|NSMiniaturizableWindowMask |NSMiniaturizableWindowMask
|NSResizableWindowMask |NSResizableWindowMask
backing:NSBackingStoreBuffered defer:NO backing:NSBackingStoreBuffered defer:NO
]; ];
NSString* appName = [[NSProcessInfo processInfo] processName]; NSString* appName = [[NSProcessInfo processInfo] processName];
[window setTitle:appName]; [window setTitle:appName];
[window cascadeTopLeftFromPoint:NSMakePoint(20,20)]; [window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
[window makeKeyAndOrderFront:nil]; [window makeKeyAndOrderFront:nil];
[[bgfxWindowDelegate sharedDelegate] windowCreated:window]; [[bgfxWindowDelegate sharedDelegate] windowCreated:window];
bgfx::osxSetNSWindow(window); bgfx::osxSetNSWindow(window);
MainThreadEntry mte; MainThreadEntry mte;
mte.m_argc = _argc; mte.m_argc = _argc;
mte.m_argv = _argv; mte.m_argv = _argv;
bx::Thread thread; bx::Thread thread;
thread.init(mte.threadFunc, &mte); thread.init(mte.threadFunc, &mte);
while (!(m_exit = [dg applicationHasTerminated])) while (!(m_exit = [dg applicationHasTerminated]))
{ {
DispatchEvent(WaitEvent()); DispatchEvent(WaitEvent());
while (DispatchEvent(PeekEvent())); while (DispatchEvent(PeekEvent()));
} }
m_eventQueue.postExitEvent(); m_eventQueue.postExitEvent();
thread.shutdown(); thread.shutdown();
return 0; return 0;
} }
EventQueue m_eventQueue; EventQueue m_eventQueue;
bool m_exit; bool m_exit;
}; };
static Context s_ctx; static Context s_ctx;
const Event* poll() const Event* poll()
{ {
return s_ctx.m_eventQueue.poll(); return s_ctx.m_eventQueue.poll();

View file

@ -20,6 +20,12 @@ namespace bgfx
void androidSetWindow(::ANativeWindow* _window); void androidSetWindow(::ANativeWindow* _window);
} // namespace bgfx } // namespace bgfx
#elif BX_PLATFORM_IOS
namespace bgfx
{
void iosSetEaglContext(void* _context, void* _layer);
} // namespace bgfx
#elif BX_PLATFORM_LINUX #elif BX_PLATFORM_LINUX
# include <X11/Xlib.h> # include <X11/Xlib.h>

View file

@ -13,7 +13,8 @@ all:
premake4 --file=premake/premake4.lua --gcc=mingw gmake premake4 --file=premake/premake4.lua --gcc=mingw gmake
premake4 --file=premake/premake4.lua --gcc=linux gmake premake4 --file=premake/premake4.lua --gcc=linux gmake
premake4 --file=premake/premake4.lua --gcc=osx gmake premake4 --file=premake/premake4.lua --gcc=osx gmake
premake4 --file=premake/premake4.lua --gcc=ios gmake premake4 --file=premake/premake4.lua --gcc=ios-arm gmake
premake4 --file=premake/premake4.lua --gcc=ios-simulator gmake
premake4 --file=premake/premake4.lua --gcc=qnx-arm gmake premake4 --file=premake/premake4.lua --gcc=qnx-arm gmake
premake4 --file=premake/premake4.lua xcode4 premake4 --file=premake/premake4.lua xcode4
make -s --no-print-directory -C src make -s --no-print-directory -C src
@ -86,11 +87,17 @@ osx-release64:
make -C .build/projects/gmake-osx config=release64 make -C .build/projects/gmake-osx config=release64
osx: osx-debug32 osx-release32 osx-debug64 osx-release64 osx: osx-debug32 osx-release32 osx-debug64 osx-release64
ios-debug: ios-arm-debug:
make -R -C .build/projects/gmake-ios config=debug make -R -C .build/projects/gmake-ios-arm config=debug
ios-release: ios-arm-release:
make -R -C .build/projects/gmake-ios config=release make -R -C .build/projects/gmake-ios-arm config=release
ios: ios-debug ios-release ios-arm: ios-arm-debug ios-arm-release
ios-simulator-debug:
make -R -C .build/projects/gmake-ios-simulator config=debug
ios-simulator-release:
make -R -C .build/projects/gmake-ios-simulator config=release
ios-simulator: ios-simulator-debug ios-simulator-release
qnx-arm-debug: qnx-arm-debug:
make -R -C .build/projects/gmake-qnx-arm config=debug make -R -C .build/projects/gmake-qnx-arm config=debug

View file

@ -30,12 +30,12 @@ project "bgfx"
"$(DXSDK_DIR)/include", "$(DXSDK_DIR)/include",
} }
configuration { "osx or ios" } configuration { "osx or ios*" }
files { files {
BGFX_DIR .. "src/**.mm", BGFX_DIR .. "src/**.mm",
} }
configuration { "vs* or linux or mingw or osx or ios" } configuration { "vs* or linux or mingw or osx or ios*" }
includedirs { includedirs {
--nacl has GLES2 headers modified... --nacl has GLES2 headers modified...
BGFX_DIR .. "3rdparty/glext", BGFX_DIR .. "3rdparty/glext",

View file

@ -102,7 +102,8 @@ function exampleProject(_name, _uuid)
"OpenGL.framework", "OpenGL.framework",
} }
configuration { "ios" } configuration { "ios*" }
kind "ConsoleApp"
files { files {
BGFX_DIR .. "examples/common/**.mm", BGFX_DIR .. "examples/common/**.mm",
} }
@ -110,6 +111,8 @@ function exampleProject(_name, _uuid)
"-framework CoreFoundation", "-framework CoreFoundation",
"-framework Foundation", "-framework Foundation",
"-framework OpenGLES", "-framework OpenGLES",
"-framework UIKit",
"-framework QuartzCore",
} }
configuration { "qnx*" } configuration { "qnx*" }

View file

@ -35,10 +35,19 @@ namespace bgfx
#if BX_PLATFORM_ANDROID #if BX_PLATFORM_ANDROID
::ANativeWindow* g_bgfxAndroidWindow = NULL; ::ANativeWindow* g_bgfxAndroidWindow = NULL;
void androidSetWindow(ANativeWindow* _window) void androidSetWindow(::ANativeWindow* _window)
{ {
g_bgfxAndroidWindow = _window; g_bgfxAndroidWindow = _window;
} }
#elif BX_PLATFORM_IOS
void* g_bgfxEaglContext = NULL;
void* g_bgfxEaglLayer = NULL;
void iosSetEaglContext(void* _context, void* _layer)
{
g_bgfxEaglContext = _context;
g_bgfxEaglLayer = _layer;
}
#elif BX_PLATFORM_OSX #elif BX_PLATFORM_OSX
void* g_bgfxNSWindow = NULL; void* g_bgfxNSWindow = NULL;
@ -638,7 +647,7 @@ namespace bgfx
s_threadIndex = BGFX_MAIN_THREAD_MAGIC; s_threadIndex = BGFX_MAIN_THREAD_MAGIC;
// On NaCl renderer is on the main thread. // On NaCl renderer is on the main thread.
s_ctx.init(!BX_PLATFORM_NACL); s_ctx.init(!BX_PLATFORM_NACL && !BX_PLATFORM_IOS);
} }
void shutdown() void shutdown()

View file

@ -156,6 +156,9 @@ namespace bgfx
{ {
#if BX_PLATFORM_ANDROID #if BX_PLATFORM_ANDROID
extern ::ANativeWindow* g_bgfxAndroidWindow; extern ::ANativeWindow* g_bgfxAndroidWindow;
#elif BX_PLATFORM_IOS
extern void* g_bgfxEaglContext;
extern void* g_bgfxEaglLayer;
#elif BX_PLATFORM_OSX #elif BX_PLATFORM_OSX
extern void* g_bgfxNSWindow; extern void* g_bgfxNSWindow;
#elif BX_PLATFORM_WINDOWS #elif BX_PLATFORM_WINDOWS

42
src/glcontext_eagl.h Executable file
View file

@ -0,0 +1,42 @@
/*
* Copyright 2011-2013 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#ifndef __GLCONTEXT_EAGL_H__
#define __GLCONTEXT_EAGL_H__
#if BX_PLATFORM_IOS
namespace bgfx
{
struct GlContext
{
GlContext()
: m_context(0)
{
}
void create(uint32_t _width, uint32_t _height);
void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync);
void swap();
void import();
bool isValid() const
{
return 0 != m_context;
}
void* m_view;
void* m_context;
GLuint m_fbo;
GLuint m_colorRbo;
GLuint m_depthRbo;
};
} // namespace bgfx
#endif // BX_PLATFORM_IOS
#endif // __GLCONTEXT_EAGL_H__

89
src/glcontext_eagl.mm Normal file
View file

@ -0,0 +1,89 @@
/*
* Copyright 2011-2013 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "bgfx_p.h"
#if BX_PLATFORM_IOS && (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGLES3|BGFX_CONFIG_RENDERER_OPENGL)
# include <UIKit/UIKit.h>
# include <QuartzCore/CAEAGLLayer.h>
# include "renderer_gl.h"
namespace bgfx
{
void GlContext::create(uint32_t _width, uint32_t _height)
{
EAGLContext* context = (EAGLContext*)g_bgfxEaglContext;
CAEAGLLayer* layer = (CAEAGLLayer*)g_bgfxEaglLayer;
[EAGLContext setCurrentContext:context];
m_context = g_bgfxEaglContext;
GL_CHECK(glGenFramebuffers(1, &m_fbo) );
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo) );
GL_CHECK(glGenRenderbuffers(1, &m_colorRbo) );
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_colorRbo) );
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer];
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colorRbo) );
GLint width;
GLint height;
GL_CHECK(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width) );
GL_CHECK(glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height) );
BX_TRACE("Screen size: %d x %d", width, height);
GL_CHECK(glGenRenderbuffers(1, &m_depthRbo) );
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_depthRbo) );
GL_CHECK(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height) );
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthRbo) );
BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)
, "glCheckFramebufferStatus failed 0x%08x"
, glCheckFramebufferStatus(GL_FRAMEBUFFER)
);
}
void GlContext::destroy()
{
if (0 != m_fbo)
{
GL_CHECK(glDeleteFramebuffers(1, &m_fbo) );
m_fbo = 0;
}
if (0 != m_colorRbo)
{
GL_CHECK(glDeleteRenderbuffers(1, &m_colorRbo) );
m_colorRbo = 0;
}
if (0 != m_depthRbo)
{
GL_CHECK(glDeleteRenderbuffers(1, &m_depthRbo) );
m_depthRbo = 0;
}
}
void GlContext::resize(uint32_t _width, uint32_t _height, bool _vsync)
{
BX_TRACE("resize context");
}
void GlContext::swap()
{
EAGLContext* context = (EAGLContext*)m_context;
[EAGLContext setCurrentContext:context];
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_colorRbo) );
[context presentRenderbuffer:GL_RENDERBUFFER];
}
void GlContext::import()
{
}
} // namespace bgfx
#endif // BX_PLATFORM_IOS && (BGFX_CONFIG_RENDERER_OPENGLES2|BGFX_CONFIG_RENDERER_OPENGLES3|BGFX_CONFIG_RENDERER_OPENGL)

View file

@ -16,18 +16,18 @@ namespace bgfx
: m_context(0) : m_context(0)
{ {
} }
void create(uint32_t _width, uint32_t _height); void create(uint32_t _width, uint32_t _height);
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
void swap(); void swap();
void import(); void import();
bool isValid() const bool isValid() const
{ {
return 0 != m_context; return 0 != m_context;
} }
void* m_view; void* m_view;
void* m_context; void* m_context;
}; };

View file

@ -282,6 +282,8 @@ namespace bgfx
} }
#endif // BGFX_CONFIG_RENDERER_OPENGL #endif // BGFX_CONFIG_RENDERER_OPENGL
extern GLuint m_backBufferFbo;
struct RendererContext struct RendererContext
{ {
RendererContext() RendererContext()
@ -428,6 +430,10 @@ namespace bgfx
if (!m_glctx.isValid() ) if (!m_glctx.isValid() )
{ {
m_glctx.create(_width, _height); m_glctx.create(_width, _height);
#if BX_PLATFORM_IOS
// BK - Temp, need to figure out how to deal with FBO created by context.
m_backBufferFbo = m_glctx.m_fbo;
#endif // BX_PLATFORM_IOS
} }
else else
{ {
@ -537,7 +543,7 @@ namespace bgfx
void init() void init()
{ {
m_glctx.create(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT); setRenderContextSize(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT);
m_vendor = getGLString(GL_VENDOR); m_vendor = getGLString(GL_VENDOR);
m_renderer = getGLString(GL_RENDERER); m_renderer = getGLString(GL_RENDERER);
@ -2427,6 +2433,7 @@ namespace bgfx
s_drawArraysInstanced = stubDrawArraysInstanced; s_drawArraysInstanced = stubDrawArraysInstanced;
s_drawElementsInstanced = stubDrawElementsInstanced; s_drawElementsInstanced = stubDrawElementsInstanced;
# if !BX_PLATFORM_IOS
if (s_extension[Extension::ARB_instanced_arrays].m_supported if (s_extension[Extension::ARB_instanced_arrays].m_supported
|| s_extension[Extension::ANGLE_instanced_arrays].m_supported) || s_extension[Extension::ANGLE_instanced_arrays].m_supported)
{ {
@ -2439,6 +2446,7 @@ namespace bgfx
s_drawElementsInstanced = glDrawElementsInstanced; s_drawElementsInstanced = glDrawElementsInstanced;
} }
} }
# endif // !BX_PLATFORM_IOS
#endif // !BGFX_CONFIG_RENDERER_OPENGLES3 #endif // !BGFX_CONFIG_RENDERER_OPENGLES3
if (s_renderCtx.m_vaoSupport) if (s_renderCtx.m_vaoSupport)
@ -2628,7 +2636,7 @@ namespace bgfx
void Context::rendererSetMarker(const char* _marker, uint32_t /*_size*/) void Context::rendererSetMarker(const char* _marker, uint32_t /*_size*/)
{ {
GREMEDY_SETMARKER(_marker); GREMEDY_SETMARKER(_marker);
} }
void Context::rendererSubmit() void Context::rendererSubmit()
@ -2639,7 +2647,7 @@ namespace bgfx
GL_CHECK(glBindVertexArray(defaultVao) ); GL_CHECK(glBindVertexArray(defaultVao) );
} }
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, s_renderCtx.m_backBufferFbo) );
s_renderCtx.updateResolution(m_render->m_resolution); s_renderCtx.updateResolution(m_render->m_resolution);

View file

@ -66,9 +66,28 @@
#elif BGFX_CONFIG_RENDERER_OPENGLES2 || BGFX_CONFIG_RENDERER_OPENGLES3 #elif BGFX_CONFIG_RENDERER_OPENGLES2 || BGFX_CONFIG_RENDERER_OPENGLES3
# if BGFX_CONFIG_RENDERER_OPENGLES2 # if BGFX_CONFIG_RENDERER_OPENGLES2
# include <GLES2/gl2platform.h> # if BX_PLATFORM_IOS
# include <GLES2/gl2.h> # include <OpenGLES/ES2/gl.h>
# include <GLES2/gl2ext.h> # include <OpenGLES/ES2/glext.h>
typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
typedef void (GL_APIENTRYP PFLGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
typedef void (GL_APIENTRYP PFLGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
//#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
#define GL_SAMPLER_3D_OES 0x8B5F
#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
# else
# include <GLES2/gl2platform.h>
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
# endif // BX_PLATFORM_
# define glProgramBinary glProgramBinaryOES # define glProgramBinary glProgramBinaryOES
# define glGetProgramBinary glGetProgramBinaryOES # define glGetProgramBinary glGetProgramBinaryOES
# define glBindVertexArray glBindVertexArrayOES # define glBindVertexArray glBindVertexArrayOES
@ -214,7 +233,7 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b
#elif BX_PLATFORM_OSX #elif BX_PLATFORM_OSX
# include "glcontext_nsgl.h" # include "glcontext_nsgl.h"
#elif BX_PLATFORM_IOS #elif BX_PLATFORM_IOS
# include "glcontext_ios.h" # include "glcontext_eagl.h"
#endif // BX_PLATFORM_ #endif // BX_PLATFORM_
#if BGFX_CONFIG_DEBUG_GREMEDY && (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX) #if BGFX_CONFIG_DEBUG_GREMEDY && (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX)

View file

@ -345,6 +345,14 @@ inline uint32_t rgbaToAbgr(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
; ;
} }
struct GroupSortByMaterial
{
bool operator()(const Group& _lhs, const Group& _rhs)
{
return _lhs.m_material < _rhs.m_material;
}
};
int main(int _argc, const char* _argv[]) int main(int _argc, const char* _argv[])
{ {
bx::CommandLine cmdLine(_argc, _argv); bx::CommandLine cmdLine(_argc, _argv);
@ -635,14 +643,6 @@ int main(int _argc, const char* _argv[])
parseElapsed += now; parseElapsed += now;
int64_t convertElapsed = -now; int64_t convertElapsed = -now;
struct GroupSortByMaterial
{
bool operator()(const Group& _lhs, const Group& _rhs)
{
return _lhs.m_material < _rhs.m_material;
}
};
std::sort(groups.begin(), groups.end(), GroupSortByMaterial() ); std::sort(groups.begin(), groups.end(), GroupSortByMaterial() );
bool hasColor = false; bool hasColor = false;