off-screen

virtual canvas putimagedata not working

青春壹個敷衍的年華 提交于 2019-12-02 18:58:20
问题 Am new to concept of virtual canvas, any idea why the below code does not work? <script type="text/javascript"> $(document).ready(function () { var c1 = document.createElement('canvas'); var ctx1 = c1.getContext("2d"); var c2 = document.getElementById('Canvas2'); var ctx2 = c2.getContext("2d"); c1.width = c2.width; c1.height = c2.height; img1 = new Image(); img1.src = 'A1.png'; img1.onload = function () { ctx1.drawImage(this, 0, 0); }; imgdata = ctx1.getImageData(0, 0, c2.width, c2.height);

virtual canvas putimagedata not working

我是研究僧i 提交于 2019-12-02 08:06:50
Am new to concept of virtual canvas, any idea why the below code does not work? <script type="text/javascript"> $(document).ready(function () { var c1 = document.createElement('canvas'); var ctx1 = c1.getContext("2d"); var c2 = document.getElementById('Canvas2'); var ctx2 = c2.getContext("2d"); c1.width = c2.width; c1.height = c2.height; img1 = new Image(); img1.src = 'A1.png'; img1.onload = function () { ctx1.drawImage(this, 0, 0); }; imgdata = ctx1.getImageData(0, 0, c2.width, c2.height); ctx2.putImageData(imgdata, 0, 0); }); </script> <canvas id="Canvas2" style="display:block;position

OpenGL offscreen render

穿精又带淫゛_ 提交于 2019-12-01 14:39:00
I have an application that creates a 3D model and exports an image from that. I use this example to do it: #include <windows.h> #include <GL\GL.h> #include <GL\glu.h> #include <GL\glut.h> #include <opencv2\highgui.hpp> GLfloat light_diffuse[] = { 1.0, 0.0, 0.0, 1.0 }; /* Red diffuse light. */ GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; /* Infinite light location. */ GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */ { -1.0, 0.0, 0.0 },{ 0.0, 1.0, 0.0 },{ 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 },{ 0.0, 0.0, 1.0 },{ 0.0, 0.0, -1.0 } }; GLint faces[6][4] = { /* Vertex indices for the

OpenGL offscreen render

让人想犯罪 __ 提交于 2019-12-01 12:19:19
问题 I have an application that creates a 3D model and exports an image from that. I use this example to do it: #include <windows.h> #include <GL\GL.h> #include <GL\glu.h> #include <GL\glut.h> #include <opencv2\highgui.hpp> GLfloat light_diffuse[] = { 1.0, 0.0, 0.0, 1.0 }; /* Red diffuse light. */ GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; /* Infinite light location. */ GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */ { -1.0, 0.0, 0.0 },{ 0.0, 1.0, 0.0 },{ 1.0, 0.0, 0.0 }, { 0

Easiest way for offscreen rendering with QOpenGLWidget

老子叫甜甜 提交于 2019-11-28 09:33:47
I have a hidden QOpenGLWidget (Qt 5.4.2, NOT QGLWidget) and I want to basically continually do grab() or grabFramebuffer() to get its content (and write it to disk). The widget renders fine when visible, but does not when hidden. If I do a show() followed by a hide() call it works. This seems strange because QOpenGLWidget does internally already render to a framebuffer according to the docs. What is the easiest way to achieve this (if possible without creating another framebuffer)? Bonus points for being able to capture an offscreen QGraphicsView using an QOpenGLWidget as its viewport with

UIView: how to do non-destructive drawing?

拈花ヽ惹草 提交于 2019-11-28 05:28:34
My original question: I'm creating a simple drawing application and need to be able to draw over existing, previously drawn content in my drawRect . What is the proper way to draw on top of existing content without entirely replacing it? Based on answers received here and elsewhere, here is the deal. You should be prepared to redraw the entire rectangle whenever drawRect is called. You cannot prevent the contents from being erased by doing the following: [self setClearsContextBeforeDrawing: NO]; This is merely a hint to the graphics engine that there is no point in having it pre-clear the view

Creating OpenGL context without window

夙愿已清 提交于 2019-11-27 23:37:29
I'm trying to figure out what is the simplest way to create a windowless OpenGL program for offscreen rendering. Currently I use this, and it works fine so far: (error checks removed here for clarity) BOOL create_opengl_context(){ GLuint PixelFormat; static PIXELFORMATDESCRIPTOR pfd; hDC = GetDC(NULL); PixelFormat = ChoosePixelFormat(hDC, &pfd); SetPixelFormat(hDC, PixelFormat, &pfd); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); } Is this safe to use? What is the "standard" way to create a windowless OpenGL program? Edit: I'm using FBO for the offscreen rendering. The old method for

Easiest way for offscreen rendering with QOpenGLWidget

前提是你 提交于 2019-11-27 03:00:44
问题 I have a hidden QOpenGLWidget (Qt 5.4.2, NOT QGLWidget) and I want to basically continually do grab() or grabFramebuffer() to get its content (and write it to disk). The widget renders fine when visible, but does not when hidden. If I do a show() followed by a hide() call it works. This seems strange because QOpenGLWidget does internally already render to a framebuffer according to the docs. What is the easiest way to achieve this (if possible without creating another framebuffer)? Bonus

UIView: how to do non-destructive drawing?

霸气de小男生 提交于 2019-11-27 00:57:13
问题 My original question: I'm creating a simple drawing application and need to be able to draw over existing, previously drawn content in my drawRect . What is the proper way to draw on top of existing content without entirely replacing it? Based on answers received here and elsewhere, here is the deal. You should be prepared to redraw the entire rectangle whenever drawRect is called. You cannot prevent the contents from being erased by doing the following: [self setClearsContextBeforeDrawing:

Creating OpenGL context without window

孤者浪人 提交于 2019-11-26 21:31:13
问题 I'm trying to figure out what is the simplest way to create a windowless OpenGL program for offscreen rendering. Currently I use this, and it works fine so far: (error checks removed here for clarity) BOOL create_opengl_context(){ GLuint PixelFormat; static PIXELFORMATDESCRIPTOR pfd; hDC = GetDC(NULL); PixelFormat = ChoosePixelFormat(hDC, &pfd); SetPixelFormat(hDC, PixelFormat, &pfd); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); } Is this safe to use? What is the "standard" way to