New answers tagged

0

First make sure that your matrices are column-major. Second this call: glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 ); Should look like this: glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 3, (void*)0 ); Because you want to move vertex attrib pointer by 3 floats (I ...


2

Your best bet is to make a class that replicates Javas Graphics class in LWJGL. For textures you can write your own LWJGL wrapper or use Slick 2D


0

So the problem might be in this place: glBindVertexArray(vao); glBindBuffer(GL_ARRAY_BUFFER, vbo); //Position glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(0); glVertexAttribDivisor(0, 1); //ID, for texture positioning ...


0

OpenGL uses column-major matrices, but as I understand from your code you pass row-major matrices. So in GLSL scale[0] is the first column of scale matrix.


0

Does Forward-Point shader compiles successfully? Does point light shader program (Program Object) links successfully? Do you call glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) before rendering? Have you enabled depth test (glEnable(GL_DEPTH_TEST))?


1

Before glfwCreateWindow() call these functions: glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); And after glfwMakeContextCurrent(window) call: printf("OpenGL version: %s\n", glGetString(GL_VERSION));


2

It turns out that the cube map texture has to be EXACTLY square or OpenGL will break, and for some reason it doesn't throw an error when I do this, so I don't really know if this is a SOIL error or OpenGL error... EDIT: I used a different library to load textures and it seems that the texture still is black when its is not perfectly square.


4

Your first check is likely to be a LoadLibrary call (or equivalent for your platform) for the Vulkan DLL: HMODULE vulkanDll = LoadLibrary("vulkan-1.dll"); Then you'll want to acquire the pointer to vkCreateInstance. PFN_vkCreateInstance vkCreateInstance; // ... vkCreateInstance = GetProcAddress(vulkanDll, "vkCreateInstance"); Then you'll want to fill ...


2

http://chat.stackexchange.com/transcript/message/30419781#30419781 Bind more than one render target. Output two different colors from the fragment shader. You will of course need a second draw call to draw a fullscreen quad containing the render target you want to show. You can also branch every fragment on a uniform if you really want. Fairly ...


0

The docs for setRenderer() say: This method should be called once and only once in the life-cycle of a GLSurfaceView. If you look at the source code, you'll find that they actually meant "must" rather than "should". The setRenderer() method checks to see if a render thread is running. If not, it creates one and starts it. If the thread already ...


0

Simplest possible way is obviously the following: create mesh with enough vertices that describes water surface configure your shader to move the vertices in a circle


0

Seems like your UVs are not correct. Can you maybe post us the contains of the vertex vec ? Sry that I made this as an answer but I cant comment yet.


0

I think glVertex3f takes NDC coords, so you have to normalize your variables.


0

Depends on which level of detail you wanna achieve. Height Maps could be a solution, try to avoid as much work on the CPU as possible in every case. You can combine also some techniques as tesselation. There are plenty sites on the web for inspiration, you know where to search :)


0

You could just try leaving VAO calls out of your code and bind VBOs etc. where VAOs are bound in the tutorials.


-1

So turns out it was a problem with my UV coordinates.


1

The depth is stored from 0 to 1 (0 - closest, 1 - farthest) by default. Addition to that, depth in perspective projection is not linear, it looked something like this: So it makes sense to me if it fades to white faster.


1

