This commit is contained in:
Joshua Granick
2014-06-09 16:03:20 -07:00
parent e491460630
commit 78bcad8f95
7 changed files with 33 additions and 15 deletions

View File

@@ -45,6 +45,8 @@ class RenderEventManager {
}
Renderer.flip ();
}

View File

@@ -109,7 +109,7 @@ namespace lime {
value lime_renderer_flip (value renderer) {
((Renderer*)(intptr_t)renderer)->Flip ();
((Renderer*)(intptr_t)val_int (renderer))->Flip ();
return alloc_null ();
}

View File

@@ -9,9 +9,19 @@ namespace lime {
SDLRenderer::SDLRenderer (Window* window) {
currentWindow = window;
sdlRenderer = SDL_CreateRenderer (((SDLWindow*)window)->sdlWindow, -1, SDL_RENDERER_ACCELERATED);
sdlWindow = ((SDLWindow*)window)->sdlWindow;
OpenGLBindings::Init ();
if (OpenGLBindings::Init ()) {
SDL_GLContext context = SDL_GL_CreateContext (sdlWindow);
if (context) {
SDL_GL_MakeCurrent (sdlWindow, context);
}
}
}
@@ -25,7 +35,7 @@ namespace lime {
void SDLRenderer::Flip () {
SDL_RenderPresent (sdlRenderer);
SDL_GL_SwapWindow (sdlWindow);
}

View File

@@ -18,7 +18,7 @@ namespace lime {
virtual void Flip ();
SDL_Renderer* sdlRenderer;
SDL_Window* sdlWindow;
};

View File

@@ -1,5 +1,4 @@
#include "SDLWindow.h"
#include <stdio.h>
namespace lime {
@@ -8,7 +7,7 @@ namespace lime {
SDLWindow::SDLWindow (Application* application) {
currentApplication = application;
sdlWindow = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, 0);
sdlWindow = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_OPENGL);
}

View File

@@ -4,6 +4,12 @@
#include "OpenGLBindings.h"
#include <string>
#ifdef NEED_EXTENSIONS
#define DEFINE_EXTENSION
#include "OpenGLExtensions.h"
#undef DEFINE_EXTENSION
#endif
#ifdef HX_LINUX
#include <dlfcn.h>
#endif
@@ -41,7 +47,7 @@ namespace lime {
value lime_gl_version() {
const char* gl_ver = (const char*)glGetString(GL_VERSION);
const char* gl_sl = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
const char* gl_ren = (const char*)glGetString(GL_RENDERER);
@@ -1019,7 +1025,7 @@ namespace lime {
value lime_gl_create_shader(value inType) {
return alloc_int(glCreateShader(val_int(inType)));
} DEFINE_PRIM(lime_gl_create_shader,1);
@@ -1825,6 +1831,7 @@ namespace lime {
bool OpenGLBindings::initialized = false;
void *OpenGLBindings::handle = 0;
bool OpenGLBindings::Init () {
@@ -1837,12 +1844,12 @@ namespace lime {
#ifdef HX_LINUX
handle = dlopen ("libGL.so.1", RTLD_NOW|RTLD_GLOBAL);
OpenGLBindings::handle = dlopen ("libGL.so.1", RTLD_NOW|RTLD_GLOBAL);
if (!handle)
handle = dlopen ("libGL.so", RTLD_NOW|RTLD_GLOBAL);
if (!OpenGLBindings::handle)
OpenGLBindings::handle = dlopen ("libGL.so", RTLD_NOW|RTLD_GLOBAL);
if (!handle) {
if (!OpenGLBindings::handle) {
//printf ("Could not load %s (%s)\n",path, dlerror());
result = false;

View File

@@ -15,10 +15,10 @@
#ifdef DECLARE_EXTENSION
namespace lime { void *OpenGLBindings::handle; }
//namespace lime { void *OpenGLBindings::handle = 0; }
#define OGL_EXT(func,ret,args) \
namespace lime { ret (CALLING_CONVENTION *func)args; }
namespace lime { extern ret (CALLING_CONVENTION *func)args; }
#elif defined(DEFINE_EXTENSION)