graphics

How can I draw a sprite in it's own class?

*爱你&永不变心* 提交于 2019-12-11 11:54:36
问题 I'm trying to program a game with a friend, and I'm very confused as to how to draw sprites. I can draw code in my Game1 class, below. namespace SweetGeorgiaBrown { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game { enum GameStates { TitleScreen, Overworld, Menu, Battle, GameOver }; GameStates gameState = GameStates.Battle; GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D dinoTex; Texture2D alienTex;

SDL_GL_SwapWindow bad performance

徘徊边缘 提交于 2019-12-11 11:45:38
问题 I did some performance testing and came up with this: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for(U32 i=0;i<objectList.length();++i) { PC d("draw"); VoxelObject& obj = *objectList[i]; glBindVertexArray(obj.vao); tmpM = usedView->projection * usedView->transform * obj.transform; glUniformMatrix4fv(shader.modelViewMatrixLoc, 1, GL_FALSE, tmpM.data()); //glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, typesheet.tbo); glUniform1i(shader.typesheetLoc, 0); glDrawArrays(GL

How to set repeating background image to a JPanel?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 11:09:25
问题 I want to set an image which repeats throughout the full width of the JPanel like we apply Background image to a DIV in CSS. How do I obtain that in swing for a JPanel? 回答1: Swing doesn't provide this functionality out of the box, so you will need to do it yourself... The overall process is relative simple, for (y = 0 to containerHeight) do for (x = 0 to containerWidth) do drawImage(tile, x, y) The fun part is knowing where and how to apply it. Take a look at: Performing Custom Painting 2D

Writing to the screen from the screen using BitBlt

ぐ巨炮叔叔 提交于 2019-12-11 11:07:33
问题 I'm trying to copy parts of the screen, modify them, and then copy those parts back to the screen. This is in windows, using C++. The general structure of my code looks like this: HDC hdcDesktop = GetDC(NULL); HDC hdcTemp = CreateCompatibleDC(hdcDesktop); BitBlt(hdcTemp, 0, 0, 100, 100, hdcDesktop, 100, 100, SRCCOPY); BitBlt(hdcDesktop, rand() % 1920, rand() % 1080, 100, 100, hdcTemp, 0, 0, SRCCOPY); This should copy a 100x100 portion of the screen starting at (100, 100) to some random part

how to capture the right click event using getMouse()

ぃ、小莉子 提交于 2019-12-11 10:53:40
问题 I am trying to use graphics.py to write a user graphics interface. The problem is that how can I capture the right click event? It seems that the function getMouse() could just returns where the mouse was left-clicked as a Point object. from graphics import * def main(): win = GraphWin("My Circle", 100, 100) c = Circle(Point(50,50), 10) c.draw(win) win.getMouse() # pause for click in window win.close() main() I want to know how can I capture the right-click event in the window, thanks. 回答1: I

Why does changing the graphics setting after doing so in the `LoadContent` method fail?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 10:45:19
问题 If I set the graphics settings in the Initialize method and then in the Update method, like so: protected override void Initialize() { graphics.ApplyChanges(); base.Initialize(); } protected override void Update(GameTime gameTime) { graphics.ApplyChanges(); base.Update(gameTime); } Everything is fine. However, when I move the code to my LoadContent method like so: protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); graphics.ApplyChanges(); } protected

Ray tracer reflections grainy

左心房为你撑大大i 提交于 2019-12-11 10:39:42
问题 I just implemented reflections in my ray tracer, here is the code that handles the reflections, however i have all my code uploaded to a github repository for better reading: Color finalColor = closestObjectMaterial.GetColor() * AMBIENTLIGHT; // Add ambient light to the calculation // Reflections if(closestObjectMaterial.GetSpecular() > 0 && closestObjectMaterial.GetSpecular() <= 1) { Vector scalar = closestObjectNormal * (closestObjectNormal.Dot(intersectingRayDir.Negative())); Vector

Direct2D - preserve the existing content and overwrite the new values

核能气质少年 提交于 2019-12-11 10:34:30
问题 I am planning to develop a XY Plotter for my application. To give some basic idea, how it should look like (of course the implementation would be different), please refer here and here. During the simulation (let's assume, it takes 4 hours to complete the simulation), on a fixed X axis, the new Y values should be (over)written. But, the problem with Direct2D is that, every time pRenderTarget->BeginDraw() is called, the existing Drawing(/Plot/BitMap/Image, etc) is deleted and a new image is

Gnuplot, how to invert x with y while plotting file data?

非 Y 不嫁゛ 提交于 2019-12-11 10:25:12
问题 I have a 'data.txt' file containing two columns and N rows, corresponding to N points, e.g. 0.2 0.3 0.4 0.6 0.1 0.7 0.9 0.6 If I use Gnuplot to plot data from this file, using the command plot "datafile.txt" with lp it plots every point in the default form (X, Y), that is Gnuplot interprets the first column as all the X values, and the second column as all the Y values. I would like to invert the meaning of X and Y. I would like to set Gnuplot this command: "Take the first column as Y, and

Button text disappearing with 4Gb Ram and IBM Java 1.5

别说谁变了你拦得住时间么 提交于 2019-12-11 10:14:50
问题 We have a very strange error occurring at a developer site which we are unable to replicate ourselves. A developer in Poland has recently upgraded his Windows XP Service Pack 3 machine to 4Gb of Ram When he did so he started experiencing graphical errors in java programs using IBM JDK 1.5 This errors only occur in IBM JDK 1.5 and not in any other version. The problem manifests itself when you create a button or control on a form and move the mouse over it. We have a test program import java