graphics

Drawing into CGImageRef

冷暖自知 提交于 2019-12-18 13:24:03
问题 I want to create a CGImageRef and draw points to it. What context to use to create an empty CGImageRef and be able to draw onto it. CGContextRef or CGBitmapContextRef? If you can provide code to create an empty CGImageRef image and draw to it I would appreciate. 回答1: #define HIRESDEVICE (((int)rintf([[[UIScreen mainScreen] currentMode] size].width/[[UIScreen mainScreen] bounds].size.width )>1)) - (CGImageRef) blerg { CGFloat imageScale = (CGFloat)1.0; CGFloat width = (CGFloat)180.0; CGFloat

What are the steps necessary to render my scene to a Framebuffer Object(FBO) and then render that FBO to the screen?

拈花ヽ惹草 提交于 2019-12-18 13:13:56
问题 I've got a fairly complicated scene with many GL_POINTS that I need to render. The scene will be largely static, so I'd like to render it to a Framebuffer Object and then only update that FBO when my scene actually changes. I'd then like to render the FBO to the screen each frame. I've found examples that render an FBO into a texture. I've found examples that render an FBO into a RenderBuffer (still not quite sure what that is). I'm not sure what the steps are to achieve this. Do I need to

Live Wallpaper Tutorial

妖精的绣舞 提交于 2019-12-18 12:42:10
问题 I am trying to do the following from a live wallpaper tutorial I found here. /** * Do the actual drawing stuff */ private void doDraw(Canvas canvas) { Bitmap b = BitmapFactory.decodeResource(context.getResources(), IMAGES[current]); canvas.drawColor(Color.BLACK); canvas.drawBitmap(b, 0, 0, null); Log.d(TAG, "Drawing finished."); } /** * Update the animation, sprites or whatever. * If there is nothing to animate set the wait * attribute of the thread to true */ private void updatePhysics() { /

How to Solve Rendering Artifact in Blinn/Loop's Resolution Independent Curve Rendering?

ぐ巨炮叔叔 提交于 2019-12-18 12:38:49
问题 In implementing Blinn/Loop's algorithm on curve rendering, I realize there is a special case on Loop Curve Type. As described in their paper (subsection 4.4, page 6-7), they said the curve should be divided into two but I'm really confused how to obtain the intersection point. Here's my rendering result: As stated in the paper, this artifact occurs when either td/sd or te/se lie in between value [0, 1]. My source code: ... case CURVE_TYPE_LOOP: td = d2 + sqrt(4.0 * d1 * d3 - 3.0 * d2 *d2); sd

Formula for a orthogonal projection matrix?

青春壹個敷衍的年華 提交于 2019-12-18 12:31:29
问题 I've been looking around a bit and can't seem to find just what I"m looking for. I've found "canonical formulas," but what's the best way to use these? Do I have to scale every single vertex down? Or is there a better way? A formula would really help me out, but I'm also looking for an explanation about the near and far z planes relative the viewer's position 回答1: Here is a reasonable source that derives an orthogonal project matrix: Consider a few points: First, in eye space, your camera is

How does GUI output work from application to hardware level?

大城市里の小女人 提交于 2019-12-18 12:27:45
问题 I am getting into GUI programming and did some research. Now not everything is clear to me. If I would use GTK+ as toolkit, how does it communicate with the graphics card? On a Linux system I suppose it would be GTK --> X Server --(OpenGL)--> graphics card. Is this right? I read that some GUIs directly draw OpenGL (e.g. Blender3D), so how do other apps draw their GUIs? If the only APIs (that i know of) for graphics cards is Direct3D and OpenGL, what is the distinction between software

How do I visualize audio data?

独自空忆成欢 提交于 2019-12-18 12:24:40
问题 I would like to have something that looks something like this. Two different colors are not nessesary. (source: sourceforge.net) I already have the audio data (one sample/millisecond) from a stereo wav in two int arrays, one each for left and right channel. I have made a few attempts but they don't look anywhere near as clear as this, my attempts get to spikey or a compact lump. Any good suggestions? I'm working in c# but psuedocode is ok. Assume we have a function DrawLine(color, x1, y1, x2,

Is there some well-known algorithm which turns user's drawings into smoothed shapes?

拈花ヽ惹草 提交于 2019-12-18 12:24:05
问题 My requirements: A user should be able to draw something by hand. Then after he takes off his pen (or finger) an algorithm smooths and transforms it into some basic shapes. To get started I want to transform a drawing into a rectangle which resembles the original as much as possible. (Naturally this won't work if the user intentionally draws something else.) Right now I'm calculating an average x and y position, and I'm distinguishing between horizontal and vertical lines. But it's not yet a

Fatal error: Call to undefined function: imagecreate()

淺唱寂寞╮ 提交于 2019-12-18 12:03:58
问题 I'm trying to put some graphics on a web page and at my prototype at the computer it's all working fine at the localhost. But now I uploaded the files to a server and I'm having a problem to plot some graphics. In my computer they are plotted, but on the server they are not. I'm getting this error Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248 Line 248 $this->img = ImageCreate($this->image_width, $this->image_height); I'm using phplot, and I

Easy way to display a continuously updating image in C/Linux

旧巷老猫 提交于 2019-12-18 11:57:53
问题 I'm a scientist who is quite comfortable with C for numerical computation, but I need some help with displaying the results. I want to be able to display a continuously updated bitmap in a window, which is calculated from realtime data. I'd like to be able to update the image quite quickly (e.g. faster than 1 frame/second, preferably 100 fps). For example: char image_buffer[width*height*3];//rgb data initializewindow(); for (t=0;t<t_end;t++) { getdata(data);//get some realtime data docalcs