Tag Info

Hot answers tagged

18

There are two possible causes for this type of problem, depending on exactly which problem it is. I'll list both: 1. You are seeing other colors from your texture along the edges of the tiles. This looks to me like the problem in this case, because all of the edge pixels are one of three colors which are plausibly in your texture: white, black, and brown. ...


18

Put it wherever you can to make it work. Anything else is design paralysis and just going to slow down your progress. When you start seeing patterns emerge, refactor your code. Lots of people will give you advice about the One True Way to do something, but without a breadth of experience to draw from, you'll just be parroting ideas without a true ...


17

You could use an algorithm that checks near blocks, and varies the probability depending on what is there - but I think it's largely the wrong approach. What you want to be looking at is fractal noise types - in this case, perlin or simplex noise. If you generate noise, you'll get values from -1 to 1. http://en.wikipedia.org/wiki/Perlin_noise You can then ...


12

This is from an old OpenGL-based game engine I was trying to write about seven years ago written in C++ so bare with me as I try to explain how I handled 3D world and 2D GUI rendering operations within it. I used four primary methods within my OpenGL renderer class (OGLRender) of which are: ready3D() for preparing OpenGL to render the 3D world scene. ...


12

You need to change the texture magnification type, like so: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); Read about glTexParameter.


12

What you have described is entirely adequate and appropriate to provide resolution independence. Anything you draw will indeed always take up the same proportion of your window. However, if you do nothing more than this, you will have aspect ratio problems. For example, given the numbers you wrote, if you draw a circle, it will be squashed — wider than it ...


12

The attenuation function you've got, att = 1.0 / (1.0 + 0.1*dist + 0.01*dist*dist) is a fairly common one in computer graphics - or, more generally, 1.0 / (1.0 + a*dist + b*dist*dist)) for some tweakable parameters a and b. To understand how this curve works it's helpful to play with the parameters interactively. This curve is nice because it approaches ...


11

One way to do this is to check the bounding box of the block against the bounding box of the current view (plus a bit for safety). If the block interacts with the view (either fully inside or clipped) then draw it. If it doesn't - i.e. is totally outside then don't draw. This check can be performed quite quickly - particularly in 2D. You don't have to know ...


11

