opengl

How I prevent having too much parameters in a function. C++ [closed]

爷,独闯天下 提交于 2021-02-11 15:39:35
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 10 months ago . Improve this question I am making a game engine with C++ and Opengl. I making a small game to test my incomplete engine. But after adding classes like Camera, Renderder, Level, Player, Zombie and Human, My Player class's function parameters getting long about 8 arguments because

Inbuilt polygon clipping in OpenGL

本小妞迷上赌 提交于 2021-02-11 15:27:38
问题 Can someone help me in understanding why below code is showing triangle in front of the Quad? For gluLookAt(10, 10, 60, 0, 0, 0, 0, 1, 0) and glOrtho(-30, 30, -30, 30, 0, 90) ? Expected Output: Because the 'z' value of the triangle is less than the quad and observer is at 60 unit in the +ive 'z' axis. Thus, the rectangle should had been visible as a whole and only a few parts of the triangle would had been visible. glBegin(GL_QUADS); glColor3f(1, 1, 1); glVertex3f(10, 10, 15); glVertex3f(20,

Inbuilt polygon clipping in OpenGL

冷暖自知 提交于 2021-02-11 15:26:27
问题 Can someone help me in understanding why below code is showing triangle in front of the Quad? For gluLookAt(10, 10, 60, 0, 0, 0, 0, 1, 0) and glOrtho(-30, 30, -30, 30, 0, 90) ? Expected Output: Because the 'z' value of the triangle is less than the quad and observer is at 60 unit in the +ive 'z' axis. Thus, the rectangle should had been visible as a whole and only a few parts of the triangle would had been visible. glBegin(GL_QUADS); glColor3f(1, 1, 1); glVertex3f(10, 10, 15); glVertex3f(20,

Can't use glGetTexImage to read a depth map texture

霸气de小男生 提交于 2021-02-11 15:14:43
问题 I've successfully created a frame buffer object and created a texture containing the depth map of my scene. I know I'm doing this correctly since I apply my texture to a rectangle and it looks just fine : Now I'd like to read the values from the texture I've created in my main program and not inside the shaders. Looking into it I found out about two functions, namely: glGetTexImage() and glReadPixels(). Since I'm quite new to openGL, the documentation about these brings more questions than

How to efficiently count the number of pixels which can be seen from a certain point of view in MonoGame if those pixels have a certain color

那年仲夏 提交于 2021-02-11 12:07:20
问题 I have a project on monogame platform. The purpose of the project is to make the calculation of the viewfactor of geometry put into the platform using the ortographic method. In a basic level, I put a basic cube and camera across from the cube. Here as I look into the cube through the camera, I am required to count the number of pixels of an object seen from a perspective by the ortographic method. I already have a solution but it is very slow. In my solution, I count the number of pixels

Instancing cubes next to each other OpenGL

自古美人都是妖i 提交于 2021-02-11 07:59:12
问题 I tried to instance many cubes side by side each other. My understanding is that I need to create a MVP matrix for each cube and bind this then somehow change the position. then run this in a for loop for how many cubes you'd want. This is what I've tried: while (!glfwWindowShouldClose(window)) { glClearColor(0.0f / 255.0f, 170.0f / 255.0f, 204.0f / 255.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(programID); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY

Compatibility function for gluLookAt

跟風遠走 提交于 2021-02-11 07:53:08
问题 I just got a new PC and now have to get my demo program running with SDL2/OpenGL. I used the program to try out various techniques and used gluLookAt (which, obviously, shouldn't be used any more or even never should have been used). Now I'm looking for a way to replace the gluLookAt method by building a transformation matrix doing the same as gluLookAt did. I came across this claiming to be usable replacement for gluLookAt (the answer - not the question). My implementation of it looks like

GLX Context Creation Error: GLXBadFBConfig

。_饼干妹妹 提交于 2021-02-11 04:28:36
问题 I used glXCreateContext to create the contexts, but the function is deprecated and always results in an OpenGL Version 3.0, where I would need at least 4. Now, if I have understood it right, GLXContext glXCreateContextAttribsARB(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int* attrib_list); replaced glXCreateContext . The "new" function allows for explicitly specifying the major version, minor version, profile et cetera in it's attrib_list like this for

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

99封情书 提交于 2021-02-10 21:38:34
问题 I am making a game (RPG) in PyOpenGL which I have a crosshair. I want to check if a 3d object is in the crosshair (or detect if it is at a point), which is a 2d overlay. How can I do that? I tried to use screen.get_at() function, but it displays an error "Cannot call on OpenGL surfaces". Also, it is not good because it only detects a colour, not an object (although you can use the colour to determine an object, but what if there are several objects that have the same colour?). This is what I

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

亡梦爱人 提交于 2021-02-10 21:38:06
问题 I am making a game (RPG) in PyOpenGL which I have a crosshair. I want to check if a 3d object is in the crosshair (or detect if it is at a point), which is a 2d overlay. How can I do that? I tried to use screen.get_at() function, but it displays an error "Cannot call on OpenGL surfaces". Also, it is not good because it only detects a colour, not an object (although you can use the colour to determine an object, but what if there are several objects that have the same colour?). This is what I