Search Results

Search found 3807 results on 153 pages for 'draw'.

Page 1/153 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Unity3D draw call optimization : static batching VS manually draw mesh with MaterialPropertyBlock

    - by Heisenbug
    I've read Unity3D draw call batching documentation. I understood it, and I want to use it (or something similar) in order to optimize my application. My situation is the following: I'm drawing hundreds of 3d buildings. Each building can be represented using a Mesh (or a SubMesh for each building, but I don't thing this will affect performances) Each building can be textured with several combinations of texture patterns(walls, windows,..). Textures are stored into an Atlas for optimizaztion (see Texture2d.PackTextures) Texture mapping and facade pattern generation is done in fragment shader. The shader can be the same (except for few values) for all buildings, so I'd like to use a sharedMaterial in order to optimize parameters passed to the GPU. The main problem is that, even if I use an Atlas, share the material, and declare the objects as static to use static batching, there are few parameters(very fews, it could be just even a float I guess) that should be different for every draw call. I don't know exactly how to manage this situation using Unity3D. I'm trying 2 different solutions, none of them completely implemented. Solution 1 Build a GameObject for each building building (I don't like very much the overhead of a GameObject, anyway..) Prepare each GameObject to be static batched with StaticBatchingUtility.Combine. Pack all texture into an atlas Assign the parent game object of combined batched objects the Material (basically the shader and the atlas) Change some properties in the material before drawing an Object The problem is the point 5. Let's say I have to assign a different id to an object before drawing it, how can I do this? If I use a different material for each object I can't benefit of static batching. If I use a sharedMaterial and I modify a material property, all GameObjects will reference the same modified variable Solution 2 Build a Mesh for every building (sounds better, no GameObject overhead) Pack all textures into an Atlas Draw each mesh manually using Graphics.DrawMesh Customize each DrawMesh call using a MaterialPropertyBlock This would solve the issue related to slightly modify material properties for each draw call, but the documentation isn't clear on the following point: Does several consecutive calls to Graphic.DrawMesh with a different MaterialPropertyBlock would cause a new material to be instanced? Or Unity can understand that I'm modifying just few parameters while using the same material and is able to optimize that (in such a way that the big atlas is passed just once to the GPU)?

    Read the article

  • Efficient Way to Draw Grids in XNA

    - by sm81095
    So I am working on a game right now, using Monogame as my framework, and it has come time to render my world. My world is made up of a grid (think Terraria but top-down instead of from the side), and it has multiple layers of grids in a single world. Knowing how inefficient it is to call SpriteBatch.Draw() a lot of times, I tried to implement a system where the tile would only be drawn if it wasn't hidden by the layers above it. The problem is, I'm getting worse performance by checking if it's hidden than when I just let everything draw even if it's not visible. So my question is: how to I efficiently check if a tile is hidden to cut down on the draw() calls? Here is my draw code for a single layer, drawing floors, and then the tiles (which act like walls): public void Draw(GameTime gameTime) { int drawAmt = 0; int width = Tile.TILE_DIM; int startX = (int)_parent.XOffset; int startY = (int)_parent.YOffset; //Gets the starting tiles and the dimensions to draw tiles, so only onscreen tiles are drawn, allowing for the drawing of large worlds int tileDrawWidth = ((CIGame.Instance.Graphics.PreferredBackBufferWidth / width) + 4); int tileDrawHeight = ((CIGame.Instance.Graphics.PreferredBackBufferHeight / width) + 4); int tileStartX = (int)MathHelper.Clamp((-startX / width) - 2, 0, this.Width); int tileStartY = (int)MathHelper.Clamp((-startY / width) - 2, 0, this.Height); #region Draw Floors and Tiles CIGame.Instance.GraphicsDevice.SetRenderTarget(_worldTarget); CIGame.Instance.GraphicsDevice.Clear(Color.Black); CIGame.Instance.SpriteBatch.Begin(); //Draw floors for (int x = tileStartX; x < (int)MathHelper.Clamp(tileStartX + tileDrawWidth, 0, this.Width); x++) { for (int y = tileStartY; y < (int)MathHelper.Clamp(tileStartY + tileDrawHeight, 0, this.Height); y++) { //Check if this tile is hidden by layer above it bool visible = true; for (int i = this.LayerNumber; i <= _parent.ActiveLayer; i++) { if (this.LayerNumber != (_parent.Layers - 1) && (_parent.GetTileAt(x, y, i + 1).Opacity >= 1.0f || _parent.GetFloorAt(x, y, i + 1).Opacity >= 1.0f)) { visible = false; break; } } //Only draw if visible under the tile above it if (visible && this.GetTileAt(x, y).Opacity < 1.0f) { Texture2D tex = WorldTextureManager.GetFloorTexture((Floor)_floors[x, y]); Rectangle source = WorldTextureManager.GetSourceForIndex(((Floor)_floors[x, y]).GetTextureIndexFromSurroundings(x, y, this), tex); Rectangle draw = new Rectangle(startX + x * width, startY + y * width, width, width); CIGame.Instance.SpriteBatch.Draw(tex, draw, source, Color.White * ((Floor)_floors[x, y]).Opacity); drawAmt++; } } } //Draw tiles for (int x = tileStartX; x < (int)MathHelper.Clamp(tileStartX + tileDrawWidth, 0, this.Width); x++) { for (int y = tileStartY; y < (int)MathHelper.Clamp(tileStartY + tileDrawHeight, 0, this.Height); y++) { //Check if this tile is hidden by layers above it bool visible = true; for (int i = this.LayerNumber; i <= _parent.ActiveLayer; i++) { if (this.LayerNumber != (_parent.Layers - 1) && (_parent.GetTileAt(x, y, i + 1).Opacity >= 1.0f || _parent.GetFloorAt(x, y, i + 1).Opacity >= 1.0f)) { visible = false; break; } } if (visible) { Texture2D tex = WorldTextureManager.GetTileTexture((Tile)_tiles[x, y]); Rectangle source = WorldTextureManager.GetSourceForIndex(((Tile)_tiles[x, y]).GetTextureIndexFromSurroundings(x, y, this), tex); Rectangle draw = new Rectangle(startX + x * width, startY + y * width, width, width); CIGame.Instance.SpriteBatch.Draw(tex, draw, source, Color.White * ((Tile)_tiles[x, y]).Opacity); drawAmt++; } } } CIGame.Instance.SpriteBatch.End(); Console.WriteLine(drawAmt); CIGame.Instance.GraphicsDevice.SetRenderTarget(null); //TODO: Change to new rendertarget instead of null #endregion } So I was wondering if this is an efficient way, but I'm going about it wrongly, or if there is a different, more efficient way to check if the tiles are hidden. EDIT: For example of how much it affects performance: using a world with three layers, allowing everything to draw no matter what gives me 60FPS, but checking if its visible with all of the layers above it gives me only 20FPS, while checking only the layer immediately above it gives me a fluctuating FPS between 30 and 40FPS.

    Read the article

  • Software to draw 3D geometry

    - by ilovekonoka
    Does anyone know any software that can draw 3D geometry like figures usually seen in computer graphics papers and articles(example: http://www.iquilezles.org/www/articles/sphereao/sphereao.htm)? I know it can be done in Inskcape or Illustrator but I'm not sure they're the only choices.

    Read the article

  • Copy all text in a LibreOffice Draw drawing

    - by harbichidian
    I have a large flowchart, created in LibreOffice Draw (3.3.1), that I would like to copy all of the text from. I do not need, nor care about the order or structure, I just need all of the text from within the blocks. I can't seem to find any way to export without turning it into an image, and none of the "Paste Special" options allow me to get unformatted text. Is there a way to do this without retyping everything?

    Read the article

  • How to draw a transparent stroke (or anyway clear part of an image) on the iPhone

    - by devguy
    I have a small app that allows the user to draw on the screen with the finger. Yes, nothing original, but it's part of something larger :) I have a UIImageView where the user draws, by creating a CGContextRef and the various CG draw functions. I primarily draw strokes/lines with the function CGContextAddLineToPoint Now the problem is this: the user can draw lines of various colors. I want to give him the ability to use a "rubber" tool to delete some part of the image drawn so far, with the finger. I initially did this by using a white color for the stroke (set with the CGContextSetRGBStrokeColor function) but it did't work out...because I discovered later that the UIImage on the UIImageView was actually with transparent background, not white...so I would end up with a transparent image with white lines on it! Is there anyway to set a "transparent" stroke color...or is there any other way to clear the content of the CGContextRef under the user's finger, when he moves it? Thanks

    Read the article

  • draw line with php using coordinates from txt file

    - by netmajor
    I have file A2.txt with coordinate x1,y1,x2,y2 in every line like below : 204 13 225 59 225 59 226 84 226 84 219 111 219 111 244 192 244 192 236 209 236 209 254 223 254 223 276 258 276 258 237 337 in my php file i have that code. This code should take every line and draw line with coordinate from line. But something was wrong cause nothing was draw :/: <?php $plik = fopen("A2.txt", 'r') or die("blad otarcia"); while(!feof($plik)) { $l = fgets($plik,20); $k = explode(' ',$l); imageline ( $mapa , $k[0] , $k[1] , $k[2] , $k[3] , $kolor ); } imagejpeg($mapa); imagedestroy($mapa); fclose($plik) ; ?> If I use imagejpeg and imagedestroy in while its only first line draw. What to do to draw every line ?? Please help :)

    Read the article

  • How to avoid/prevent the system to draw/redraw/refresh/paint a WPF window

    - by Leo
    I have an Application WPF with Visual C# (using visual studio 2010) and I want to draw OpenGL scenes on the WPF window itself. As for the OpenGL drawinf itself, I'm able to draw it w/o problems, meaning, I can create GL render context from the WPF main window itself (no additional OpenGL control, no win32 window inside WPF window), use GL commands and use swapbuffer (all this is done inside a dll - using C - I created myself). However, I have an annoying flickering when, for example, I resize the window. I overrided the OnRender method to re-draw with opengl, but after this, the window is redraw with the background color. It's likely that the system is automatically redrawing it. With WindowForms I'm able to prevent the system to redraw automatically (defining some ControlStyles to true or false, like UserPaint = true, AllPaintingInWmPaint = true, Opaque = true, ResizeRedraw = true, DoubleBuffer = false), but, aside setting Opacity to 1, I don't know how to do all that with WPF. I was hoping that overriding OnRender with no operations inside it would avoid redrawin, but somehow the system still draw the background. Do anyone know how to prevent system to redraw the window? Thx for your time

    Read the article

  • How do I determine the draw order in an isometric view flash game?

    - by Gajet
    This is for a flash game, with isometric view. I need to know how to sort object so that there is no need for z-buffer checking when drawing. This might seem easy but there is another restriction, a scene can have 10,000+ objects so the algorithm needs to be run in less than O(n^2). All objects are rectangular boxes, and there are 3-4 objects moving in the scene. What's the best way to do this? UPDATE in each tile there is only object (I mean objects can stack on top of each other). and we access to both map of Objects and Objects have their own position.

    Read the article

  • Software to draw 3D geometry

    - by ilovekonoka
    Does anyone know any software that can draw 3D geometry like figures usually seen in computer graphics papers and articles(example: http://www.iquilezles.org/www/articles/sphereao/sphereao.htm)? I know it can be done in Inskcape or Illustrator but I'm not sure they're the only choices.

    Read the article

  • C++ Draw program, split in groups of two

    - by Levo
    I would like to make a draw application. I want to enter user names until eg "end" is entered and then the program to split them in groups of two. Can you suggest any examples? I don't know from where to start! If possible, I want to be Cross-platform, if not I want it for linux.

    Read the article

  • Javascript draw dynamic line

    - by Ranch
    Hello, I'm looking for Javascript code for letting the user draw a line (on an image). Just as the line tool in Photoshop (for example): The user clicks on the image, drags the mouse (while the line between the start point and the mouse point is dynamically drawn on mouse drag). I would also need a callable function to send the page the start and end coordinates. I've found this very nice script for area selection: http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/ and I've found many script for drawing lines (and other shapes in JS), but could not find what I'm looking for. Thanks

    Read the article

  • How to draw to screen in c++ ?

    - by Kesarion
    How would I draw something on the screen ? not the console window but the entire screen, preferably with the console minimised. Also, would it show up on a printscreen ? What I want to do is create something like a layer on top of the screen that only me and my aplication are aware of yet still be able to use aplications as usual. Here's an example: Let's say I want 2 yellow squares 5 by 5 pixels in size appearing in the center of the screen on top of all the other applications, unclickable and invisible to a printscreen.

    Read the article

  • Ability to draw and record a signature as part of a form - iphone

    - by mustic
    Apolgies in advance for any errors.. new to this and am not a developer/programmer.. just have some basic unix experience. I have searched the web and struggled to find a solution to my problem when I stumbled onto this website which maybe suggested that there is a solution to my question. For work i use a windows mobile device because we have to get customers to sign and form after a customer visit. the signature being very important. On the windows device i use the notes application and am able to record details and obtain/record (using draw) a customer signature. the form is then emailed back to HQ. The format being used is a *.pwi I have downloaded and paid for several applications for my iphone which is my preferred device and cant quite find anything that does both. the critical bit here is to be able to take a signature on the phone, save the doc in a format such as .txt, .doc or .pdf where i can control the file name then be able to email back to HQ. Am i asking too much? I hope that makes sense.. Any help would be much appreciated many thanks in advance

    Read the article

  • Cocos2dx- Draw primitives(polygons) on Update

    - by Haider
    In my game I'm trying to draw polygons on on each step i.e. update method. I call draw() method to draw new polygon with dynamic vertices. Following is my code: void HelloWorld::draw(){glLineWidth(1);CCPoint filledVertices[] = {ccp(drawX1,drawY1),ccp(drawX2,drawY2), ccp(drawX3,drawY3), ccp(drawX4,drawY4)};ccDrawSolidPoly( filledVertices, 4, ccc4f(0.5f, 0.5f, 1, 1 ));} I call the draw() method from the update(float dt) method. The engine is behaving inconsistently i.e. sometimes it displays the polygons and on other occasions it does not. Is it the right approach to do such a task? If not what is the best way to display large number of primitives?

    Read the article

  • Draw order in XNA

    - by Petr Abdulin
    It is possible to set draw order of a DrawableGameComponent by setting DrawOrder property. But is it possible to set draw order of "main" Game class? I have 2 DrawableGameComponents, and Draw method of a main Game class is called first, while I want it to be the last. Should I just mode all "main" draw code to another component and set it DrawOrder? Answer: seems like I'm just confused myself a little. Black on black, that's why I didn't saw it. Main Draw is called last, as expected.

    Read the article

  • faster way to draw an image

    - by iHorse
    im trying to combine two images into a single image. unfortunately this has to be done very quickly in response to a user sliding a UISlider. i can combine the two images into a single image no problem. but the way I'm doing it is horribly slow. the sliders stick and jump rather frustratingly. i don't think i can throw the code into a background thread because i would run out of threads to quickly. i haven't actually tired that yet. below is my code. any ideas on how to speed it up would be helpful. UIGraphicsBeginImageContext(CGSizeMake(bodyImage.theImage.image.size.width * 1.2, bodyImage.theImage.image.size.height * 1.2)); [bodyImage.theImage.image drawInRect: CGRectMake(-2 + ((bodyImage.theImage.image.size.width * 1.2) - bodyImage.theImage.image.size.width)/2, kHeadAdjust, bodyImage.theImage.image.size.width * bodyImage.currentScale, bodyImage.theImage.image.size.height * bodyImage.currentScale)]; if(isCustHead) { [Head.theImage.image drawInRect: CGRectMake((bodyImage.theImage.image.size.width * 1.2 - headWidth)/2 - 11, 0, headWidth * 0.92, headWidth * (Head.theImage.image.size.height/Head.theImage.image.size.width) * 0.92)]; } else { [Head.theImage.image drawInRect: CGRectMake((bodyImage.theImage.image.size.width * 1.2 - (headWidth * defaultHeadAdjust))/2 - 10, 0, (headWidth * defaultHeadAdjust * 0.92), (headWidth * defaultHeadAdjust) * (Head.theImage.image.size.height/Head.theImage.image.size.width) * 0.92)]; } drawSurface.theImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

    Read the article

  • Python. Draw rectangle in basemap

    - by user2928318
    I need to add several rectangles in my basemap. I nee four rectangles with lat and log ranges as below. 1) llcrnrlon=-10, urcrnrlon=10, llcrnrlat=35,urcrnrlat=60 2) llcrnrlon=10.5, urcrnrlon=35, llcrnrlat=35,urcrnrlat=60 3) llcrnrlon=35.5, urcrnrlon=52, llcrnrlat=30,urcrnrlat=55 4) llcrnrlon=-20, urcrnrlon=35, llcrnrlat=20,urcrnrlat=34.5 My script is below. I found "polygon" packages to add lines but I do not exactly know how to do. Please help me!! Thanks a lot for your help in advance! from mpl_toolkits.basemap import Basemap m=basemaputpart.Basemap(llcrnrlon=-60, llcrnrlat=20, urcrnrlon=60, urcrnrlat=70, resolution='i', projection='cyl', lon_0=0, lat_0=45) lon1=np.array([[-180.+j*0.5 for j in range(721)] for i in range(181)]) lat1=np.array([[i*0.5 for j in range(721)] for i in range(181) ]) Nx1,Ny1=m(lon1,lat1,inverse=False) toplot=data[:,:] toplot[data==0]=np.nan toplot=np.ma.masked_invalid(toplot) plt.pcolor(Nx1,Ny1,np.log(toplot),vmin=0, vmax=5) cbar=plt.colorbar() m.drawcoastlines(zorder=2) m.drawcountries(zorder=2) plt.show()

    Read the article

  • Drawing Grid in 3D view - Mathematically calculate points and draw line between them (Not working)

    - by Deukalion
    I'm trying to draw a simple grid from a starting point and expand it to a size. Doing this mathematically and drawing the lines between each point, but since the "DrawPrimitives(LineList)" doesn't work the way it should work, And this method can't even draw lines between four points to create a simple Rectangle, so how does this method work exactly? Some sort of coordinate system: [ ][ ][ ][ ][ ][ ][ ] [ ][2.2][ ][0.2][ ][2.2][ ] [ ][2.1][1.1][ ][1.1][2.1][ ] [ ][2.0][ ][0.0][ ][2.0][ ] [ ][2.1][1.1][ ][1.1][2.1][ ] [ ][2.2][ ][0.2][ ][2.2][ ] [ ][ ][ ][ ][ ][ ][ ] I've checked with my method and it's working as it should. It calculates all the points to form a grid. This way I should be able to create Points where to draw line right? This way, if I supply the method with Size = 2 it starts at 0,0 and works it through all the corners (2,2) on each side. So, I have the positions of each point. How do I draw lines between these? VerticeCount = must be number of Points in this case, right? So, tell me, if I can't supply this method with Point A, Point B, Point C, Point D to draw a four vertice rectangle (Point A - B - C - D) - how do I do it? How do I even begin to understand it? As far as I'm concered, that's a "Line list" or a list of points where to draw lines. Can anyone explain what I'm missing? I wish to do this mathematically so I can create a a custom grid that can be altered.

    Read the article

  • PeopleSoft Grants & the Federal Agency Letter of Credit Draw Changes

    - by Mark Rosenberg
    For decades, most, if not all, US Federal agencies that sponsor research allowed grant recipients to request and receive payments using pooled accounts, commonly known as pooled letter of credit (LOC) draws. This enabled organizations, such as universities and hospitals, fast and efficient access to reimbursement of the expenditures they incurred conducting research across a portfolio of grants. To support this business practice, the PeopleSoft Grants solution has delivered an LOC Draw report to provide the total request amount along with all of the supporting invoice details for reconciliation and audit purposes. Now, in an attempt to provide greater transparency, eliminate fraud, strengthen accountability for grant-related financial transactions, and simplify grant award closeout, many US Federal sponsors are transitioning from the “pooling” letter of credit draw method to requesting on a “grant-by-grant” basis. The National Science Foundation, the second largest issuer of Federal awards, already transitioned to detailed grant draws in 2013. And, in response to the U.S. Department of Health and Human Services (HHS) directive to HHS-supported Agencies, the largest Federal awards sponsor, the National Institutes of Health (NIH), will fully transition to the new HHS subaccount draw method. This will require NIH award recipients to request payments based on actual expenses incurred on an award-by-award basis. NIH is expected to fully transition to this new draw method by the end of Federal fiscal year 2015.  (The NIH had planned to fully transition to this new method by the end of fiscal 2014; however, the impact to institutions was deemed to be significant enough that a reprieve was recently granted.) In light of these new Federal draw requirements, we have recently released these new features to aid our customers on both PeopleSoft Grants releases 9.1 and 9.2:1. Federal Award Identification Number on the Proposal and Award Profile 2. Letter of credit fields on contract lines to support award basis draws and comply with Federal close out mandates3. Process to produce both pro forma and final LOC Draw Reports in BI Publisher report format4. Subacccount ID field on the LOC Summary and a new BI Publisher version of the LOC Summary report 5. Added Subaccount Field and contract info to be displayed on the LOC summary page6. Ability to generate by a variety of dimensions pro forma and invoiced draw listings 7. Queries for generation and manipulation of data to upload into sponsor payment request systems and perform payment matching8. Contracts LOC Close Out query to quickly review final balances prior to initiating final draws and preparing Federal Financial Reports prior to close The PeopleSoft Development team actively monitors this and other major Federal changes and continues working closely with the Grants Product Advisory Group of the Higher Education User Group to ensure a clear understanding of what our customers need in order to transition to new approaches for doing business with the Federal government. For more information regarding the enhancements to the PeopleSoft Grants solution, existing customers can login to My Oracle Support and review the Enhancements to Letter of Credit Process (Doc ID 1912692.1) associated with resolution ID 904830. This enhanced LOC functionality is available in both PeopleSoft FSCM 9.1 Bundle #31 and PeopleSoft FSCM 9.2 Update Image 8.

    Read the article

  • How to learn to draw UML sequence diagrams

    - by PeterT
    How can I learn to draw UML sequence diagrams. Even though I don't use UML much I find that type of diagrams to be quite expressive and want to learn how to draw them. I don't plan to use them to visualise a large chunks of code, hence I would like to avoid using tools, and learn how to draw them with just pen and paper. Muscle memory is good. I guess I would need to learn some basics of notation first, and then just practice it like in "take the piece of code, draw a seq. diagram visualising the code, then generate the diagram using some tool/website, then compare what I'd drawn to what the tool result. Find the differences, correct them, repeat.". Where do I start? Can you recommend a book or a web site or something else?

    Read the article

  • Draw a never-ending line in XNA

    - by user2236165
    I am drawing a line in XNA which I want to never end. I also have a tool that moves forward in X-direction and a camera which is centered at this tool. However, when I reach the end of the viewport the lines are not drawn anymore. Here are some pictures to illustrate my problem: At the start the line goes across the whole screen, but as my tool moves forward, we reach the end of the line. Here are the method which draws the lines: private void DrawEvenlySpacedSprites (Texture2D texture, Vector2 point1, Vector2 point2, float increment) { var distance = Vector2.Distance (point1, point2); // the distance between two points var iterations = (int)(distance / increment); // how many sprites with be drawn var normalizedIncrement = 1.0f / iterations; // the Lerp method needs values between 0.0 and 1.0 var amount = 0.0f; if (iterations == 0) iterations = 1; for (int i = 0; i < iterations; i++) { var drawPoint = Vector2.Lerp (point1, point2, amount); spriteBatch.Draw (texture, drawPoint, Color.White); amount += normalizedIncrement; } } Here are the draw method in Game. The dots are my lines: protected override void Draw (GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.Black); nyVector = nextVector (gammelVector); GraphicsDevice.SetRenderTarget (renderTarget); spriteBatch.Begin (); DrawEvenlySpacedSprites (dot, gammelVector, nyVector, 0.9F); spriteBatch.End (); GraphicsDevice.SetRenderTarget (null); spriteBatch.Begin (SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.transform); spriteBatch.Draw (renderTarget, new Vector2 (), Color.White); spriteBatch.Draw (tool, new Vector2(toolPos.X - (tool.Width/2), toolPos.Y - (tool.Height/2)), Color.White); spriteBatch.End (); gammelVector = new Vector2 (nyVector.X, nyVector.Y); base.Draw (gameTime); } Here's the next vector-method, It just finds me a new point where the line should be drawn with a new X-coordinate between 100 and 200 pixels and a random Y-coordinate between the old vector Y-coordinate and the height of the viewport: Vector2 nextVector (Vector2 vector) { return new Vector2 (vector.X + r.Next(100, 200), r.Next ((int)(vector.Y - 100), viewport.Height)); } Can anyone point me in the right direction here? I'm guessing it has to do with the viewport.width, but I'm not quite sure how to solve it. Thank you for reading!

    Read the article

  • Draw multiple objects with textures

    - by Simplex
    I want to draw cubes using textures. void OperateWithMainMatrix(ESContext* esContext, GLfloat offsetX, GLfloat offsetY, GLfloat offsetZ) { UserData *userData = (UserData*) esContext->userData; ESMatrix modelview; ESMatrix perspective; //Manipulation with matrix ... glVertexAttribPointer(userData->positionLoc, 3, GL_FLOAT, GL_FALSE, 0, cubeFaces); //in cubeFaces coordinates verticles cube glVertexAttribPointer(userData->normalLoc, 3, GL_FLOAT, GL_FALSE, 0, cubeFaces); //for normals (use in fragment shaider for textures) glEnableVertexAttribArray(userData->positionLoc); glEnableVertexAttribArray(userData->normalLoc); // Load the MVP matrix glUniformMatrix4fv(userData->mvpLoc, 1, GL_FALSE, (GLfloat*)&userData->mvpMatrix.m[0][0]); //Bind base map glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_CUBE_MAP, userData->baseMapTexId); //Set the base map sampler to texture unit to 0 glUniform1i(userData->baseMapLoc, 0); // Draw the cube glDrawArrays(GL_TRIANGLES, 0, 36); } (coordinates transformation is in OperateWithMainMatrix() ) Then Draw() function is called: void Draw(ESContext *esContext) { UserData *userData = esContext->userData; // Set the viewport glViewport(0, 0, esContext->width, esContext->height); // Clear the color buffer glClear(GL_COLOR_BUFFER_BIT); // Use the program object glUseProgram(userData->programObject); OperateWithMainMatrix(esContext, 0.0f, 0.0f, 0.0f); eglSwapBuffers(esContext->eglDisplay, esContext->eglSurface); } This work fine, but if I try to draw multiple cubes (next code for example): void Draw(ESContext *esContext) { ... // Use the program object glUseProgram(userData->programObject); OperateWithMainMatrix(esContext, 2.0f, 0.0f, 0.0f); OperateWithMainMatrix(esContext, 1.0f, 0.0f, 0.0f); OperateWithMainMatrix(esContext, 0.0f, 0.0f, 0.0f); OperateWithMainMatrix(esContext, -1.0f, 0.0f, 0.0f); OperateWithMainMatrix(esContext, -2.0f, 0.0f, 0.0f); eglSwapBuffers(esContext->eglDisplay, esContext->eglSurface); } A side faces overlapes frontal face. The side face of the right cube overlaps frontal face of the center cube. How can i remove this effect and display miltiple cubes without it?

    Read the article

  • Draw depth works on WP7 emulator but not device

    - by Luke
    I am making a game on a WP7 device using C# and XNA. I have a system where I always want the object the user is touching to be brought to the top, so every time it is touched I add float.Epsilon to its draw depth (I have it set so that 0 is the back and 1 is the front). On the Emulator that all works fine, but when I run it on my device the draw depths seem to be completely random. I am hoping that anybody knows a way to fix this. I have tried doing a Clean & Rebuild and uninstalling from the device but that is no luck. My call to spritebatch.Begin is: spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend); and to draw I use spriteBatch.Draw(Texture, new Rectangle((int)X, (int)Y, (int)Width, (int)Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, mDrawDepth); Where mDrawDepth is a float value of the draw depth (likely to be a very small number; a small multiple of float.Epsilon. Any help much appreciated, thanks!

    Read the article

  • SFML 2.0 Too Many Variables in Class Preventing Draw To Screen

    - by Josh
    This is a very strange phenomenon to me. I have a class definition for a game, but when I add another variable to the class, the draw method does not print everything to the screen. It will be easier understood showing the code and output. Code for good draw output: class board { protected: RectangleShape rect; int top, left; int i, j; int rowSelect, columnSelect; CircleShape circleArr[4][10]; CircleShape codeArr[4]; CircleShape keyArr[4][10]; //int pegPresent[4]; public: board(void); void draw(RenderWindow& Window); int mouseOver(RenderWindow& Window); void placePeg(RenderWindow& Window, int pegSelect); }; Screen: Code for missing draw: class board { protected: RectangleShape rect; int top, left; int i, j; int rowSelect, columnSelect; CircleShape circleArr[4][10]; CircleShape codeArr[4]; CircleShape keyArr[4][10]; int pegPresent[4]; public: board(void); void draw(RenderWindow& Window); int mouseOver(RenderWindow& Window); void placePeg(RenderWindow& Window, int pegSelect); }; Screen: As you can see, all I do is un-comment the protected array and most of the pegs are gone from the right hand side. I have checked and made sure that I didn't accidentally created a variable with that name already. I haven't used it anywhere. Why does it not draw the remaining pegs as it should? My only thought is that maybe I am declaring too many variables for the class, but that doesn't really make sense to me. Any thoughts and help is greatly appreciated.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >