Questions tagged [opengl]

21981 questions
1

votes
2

answer
89

Views

OpenGL: Quads seemingly not culled properly

I have built a simple scene like the following: The problem is, the blue shape is lower than the red one but somehow bleeds through. It looks proper when I rotate it like the following: From what I searched this could be related to the order of vertices being sent, and here is my definition for thos...
SenselessCoder
1

votes
1

answer
83

Views

Problem with calculating the bounding box of a 3D object with transformation

So I have a really weird behavior for my bounding boxes. Everytime I translate an object with any value being negative the bounding box gets stretched to the 0 point. Here is how it looks with a positive translation: Everything is fine. But now I translate it with a negative Z coordinate. Here is my...
RalleYTN
1

votes
3

answer
121

Views

Qt3d. Draw transparent QSphereMesh over triangles

I have a function that draws triangles through OpenGL I draw two triangles by pressing a button (function on_drawMapPushButton_clicked()). Then i draw a sphere that placed above these triangles. And now i see, that sphere is drawed correctly over first triangle, but second triangle drawed over the...
Ligvest O
1

votes
1

answer
60

Views

How do I use a mixed type c++ struct and only pass some values to OpenGL?

I have read high and low and thought I understood C++ and OpenGL vertex data layouts, but I must be wrong somewhere... I have a struct to create a Line object. Therefore it has two points (each of 3 floats to represent a vector position). It must also have an object ID to allow me to track the speci...
Nas25
1

votes
1

answer
71

Views

Movement of '2D' camera in OpenGL/C++

I've checked every other related question on this site but none of the solutions have worked for me. I'm simply trying to follow my rectangle, which moves left and right with key presses in OpenGL. Here's my very simple program: /*Begin useful backend functions/vars*/ /******************************...
eddiewastaken
1

votes
1

answer
72

Views

How to fix lighting rotating with model?

My goal is to create small scene with lighting. However, lighting seem to rotate together with my rendered object (test cube). In most responses I've read I should use GL11.glLight in projection and model matrix mode, I assumed. Please correct me if I'm wrong. However, result is that lighting works...
ShirouWrath
1

votes
1

answer
51

Views

Understanding the OpenGL projection matrix

