|
Post by scalion on Jan 29, 2024 9:50:24 GMT 1
Hi all,
Following my wanderings regarding shaders with OpenGl I developed a library (not exhaustive for the moment). It simplifies the compilation and use of shaders as well as the creation of VertexArrays. I incorporated 2 personal functions to create a Torus and a Sphere with VertexArrays. Take a look at the demo source for more information.
Fr : Suite à mes pérégrinations concernant les shaders avec OpenGl je me suis développé une librairie (non exhaustive pour l'instant). Elle permet de simplifier la compilation et l'utilisation des shaders ainsi que la création de VertexArrays. J'y ai incorporé 2 fonctions perso pour créer un Torus et une Sphère avec des VertexArrays. Jetez un oeil sur la source de la démo pour plus d'informations.
|
|
|
Post by (X) on Jan 29, 2024 23:25:15 GMT 1
Seul le 2ième exemple fonctionne mais avec 'Flat Shading'...
On obtient le message: "Program Linking error."
|
|
|
Post by scalion on Jan 30, 2024 8:55:17 GMT 1
Seul le 2ième exemple fonctionne mais avec 'Flat Shading'...
On obtient le message: "Program Linking error."
Normalement tu dois avoir d'autres messages d'erreur avant le "Program Linking error.". Quels sont-ils ? ( fais moi des copies d'écran si tu préfères ).
|
|
|
Post by (X) on Jan 30, 2024 19:00:16 GMT 1
Pour le 3ième choix "User Shaders"
Première fenêtre: "Program linking error:" suivie de "PRogram Fail."
J'ai fait des traces pour vérifier des valeurs de variables...
En passant, les autres exemples: Fractals fonctionnent encore bien.
|
|
|
Post by (X) on Jan 30, 2024 20:21:55 GMT 1
J'ai fouillé dans la librarie:"OpenglExtensions.g32" J'ai trouvé que ça marche tel que prévu en remplacant: "If InfoLogLength > 0" par:"If !Result" dans la fonction: "Function ShadersCompilation(Vertex_Shader_Code As String, Fragment_Shader_Code As String) As Long"
I searched the "OpenglExtensions.g32" library. I found that it works as expected by replacing: "If InfoLogLength > 0" with: "If !Result" in the function: "Function ShadersCompilation(Vertex_Shader_Code As String, Fragment_Shader_Code As String) As Long".
Ich habe die Bibliothek "OpenglExtensions.g32" durchsucht. Ich fand, dass es wie erwartet funktioniert, indem ich ersetzte: "If InfoLogLength > 0" mit: "If !Result" in der Funktion: "Function ShadersCompilation(Vertex_Shader_Code As String, Fragment_Shader_Code As String) As Long".
// Check the program glGetProgramiv(ProgramID, GL_LINK_STATUS, Result) Message "Link Status:" & Result & #10 & "Info len:" & InfoLogLength glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, InfoLogLength) °If InfoLogLength > 0 // Original code If !Result // If Not (Result == 0) Local String ProgramErrorMessage = Space(InfoLogLength + 1) glGetProgramInfoLog(ProgramID, InfoLogLength, Null, V:ProgramErrorMessage) Message "Program linking error : "#13#10 & ProgramErrorMessage Success = False EndIf
|
|
|
Post by (X) on Jan 30, 2024 22:27:54 GMT 1
I asked BING to create a movie poster called: "SHADERS FROM MARS". Ah man! BING (and AI) is getting pretty good at this!
I am NOT saying that scalion is a martian. But I am saying that his coding ability is "Out of this world!"
|
|
|
Post by Roger Cabo on Jan 31, 2024 1:16:10 GMT 1
Yes scalion has real great acknowledge about this stuff and math. But I hope it's possible to solve the 64bit Double precision for vertexes. I'm about 3 day on the search to fix this problems, but no lights in the dark...
|
|
|
Post by (X) on Jan 31, 2024 14:40:44 GMT 1
It's all pretty new to me, but here is a conversation with BING about a minimal demo using Double precision Vertex data...
I asked BING: "In opengl is it possible to use 64bit Double precision values in a vertex shader?" Answer... Ok, can you give me a minimal example?
// Vertex shader #version 430
layout(location = 0) in dvec3 position;
void main() { gl_Position = vec4(position, 1.0); }
// Create a vertex array object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao);
// Create a vertex buffer object GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo);
// Define the vertex data double vertexData[] = { 0.0, 0.0, 0.0 };
// Upload the vertex data to the GPU glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
// Specify the vertex attribute GLuint index = 0; GLint size = 3; GLenum type = GL_DOUBLE; GLboolean normalized = GL_FALSE; GLsizei stride = 0; const GLvoid* pointer = 0; glVertexAttribLPointer(index, size, type, stride, pointer); glEnableVertexAttribArray(index);
Me: If I run this what should I see?
Since I am here, can you suggest code that will draw a green unit cube? Certainly! Here's a minimal example of how to draw a green unit cube in OpenGL: // Vertex shader #version 330 core
layout (location = 0) in vec3 position;
uniform mat4 model; uniform mat4 view; uniform mat4 projection;
void main() { gl_Position = projection * view * model * vec4(position, 1.0f); }
// Fragment shader #version 330 core
out vec4 color;
void main() { color = vec4(0.0f, 1.0f, 0.0f, 1.0f); }
// Main program #include <glad/glad.h> #include <GLFW/glfw3.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow* window);
const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600;
int main() { // Initialize GLFW and configure the window glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Create the window GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Green Cube", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window);
// Initialize GLAD if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; }
// Set the viewport glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
// Register the framebuffer size callback glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// Define the vertex data float vertices[] = { // Positions -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f,
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
-0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0 Source: Conversation with Bing, 2024-01-31 (1) Tutorial 4 : A Colored Cube - opengl-tutorial.org. www.opengl-tutorial.org/beginners-tutorials/tutorial-4-a-colored-cube/. (2) OpenGL Programming/Modern OpenGL Tutorial 05 - Wikibooks. en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_05. (3) c++ - How to draw a cube in OpenGL? - Stack Overflow. stackoverflow.com/questions/34118650/how-to-draw-a-cube-in-opengl. (4) Opengl Basic cube drawing, but cube draws in single color. stackoverflow.com/questions/3808450/opengl-basic-cube-drawing-but-cube-draws-in-single-color. (5) github.com. github.com/Scott525/OpenGLVSCode/tree/6d618bdde3d77e7b0b4e24c0b586efba853dbcb4/.history%2Fsrc%2Fmain_20210714091621.cpp. (6) github.com. github.com/xingjun415/learnopengl/tree/51245a35e810feedf23595df3ee6893ed94aff80/docs%2Fopengl.md. (7) github.com. github.com/lshays/openglCube/tree/5ae72c92d15ac12003bbb8716524f7ca785db65f/cube%2FSource.cpp. (8) github.com. github.com/wangzhenGitHup/OpenGL/tree/b135acab80711b2843469d30249a4c0ab804f9b1/CubeMapTest%2FOpenGLTest%2Fmain%20-%20uniform-buffer.cpp. (9) github.com. github.com/fusijie/LearnOpenGL/tree/17d3233d65e58ca5fb45c5192a0b8c2e3234ecac/LearnOpenGL%2F49_multiSampling%2Fmain.cpp.
|
|
|
Post by (X) on Jan 31, 2024 15:03:55 GMT 1
Me: Does the previous example use doubles for the vertex data? BING: The example I provided does not use double precision values for the vertex data. Instead, it uses single precision values represented by the `float` data type. If you would like to use double precision values for the vertex data, you can modify the example to use the `dvec3` data type instead of `vec3`. Here's an updated version of the example that uses double precision values: // Vertex shader #version 430
layout(location = 0) in dvec3 position;
void main() { gl_Position = vec4(position, 1.0); } In this example, we are using the `dvec3` data type to represent a 3D position with double precision. The `layout(location = 0)` qualifier specifies that this attribute is bound to location 0 in the vertex buffer. The `gl_Position` variable is a built-in output variable that specifies the position of the vertex in clip space. To pass the double precision values to the shader, you need to use generic vertex attributes instead of old fixed-function `gl_Vertex` and `glVertexPointer`. You can use `glVertexAttribLPointer` with a proper generic vertex attribute index to read double-precision values into your shader ¹³. Here's an example of how to use generic vertex attributes with doubles: // Create a vertex array object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao);
// Create a vertex buffer object GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo);
// Define the vertex data double vertexData[] = { 0.0, 0.0, 0.0 };
// Upload the vertex data to the GPU glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
// Specify the vertex attribute GLuint index = 0; GLint size = 3; GLenum type = GL_DOUBLE; GLboolean normalized = GL_FALSE; GLsizei stride = 0; const GLvoid* pointer = 0; glVertexAttribLPointer(index, size, type, stride, pointer); glEnableVertexAttribArray(index); In this example, we are creating a vertex array object and a vertex buffer object. We are then defining the vertex data as a double-precision value and uploading it to the GPU using `glBufferData`. Finally, we are specifying the vertex attribute using `glVertexAttribLPointer` and enabling it using `glEnableVertexAttribArray`. I hope this helps! Source: Conversation with Bing, 2024-01-31 (1) Tutorial 4 : A Colored Cube - opengl-tutorial.org. www.opengl-tutorial.org/beginners-tutorials/tutorial-4-a-colored-cube/. (2) c++ - How to draw a cube in OpenGL? - Stack Overflow. stackoverflow.com/questions/34118650/how-to-draw-a-cube-in-opengl. (3) OpenGL Programming/Modern OpenGL Tutorial 05 - Wikibooks. en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_05. (4) Opengl Basic cube drawing, but cube draws in single color. stackoverflow.com/questions/3808450/opengl-basic-cube-drawing-but-cube-draws-in-single-color.
|
|
|
Post by (X) on Jan 31, 2024 15:17:52 GMT 1
As you can see by now, BING struggles to stay on track...
Me: Does the example you gave me draw a cube? BING:
// Vertex shader #version 430
layout(location = 0) in dvec3 position;
void main() { gl_Position = vec4(position, 1.0); }
// Create a vertex array object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao);
// Create a vertex buffer object GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo);
// Define the vertex data double vertexData[] = { 0.0, 0.0, 0.0 };
// Upload the vertex data to the GPU glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
// Specify the vertex attribute GLuint index = 0; GLint size = 3; GLenum type = GL_DOUBLE; GLboolean normalized = GL_FALSE; GLsizei stride = 0; const GLvoid* pointer = 0; glVertexAttribLPointer(index, size, type, stride, pointer); glEnableVertexAttribArray(index);
// Fragment shader #version 430
out vec4 color;
void main() { color = vec4(0.0, 1.0, 0.0, 1.0); }
// Main program #include <glad/glad.h> #include <GLFW/glfw3.h> #include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow* window);
const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600;
int main() { // Initialize GLFW and configure the window glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Create the window GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Green Cube", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window);
// Initialize GLAD if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; }
// Set the viewport glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
// Register the framebuffer size callback glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// Define the vertex data double vertices[] = { // Front face -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5,
// Back face -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, };
// Define the indices unsigned int indices
|
|
|
Post by (X) on Jan 31, 2024 15:26:10 GMT 1
Obviously, before getting comfortable with OpenGL, one needs to get a lay of the land and start by studying simple demos. I hope this cube demo might serve as a proof of concept at least.
Évidemment, avant de se sentir à l'aise avec OpenGL, il faut se familiariser avec le terrain et commencer par étudier des démonstrations simples. J'espère que cette démo de cube servira au moins de preuve de concept.
Bevor man sich mit OpenGL anfreunden kann, muss man sich natürlich erst einmal einen Überblick verschaffen und einfache Demos studieren. Ich hoffe, dass diese Würfeldemo zumindest als Proof of Concept dienen kann.
|
|
|
Post by Roger Cabo on Jan 31, 2024 17:42:41 GMT 1
Cool.. looks promising! ChatGPT 4.1 told me: English: The use of a Geometry Shader for 64-bit (Double Precision) data in OpenGL depends on the specific requirements of your graphics application. Here are some points to consider: Need for a Geometry Shader: A Geometry Shader is not specifically required for processing 64-bit data. It is used for additional processing steps between the Vertex Shader and the Fragment Shader, such as generating or transforming geometries. 64-Bit Vertex Data: To use 64-bit vertex data, your Vertex Shader must be configured to support Double Precision data types, including dvec2, dvec3, dvec4, dmat3, dmat4, etc. Transferring 64-Bit Data: Ensure that the 64-bit data is correctly passed to the shader, usually through properly configured Vertex Buffer Objects (VBOs) and appropriate calls to glVertexAttribLPointer. Shader Compatibility: All shaders in the pipeline should be compatible regarding the data passed. If you are using 64-bit data in Vertex and Geometry Shaders, ensure the data is appropriately handled and passed to the Fragment Shader. OpenGL Extensions: For using 64-bit data in shaders, you may need to activate special OpenGL extensions such as GL_ARB_gpu_shader_fp64.
L'utilisation d'un shader géométrique pour des données 64 bits (double précision) dans OpenGL dépend des exigences spécifiques de votre application graphique. Voici quelques points à considérer : Nécessité d'un shader géométrique : Un shader géométrique n'est pas spécifiquement requis pour le traitement de données 64 bits. Il est utilisé pour des étapes de traitement supplémentaires entre le shader de sommets et le shader de fragments, telles que la génération ou la transformation de géométries. Données de sommets 64 bits : Pour utiliser des données de sommets 64 bits, votre shader de sommets doit être configuré pour supporter les types de données en double précision, y compris dvec2, dvec3, dvec4, dmat3, dmat4, etc. Transmission de données 64 bits : Assurez-vous que les données 64 bits sont correctement transmises au shader, habituellement à travers des objets tampons de sommets (VBOs) configurés correctement et des appels appropriés à glVertexAttribLPointer. Compatibilité des shaders : Tous les shaders dans la chaîne de traitement doivent être compatibles en termes de données transmises. Si vous utilisez des données 64 bits dans les shaders de sommets et géométriques, assurez-vous que ces données sont correctement traitées et transmises au shader de fragments. Extensions OpenGL : Pour l'utilisation de données 64 bits dans les shaders, vous devrez peut-être activer des extensions OpenGL spéciales telles que GL_ARB_gpu_shader_fp64. Support matériel : Toutes les cartes graphiques ne supportent pas la double précision dans les shaders. Vérifiez que votre matériel est compatible avec cette fonctionnalité. Il est généralement conseillé de vérifier si l'utilisation de la double précision est nécessaire pour votre application spécifique, car elle peut requérir plus d'espace de stockage et de puissance de calcul. unsigned int VBO;
// Vertex-Buffer glGenBuffers(1, &VBO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// declare double precision glVertexAttribLPointer(0, 3, GL_DOUBLE, GL_FALSE, 3 * sizeof(double), (void*)0); glEnableVertexAttribArray(0);
#version 430 core #extension GL_ARB_gpu_shader_fp64 : enable In shaders for example: in dvec3 position[]; in dvec3 normal[]; in dvec2 texCoords[];
// declare out vars out dvec3 fragPosition; out dvec3 fragNormal; out dvec2 fragTexCoords;
// Uniform-Matrx (Double) uniform dmat4 modelMatrix; uniform dmat4 viewMatrix; uniform dmat4 projectionMatrix;
What Bing respond to ChatGpt! Bing link sl.bing.net/cwoyyo0jrJk
|
|
|
Post by Roger Cabo on Jan 31, 2024 21:04:37 GMT 1
Obviously, before getting confortable with OpenGL, one needs to get a lay of the land and start by studying simple demos. I hope this cube demo might serve as a proof of concept at least.
Yes.. true... I have the old specular shader version. with the torus.. It contains a Translate(x,y,z) function. Now I like to move the torus and the camera to position +100000,+100000, +100000 then trying to move the camera slightly left and right , then jitter should occur because of the low pecision single.. Later If I got double enabled anyhow, then the animation should appear smooth instead of jerky like before.. true?
|
|
|
Post by (X) on Jan 31, 2024 23:50:48 GMT 1
Do you have a link to a demo that jitters? I would like play around with that and try different things.
|
|
|
Post by Roger Cabo on Feb 1, 2024 10:44:06 GMT 1
I will post in the evening...
|
|
|
Post by scalion on Feb 1, 2024 12:06:24 GMT 1
Version 2 : Quoi de neuf ? La démo est débuggée, j'ai inséré un glPushAttrib(GL_ENABLE_BIT)/glPopAttrib() et j'ai modifié quelque peu la démo "user" pour qu'elle soit un peu plus intéressante avec une interaction de la souris. J'ai ajouté aussi la suppression des buffers et vertexarrays qui manquaient. Dans la librairie nous avons ces nouvelles fonctions : - glDeleteVertexArrays() - glDeleteBuffers() - InitialisationOpenGL(Hwnd%) qui initialise le minimum nécessaire pour démarrer OpenGL dans une fenêtre - BuildVertexArray() qui gère les déclarations nécessaires. La fonction génère le VertexArrayID et le VertexBuffer. Les données sont du type Float obligatoirement et doivent être stockées en suivant ce schéma : vertex (x,y,z) + normal (x,y,z) + textureCoords (u,v). La fonction retourne le ArrayVertexID et fixe la valeur de VertexBuffer.
US : What's new ?
The demo is debugged, I inserted a glPushAttrib(GL_ENABLE_BIT)/glPopAttrib() and I modified the "user" demo a bit to make it a little more interesting with mouse interaction. I also added the deletion of missing buffers and vertexarrays.
In the library we have these new functions:
- glDeleteVertexArrays() - glDeleteBuffers() - InitializationOpenGL(Hwnd%) which initializes the minimum necessary to start OpenGL in a window. - BuildVertexArray() which manages the necessary declarations. The function generates the VertexArrayID and the VertexBuffer. The data must be of the Float type and must be stored following this schema: vertex (x,y,z) + normal (x,y,z) + textureCoords (u,v). The function returns the ArrayVertexID and sets the value of VertexBuffer.
Demo OpenglShaders library.G32 (20.76 KB)
|
|
|
Post by (X) on Feb 1, 2024 13:26:19 GMT 1
Désolé. "Program linking error" As tu le nouveau code source de la lib: "OpenglExtensions.G32"?
|
|
|
Post by scalion on Feb 1, 2024 15:50:15 GMT 1
Désolé. "Program linking error" As tu le nouveau code source de la lib: "OpenglExtensions.G32"?
Oups, je me suis trompé de fichier ! je le remets dans le post. Merci pour le retour.
Il va vraiment falloir que je me penche sur ce problème que tu rencontres (chez moi ca fonctionne ! étonnant). Je n'arrive pas à comprendre ce qui se passe.
|
|
|
Post by (X) on Feb 1, 2024 18:31:20 GMT 1
Le OpenglExtensions.G32 a encore le même problème... Ceci corrige l'erreur: // Check the program glGetProgramiv(ProgramID, GL_LINK_STATUS, Result) glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, InfoLogLength) If !Result //InfoLogLength > 0 Local String ProgramErrorMessage = Space(InfoLogLength + 1) glGetProgramInfoLog(ProgramID, InfoLogLength, Null, V:ProgramErrorMessage) Message "Program linking error : "#13#10 & ProgramErrorMessage Success = False EndIf
J'ai changé: "InfoLength > 0" pour: "!Result" et ça marche.
|
|
|
Post by (X) on Feb 1, 2024 18:35:22 GMT 1
Désolé. "Program linking error" As tu le nouveau code source de la lib: "OpenglExtensions.G32"?
Oups, je me suis trompé de fichier ! je le remets dans le post. Merci pour le retour.
Il va vraiment falloir que je me penche sur ce problème que tu rencontres (chez moi ca fonctionne ! étonnant). Je n'arrive pas à comprendre ce qui se passe.
Est-ce possible que le fichier OpenglExtensions.lg32 soit à deux places?
|
|
|
Post by Roger Cabo on Feb 1, 2024 19:11:19 GMT 1
From the torus shader demo..
glEnableVertexAttribArray(0) glEnableVertexAttribArray(1) glEnableVertexAttribArray(2)
Rotate(Timer * 20, 0, 0, 1) glDrawArrays(GL_TRIANGLES, 0, Torus_Triangles_Count * 3)
' Reset Transformationsmatrix glLoadIdentity() Rotate(Timer * 200, 0, 1, 0) glDrawArrays(GL_TRIANGLES, 0, Torus_Triangles_Count * 3)
' Reset Transformationsmatrix glLoadIdentity() Rotate(Timer * 20, 1, 0, 0) glDrawArrays(GL_TRIANGLES, 0, Torus_Triangles_Count * 3)
glDisableVertexAttribArray(0) glDisableVertexAttribArray(1) glDisableVertexAttribArray(2)
Hmm there is anything strange.. after using the glLoadIdentity() the following objects are invisible.. ChatGPT doesn't find the error..
The idea was to rotate each torus separately and reset the matrix : by glLoadIdentity()
|
|
|
Post by scalion on Feb 1, 2024 19:31:27 GMT 1
Oups, je me suis trompé de fichier ! je le remets dans le post. Merci pour le retour.
Il va vraiment falloir que je me penche sur ce problème que tu rencontres (chez moi ca fonctionne ! étonnant). Je n'arrive pas à comprendre ce qui se passe.
Est-ce possible que le fichier OpenglExtensions.lg32 soit à deux places? Oui c'est possible mais déconseillé, si tu modifies le mauvais fichier par erreur tu vas perdre un temps fou. L'IDE va chercher le premier disponible en suivant les directives du menu extra/property/extra :
|
|
|
Post by scalion on Feb 1, 2024 19:44:37 GMT 1
From the torus shader demo.. glEnableVertexAttribArray(0) glEnableVertexAttribArray(1) glEnableVertexAttribArray(2)
Rotate(Timer * 20, 0, 0, 1) glDrawArrays(GL_TRIANGLES, 0, Torus_Triangles_Count * 3)
' Reset Transformationsmatrix glLoadIdentity() Rotate(Timer * 200, 0, 1, 0) glDrawArrays(GL_TRIANGLES, 0, Torus_Triangles_Count * 3)
' Reset Transformationsmatrix glLoadIdentity() Rotate(Timer * 20, 1, 0, 0) glDrawArrays(GL_TRIANGLES, 0, Torus_Triangles_Count * 3)
glDisableVertexAttribArray(0) glDisableVertexAttribArray(1) glDisableVertexAttribArray(2)
Hmm there is anything strange.. after using the glLoadIdentity() the following objects are invisible.. ChatGPT doesn't find the error.. The idea was to rotate each torus separately and reset the matrix : by glLoadIdentity() Il y a 2 erreurs :
Quand tu fais un Rotate n'oublie pas que OpenGL ne gère pas les fonctions trigonométriques au format Double, tu lui envoies Timer * 200 ce qui est une valeur double, c'est peut-être un test ? Pour obtenir une rotation sans "jitter" il vaut mieux rester dans la fourchette -360 * 16000 / +360 *16000. Après un glLoadIdentity() le point de vue se retrouve à 0,0,0 ce qui explique que tu ne voies rien. Insère simplement une instruction gluLookAt() juste après glLoadIdentity() ou si tu n'as pas encore trop modifié le code fait un copier coller de :
US : There are 2 errors: When you do a Rotate don't forget that OpenGL does not manage trigonometric functions in Double format, you send it Timer * 200 which is a double value, perhaps this is a test? To obtain a rotation without "jitter", it is better to stay in the range -360 * 16000 / +360 *16000. After a glLoadIdentity() the point of view ends up at 0,0,0 which explains why you see nothing. Simply insert a gluLookAt() instruction just after glLoadIdentity() or if you haven't modified the code too much yet, copy and paste:
LookAt(eye.x, eye.y, eye.z, 0, 0, 0, 0, 1, 0)
|
|