There is no such directory; %APPDATA% is Windows-specific. You'll have to abstract it yourself: create your own GetSaveGameDirectory function that returns an appropriate path on whatever operating system you're running on. You can typically make this determination at compile time with preprocessor checks against the appropriate macros in C (and it's ilk). ...


10

Pedantic note: There is no such thing in OpenGL as a "Vertex Buffer Object." There are simply Buffer Objects. A buffer object is simply a linear array of GPU memory that you can allocate, fill with data, read from, and use in a variety of ways. One of the things you can do with buffer objects is store vertex data in them and use them as source arrays for ...


10

The reason you're limited to power-of-two sizes is due to how video ram works. Note that what you should do is typically make the image the next highest power of two (.e. 512x256), and then just use a portion of that image for your graphics. You'd be setting your UV coordinates to only use a subsection of the image onto whatever triangles you're rendering. ...


8

Look at your if statements. You set paused to true, then the next statement evaluates true (because there's no way to not press p for a short enough time and you just set paused to true), and it sets it to false. Try: if(Keyboard.isKeyDown(Keyboard.KEY_P) && !gamePaused) { gamePaused = true; } else if(Keyboard.isKeyDown(Keyboard.KEY_P) ...


8

The reason you're not finding anything is probably because it's so exceedingly simple there's nothing to ask about and nothing much to talk about. Here's how a day/night cycle works: You have a sun and moon that travel overhead (maybe also stars, etc). Your game has a time of day. The position of the sun and moon, and appearance of the sky, depends on the ...


8

This will depend a lot on what you want to acomplish and the type of game you have. You would have a 'game world' time that advances based on the cpu clock. Generally at a much faster pace so it can be seen. And you will need to take into account pausing, alt-tabbing and so on. You can also advance it manually such as when the player sleeps, uses some kind ...


7

The best way in my opinion is to write your own parser for .obj exported with Blender or your preferred 3D modeling software. It will really only take you a maximum of one hour and you won't have to worry about distribution/licence issues. Here is a video about this question: http://youtu.be/izKAvSV3qk0.


7

You'll want to use 3D picking. Here's some code I use in my game. First I cast a ray from my camera. I'm using the mouse, but if you're just using where the user is looking, you can just use the center of the window. This is that code from my camera class: public Ray GetPickRay() { int mouseX = Mouse.getX(); int mouseY = ...


7

Instead of me just giving you the classes and you not knowing what is happening in them, I will provide you with an explanation and run down of what is happening and then you can give it a go yourself. I believe it's better to teach someone how to fish rather than catching the fish for them :) Ok so lets get into it! A camera is basically just an x and y ...


6

These can be done using shadow mapping. Basically, place the camera at the light source and render the scene into a depth buffer; the resulting buffer identifies all the lit surfaces since they are just the surfaces the light can "see". This texture is then used in the pixel shaders in the main render to mask away light on surfaces behind the shadow map. ...


6

What that code is doing is limiting motion to only if you're inside the screen. What you should instead do is something like this: //control code here if(player.getx() > 1024){ player.setx(1024); }else if(player.getx() < 0){ player.setx(0); } that way if the player exceeds the bounds of the screen the position will be set back to the ...


6

If you build your meshes more carefully, ensuring you are reusing vertices wherever possible, you should be fine: That is, you must not duplicate vertices per face as then the GPU rasteriser will see them as two discrete objects and sometimes fail to rasterise the in-between space (thus defaulting to the GL's clear colour) due to floating point limitations; ...


6

There are a couple things you can do. First, don't update every tile every tick of the game. Games like Terraria do periodic updates on only parts of the world at any time. Sub-divide your tile grid into chunk. Update one chunk each tick. You don't need to do it any more. You might even need to do it less. Things like growing grass and such are ...


6

The oscillation is a common thing. Likely from CPU scheduling and other processes on the system. The first frame being very long is an error in your code. Consider what lastFrame is set to when the application starts (likely 0), so for the first frame you're just setting deltaTime to the time/1000. You can add a check that if lastFrame is 0, the deltaTime ...


5

This is a common problem even on new GPUs when drivers are not installed. OpenGL version is 1.0 1.1 and is running in software mode. Install/update GPU drivers and add version query to your application. If returned OpenGL version is below 1.1 then it is definitely missing drivers.


5

You can't. The nature of any kind of digital data is that once information has been removed it can never be put back, and likewise you can't fill in information that was never there in the first place - the best you can do is a rough approximation, which gives you blurriness. Using GL_NEAREST won't blur but it will become pixellated instead. The solution ...


5

A simple suggestion and something I recently put into my game. For all the horizontal upward faces, find if they are also the base of an adjacent horizontal face. For example, when I'm building my VBOs I run some code like this: Color[] colors = new Color[4]; Color faceColor = GetColorForFace(x, y, z, face); colors[0] = faceColor; //mpp ...


5

For lighting to work, every vertex needs a normal. What seems to be the case right now is that all of your vertices have the same normal, which is why all the faces are getting the same amount of light. To calculate the normal for a triangle, take the cross-product using two of its sides and normalize it. However, this will produce hard edges, which are ...


5

Usually you would just leave this up to the user to decide or alternately run a small bench test and recommend settings to the user. If you want to bench test to recommend settings or just put it on regardless all you need to do is see how long it takes to complete your render call. If a frame is 25 milliseconds, for example, and all your draws are done in ...


5

LWJGL prefaces all core functions and enumerators with the OpenGL version that those functions were introduced in. So glBindBuffer, a function introduced in OpenGL version 1.5, is called GL15.glBindBuffer. That's just how it works. It's not really importing "a bunch of different OpenGL versions"; it's just using the version those functions/enumerators was ...


5

There are many reasons why a game may be limited to a specific framerate, and only one of them is relative performance of the API version. Let's look at two of the most simple examples. vsync can limit framerate to the refresh rate of your monitor. If you have a 100hz monitor and if vsync is enabled, you'll never run faster than 100fps. The game may have ...


5

I think your problem may lie here: glOrtho(0,Display.getWidth(),Display.getHeight(),0,1,-1); In OpenGL, coordinates go from -1 on the left of the viewport to 1 on the right, and -1 on the bottom to 1 on the top, with (0,0) in the center of the screen (and the Z axis going back to front). This is the same regardless of the shape of your viewport, and it is ...



Only top voted, non community-wiki answers of a minimum length are eligible