Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add support for a different default renderer #1967

Closed
wants to merge 1 commit into from

1 participant

@underdoeg
Collaborator

I recently wanted to use something else than OpenGL in OF and didn't see a way to not automatically initialize the opengl renderer and glew. This PR introduces different versions of ofSetupOpenGL so a default renderer can be passed and an optional bool whether to initialize glew or not. Personally I think this function is now a little bit too long. But ways how an OF app could also be initialized is a completely different topic...

@underdoeg underdoeg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2013
  1. add support for windowless of app

    Philip Whitfield authored
This page is out of date. Refresh to see the latest.
View
26 libs/openFrameworks/app/ofAppRunner.cpp
@@ -44,6 +44,10 @@ void ofSetupOpenGL(ofAppBaseWindow * windowPtr, int w, int h, int screenMode){
ofSetupOpenGL(ofPtr<ofAppBaseWindow>(windowPtr,std::ptr_fun(noopDeleter)),w,h,screenMode);
}
+void ofSetupOpenGL(ofAppBaseWindow * windowPtr, int w, int h, int screenMode, ofBaseRenderer* renderer, bool initGlew){
+ ofSetupOpenGL(ofPtr<ofAppBaseWindow>(windowPtr,std::ptr_fun(noopDeleter)),w,h,screenMode, ofPtr<ofBaseRenderer>(renderer), initGlew);
+}
+
void ofExitCallback();
@@ -83,24 +87,30 @@ void ofRunApp(ofBaseApp * OFSA){
//--------------------------------------
void ofSetupOpenGL(ofPtr<ofAppBaseWindow> windowPtr, int w, int h, int screenMode){
+ ofSetupOpenGL(windowPtr, w, h, screenMode, ofPtr<ofBaseRenderer>(new ofGLRenderer(false)));
+}
+
+//--------------------------------------
+void ofSetupOpenGL(ofPtr<ofAppBaseWindow> windowPtr, int w, int h, int screenMode, ofPtr<ofBaseRenderer> rendererPtr, bool initGlew){
window = windowPtr;
window->setupOpenGL(w, h, screenMode);
#ifndef TARGET_OPENGLES
- glewExperimental = GL_TRUE;
- GLenum err = glewInit();
- if (GLEW_OK != err)
- {
- /* Problem: glewInit failed, something is seriously wrong. */
- ofLog(OF_LOG_ERROR, "Error: %s\n", glewGetErrorString(err));
+ if(initGlew){
+ glewExperimental = GL_TRUE;
+ GLenum err = glewInit();
+ if (GLEW_OK != err)
+ {
+ /* Problem: glewInit failed, something is seriously wrong. */
+ ofLog(OF_LOG_ERROR, "Error: %s\n", glewGetErrorString(err));
+ }
}
#endif
- ofSetCurrentRenderer(ofPtr<ofBaseRenderer>(new ofGLRenderer(false)));
+ ofSetCurrentRenderer(rendererPtr);
//Default colors etc are now in ofGraphics - ofSetupGraphicDefaults
//ofSetupGraphicDefaults();
}
-
//--------------------------------------
void ofSetupOpenGL(int w, int h, int screenMode){
#ifdef TARGET_OF_IPHONE
View
3  libs/openFrameworks/app/ofAppRunner.h
@@ -7,9 +7,12 @@
class ofAppBaseWindow;
class ofBaseApp;
+class ofBaseRenderer;
+void ofSetupOpenGL(ofPtr<ofAppBaseWindow> windowPtr, int w, int h, int screenMode, ofPtr<ofBaseRenderer> rendererPtr, bool initGlew = true); //to pass a different renderer than opengl
void ofSetupOpenGL(ofPtr<ofAppBaseWindow> windowPtr, int w, int h, int screenMode); // sets up the opengl context!
void ofSetupOpenGL(ofAppBaseWindow * windowPtr, int w, int h, int screenMode); // this is deprecated, use an ofPtr
+void ofSetupOpenGL(ofAppBaseWindow * windowPtr, int w, int h, int screenMode, ofBaseRenderer* renderer, bool initGlew = true); //this should also be deprecated but it is in here for the sake of completion
void ofSetupOpenGL(int w, int h, int screenMode); // sets up the opengl context!
void ofRunApp(ofPtr<ofBaseApp> OFSA); // this is for deprecated, use an ofPtr
Something went wrong with that request. Please try again.