All Questions

Tagged with
Filter by
Sorted by
Tagged with
179 votes
7 answers
308k views

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with g++ -Wall -lglut part8.cpp -o part8 So I was wondering if it is possible to have g++ make static compiled ...
Louise's user avatar
  • 6,463
126 votes
9 answers
83k views

opengl: glFlush() vs. glFinish()

I'm having trouble distinguishing the practical difference between calling glFlush() and glFinish(). The docs say that glFlush() and glFinish() will push all buffered operations to OpenGL so that one ...
jay.lee's user avatar
  • 19.6k
115 votes
1 answer
240k views

How to properly link libraries with cmake?

I can't get the additional libraries I am working with to link into my project properly. I am using CLion, which uses cmake to build it's projects. I am trying to use several libraries in conjunction ...
Cache Staheli's user avatar
104 votes
3 answers
135k views

How to use glOrtho() in OpenGL?

I can't understand the usage of glOrtho. Can someone explain what it is used for? Is it used to set the range of x y and z coordinates limit? glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); It means that ...
ufk's user avatar
  • 31.5k
101 votes
5 answers
80k views

Confusion between C++ and OpenGL matrix order (row-major vs column-major)

I'm getting thoroughly confused over matrix definitions. I have a matrix class, which holds a float[16] which I assumed is row-major, based on the following observations: float matrixA[16] = { 0, 1, 2,...
Mark Ingram's user avatar
  • 72.8k
89 votes
5 answers
38k views

What is the role of glBindVertexArrays vs glBindBuffer and what is their relationship?

I'm new to OpenGL and Graphics Programming. I've been reading a textbook which has been really thorough and well-written so far.However, I've hit a point in the code that I'm not quite understanding ...
DashAnimal's user avatar
85 votes
10 answers
116k views

Drawing Sphere in OpenGL without using gluSphere()?

Are there any tutorials out there that explain how I can draw a sphere in OpenGL without having to use gluSphere()? Many of the 3D tutorials for OpenGL are just on cubes. I have searched but most of ...
Carven's user avatar
  • 15.3k
80 votes
7 answers
239k views

How to get the GL library/headers?

#include <gl\gl.h> #include <gl\glu.h> #include <gl\glaux.h> This is an example, but where to get GL headers?
cdxf's user avatar
  • 5,559
73 votes
4 answers
153k views

Understanding glm::lookAt()

I am following a tutorial to learn OpenGL in which they used glm::lookAt() function to build a view but I cannot understand the working of glm::lookAt() and apparently, there is no detailed ...
Cashif Ilyas's user avatar
  • 1,683
70 votes
11 answers
47k views

How to Practically Ship GLSL Shaders with your C++ Software

During OpenGL initialization, the program is supposed to do something like: <Get Shader Source Code> <Create Shader> <Attach Source Code To Shader> <Compile Shader> Getting ...
Korchkidu's user avatar
  • 4,938
65 votes
2 answers
60k views

Camera position in world coordinate from cv::solvePnP

I have a calibrated camera (intrinsic matrix and distortion coefficients) and I want to know the camera position knowing some 3d points and their corresponding points in the image (2d points). I know ...
nkint's user avatar
  • 11.7k
61 votes
6 answers
48k views

Why are SDL and OpenGL related?

I was messing around with SDL and found out that you cannot rotate images with SDL. Everywhere the question was asked, people said to use OpenGL to do rotation. I always thought that SDL was ...
Devan Buggay's user avatar
  • 2,737
57 votes
6 answers
78k views

Calculating normals in a triangle mesh

I have drawn a triangle mesh with 10000 vertices(100x100) and it will be a grass ground. I used gldrawelements() for it. I have looked all day and still can't understand how to calculate the normals ...
Vince's user avatar
  • 623
57 votes
4 answers
27k views

Segmentation fault at glGenVertexArrays( 1, &vao );

My gdb backtrace gives: (gdb) backtrace #0 0x00000000 in ?? () #1 0x0804a211 in init () at example1.cpp:147 #2 0x0804a6bc in main (argc=1, argv=0xbffff3d4) at example1.cpp:283 Not very ...
Rooster's user avatar
  • 1,277
53 votes
5 answers
20k views

What are some best practices for OpenGL coding (esp. w.r.t. object orientation)?

This semester, I took a course in computer graphics at my University. At the moment, we're starting to get into some of the more advanced stuff like heightmaps, averaging normals, tesselation etc. I ...
fluffels's user avatar
  • 4,071
53 votes
2 answers
52k views

OpenGL bool uniform?

I'm trying to send a boolean to an OpenGL glsl shader. Currently I have this in the shader: uniform bool foo; And I use this to set it: glUniform1i(glGetUniformLocation(shader, "foo"), true); ...
Jan Rüegg's user avatar
  • 9,817
52 votes
6 answers
158k views

How to draw text using only OpenGL methods?

I don't have the option to use but OpenGL methods (that is glxxx() methods). I need to draw text using gl methods only. After reading the red book, I understand that it is possible only through the ...
sathish v's user avatar
  • 529
