As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [c++]

General-purpose programming language used widely in game development and CPU-intensive tasks.

Filter by
Sorted by
Tagged with
2 votes
2 answers
1k views

How to watch image being ray traced?

In my ray tracer, I render my images out to a .PPM file and then view it in photoshop. To make things easier and faster I want my ray tracer to open up another window and show the image being rendered ...
Arjan Singh's user avatar
  • 2,473
3 votes
1 answer
2k views

How to get the GLFW_CONTEXT_VERSION_MAJOR value?

This code snippet: ...
Adrian's user avatar
  • 647
18 votes
1 answer
6k views

What does "makeContextCurrent" do exactly?

I am pretty confused about that function. GLFW Context reference says as follow: This function makes the OpenGL or OpenGL ES context of the specified window current on the calling thread. A ...
Adrian's user avatar
  • 647
2 votes
3 answers
990 views

Is there a difference between window and screen in computer graphics?

I've been reading some code which setups a ray tracer and I've realized I've a doubt regarding what's a screen and what's a window in this context. Here's the relevant code using Qt: ...
user avatar
5 votes
1 answer
3k views

Modern way of light sources in OpenGL?

In older versions of OpenGL there were things like: glLight(...) gl_LightSourceParameters The modern way of doing lighting is passing light source parameters manually to the shader in vao-s? Or ...
Tudvari's user avatar
  • 313
5 votes
1 answer
249 views

How to rasterize a line when the background color is not always white?

I've to rasterize a line taking into account not only the background color of the screen, which is white, but also the color of other objects in the scene. In my case, I've just another object, a ...
user avatar
1 vote
3 answers
526 views

How are the colors for each pixel from a Ray Tracer stored in an Image?

I have begun learning how to create a Ray Tracer and 1 thing I am confused about is how the pixel color from a Ray Tracer is stored into an image. Do we use SetPixel...
Arjan Singh's user avatar
  • 2,473
4 votes
1 answer
295 views

Material Layering

So after reading this Unreal Engine 4 Documentation page: https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/LayeredMaterials/ (Which describes how to use material layering in UE4) ...
Arjan Singh's user avatar
  • 2,473
3 votes
1 answer
575 views

Flexible Vertex Format Constants in Direct3D 11

How do you migrate Flexible Vertex Format Constants (or FVF codes) from DirectX 9 to Direct3D 11? Old code: ...
Matthias's user avatar
  • 1,044
5 votes
2 answers
144 views

Problem with Basic Diffuse Lighting

So recently I have been learning how to implement Diffuse Lighting in DirectX and I have done so with the following code: ...
Arjan Singh's user avatar
  • 2,473
3 votes
1 answer
543 views

Creating a gently moving 2D fog effect

I am trying to create a fog-like effect, similar to that found using perlin noise. I know where I can find information about that effect, but it's harder for me to tell if it's an efficient route for ...
aceslowman's user avatar
1 vote
1 answer
787 views

How to use Shaders with vertex & index buffers?

I'm trying to render a randomly generated terrain with vertex buffers and OpenGL. I want to use a shader to color the terrain, but it seemms like my shader isn't used. I have used shaders before when ...
lega's user avatar
  • 57
7 votes
1 answer
362 views

Ray casting in fan configuration produces point cloud with curvature, how to eliminate curvature?

I'm attempting to perform an intersection test using ray casting (not sure if correct term so please forgive me if not) and am outputting the intersections as a point cloud, and the point cloud shows ...
Irongrave's user avatar
  • 173
4 votes
1 answer
2k views

Compute shader not updating buffer, or vertex buffer unable to read the updates

I'm learning OpenGL compute shaders and following this guy's code, and I have stuff drawing, but not updating. The particles are spread out in their starting positions, but they stay there. ...
John Cox's user avatar
  • 161
7 votes
1 answer
210 views

Proper architecture for rendering history of streamed data (points)

Overview My program receives some data points (0-400 per sec). ...
BPiek's user avatar
  • 307
3 votes
1 answer
299 views

Can't make blending work

I have a 3 dimensional dataset where each value of the dataset is normalized to [0, 1]. I want to visualize this dataset by using texture, and blending. However, it ...
Sayan Pal's user avatar
  • 263
2 votes
1 answer
181 views

Uniform not set, despite valid location

I try to write a simple triangle mesh renderer with OpenGL. ...
Dragonseel's user avatar
  • 1,800
4 votes
2 answers
1k views

How to check which API's are available on a given machine?

