graphics

Slow map in java

心已入冬 提交于 2019-12-23 01:13:50
问题 I'm making a game in java, is a rpg, however, only with the map the game is slow. The map is made ​​in TiledMap Editor, therefore, an XML that is read and loaded into an ArrayList. My PC is a dual-core 3.0, 4GB RAM, 1GB Video. The do the rendering is done as follows: //method of tileset class public void loadTileset(){ positions = new int[1 + tilesX * tilesY][2]; int yy = 0; int xx = 0; int index = 0; // save the initial x and y point of each tile in an array named positions // positions

How to render a WPF Hwnd with Graphics Object

一曲冷凌霜 提交于 2019-12-22 22:29:07
问题 After the RenderTargetBitmap is much too slow. I tried a different approach. Unfortunately my attempt was not successful. Hopefully some of you guys can figure out why this code is not working. var myPopup = new Popup(); var child = new Grid() { Background = new VisualBrush(myVisual)}; myPopup.StaysOpen = false; myPopup.Child = child; myPopup.IsOpen = false; myPopup.Opened += (sender, args) => { var source = ((HwndSource)PresentationSource.FromVisual(myPopup.Child)); var image = new Bitmap

Rotate Bitmap (Rectangle) While Maintining Area

徘徊边缘 提交于 2019-12-22 18:39:09
问题 How can I rotate an Bitmap a given number of degrees while maintaining the area of the original bitmap. ie, what I rotate a bitmap of Width:100,Height:200, my end result will be a bigger image but the rotated portion will still have an area of 100*200 回答1: The graphics transform function is perfect for this. Create a new bitmap of the size you want, create a graphics object based off that bitmap, apply the transform then draw onto the canvas (graphics.drawimage(original_image)). Here is a

R: display values in levelplot stratified by a grouping variable

霸气de小男生 提交于 2019-12-22 18:32:29
问题 In this following example, I need to display the values for each of the cells in each of the panels stratified by the grouping variable class : library("lattice") x <- seq(pi/4, 5*pi, length.out=5) y <- seq(pi/4, 5*pi, length.out=5) r1 <- as.vector(sqrt(outer(x^2, y^2, "+"))) r2 <- as.vector(sqrt(outer(x^2, y^2, "/"))) grid1 <- grid2 <- expand.grid(x=x, y=y) grid1$z <- cos(r1^2)*exp(-r1/(pi^3)) grid2$z <- cos(r2^2)*exp(-r2/(pi^3)) grid <- rbind(grid1, grid2) grid$class <- c(rep("addition"

How Might I organize vertex data in WebGL for a frame-by-frame (very specific) animated program?

萝らか妹 提交于 2019-12-22 16:29:54
问题 I have been working on an animated graphics project with very specific requirements, and after quite a bit of searching and test coding, I have figured that I could take several approaches, but the Khronos and MDN documentation I have been reading coupled with other posts I have seen here don't answer all of my questions regarding my particular project. In the meantime, I have written short test programs (setting infrastructure for testing). Firstly, I should describe the project: The main

How do you represent a normal or texture coordinate using GLshorts?

纵饮孤独 提交于 2019-12-22 14:14:18
问题 A lot of suggestions on improving the performance in iPhone games revolve around sending less data to the GPU. The obvious suggestion is to use GLshorts instead of GLfloat wherever possible, such as for vertices, normals, or texture coordinates. What are the specifics when using a GLshort for a normal or a texture coordinate? Is it possible to represent a GLfloat texture coordinate of 0.5 when using a GLshort? If so, how do you do that? Would it just be SHRT_MAX/2? That is, does the range of

How do you represent a normal or texture coordinate using GLshorts?

▼魔方 西西 提交于 2019-12-22 14:12:07
问题 A lot of suggestions on improving the performance in iPhone games revolve around sending less data to the GPU. The obvious suggestion is to use GLshorts instead of GLfloat wherever possible, such as for vertices, normals, or texture coordinates. What are the specifics when using a GLshort for a normal or a texture coordinate? Is it possible to represent a GLfloat texture coordinate of 0.5 when using a GLshort? If so, how do you do that? Would it just be SHRT_MAX/2? That is, does the range of

Java color changing Graphics with Timer

两盒软妹~` 提交于 2019-12-22 13:59:20
问题 I want to draw a disc that changes colors twice a second. The disk is drawn on a DrawPanel which extends a JPanel and in the main method the DrawPanel is added to a frame. For the colorchanging I use a timer which works when I'm trying to change the background of the DrawPanel in the main method (what i commented out). Can someone tell me why it doesn't work for the Graphics g object or any other suggestions? I just copied the code from the main method and added it into the paintComponent()

Calculate the horizon of a curved face?

烂漫一生 提交于 2019-12-22 11:01:04
问题 I need to find the 2 points of the visual horizon , of a curved face. I have: XYZ of the 4 corner points XYZ of the 2 curved edge bezier points And I need to calculate either: XY of the horizon points XYZ of the horizon points 回答1: First off you have to convert your 3D beziers to 2D. If I remember right it's sufficient to project the curves just like you project 3D points for rendering. Afterwards you have to find the extrema of the curves. A small HowTo: Convert your bezier-curve from bezier

How to render an emoji with libgdx

柔情痞子 提交于 2019-12-22 10:49:57
问题 I have loaded a font with emoji support and I am trying to render a string with emoji's with libgdx. However, it renders the text, but not the emojis. Code Load Font FileHandle fontFile = Gdx.files.internal("path/to/file.ttf"); FreeTypeFontGenerator g = new FreeTypeFontGenerator(fontFile); FreeTypeFontGenerator.FreeTypeFontParameter p = new FreeTypeFontGenerator.FreeTypeFontParameter(); // Some config here with p BitmapFont emojiFont= g.generateFont(p); Render Font public static void