51 votes
3 answers
66k views

How to initialize a glm::mat4 with an array?

I'm using the OpenGL Mathematics Library (glm.g-truc.net) and want to initialize a glm::mat4 with a float-array. float aaa[16]; glm::mat4 bbb(aaa); This doesn't work. I guess the solution is ...
j00hi's user avatar
  • 5,700
49 votes
2 answers
35k views

VBOs with std::vector

I've written a model loader in C++ an OpenGL. I've used std::vectors to store my vertex data, but now I want to pass it to glBufferData(), however the data types are wildly different. I want to know ...
Bojangles's user avatar
  • 101k
49 votes
4 answers
78k views

Learning OpenGL in Ubuntu [closed]

I'm trying to learn OpenGL and improve my C++ skills by going through the Nehe guides, but all of the examples are for Windows and I'm currently on Linux. I don't really have any idea how to get ...
victor's user avatar
  • 6,738
45 votes
1 answer
5k views

Efficient off-screen rendering of QPainterPaths (OpenGL and non-OpenGL solution required)

In my application, I paint a street map using QPainter on a widget made by QPainterPaths that contain precalculated paths to be drawn the widget is currently a QWidget, not a QGLWidget, but this ...
leemes's user avatar
  • 45.5k
43 votes
5 answers
69k views

How to render offscreen on OpenGL? [duplicate]

My aim is to render OpenGL scene without a window, directly into a file. The scene may be larger than my screen resolution is. How can I do this? I want to be able to choose the render area size to ...
Rookie's user avatar
  • 4,104
43 votes
4 answers
72k views

Generating a normal map from a height map?

I'm working on procedurally generating patches of dirt using randomized fractals for a video game. I've already generated a height map using the midpoint displacement algorithm and saved it to a ...
Dawson's user avatar
  • 2,723
40 votes
2 answers
2k views

X hangs up because of application (use C++, Qt, OpenGL)

My application gets data from the network and draws it on the scene (scene uses handmade OpenGL engine). It works for several hours. When I'm not using my desktop, my monitor, because of Display ...
poljak181's user avatar
  • 585
39 votes
7 answers
36k views

How to pass an std::string to glShaderSource?

I have the following code: glShaderSource(shader, 1, (const char **)data.c_str(), NULL); But it makes my program crash. How do I convert std::string into const char ** ? I also tried (const char **)...
Rookie's user avatar
  • 3,773
39 votes
2 answers
34k views

Develop using OpenGL 4.x on OSX Big Sur

According to Apple, OpenGL is no longer supported. However, it appears v4.1 of OpenGL was supported on many devices as of July 28, 2020. I have a 2020 Macbook Pro 16" model, which does not show ...
ryno's user avatar
  • 906
39 votes
6 answers
20k views

Learning modern OpenGL

I am aware that there were similar questions in past few years, but after doing some researches I still can't decide where from and what should I learn. I would also like to see your current, actual ...
Neomex's user avatar
  • 1,650
38 votes
4 answers
71k views

error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup, but this time it's NOT a Windows/Console problem!

So, the infamous error is back. The project is complaining that it can't find the main() method (that's what the error means, right). However I do have a main, and my project is a Console project, as ...
OddCore's user avatar
  • 1,554
37 votes
1 answer
16k views

glVertexAttribPointer raising GL_INVALID_OPERATION

I'm trying to put together a very basic OpenGL 3.2 (core profile) application. In the following code, which is supposed to create a VBO containing the vertex positions for a triangle, the call to ...
user avatar
37 votes
3 answers
25k views

glPixelStorei(GL_UNPACK_ALIGNMENT, 1) Disadvantages?

What are the disadvantages of always using alginment of 1? glPixelStorei(GL_UNPACK_ALIGNMENT, 1) glPixelStorei(GL_PACK_ALIGNMENT, 1) Will it impact performance on modern gpus?
ronag's user avatar
  • 50.5k
37 votes
3 answers
36k views

What's the advantage of using GLuint instead of unsigned int?

I like to be more standard as possible, so why should I "constrain" my classes defining it's members as OpenGL types when I can use primitive types? Is there any advantage?
JSeven's user avatar
  • 635
36 votes
1 answer
65k views

Error1 error LNK1107: invalid or corrupt file: cannot read at 0x2B0

I am new in opengl and i have no idea what this error means. I am using Visual Studio 2012 > C++ > Empty Project. I Follow these steps in other pc thats work for me but i am doing this in my pc ...
Uzair's user avatar
  • 735
36 votes
3 answers
5k views

Organizing GLSL shaders in OpenGL engine

Which is better ? To have one shader program with a lot of uniforms specifying lights to use, or mappings to do (e.g. I need one mesh to be parallax mapped, and another one parallax/specular mapped)....
Pythagoras of Samos's user avatar
35 votes
1 answer
23k views

Point Sprites for particle system