I'm building an engine, which has Vulkan for its primary rendering engine. But to have at least some backwards compatibility with devices that don't have drivers for it (mainly mobile) I want to ...
Aaro's user avatar
  • 43
6 votes
1 answer
723 views

Perspective correct interpolation of normal values

I'm currently writing a software rasterizer and I'm at the point where I can draw arbitrary triangles with vertex colors and perspective correct texture mapping. I do point and directional lighting by ...
Leon2806's user avatar
6 votes
2 answers
770 views

Open GL Shader Storage Buffer Objects to replace Vertex Attributes

At first: I already posted this on the stackoverflow community. I'm new and didn't know about this community here. I apologize. I basically got the same question as the guy who asked here: https://...
try_some_ubik's user avatar
7 votes
1 answer
1k views

Resulting Probabilty Density in Path Tracer for paths using Next Event Estimation

I am trying to implement my own Gradient Domain Path Tracer by following the code of this guy who already implemented it: https://gist.github.com/BachiLi/4f5c6e5a4fef5773dab1 I already managed to ...
Tarta's user avatar
  • 355
8 votes
1 answer
2k views

Role of PDF of Uniform Random Sampling in a path tracer

I am trying to implement my own path tracer but before arriving to the question I want to give you a short overview: In the implementation of the rendering equation I use some particular technique in ...
Tarta's user avatar
  • 355
2 votes
1 answer
367 views

Generate this kind of 2d burst or pulse algorithm?

I'm currently trying to develop a game using Cocos2d-x using C++. I really need to generate this burst or (donut-shaped) pulse. I'm having a difficult time how to generate such shape. At first, I was ...
quinnavery's user avatar
4 votes
0 answers
1k views

Represent vector with arrow

Another code review question. I am trying to draw an arrow to represent a vector. I have started with an unit arrow with vertices defined as follows: ...
Sayan Pal's user avatar
  • 263
3 votes
1 answer
694 views

Ray-tracing the Cornell Box results in really inconsistent image

So I have a vector of glm::vec3 containing the triangles for the classic Cornell Box called triangles. The Draw method casts a ray for each pixel on the screen and ...
swedish_fisk's user avatar
6 votes
1 answer
1k views

How to compensate low amount of rays reaching the light in a Path Tracer

I am trying to implement for research purposes a path tracer, but so far but results are not so good and I will explain you why. The general idea before getting to the code: I am working on paths ...
Tarta's user avatar
  • 355
5 votes
2 answers
756 views

Path tracer not rendering shadows

I am trying to implement for research purposes a gradient-domain path tracer. In order to achieve this step I first need a working Path tracer. I have been creating one so far but results are wrong ...
Tarta's user avatar
  • 355
2 votes
1 answer
1k views

OpenGL C++ Camera Rotation Problem

