Tag Info

New answers tagged

0

Do I need to pass a 4D vector with values (x,y,z,w), where w = z? No, you don't need to. And this would even be wrong, w is 1 for positions and 0 for directions. When you want to multiply the vertex with a mat4 usually you convert it to a vec4 on the fly with vec4(your_position, 1.0). In the vertex shader code, do I need to manually divide the x and ...


-1

power of 2 textures increase performance about 30% for any type of GPU not only old GPUs (30% faster is the difference between a high end GPU and an average one) they take 30% more ram but less vram is needed they increase quality by providing proper texture size for specific distance it works like anti-aliasing for textures dark line artifact should be ...


0

Well, I finally got it after messing around with the math for awhile I kinda understand it. If anyone wants the code here it is. double dcx = double(cx) / double(w); double dcy = double(cy) / double(h); double dcw = (double(cx)+double(cw)) / double(w); double dch = (double(cy)+double(ch)) / double(h); glBegin(GL_QUADS); glTexCoord2f(dcx, dcy); ...


1

The problem is you are passing an address value to data rather than the data itself. A naive solution is to change: glBufferData(GL_ARRAY_BUFFER, 4*oindices, faceVBO[0], GL_STATIC_DRAW); to: glBufferData(GL_ARRAY_BUFFER, 4*oindices, *faceVBO[0], GL_STATIC_DRAW); To clarify: in your implementation, 'faceVBO' is a pointer to a set of pointers, and ...


1

You just don't tonemap bloom, or blur, or depth of field. Those effects come on top of all other. Try to experiment with the values also.


0

Updated with a minor fix: Yes, the problem was: textCoo -= deltaTextCoord; Due to the fp precision the error accumulated grows to something like 2.7%. Calculating it each loop instead of subtracting a delta fixes a big part of the problem. As for optimization, I am using some techniques, got a reasonable 40fps. See this post, I asked the same ...


0

I don't quite understand what your problem is, since you're not being very specific. But I'll try. Your code seems fine to me. glVertex2f() controls where you want to render your quad to the screen. glTexCoord2f() controls what part of the texture you want to apply to the quad. So obviously if you increase the size of your quad but don't increase the part ...


0

Okey I found the problem. I had placed my glew32.dll file in a separate folder and set the environmental path to that location. e.g: Properties > Configuration Properties > Debugging > Environment = PATH=$(ProjectDir)..\dependencies\bin;%PATH% Apparently Nsight didn't realize this and thus couldn't find the dll.


1

The glGenVertexArrays() interface was added to OpenGL core contexts in version 3.0, the same version in which immediate mode rendering was removed from OpenGL (although it had long since been deprecated, 3.0 is where it finally absolutely went away) So you are correct. If immediate mode drawing works, then you are using an OpenGL context old enough that ...


1

You should draw everything, and swap the buffer (display), at most once per frame (usually 1/60th second). You should definitely not call window.display() more than once per frame. If nothing at all has moved, you might choose to skip drawing and displaying entirely for that frame, especially on a mobile device to conserve power. On a desktop, typically, ...


-2

You could potentially use Vector4f's to calculate the bottom (and/or the entire areal of the object) to more easily calculate the boxes around the object. This will use its own methods and I am working on it right now. I will add a comment with the result (eventually).


0

WebGL is based on OpenGL ES. Precision qualifiers (like "precision mediump float;") were introduced in OpenGL ES to optimize performance on embedded systems with lower hardware (like smartphones). In desktop OpenGL these precision qualifier do nothing. They only exist for compatibillity to OpenGL ES / WebGL. Source: ...


0

Honeybunch answered for video memory I believe, I'm not that familiar with GL. But to store a map like that in memory and eventually on disk you need to think about what you want with the map. If you have less then 256 types of tiles and nothing else simply use a unsigned bytes in a array (vector in c++ right?). Having thousands of tiles is not that special ...


0

Load each image once then bind the texture before you draw the tile. Efficiency can be improved if you only draw tiles that will be visible or partially visible by the camera. http://docs.gl/gl4/glGenTextures http://docs.gl/gl4/glGenerateMipmap http://docs.gl/gl4/glBindTexture void init() { //load geometry //load textures //Setup entities ...


0

I've done it the way I described in the update of the question. I'll refer to that.


0

Well, first of all, the latest OpenGL version is not 3. We are currently at version 4.5 :) With that out of the way: If you want to learn OpenGL, I recommend using version 3 if you are completely new, since there are tons of tools and tutorials ready for you to use (I recommend this free tut). You could try OpenGL 4 if you think you can manage the lack of ...


0