Are point sprites the best choice to build a particle system? Are point sprites present in the newer versions of OpenGL and drivers of the latest graphics cards? Or should I do it using vbo and glsl?
Javier Ramírez's user avatar
35 votes
2 answers
6k views

Visualising 4D objects in OpenGL [closed]

Do you know of any, actively developed, C/C++ library that can take a bunch (preferably a large amount) of 4D vertices, project them back into 3D space with respect to some arbitrary "4D camera" ...
MasterM's user avatar
  • 1,183
35 votes
1 answer
1k views

Packing arbitrary triangles into a finite box?

I need to pack triangles into a box as tightly as reasonable, as part of a 3D optimization (I'm stuffing alpha-using segments of different textures into a single different texture, for use with depth-...
Anne Quinn's user avatar
  • 12.8k
33 votes
3 answers
28k views

In What Order Should I Send My Vertices To OpenGL for Culling

I'm learning a spot of 3d opengl, and it's going rather well, I've got a nice camera moving about and some simple cube objects, at the moment. Currently using vertex arrays, but I'm swapping to VBOs ...
ultifinitus's user avatar
  • 1,853
33 votes
5 answers
9k views

Windowless OpenGL

I would like to have a windowless OpenGL context (on both GNU/linux with Xorg and Windows). I'm not going to render anything but only call functions like glGetString, glCompileShader and similar. I'...
ext's user avatar
  • 2,703
32 votes
2 answers
81k views

How to use alpha transparency in OpenGL?

Here's my code: void display(void); int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA); glBlendFunc(GL_SRC_ALPHA, ...
H-H's user avatar
  • 4,541
32 votes
1 answer
46k views

Is glm::ortho() actually wrong?

I recently thought it would be a good idea to switch from the old (deprecated) functionality that OpenGL provides, such as matrix operations and the fixed function pipeline. I am using GLM as my ...
Jamie Syme's user avatar
32 votes
1 answer
68k views

Cmake link library target link error

Hi I have problem with linkg Glfw and other libraries using cmake. From command line i compile like this g++ main.cpp -lGL -lGLU -lGLEW -lglfw But I wanted to use cmake for compiling. I tried to use ...
Luffy's user avatar
  • 677
32 votes
4 answers
27k views

Easy framework for OpenGL Shaders in C/C++

I just wanted to try out some shaders on a flat image. Turns out that writing a C program, which just takes a picture as a texture and applies, let's say a gaussian blur, as a fragment shader on it is ...
Nils's user avatar
  • 13.6k
32 votes
5 answers
2k views

OpenGL, How to create a "bumpy Polygon"?

I am unsure of how to describe what I'm after, so I drew a picture to help: My question, is it possible within OpenGL to create the illusion of those pixel looking bumps on a single polygon, without ...
Anne Quinn's user avatar
  • 12.8k
32 votes
3 answers
19k views

Understanding Vertex Array Objects (glGenVertexArrays )

I am confused with the point in generating/creating a Vertex Array Object (VAO) with: glGenVertexArrays(GLsizei n, GLuint *arrays); and glBindVertexArray(GLuint); Because I can still create a ...
bluth's user avatar
  • 481
32 votes
1 answer
7k views

Qt3D: How to render a mesh in wireframe mode using Qt C++?

Qt3D documentation is increasing but still lacking some information especially on how to do things without Qml/QtQuick. After heavily searching the web about rendering a mesh in wireframe mode, I ...
Hans's user avatar
  • 337
31 votes
2 answers
44k views

Why does glGetString(GL_VERSION) return null / zero instead of the OpenGL version?

I'm on Linux Mint 13 XFCE. My problem is that when I run in terminal the command: glxinfo | grep "OpenGL version" I get the following output: OpenGL version string: 3.3.0 NVIDIA 295.40 But when I ...
lyra42's user avatar
  • 375
30 votes
2 answers
52k views

Loading PNG with stb_image for OpenGL texture gives wrong colors

I am using stb_image to load a 32-bit PNG file (RGBA) and I am creating an OpenGL texture with it. It works fine for 24-bit PNG files (with no alpha channel), but when I use a 32-bit PNG file, ...
brettwhiteman's user avatar
30 votes
2 answers
30k views

Why does my color go away when I enable lighting in OpenGL?

I am developing a graphics application in C++ with the OpenGL API and GLUT. To add lighting, I made the following changes in my modelview matrix: glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // ...
dangerChihuahua007's user avatar
30 votes
2 answers
9k views

Do I have to use the OpenGL data types (GLint, CLchar, ...) for a cross platform game?

I have a short question. Why does OpenGL come with its own datatypes for standard types like int, unsigned int, char, and so on? And do I have to use them instead of the build in C++ datatypes? For ...
danijar's user avatar
  • 33.4k
30 votes
1 answer
8k views

Do uniform values remain in GLSL shader if unbound?

I am writing a program that uses two different shaders for different primitives. My question is: if I bind a program, send it uniform variables, then use another shader program and come back to the ...
Sebastian Mendez's user avatar

1
2 3 4 5
294