Shader optimization: Is a ternary operator equivalent to branching?

Actually this depends on the shader language one uses. In HLSL and Cg a ternary operator will never lead to branching. Instead both possible results are always evaluated and the not used one is being discarded. To quote the HLSL documentation: Unlike short-circuit evaluation of &&, ||, and ?: in C, HLSL expressions never short-circuit … Read more

How to recognize rectangles in this image?

Opencv (image processing and computer vision library written in c) has implementation for hough transform (the simple hough transform find lines in an image, while the generalized one finds more complex objects) so that could be a good start. For the rectangles which do have closed corners there are also corner detectors such as cornerHarris … Read more

How to use an arrow marker on an SVG element?

If you meant ‘how do I use an arrow marker on a <line> element?’ then here’s how you do that: <line x1=”100″ y1=”230″ x2=”300″ y2=”230″ marker-end=”url(#yourMarkerId)” stroke=”black” stroke-width=”10″/> Here’s a full example. And note that marker-end is a css property, so you can also put that part in a stylesheet if you want. If you … Read more

Java 2D Drawing Optimal Performance

A synthesis of the answers to this post, the answers to Consty’s, and my own research: What works: Use GraphicsConfiguration.createCompatibleImage to create images compatible with what you’re drawing on. This is absolutely essential! Use double-buffered drawing via Canvas.createBufferStrategy. Use -Dsun.java2d.opengl=True where available to speed up drawing. Avoid using transforms for scaling. Instead, cache scaled versions … Read more

Nvidia graphics driver causing noticeable frame stuttering

… or is there something I can do to fix it other telling people to disable Threaded “Optimization”? Yes. You can create custom “Application Profile” for your game using NVAPI and disable “Threaded Optimization” setting in it. There is a .PDF file on NVIDIA site with some help and code examples regarding NVAPI usage. In … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)