I've been writing a program to display 3d models using OpenGL and until now I've used orthographic projection, but I want to switch to a perspective projection so that as the camera goes toward the model it appears to get larger. I understand that I have to multiply three matrices (model, view, and...
sam
1

votes
2

answer
33

Views

openGL - failed to display an images

Learning to display images using QOpenGLWidget. However, I've met some problems. How can I pass the GLuint texture variable (the actual texture loaded from the image) into the shader scripts? Like how to bind GLuint texture to uniform sampler2D texture? Maybe I am just not realising I already did th...
Jinx
1

votes
1

answer
57

Views

How can I add multiple textures to my openGL program?

I am writing an openGL program and have multiple models drawn into the environment, but I don't know how to apply different textures to each of those models, so for now they all have the same texture. I've read that I need to add multiple texture units into the program or use a texture atlas. A text...
sam
1

votes
2

answer
31

Views

Encode axis aligned unit vector in a single float value

I want to encode axis-aligned unit vector in a single float value. Like this: 0: vec3(0, 0 ,0) 1: vec3(1, 0, 0) 2: vec3(0, 1, 0) 3: vec3(0, 0, 1) To convert float to vector according to the table I can write a simple code in float axisIndex ... vec3 axis = vec3(0.0, 0.0, 0.0); if (axisIndex > 0.5) {...
Rem
0

votes
0

answer
14

Views

How to render specific data set(not in a common RGBA format) with openGL?

I have a set of data, which is 256x256x18 byte (means 256 in width, 256 in height and every 'pixel' is 18 byte). And I want to render it to a 256x256 normal RGBA picture. I known how to do this in CPU. Besides, I have learned how to use texture2D to do some pixel work with normal RGBA pictures. I wo...
DWCarrot
-2

votes
1

answer
102

Views

GLSL Shader compilation fails without error message

I got the following shader embedded in my code: static const GLchar * frag_shader_rect = 'precision mediump float;\n' 'varying vec4 v_color;\n' 'void main() {\n' ' gl_FragColor = v_color;\n' '}\n'; When I try to compile this shader with glShaderSource(shader, 1, &frag_shader_rect, NULL); glCompile...
Nidhoegger
-2

votes
0

answer
10

Views

Why window 2D coordinates doesn't equal to 3D coordinates

I have OpenGL Window 640x640. 2D shapes are drawing correctly, but 3D shapes(2D shapes in space) don't depends on it, looks like it has own coordinates(from -1 to 1 by x,y,z). Why is it like this? What should I configure? I use glut.
AWRDev.
1

votes
1

answer
744

Views

glBlendFunc transparency in OpenGL with GLKit

I'm using GLKit for an iPad app. With this code I setup blending: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); It works fine, but when I try to get a screenshot the blend mode seems wrong. It doesn't matter if I use GLKit's snapshot or glReadPixels. This is what I get when...
Odrakir
1

votes
1

answer
16

Views

Is it possible not to clamp data when using glReadPixels?

I'm trying to develop a code where I load a 3d model with assimp, do stuff with the 3d coordinates and normals of verticies and then I want to retrieve my textures to CPU. I tried using 'glReadPixels' to retrieve the textures but my data is getting clamped between [0 1] as they describe in here. An...
user6138759
1

votes
1

answer
348

Views

In OpenGL, is there a way to blend based on a separate channel's value in the shader?

In OpenGL (not ES), is there a universal way to blend based a texture while drawing based on another texture or variable's value? On OpenGLES, I know that I can do custom blending on some platforms via extensions like GL_EXT_shader_framebuffer_fetch. The reason I ask, is that I have a special textur...
David
1

votes
2

answer
62

Views

Rotation accuracy error builds up too fast?

When applying rotations one after another, precision errors accumulate. But I am surprised of how fast the error builds up. In this example I am comparing 2 transformations that are equivalent in theory. In practice I get 0.02 degrees error by doing just 2 rotations instead of one. I was expecting t...
Octo
1

votes
1

answer
73

Views

Stop the background from moving

#include #include 'glut.h' #include float squareX = 0.0f; float squareY = -0.3f; float squareZ = 0.0f; static int flag = 1; // The background void drawBackground() { // draw the green ground glBegin(GL_POLYGON); glColor3f(0.0, 0.60, 0.0); glVertex2f(800, 100); glVertex2f(800, 0); glVertex2f(0, 0);...
Muddy
1

votes
1

answer
55

Views

Legacy OpenGL texturing cube

I am trying to texture a cuboid in legacy OpenGL. No matter which side of the cuboid I render first, this side is not textured correctly where as all other sides are textured correctly. I have tried rendering different sides of the cube first. This is the code that draws the cube including it's text...
callum perks
1

votes
1

answer
40

Views

Legacy OpenGL Textures not working correctly

I am usign legacy openGL. I am drawing multiple objects in a scene. I want the sphere that is being drawn to be textured but all other objects to be solid colours. However, if I try to disable the texture after drawing the sphere, everything else is black. This is the code where I create the texture...
callum perks
1

votes
1

answer
85

Views

Why does the 'f' suffix when defining floats sometimes cause GLSL compiler errors?

I've been making my own OpenGL game for fun to learn C++ (coming from Java). I was testing it on another computer I have so I could test it's performance on a weaker system, and I found that there was a shader compiler error. It seems that on my computer running with Intel Integrated Graphics, the f...
Robert
1

votes
1

answer
85

Views

OpenGL 3.3 (mac) Error validating program: Validation Failed: No vertex array object bound

The following code compiles and runs without errors on linux but gives error 'Error validating program: 'Validation Failed: No vertex array object bound.' on mac OS 10.14.2 (Mojave). Note that the program compiles successfully but has a problem during runtime. MacBook Pro (Retina, 15-inch, Mid 20...
Satu0King
1

votes
1

answer
78

Views

Making the square bigger when it moves

#include // this library is for standard input and output #include 'glut.h' // this library is for glut the OpenGL Utility Toolkit #include float squareX = 0.0f; float squareY = 200.0f; static int flag = 1; void drawShape(void) { float width = 58.0f; float height = 40.0f; glTranslatef(squareX, squ...
Muddy
1

votes
1

answer
47

Views

Using Texture1D instead of uniforms

I'm using a color palette of 5 colors in my game, and every time I am passing every single color as a uniform vec3 to the program. Would it be more efficient if I was using a one dimensional texture that contains all 5 colors (15 floats in the texture)? That's just one of the situations where I wou...
1

votes
1

answer
51

Views

OpenGL default framebuffer contents disappear after minimize/restore cycle?

This program draws a point per frame until the screen is full of points. #include #include int SCREEN_WIDTH = 500, SCREEN_HEIGHT = 500; int main( int argc, char** argv ) { SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3 ); SDL_GL_SetAttr...
Tristan
1

votes
2

answer
59

Views

What's minimum required code to MODIFY a WebGL shader at runtime?

Suppose I have created a WebGL program, attached some initial shaders, linked the program, validated and after some time I want to modify source of one of the attached shaders. Should I create a new WebGL program with the gl.createProgram(), or I can just reuse it and attach shaders? I'm a bit conf...
HankMoody
1

votes
1

answer
125

Views

Updated graphics card does not update opengl32.dll

I've been trying to paint a texture on a square for the last week, but to no avail. The square draws but no texture. I'm using OpenGL, Delphi XE3 & Windows 10. The problem is the glGenerateMipmap function. My older version of opengl doesn't have the MipMap functions. So I replaced my card with...
Humanoid1000
1

votes
1

answer
33

Views

How to fix black screen output in OpenGL 3.3

I am experiencing a black screen in my project using OpenGL and C++. I am in need of assistance as to where I went wrong rendering a red triangle to the screen. I have tried checking for errors in the vertex and fragment shader. #include #include #include #include #include using namespace std;...
rial
1

votes
2

answer
684

Views

Can I still do object oriented programming when using OpenGL ES on iPhone OS?

When I program with OpenGL ES on iPhone OS, I have to use a lot of OpenGL functions. This looks very procedural to me. I wonder if I could make a class called 'cube', which will draw an cube if called. Or must all the application code be in one huge scope?
Thanks
1

votes
2

answer
1.3k

Views

Problems about allocating openGL 3D texture size of 1G

I'm doing some work on Volume Rendering. I want to allocate a 3D luminance texture of 1024x1024x1024 uchar. Unfortunately it always fails. By adding glGetError() after glTexImage3D(...), I get the error code 1285, which means 'Out of memory'. However, my card is NV quadro 4800, whose memory size is...
rtrobin
0

votes
0

answer
13

Views

How to use keyboard and mouse input to navigate a figure

I'm working on a project involving viewing a 3D from different viewpoints using mouse and keyboard input. When I submitted my first draft, I received the following feedback: 'Your object did not react to any of the buttons I pressed to change the camera view! The object of this project is to have th...
Tracy Harrison
0

votes
0

answer
10

Views

How to zoom in on cursor point in Mandelbrot Set?

I'm currently trying to implement a zoom feature for the Mandelbrot Set code I've been working on. The idea is to zoom in/out where I left/right click. So far whenever I click the screen, the fractal is indeed zoomed in. The issue is that the fractal is rendered not at the origin-- in other words, i...
dave pleteau
1

votes
1

answer
68

Views

OpenGL storing variables per shape without any duplicates

I've been working on a sprite renderer, and I have rectangles being rendered correctly, but now I want to rotate them and perhaps add textures to the endeavor. However, I don't know how to store the angle, for example, without duplicating the data. Currently, every vertex has its position, and it wo...
Whiteclaws
1

votes
0

answer
43

Views

How set the opacity/alpha of an image using OpenGL ES 2.0 and GLKit?

I have create function with OpenGL ES 2.0 and GLKit. I have used GLKBaseEffect for draw GLKTextureInfo and GLKTextureLoader for load PNG file on GLKTextureInfo. (heart.png) Now, I want to set the opacity of the PNG image. This may sound simple, but I have no idea how I can change the opacity...
Easy Soft
1

votes
1

answer
139

Views

OpenGL compute shader premature abort after calling glComputeDispatch

I have been trying to run a very simple counting compute shader to get a grasp on how many times my shader runs and how large of a compute array I can process. It seems that I'm either hitting some driver limit or my shader takes too long for the card to execute so it is prematurely aborted or some...
Martin
1

votes
1

answer
132

Views

Code of Computer Graphics not compiled or installation failed

I followed instruction described http://www.cse.iitm.ac.in/~vplab/courses/CG/opengl_start.html that is as following - OpenGL (GLUT) on Linux (Ubuntu) Installation Install the following packages from the ubuntu repository: 1. freeglut3-dev 2. mesa-common-dev sudo apt-get install freeglut3 freeglut3...
1

votes
1

answer
248

Views

LibGDX optimize way to draw background with large resolution

I have a problem that has been torturing me for a month, and maybe more. There is a large background of about 9000x13000 pixels. And I am trying to bring this background to the screen. Since my video card only supports textures with a resolution of not more than 8192x8192 pixels, a black area is dis...
Ryder95
1

votes
0

answer
178

Views

C++ Can I use OpenGL framebuffer without seeing the window?

I have an OpenGL application, that displays a camera frame with some 3d elements rendered on top of it. What i am trying to do is use openGL to combine the frame and elements, but then display the image with OpenCv, and not show the OpenGL window. Is this possible? The current code is: int main() {...
anti
1

votes
0

answer
296

Views

What do glAttachShader and glLinkShader actually do?

As these steps are followed to create a shader program which can later be used to draw an object on the screen. glCreateShader -> glShaderSource -> glCompileShader -> glCreateProgram -> glAttachShader -> glLinkProgram -> glUseProgram What does glAttachShader do? Does it copy shader object inside...
user2259784
1

votes
1

answer
52

Views

Newly Build APK in Unity Crashes

On my logcat the error says version 100 01-09 11:34:55.899 23467-23515/? D/Unity: #ifndef SHADER_TARGET 01-09 11:34:55.899 23467-23515/? D/Unity: #define SHADER_TARGET 30 01-09 11:34:55.899 23467-23515/? D/Unity: #endif 01-09 11:34:55.899 23467-23515/? D/Unity: #ifndef UNITY_NO_DXT5nm 01-09 11:34:55...
NoobProgrammer

View additional questions