The graphics API you select is but a small part of making a game. If your intent is to learn how to make a game, pick the API that is least in the way while still letting you figure out hard game/engine bits. If your intent is to learn how to use a graphics API, make a game-less tech demo. Older API versions, while a bit gnarly, are often more covered in ...


1

glOrtho( 0.f, viewWidth, viewHeight, 0.f, 0.f, 1.f ); Assuming that you're starting from an identity matrix, this glOrtho() call will give you a traditional window coordinate system with 0,0 at the top left corner, such that one unit in OpenGL space corresponds exactly to one pixel in the view which contains the OpenGL-rendered image. Man page for glOrtho. ...


0

My understanding is that the goal is to have a background "high quality render" while still updating an on-screen progress bar and eventually producing a still image from the background process. The easiest way to do this will probably involve having two separate OpenGL contexts, each set as 'current' on one thread. The first one renders your progress bar ...


0

It's not just the EGL Context that gets lost; Android can (and will) simply kill any application running in the background when it's running low on resources and needs to reclaim them. There's simply no guarantee that your app won't have been unloaded since you last left it. When your activity receives a call to the onStop() method, it's no longer ...


1

Maybe. Broadly, there are two ways to categorize geometry (triangles you will render): either the geometry is static, and all sits in the same fixed place in the world, or the geometry is dynamic and either moves around in the world or otherwise animates the geometry is defined according to a specific vertex format (this geometry has a position, normal, ...


1

No, that's not how shaders work. If you want to use a shader to manipulate a texture, you need to set up a render-to-texture operation. Create a result texture, bind it as the render target, bind your input texture as a regular input texture, and bind the shader you want to execute "once." Render a fullscreen quad mapped with the input texture using the ...


0

no, you cannot stop shaders. That would break the render pipeline and as a result you would break rendering. Doing such a sweep is simply setting the uniforms to the needed values from your application (for ex. incrementing the texture position values on each iteration). Inside your application, you know the size of the underlying object and can stop using ...


1

tl;dr: NO. Long answer: As @LarsViklund pointed out, you will have significant trouble using multiple threads to render. OpenGl is kinda bad at multithreading, so don't. If your rendering is slow it's not because of slow OpenGL calls. Your architecture is just bad. You can improve it by moving away all your logic (UI events, physics, AI,...) from your ...


0

Alternatively, you can break up your long, slow render parts to intersperse with your UI updates. Slow part takes too long? Break it into multiple draws. Each draw is still too long? Fill a smaller area. It might be a little bit inside out, but it's a way to do it all in one thread.


1

An OpenGL context may be current on at most one thread at a time. If you make a context current in one thread, it will be made uncurrent in the previous thread. So while you can migrate contexts between threads, you can not do so in any concurrent manner. While there is the existence of shared contexts and shared resources, those are not exactly in the fast ...


1

For your first question yes your understanding is right. Secondly I would argue that doing Multidraw*Indirect (without glPrimitiveRestartIndex​()) would be better for performace (most optimized). The main thing to remember is that each OpenGL call you are doing is calling the OpenGL driver. So the more calls you do the more driver overhead you incurr. A ...


0

It's possible that your attribute offsets supplied to glVertexAttribFormat are failing to take data structure padding into account, leading to incorrectly-read vertex normals once your interleaved vertex buffer is bound. When using glVertexAttribPointer, did you calculate the offset pointer in the same way as described above, or were you taking it from the ...


1

You can see the value of your member variables in your debugger, and it will show you the correct values. Your problem lies in that the matrix transformation commands of legacy OpenGL are accumulating on top of each other. If you want to start from a known state, you need to look into the functions that let you load an identity matrix, push and pop on the ...


0

You're passing the Render instance to your cube class by value. This is probably copying or reinitializing a bunch of state. Remember that you can make classes non-copyable for cases like this. I always make systems/module classes like that non-copyable to avoid bugs like these. For things like your cube you'll also have problems (you'll end up deleting ...


0

I had exactly this problem. To verify my operations to the framebuffer, I was drawing the framebuffer texture back to the screen using a simple GL_QUAD. But it was not giving correct output since I was not setting glUseProgram(0) before drawing that quad. So the correct sequence of operations goes something like this: glBindFramebuffer(GL_FRAMEBUFFER, ...


0

The problem is that obj files contain vertex data in parts:pos,tex,normal and indices in them point to each of these parts individually. In OpenGL you need to combine those parts into one data object - vertex. And have your indices point to vertices, not their parts. My code (scala, but should be ok) val vertexListB = new RList[vec3]()//output positions ...


0

Lets say you have your rectangles at a certain coordinate to the right (x,y). Then, an easy way is that on each rendering call you reduce the x coordinate of the rectangles by some dx. #define dx 0.1 render(){ draw_rectangle(xrec, yrec, zrec); xrec -= dx; } If you have a logic loop separated from the rendering loop, then it is better to do the ...


0

Looks not too bad to me. Only thoughts are to consolidate your camera to have a setMVPUniform(GLuint uloc, matrix model) or similar function. Likewise make similar classes for Lights, textures, VAOs, etc. Wrap anything you find yourself copypasting into a function. As long as you keep your things public you'll still have low level access where needed. ...


0

First, this question is about asking for a tutorial, and as far as i know googling "opengl tutorial" is enough to get you started. Second, i don't recommend you to use such an old version of opengl, even if you want to support an extremely large range of computers, the 'modern opengl' (a.k.a. Opengl 3.0+) is widely supperted as well. And imho learning opengl ...


2

For a really good and in-depth article on this subject, just read Fix Your Timestep. There's also a ton of existing questions about this subject, although addressing different angles. But in really simple terms, this is how you get a fixed physics (or anything, really) frame rate despite the rendering frame rate being unpredictable: loop check how long ...


1

To do this, firstly you need to define a physics update time period (say, evry 16ms) and then you need to handle the case of when your game runs too fast, and when it runs too slow. When the game runs too quickly (faster than your physics update period) you need to interpolate between the last physics frame data and the next physics frame data based on what ...


0

If you're using SDL 2 you should just be able to port to mobile quite easily. SDL 2 has support out of the box for mobile. It won't be a 2-click port but it will be very possible to do. Check out the download page: http://www.libsdl.org/download-2.0.php#source There are versions of SDL 2 for iOS and Android that you can build from source. SDL is very well ...


0

Here is an example with a very simple tile/sprite sheet. Each tile is 32x32 and the red line marks the left and the upper corner of each tile. You always want to use sheets like this when rendering tiles. Switching textures is much more expensive than drawing a bunch of vertices. You can either index it either by using a 2D vector or just a number. To ...


0

I don't think you should be instancing individual blocks. That's a lot of data you have to send back and forth to the GPU... it just isn't feasible, especially for a voxel engine. I would construct a mesh from the chunk data and place it into a VBO. Every time there is a chunk update, discard the mesh and create a new one in it's place. I feel that the ...


1

The bulk of Minecraft's chunk rendering goes through a vertex array. The world is split into 16x16x16-block render-chunks (which currently happen to be the same as storage-chunks, but it wasn't always that way). Each render-chunk is converted to a vertex array, and rendered. It uses OpenGL display lists (one per render-chunk) as an older alternative to ...


1

Modern iterations Minecraft can use both VBOs or immediate mode (glBegin and friends). The reason why it can get away with that is because of other rendering optimizations. Try refraining from rendering any blocks that are not adjacent to air (less bandwidth), building and optimizing meshes from chunk data (less vertices to draw), or cutting down on the ...


2

If you open the image above in its full resolution and look closely (with something like Magnifier on Windows), you should see that all the pixels simply have something like a blurred edge. Since there can be seen standalone "edges" of pixels, it is clearly not a post-processing method. When looking at screenshots in different resolutions, the edge ...


0

You'd draw a tile map in OpenGL the same way you'd draw a sprite that has multiple frames in a single texture; by adjusting the texture coordinates such that you only drew a portion of the texture onto the quad that represents the tile. A rough way to do it would be to create a mesh of quads/triangles that represents your tile map; each tile's world ...


0

Since you already have a sorted list of things to render (front to back) do you really need to increment the Z index? Can't you use "less or equal" for the "checking function"? This way it would actually check if a specific pixel was already drawn or not.


0

I found a solution. I cannot really explain why it changes the outcome since all UV's are in the [0;1] range. Yet, addin the lines glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); Just after loading the texture solved the problem just fine.


1

I'm lazy, so here is the way I'd tackle this issue: it would be by coupling the graphics with a collision/physics engine. You could try and find a basic collision engine for your language and implement something like this for your collisions and graphics: The image is composed with square sprites images; here is the colour coding (note that the first row, ...


0

Looks like you have some problems with references. Strictly saying, you cannot return local object as a reference, nor you can bind non-const reference to a temp object like this: Add("something", GameObject()); I wonder how did you get it to compile... If you want to remove references be sure that they are not destroyed (e.g. by goingout of scope). ...


3

The way you are rendering voxels is extremely ineffective. For each cube you have to do calculations, set uniforms, and worst of all bind textures(This is usually a very expensive operation) Typically effective voxel rendering involves multiple techniques to speed up rendering: Rendering in chunks: You split your world into neatly sized proportions, which ...


0

It seems that you have used different types in it->second.Update(ev) (ev - SDL_Event&). And in it second type is GameObject&.



Top 50 recent answers are included