Your depth buffer seems fine to me. The images you posted most likely have been normalized to make details more easily seen. This process consists of finding the maximum and minimum value of the depth buffer and remapping the color range onto that range. It is also linearized. Graphics debuggers have usually such an option to render the depth buffer (or even ...


0

There are two really good tutorials on the internet about how to improve performance, both by a guy called ThinMatrix. The first is mostly what you are looking for, but if you want to make it SUPER efficient you can also take a look at second one: First: https://youtu.be/X6KjDwA7mZg Second: https://youtu.be/Rm-By2NJsrc


1

There are only a couple of coding related restrictions: Unity is not (very) mulit-threaded. You don't get direct access to the app's starting point or it's core rendering loop. You can't call core windows or other OS specific libraries easily (because it's cross platform). Other than that, you have almost the entire scope of .net 3.5 (C# and a version ...


0

It is actually easier than you think. The way this works is really simple, it is a lot like video. So, when you watch a video(I am sure you know this already but just as a reminder) you are not actually watching a moving image, instead you are watch a lot of images getting displayed one after the other REALLY fast, faster than your eye can see(There is a ...


0

First of all, please put a simple version of your code here so I can fix it for you. But for now, there is lots of reason you can't render correctly in your cube map: Early use of texture (use flush and finish to make sure your using a completed frame buffer) Maybe your texture and frame buffer format are mismatched. There is lots of other problematic ...


4

Fixed it! One of the TBOs is filled with unsigned integers, therefore usamplerBuffer has to be used instead of samplerBuffer — layout(binding = 0) uniform usamplerBuffer primIdToFaceId; layout(binding = 1) uniform samplerBuffer faceNormals; Some debugging and results. Using fColor = vec4(0.0, mod(gl_PrimitiveID,256)/255, 0.0, 1.0); in the fragment ...


-2

after setting glDepthRange(n, f); Full formula: finalDepth = (gl_Position.z/gl_Position.w)*(f-n)*0.5+(f+n)*0.5 Bonus: Every other answer out there about depth buffer always assumes the use of projection matrix, this matrix is a waste of space, time and precision, of the 16 floats that it has only 2 are really needed, the "field of view" and the "...


0

After all of your transformations are applied (rotations, perspective transformations, etc.), all of the coordinates are divided by w (the fourth value in the gl_Position vector) to determine Normalized Device Coordinates, NDC. In other words NDC = (x/w, y/w, z/w) The x, y, and z coordinates in NDC space are in the range [-1..1] if they are in the clip ...


0

If I remember correctly, z (as well as x and y) will be divided by w. Then, everything outside of -1..1 will be culled. And then, resulting value will be mapped to 0..1 (or to whatever range you selected with glDepthRange()). In case of default range, full formula would be depth = z / w / 2 + 0.5.


4

In short - you track input events (whatever you have), and check if mouse/touch/whatever click coordinates is crossing sensing area that designate your button on screen. Then you call associated function that process this event.Detailed answer will require explaining lots of very basic stuff (you didn't even name your windowing lib/framework/api), and you ...


2

Thats because glBegin, glVertex2f and glColor3f are legacy functions which are deprecated. You may still use them if you request a backwards-compatible context, however I'd recommend you stick to your core-context (which is not backwards compatible) and learn the more powerful modern OpenGL. There is a pretty good modern OpenGL tutorial series on opengl-...


0

If you have multiple object, then of course you must check each. However, you can first get the closest object to the cursor, and then check if it's inside. Object closestObj = null; // no object selected float closestDist = 50; // all objects are smaller than that, Object currentObj; float currentDist; for each currentObj in sccne { currentDist = ...


0

Now, if the object is a circle, you must use another formula. Suppose that the circle is centered on (centerX, centerY) and its radius is radius. The mouse cursor is inside the circle if... (cursorX - centerX)^2 + (cursorY - centerY)^2 < radius^2 If it's an ellipse where the horizontal radius is radiusX and the vertical radius is radiusY, then the ...


0

"I need to know how to use it to check if the mouse is currently over any of my rendered objects." Suppose that your object is a rectangle with the following attributes: posX: horizontal distance from left of the screen to the first pixel of the object. posY: vertical distance from top of the screen to the first pixel of the object. sizeX: horizontal size....


0

I finally found the solution to my problem: I have to set the viewport to begin at origin when I render to framebuffer. I didn't mentioned that I was rendering my scene to the framebuffer, because I thought it was irrelevant and apparently that casued the problem. In my case viewport transfromations accumulated: first when rendering to texture using ...


1

You don't have to change your projection matrix accordingly to the viewport. Have you considered to render the scene to a fbo and then render the fbo fullscreen (from -1, -1 to 1, 1) with glViewport(width / 2, height / 2, width / 2, height / 2)? This will took a quarter of the screen (top right). In my current project, i can freely set the offset of ...


1

It is possible with Pyglet (even without PyOpenGL), I've successfully done it with the following code (slightly modified). However, my Pyglet version is a little behind. With the code you can create a valid Pyglet texture which you can use as a render target. Set the render target to None when you want to draw to the screen again. import pyglet, traceback, ...


0

Last time I checked the cel based approach was popular (and I believe minecraft does something similar) That said here's a previous answer to this problem: How can I implement lighting in a voxel engine?


0

If I understand your question: Your asking how to get the world coordinates of the camera, with a look vector to raytrace? Start by getting the position of your camera, which is simple how you translated the world to get from it's position relative to 0,0 (where the camera always is). Then, look at how you rotate the scene to do the same. From there, you ...


0

A guess as to why that line is there is that your flipping algorithm doesn't handle odd/middle lines well. I recommend the classical algorithm for flipping, for(int i = 0;i<length/2;i++) array[i] = array[array.length-i - 1] (psuedocode).


0

Okay, after some hours of research, i finally ran into this site which work exactly how i wanted. The techique works as follows: Render the objects as usual into the G buffer so that the depth buffer will be properly populated. Disable writing into the depth buffer. From now on we want it to be read-only Disable back face culling. We want the ...


0

First of all, please give a complete source code of (small error-prone version of) your project, because this kind of problem depends on lots of things. However, there are lots of reasons that can make unwanted black screen, most common mistakes that I can guess in your case, are: mathematics mistakes camera matrix (in your case see your clipping range) ...


1

Here's what I think is happening: the matrices in your static singleton sprite class (say that three times fast) -- specifically the model-view matrix -- is being modified on drawing every sprite without being reset to how it was before the modification. As such, any transformation you perform for one object is also applied to any subsequently drawn object ...



Top 50 recent answers are included