Help for create ofAppGLFWWindow transparency application

Hi,
I use this code to create a GLFW transparency application, and that work fine !

// g++ -o glfw_transparent glfw_transparent.cpp -lglfw -lGL
#include <GLFW/glfw3.h>
//========================================================================
int main( ){

  GLFWwindow* window;
  int windowSizeW = 640, windowSizeH = 480;
  // initialize the library
  if (!glfwInit())
    return -1;
		
  glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);

  // create a windowed mode window and its OpenGL context
  window = glfwCreateWindow(windowSizeW, windowSizeH, "Hello World", NULL, NULL);
  if (!window)
  {
    glfwTerminate();
    return -1;
  }

  // make the window's context current
  glfwMakeContextCurrent(window);

  // reset the window hints to default
  glfwDefaultWindowHints();

  // show the window
  glfwShowWindow(window);

  // Loop until the user closes the window
  while (!glfwWindowShouldClose(window))
  {
    // render
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_QUADS);
    glColor3f(0, 0, 1);
    glVertex3f(-0.5, -0.5, -1);
    glColor3f(0, 1, 0);
    glVertex3f(0.5, -0.5, -1);
    glColor3f(1, 0, 1);
    glVertex3f(0.5, 0.5, -1);
    glColor3f(1, 1, 0);
    glVertex3f(-0.5, 0.5, -1);
    glEnd();

    // swap front and back buffers
    glfwSwapBuffers(window);

    // poll for and process events
    glfwPollEvents();
  }

  glfwTerminate();
  
  return 0;
 }

But i can implement it for ofApp with ofAppGLFWWindow
i try to add in ofAppGLFWWindow.cpp to force it … but nothing
line 170 : glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);

and try this code for add settings but not working

int main( ){
  ofSetLogLevel(OF_LOG_VERBOSE);

  if(!glfwInit( )){
		ofLogError("ofAppGLFWWindow") << "couldn't init GLFW";
		return 0;
	}

	glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);

	ofGLFWWindowSettings settings;
  settings.setGLVersion(3,2);
	settings.decorated   = false;
	settings.setSize(600, 600);
	settings.windowMode = OF_WINDOW;
  settings.doubleBuffering = true;
  settings.resizable = false;
  settings.visible = true;

  ofCreateWindow(settings);	
  ofRunApp( new ofApp() );
}

Plz help me, thx

Hi @Christophe , I may not be of much help with this, but here are a couple of thoughts. There are a lot of calls to glfwWindowHint() in ofAppGLFWWindow::setup(). So you could look to see if the any of those glfwWindowHint() calls conflict with the one you want to use. And you could modify that function to see if it works. If it does, there is probably a better way to incorporate it than directly modifying the oF header. I wish I could be of more help with your question.

hi @TimChi, today at15h00 i WIN !!!
So i create a new instance of ofAppGLWWindow, modify it for add

glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);

and modify ::Draw() function with currentRenderer->clearAlpha();
and modify ::clearAlpha() function with comment glColorMask and modify clear color with alpha set to 0

Thx for your answers

2 Likes