Tag Info

New answers tagged

2

Since m_VAO is valid in constructor but not in draw(), it seems that the destructor was called before draw(), perhaps by copying an instance of the Polygon class. P.S. Errors like these could be prevented by following the Rule of three.


1

Please take note that the question was unclear and changed meaning 3 times, hence the 3 answers in one How can I verify that a given size is a multiple of another? This is a very good case to use the Modulo operator. Let's say you have a texture tex with size (width, height). Now you want to render the texture with size (drawWidth, drawHeight) on the ...


1

Having done both, I can say that using a single quad is best in circumstances where none of your larger objects take up more than one grid square and/or are square/cube-shaped. Otherwise, you will eventually run into Z-sorting issues. The multiple-quad solution was the best one that I found to deal with that particular situation. IE, if you had larger, ...


0

Your performance hit come from driver overhead (state changes). Having 50K VAOs is wayyyyy too much. If all your models are the same format (for example the format x,y,z,r,g,b,a) then you should use one VAO and one VBO. You can use something like glMultiDrawArraysIndirect for rendering large amounts of object and you can create commands (which require no ...


2

You can also use the OpenGL Extensions WGL_NV_DX_interop and WGL_NV_DX_interop2 The first one is well supported by Nvidia and AMD and even Intel chips but works only with D3D9 objects. If you want to use DXGI (DirectX 10 and 11) you need to use the second one which only works with Nvidia and some AMD GPUs. By using these extensions you can render to a ...


0

Of course right after I post this I realize what I did wrong: // Attach then link shaders GLuint shaderProgram; should be // Attach then link shaders GLuint shaderProgram = glCreateProgram();


0

You need to disable textures before drawing the quads. Here's basically what's going on: You enable textures (in setCamera). You draw a button which: Draws a quad (which is textured, not just a solid color, but texcoords aren't set so...weirdness happens, and it might not be entirely predictable) Then you draw text (correctly) by: Enabling textures. ...


1

gl_TexCoord[0].stp = normalize(gl_Vertex.xyz); Is your problem, I believe you need: gl_TexCoord[0].stp = normalize(gl_Normal.xyz * gl_ModelViewMatrix); Possibly without the matrix multiplier -- I'm a bit rusty. Note that the meaning of 'normal' can be a bit confusing here -- The 'vertex normal' (gl_Normal) is a vector pointing directly 'away' from the ...


1

In a client/server architecture it is not required that client and server are implemented in the same programming language. They usually communicate by sending raw data via network sockets. So you can choose the technology for each component separately, depending on your requirements, skillset and personal preferences. An exception would be when you want to ...


3

This is a known issue in some drivers. Including (at time of writing) the most recent ATI drivers across both Windows and Linux. From the OpenGL wiki page on GLSL uniforms: Platform Issue (Unknown): Some drivers do not implement uniform initializers correctly. Best practice is therefore to set all of your shaders' uniforms explicitly from inside your ...


0

You miss some important things. You have to transform the clip-coordinates to camera coordinates and do the clipping with those. But you dont have to reinvent the wheel. Go to github - andengine - there is already a class called ClipEntity that does exactly what you want to achieve.


3

Loading: To expand on what Sandalfoot said: You must create you models in an external application, (Blender is popular and free, 3DSMax is free for non-commercial use) and then export them in a suitable format. There are many different model formats which target different things. Here are some: The Wavefront .OBJ format is very simple and easy to load, ...


0

It seems that BufferedImage does not keep that kind of information from the original PNG file. The type of the BufferedImage may or may not correlate with the type of the PNG. You can check the type of the BufferedImage with BufferedImage.getType(), which may help you, but the implementation of image loading is free to convert the images to other formats at ...


2

It depends. Generally speaking, yes; you will create your models in an external program (Blender, 3DSMax, etc.) and export them into a format that your game can read. Unless you feel like writing a parser for an existing format from scratch, though, chances are you will be able to find a library to load any kind of model format your software can export. ...


1

Have a look to http://www.scala-js.org/ - it is Scala to JavaScript compiler. Supports source maps and since version 0.6 is not longer experimental. http://www.scala-lang.org/news/2015/02/05/scala-js-no-longer-experimental.html


-2

Export the model as an .obj file, and write a parser. Heres a good video tutorial. Written in Java, but the logic should be about the same. Part 1 https://www.youtube.com/watch?v=KMWUjNE0fYI&list=PLRIWtICgwaX0u7Rf9zkZhLoLuZVfUksDP&index=9 Part 2 https://www.youtube.com/watch?v=YKFYtekgnP8&index=10&list=PLRIWtICgwaX0u7Rf9zkZhLoLuZVfUksDP


-2

In general, you can't. The typical development environments only give you visibility on the C/C++ side. So, I say "you can't" but that's obviously not exactly true. You can't step through the shader and print variables, but still we all develop and debug shaders. But it's a lot of intuiting indirectly what's going on, by repeated runs. Some of the things I ...


2

To answer the first question there is an open source library Assimp which can read such model file, but it comes with an extensive 40+ file types as a generic library which could be a bit bigger in size when you compile. Also it is distributed under 3-clause BSD-License. If you are creating your own gaming engine, then think about creating your own model ...


1

I can't speak specifically for Unity, as I don't use it, but based on my understanding of graphics hardware (I have written a multi-platform 2D rendering engine or two), there will be no performance overhead using non-pot sections of a pot texture. I can think of no reason why this would be any different for Unity. The overhead is purely hardware based.


1

The reason for you getting a black screen when you put the camera inside the cube is most likely back face culling. Try calling: glDisable(GL_CULL_FACE); In the beginning of your display function or in main (after enabling depth test) to disable back face culling. If that is helpful you can either change the winding order of your polygons or change ...


0

I think I found answer. I inattentively read article. "Next, we map xp and yp to xn and yn of NDC with linear relationship." So, xn is linear function from xp. (http://www.mathsisfun.com/algebra/linear-equations.html) And goal is find value of xn in [-1, 1] range. Anyway I didn't understand how author find bottom projection row W (0,0,-1,0).


1

Your problem is your translation matrices. You are not translating enough. Your quad starts at position (50, 50) and is of size (200, 200). That means we have 4 vertices: ( 50, 50) (250, 50) (250, 250) ( 50, 250) You are applying a translation of 200/2 (100) on both axis, which will transform your vertices to these: (-50, -50) (150, -50) (150, 150) ...


0

Two things others didn't mention: The ripples in the water surface are made by Bump-mapping, where you use a texture to add fake depth to your objects(a.k.a. Normal mapping). You could even animate this with noise, so you don't need a texture, just GLSL noise generation.(Quite simple and awesome effect) The very subtle "fog" around the planet might be a ...


3

In very broad strokes, you can accomplish this by: Yes, using shaders Binding three textures to the shader program before drawing On your polygons, have the usual UV vec2 for each vertex. This is used by any of the textures Have another attribute which is "weight of each texture at this vertex". It could be a vec3 or three separate floats. For the ...


0

I was not able to get additive blending working with an integer buffer, however I did get it working with a single channel 32 bit float. I got the effect I was going for by outputting 1 / 2^30 in fragment the shader, with glBlendFunc( GL_ONE, GL_ONE ), then multiplying by 2^30 after reading back the pixels.


0

If the only way your particles die is through age, then there's no need to read the data back from the OpenGL buffers at all. Keep a CPU side buffer that tracks the current age for each particle (or equivalently, remembers the time at which they will die), then your CPU can scan through that list quickly every frame to find particles which need to be ...


0

I agree with everything @Waterlimon stated, that's how our custom game engine works: traverse the scene graph, collect every item to be rendered into either an opaque or transparent render queue (each entry is a pointer to a mesh plus the current world matrix for that mesh and any other render values calculated during the scene graph traversal, like ...


2

As far as I know, modern high performance rendering engines gather render operations into a so called "render queue". Each such operation is basically a single drawcall: it has buffers, shaders, shader uniform data, textures, whatever other state needed... These are then sorted, most expensive to switch property first. Shaders are expensive to switch, so ...


1

GL_RGB32UI <- Is this right? Each texel value is 4 32bit integers? The last time I did this and wrote a single 32bit integer to a texture, I used GL_R32I and GL_RED_INTEGER. I've never had that error before but it seems reasonable if you're texture isn't big enough.


0

EDIT: There is actually no support for what you're trying to do. There is no equivalent function to glVertexPointer in OpenGL for the indexes. I earlier suggested glIndexPointer but it uses an array of colors, not indexes (a very misleading name, and my bad for posting it). Unfortunately you will have to supply a contiguous array of indexes, or find another ...


2

Ok so to answer my own question, it turns out I'm an idiot and overlooked something really simple. The code in my question works perfectly, but I never set the text renderer's projection matrix. To make it work, in the resize method I added the following code: renderer.enable(gl, true); renderer.reshapeOrtho(width, height, 0.1f, 1000.0f); ...


0

It might be worth taking a look at the difference between depth pass and depth algorithms for the shadow volumes rendering (https://en.wikipedia.org/wiki/Shadow_volume) since the problem is similar IIRC. It might be easier to convince yourself with the shadows. You have some pictures here ...


1

I found this paper: "Efficient GPU-Based Texture Interpolation using Uniform B-Splines" http://www.mate.tue.nl/mate/pdfs/10318.pdf Which states: It should be noted that there are some precision issues associated with the hard-wired linear texture interpolation. When, e.g.,an eight-bit texture is filtered, most people would expect that first the ...


0

Basically, there is Vertex data, which is stored in one or more VBOs. Typical (3D) vertex has like: vec3 pos, vec2 uv, mat3 tbn (or vec3 normal) - maybe some other modifiers, possibly several different uv coords or something like that. Anyways, no matter if you store those to 1 or multiple VBOs, IBO will index all the buffers with same index. So, each ...


0

Seeing as though you said you need to support OSX I'm going to presume you request a 3.3 core context or better. You said you don't want to pull in any extra dependencies and to keep it cross platform, so I will try to adhere to this as much as possible. I am using stb_image.h from the Nothing itself nothings. I'm going to define a basic class for a ...


0

DirectX and OpenGl have different coordinate systems for their texture coordinates. OpenGl uses a origin in the lower left but your model assumes that the origin is in the upper left. Because of that you need to mirror the UV coordinates or your images along the y axis. You can do so by setting the v component to 1 - loadedV.


0

When using index buffers, you are indexing into all of the buffers at the same time. That means that if you have a point which can have multiple texture coordinates(If there is a seam at that point) or normals(for example if faceted) then you need to duplicate the given points vertex coordinates with all possible combinations. If you want to have indexing ...


2

As luck would have it Iñigo Quilez wrote an article about this which popped up in my Facebook feed this morning. Hardware texture intepolation is fast and convenient. It is bilinear (plus mipmapping), and despite it can be somehow improved, it works great for most cases. Most cases being texture mapping of surfaces with color/albedo, normal and ...


1

Your picture is of a cube, so I assume that's what you're talking about. You can only share vertices between continuous surfaces. That is, on a sphere, you share all/most of the vertices. On a cube, you must you separate vertices for each face. Aside from texturing, think of the normals you need for lighting. The normal for each side of a cube should point ...


-1

After you are done with the first VAO call glUseProgram(0);. Same applies for the second VAO. void GLViewer::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(handleShaderProg1); glBindTexture(GL_TEXTURE_2D, textureHandle); //Bind texture glBindVertexArray(vaoHandle1); //Bind VAO glDrawArrays(GL_TRIANGLE_FAN, ...


1

Your problem and a possible solution is supplied by chipgw. But there is an alternate solution, which is an importer flag, which will pre-transform everything for you. So you can simply add this flag to your importer: aiProcess_PreTransformVertices. But note that this has a huge negative: It drops all animations.(Although the node tree is kept)


1

As Stephen said in the comments there is transformation data that you are missing. This data is not stored in aiMesh, but in aiNode. Instead of iterating over scene->mMeshes iterate recursively over scene->mRootNode and it's mChildren. Then you iterate over node->mMeshes and use them as the index of scene->mMeshes[index]. Lastly, you need to ...


1

Now I would first suggest you use GLM, but you're using C (according to your tag) so probably not. The best math I suggest in that case is continual use of the sine and cosine functions. My examples will require math.h You will want to first store your camera's position (if you haven't already) float horizontal = cos(pitch) * GetCameraForwardSpeed(); ...



Top 50 recent answers are included