Currently for a university assignment I have been given a 3D rendering engine, capable of rendering a 3D world. One task is to create a first person camera for it (I know with OpenGL you don't have a ...
iBaconButty's user avatar
2 votes
1 answer
3k views

Creating vector shapes using only C++ [closed]

I've been researching for quite a while and I couldn't find any explanation or at least a how to create a vector graphic application (specifically in windows) where I can create a 3D vector shape, say ...
charle's user avatar
  • 21
2 votes
0 answers
211 views

Free 3D Scene Simulation Framework [closed]

I want to visualize a scene with simple shapes (e.g. boxes, pyramides, etc.) and I am looking for a tool or framework in C/C++ to do this. Focus of the application is to parameterize the relative ...
dcfyg's user avatar
  • 21
21 votes
1 answer
21k views

Get vector length with GLM

I am quite confused over how GLM library is behaving or I am using it improperly. glm::vec2 testVec(6,-4); float len = testVec.length(); I get the value ...
sajis997's user avatar
  • 1,209
7 votes
2 answers
2k views

OpenGL with SFML, create an n-pointed star?

Completely stuck on how to do this. Yes, it is a homework problem, but its the first we've had in the class so not too familiar with graphics. Also, seeing as its homework, please don't just give the ...
user2645's user avatar
6 votes
1 answer
1k views

Type conversion to GL-types

If I have a std::vector<Foo> and want to store its size in a GLuint, my compiler gives a warning that there is possible ...
Dragonseel's user avatar
  • 1,800
1 vote
0 answers
119 views

Selecting pixels within a circle having a decimal (non integer) radius

I want to select a pixel within a circle of a certain radius. But the radius is expressed in a decimal form (0.12). What does it mean to have a radius equal to 0.12? And concretely how to pick a pixel ...
S.E.K.'s user avatar
  • 141
6 votes
1 answer
171 views

How should I generate the view position for a light at infinity when creating depth maps?

I'm working on implementing Bruneton's cloud rendering paper, which requires one to render a pair of depth maps, similar to how shadow mapping works. In this case, my light source is the sun (or ...
stix's user avatar
  • 163
5 votes
1 answer
261 views

How to set the GLFW OpenGL target?

I'm programming on a Mac and I'm learning OpenGL in the library GLFW. My problem is that my Mac supports OpenGL up to version 4.1, but when I try to compile the shaders with ...
Leonardo D. Mariscal's user avatar
4 votes
1 answer
816 views

Angle between two points in Cartesian coordinate system C++

I'm trying to rotate a rectangle so that it faces another rectangle in a spiral. Im using the Bullet pyhics library and freeglut for the 3d application, for anyone interested https://github.com/...
David's user avatar
  • 303
9 votes
2 answers
8k views

Archimedean spiral in C++

Im trying to plot the x and y positions of an Archimedean spiral in C++. So far I've been trying something like this, but no luck: ...
David's user avatar
  • 303
8 votes
1 answer
1k views

The meaning of early ray termination and front-to-back traversal in ray tracing

I'm new to computer graphics. These days I've been trying to understand how ray tracing using an acceleration data structure works. I came across the term "early ray termination" several times, I ...
S.E.K.'s user avatar
  • 141
5 votes
1 answer
2k views

Draw angles lines in raster graphics using bresenham line algorithm

I at the moment trying to draw some angled lines using bresenham line algorithm which can circulate a 2d array of size 21x21, as a line angled from 0 - 2pi. So the idea is that the program has to ...
Bob Burt's user avatar
  • 183
3 votes
0 answers
65 views

Draw lines angled from 0 to 2 pi in a raster grid [duplicate]

I am trying to draw an angled line in a raster grid. The idea is to create a function that given a start point, a length and an angle, would give me the pixel positions that combined would give me a ...
noob's user avatar
  • 31
5 votes
1 answer
1k views

Ray-triangle intersection algorithm not intersecting (C++)

I've been trying to implement the Moller-Trumbore ray-triangle intersection algorithm in my raytracing code. The code is supposed to read in a mesh and light sources, fire off rays from the light ...
Haley's user avatar
  • 51
7 votes
1 answer
6k views

Shadow rays in Raytracing

After spending a few days making very little headway with a simple Raytracing program that implements Phong illumination (with shadows and no attenuation), I'm convinced I've made a logic error that I'...
user1764241's user avatar
8 votes
1 answer
862 views

DirectX12 CbvHeap

With directX12 they introduced heap descriptors. A way for us to describe the table for resources we wanted to send to the shaders. I'm admittedly very new at computer graphics and only tinkered a bit ...
Andrew Wilson's user avatar
4 votes
1 answer
5k views

DirectX 12 Constant Buffer Binding

I can't really seem to figure out how to bind two constant buffers to my shaders. I have them described like so. One in slot b0 and the other in slot b1. ...
Andrew Wilson's user avatar
14 votes
4 answers
1k views

Projected grid water horizon detail

I'm trying to implement an ocean scene with C++ and DirectX11. Currently I have a projected grid, Gerstner waves and a basic shading. My problem is that when I aim my camera horizontally, so I can see ...
Gábor Szalóki's user avatar
3 votes
1 answer
205 views

First quad being re-used?

I had posted about this issue in a previous question, however, I thought instancing was causing it, whereas even using normal uniforms or a SSBO (which's what I'm using right now) causes it, which ...
Darkilon's user avatar
5 votes
0 answers
352 views

Incorrect instanced rendering

Previously, to render a bunch of quads, I was simply using a few uniforms (one for a model matrix and another for the texture layer ID). However, I'd rather not have to loop through each quad and set ...
Darkilon's user avatar
5 votes
1 answer
975 views

Dx12 Vertex Buffer incorrect

I'm playing around with directX 12 and I'm having some problems loading geometry in. I have a std::vector vertices definition and I do exactly what the dx12 template does with it. ...
Andrew Wilson's user avatar
7 votes
1 answer
2k views

How to convert a thread ID into Screen Space Coord in an OpenGL Compute Shader?

I've written an implementation of the sphere tracing algorithm in OpenGL 4+. As an experiment/toy project, I'm re-implementing it using the OpenGL 4.3 compute shader, but I'm having trouble with the ...
Matteo Bertello's user avatar

1 2 3
4