<div dir="ltr"><div>Hi Martin and team,</div><div>Same problem with the 3d sandbox code . image is attached of application window, </div><div>Here is the application output:-</div><div>12:02:25: Starting /home/aman/QGIS-CODE/QGIS-CPP-API-QT5/3DMapQGIS2/build/Desktop_Qt_5_15_1_GCC_64bit-Debug/3DMapQGIS2 /home/aman/sample3dProject.qgz...</div><div> Logged warning: Qgs3DAxis: no canvas defined!</div>pending jobs: 0<br>src/gui/qgsproviderguiregistry.cpp:174 : (loadDynamicProviders) [323ms] No dynamic QGIS GUI provider plugins found in:<br>/home/aman/QGIS-CODE/QGIS-CPP-API-QT5/3DMapQGIS2/build/lib/qgis/plugins<br><br>QOpenGLShader::compile(Fragment): 0(3) : error C0000: syntax error, unexpected '-', expecting "::" at token "-"<br>0(74) : error C0000: syntax error, unexpected '}' at token "}"<br>0(76) : error C1503: undefined variable "auto"<br>0(76) : error C1154: non constant expression in layout value<br>0(84) : error C7566: uniform blocks require #version 140 or later<br>0(84) : error C0000: ... or #extension GL_ARB_gpu_shader5 : enable<br>0(84) : error C0000: ... or #extension GL_ARB_uniform_buffer_object : enable<br>0(84) : error C7532: layout qualifier 'binding' requires "#version 420" or later<br>0(84) : error C0000: ... or #extension GL_ARB_shading_language_420pack : enable<br>0(86) : error C1503: undefined variable "auto"<br>0(86) : error C1154: non constant expression in layout value<br>0(88) : error C7566: uniform blocks require #version 140 or later<br>0(88) : error C0000: ... or #extension GL_ARB_gpu_shader5 : enable<br>0(88) : error C0000: ... or #extension GL_ARB_uniform_buffer_object : enable<br>0(88) : error C7532: layout qualifier 'binding' requires "#version 420" or later<br>0(88) : error C0000: ... or #extension GL_ARB_shading_language_420pack : enable<br>0(21) : error C1503: undefined variable "auto"<br>0(21) : error C1154: non constant expression in layout value<br>0(25) : error C7566: uniform blocks require #version 140 or later<br>0(25) : error C0000: ... or #extension GL_ARB_gpu_shader5 : enable<br>0(25) : error C0000: ... or #extension GL_ARB_uniform_buffer_object : enable<br>0(25) : error C7532: layout qualifier 'binding' requires "#version 420" or later<br>0(25) : error C0000: ... or #extension GL_ARB_shading_language_420pack : enable<br>0(28) : error C1503: undefined variable "auto"<br>0(28) : error C1154: non constant expression in layout value<br>0(28) : error C7532: layout(binding) requires "#version 420" or later<br>0(28) : error C0000: ... or #extension GL_ARB_shading_language_420pack : enable<br>0(29) : error C1503: undefined variable "auto"<br>0(29) : error C1154: non constant expression in layout value<br>0(29) : error C7532: layout(binding) requires "#version 420" or later<br>0(29) : error C0000: ... or #extension GL_ARB_shading_language_420pack : enable<br>0(11) : error C7548: 'layout(location)' requires "#extension GL_ARB_explicit_attrib_location : enable" before use<br>0(11) : error C0000: ... or #extension GL_ARB_separate_shader_objects : enable<br>0(11) : error C0000: ... or #version 330<br>0(11) : error C5060: out can't be used with non-varying fragColor<br>0(15) : error C1503: undefined variable "ka"<br>0(15) : error C1503: undefined variable "kd"<br>0(15) : error C1503: undefined variable "ks"<br>0(15) : error C1503: undefined variable "shininess"<br>0(15) : error C1503: undefined variable "worldPosition"<br>0(15) : error C1503: undefined variable "worldPosition"<br>0(15) : error C1503: undefined variable "worldNormal"<br><br>*** Problematic Fragment shader source code ***<br>#version 110<br>#ifdef GL_KHR_blend_equation_advanced<br>#extension GL_ARB_fragment_coord_conventions : enable<br>#extension GL_KHR_blend_equation_advanced : enable<br>#endif<br>#define lowp<br>#define mediump<br>#define highp<br>#line 1<br><br>add-input varying vec3 worldPosition<br>add-input varying vec3 worldNormal<br>add-input uniform float shininess<br>add-input uniform vec4 ks<br>add-input uniform vec4 kd<br>add-input uniform vec4 ka<br>/****************************************************************************<br>**<br>** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).<br>** Contact: <a href="https://www.qt.io/licensing/">https://www.qt.io/licensing/</a><br>**<br>** This file is part of the Qt3D module of the Qt Toolkit.<br>**<br>** $QT_BEGIN_LICENSE:BSD$<br>** Commercial License Usage<br>** Licensees holding valid commercial Qt licenses may use this file in<br>** accordance with the commercial license agreement provided with the<br>** Software or, alternatively, in accordance with the terms contained in<br>** a written agreement between you and The Qt Company. For licensing terms<br>** and conditions see <a href="https://www.qt.io/terms-conditions">https://www.qt.io/terms-conditions</a>. For further<br>** information use the contact form at <a href="https://www.qt.io/contact-us">https://www.qt.io/contact-us</a>.<br>**<br>** BSD License Usage<br>** Alternatively, you may use this file under the terms of the BSD license<br>** as follows:<br>**<br>** "Redistribution and use in source and binary forms, with or without<br>** modification, are permitted provided that the following conditions are<br>** met:<br>** * Redistributions of source code must retain the above copyright<br>** notice, this list of conditions and the following disclaimer.<br>** * Redistributions in binary form must reproduce the above copyright<br>** notice, this list of conditions and the following disclaimer in<br>** the documentation and/or other materials provided with the<br>** distribution.<br>** * Neither the name of The Qt Company Ltd nor the names of its<br>** contributors may be used to endorse or promote products derived<br>** from this software without specific prior written permission.<br>**<br>**<br>** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS<br>** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT<br>** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR<br>** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT<br>** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,<br>** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT<br>** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,<br>** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY<br>** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT<br>** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE<br>** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."<br>**<br>** $QT_END_LICENSE$<br>**<br>****************************************************************************/<br><br>layout(std140, binding = auto) uniform qt3d_render_view_uniforms {<br> mat4 viewMatrix;<br> mat4 projectionMatrix;<br> mat4 viewProjectionMatrix;<br> mat4 inverseViewMatrix;<br> mat4 inverseProjectionMatrix;<br> mat4 inverseViewProjectionMatrix;<br> mat4 viewportMatrix;<br> mat4 inverseViewportMatrix;<br> vec4 textureTransformMatrix;<br> vec3 eyePosition;<br> float aspectRatio;<br> float gamma;<br> float exposure;<br> float time;<br>};<br><br>layout(std140, binding = auto) uniform qt3d_command_uniforms {<br> mat4 modelMatrix;<br> mat4 inverseModelMatrix;<br> mat4 modelViewMatrix;<br> mat3 modelNormalMatrix;<br> mat4 inverseModelViewMatrix;<br> mat4 mvp;<br> mat4 inverseModelViewProjectionMatrix;<br>};<br><br>layout(std140, binding = auto) uniform qt3d_extras_uniforms {<br> float texCoordScale;<br>};<br><br>#line 2<br><br>const int MAX_LIGHTS = 8;<br>const int TYPE_POINT = 0;<br>const int TYPE_DIRECTIONAL = 1;<br>const int TYPE_SPOT = 2;<br><br>struct Light {<br> vec3 position;<br> float intensity;<br> vec3 color;<br> float constantAttenuation;<br> vec3 direction;<br> float linearAttenuation;<br> float quadraticAttenuation;<br> float cutOffAngle;<br> int type;<br>};<br><br>layout(std140, binding = auto) uniform qt3d_light_uniforms {<br> Light lights[MAX_LIGHTS];<br> int lightCount;<br> int envLightCount;<br>};<br><br>// Pre-convolved environment maps<br>layout(binding = auto) uniform samplerCube envLight_irradiance; // For diffuse contribution<br>layout(binding = auto) uniform samplerCube envLight_specular; // For specular contribution<br><br>#line 52<br><br>void adsModel(const in vec3 worldPos,<br> const in vec3 worldNormal,<br> const in vec3 worldView,<br> const in float shininess,<br> out vec3 diffuseColor,<br> out vec3 specularColor)<br>{<br> diffuseColor = vec3(0.0);<br> specularColor = vec3(0.0);<br><br> // We perform all work in world space<br> vec3 n = normalize(worldNormal);<br> vec3 s = vec3(0.0);<br><br> for (int i = 0; i < lightCount; ++i) {<br> float att = 1.0;<br> float sDotN = 0.0;<br><br> if (lights[i].type != TYPE_DIRECTIONAL) {<br> // Point and Spot lights<br><br> // Light position is already in world space<br> vec3 sUnnormalized = lights[i].position - worldPos;<br> s = normalize(sUnnormalized); // Light direction<br><br> // Calculate the attenuation factor<br> sDotN = dot(s, n);<br> if (sDotN > 0.0) {<br> if (lights[i].constantAttenuation != 0.0<br> || lights[i].linearAttenuation != 0.0<br> || lights[i].quadraticAttenuation != 0.0) {<br> float dist = length(sUnnormalized);<br> att = 1.0 / (lights[i].constantAttenuation +<br> lights[i].linearAttenuation * dist +<br> lights[i].quadraticAttenuation * dist * dist);<br> }<br><br> // The light direction is in world space already<br> if (lights[i].type == TYPE_SPOT) {<br> // Check if fragment is inside or outside of the spot light cone<br> if (degrees(acos(dot(-s, lights[i].direction))) > lights[i].cutOffAngle)<br> sDotN = 0.0;<br> }<br> }<br> } else {<br> // Directional lights<br> // The light direction is in world space already<br> s = normalize(-lights[i].direction);<br> sDotN = dot(s, n);<br> }<br><br> // Calculate the diffuse factor<br> float diffuse = max(sDotN, 0.0);<br><br> // Calculate the specular factor<br> float specular = 0.0;<br> if (diffuse > 0.0 && shininess > 0.0) {<br> float normFactor = (shininess + 2.0) / 2.0;<br> vec3 r = reflect(-s, n); // Reflection direction in world space<br> specular = normFactor * pow(max(dot(r, worldView), 0.0), shininess);<br> }<br><br> // Accumulate the diffuse and specular contributions<br> diffuseColor += att * lights[i].intensity * diffuse * lights[i].color;<br> specularColor += att * lights[i].intensity * specular * lights[i].color;<br> }<br>}<br><br>vec4 phongFunction(const in vec4 ambient,<br> const in vec4 diffuse,<br> const in vec4 specular,<br> const in float shininess,<br> const in vec3 worldPosition,<br> const in vec3 worldView,<br> const in vec3 worldNormal)<br>{<br> // Calculate the lighting model, keeping the specular component separate<br> vec3 diffuseColor, specularColor;<br> adsModel(worldPosition, worldNormal, worldView, shininess, diffuseColor, specularColor);<br><br> // Combine spec with ambient+diffuse for final fragment color<br> vec3 color = (ambient.rgb + diffuseColor) * diffuse.rgb<br> + specularColor * specular.rgb;<br><br> return vec4(color, diffuse.a);<br>}<br><br>#line 10<br>layout(location = 0) out vec4 fragColor;<br><br>void main()<br>{<br> fragColor = (((((((phongFunction(ka, kd, ks, shininess, worldPosition, normalize(((eyePosition - worldPosition))), normalize(worldNormal)))))))));<br>}<br><br><div>***</div><div><br></div><div><br></div><div>Regards,</div><div>Aman</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Mar 3, 2025 at 3:53 PM Martin Dobias <<a href="mailto:wonder.sk@gmail.com">wonder.sk@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Aman</div><div><br></div><div>I would suggest that you try running the 3D sandbox first - it is a small test app that takes a QGIS project and shows it in a 3D canvas:</div><div><br></div><div><a href="https://github.com/qgis/QGIS/blob/master/tests/src/3d/sandbox/qgis_3d_sandbox.cpp" target="_blank">https://github.com/qgis/QGIS/blob/master/tests/src/3d/sandbox/qgis_3d_sandbox.cpp</a></div><div><br></div><div>It is small amount of code, so it should be easy to study, and hopefully it will help you to identify issues in your code...</div><div><br></div><div>Cheers</div><div>Martin</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 27, 2025 at 9:32 AM Aman Jaiswal via QGIS-Developer <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank">qgis-developer@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello, <br></div><div>I am using QGIS 3.42 with Qt5 cpp.</div><div>While loading qgs3dmapcanvas i got black screen. Can you suggest to resolve.</div><div>Here is the code <br></div><div>MainWindow::MainWindow(QWidget *parent)<br> : QMainWindow(parent)<br>{<br> // Set up the main window<br> setWindowTitle("QGIS 3D Map Example");<br> resize(800, 600);<br><br> // Set OpenGL version to 4.2 (or higher)<br> QSurfaceFormat format;<br> format.setVersion(4, 2); // Request OpenGL 4.2<br> format.setProfile(QSurfaceFormat::CoreProfile);<br> format.setOption(QSurfaceFormat::DebugContext);<br> QSurfaceFormat::setDefaultFormat(format);<br><br> qDebug() << "OpenGL Version:" << format.version();<br><br> // Load the TIFF file<br> QString tiffFilePath = "/home/aman/Downloads/Data_Developing3d/Data_Developing3d/DEM.tif";<br> rasterLayer = new QgsRasterLayer(tiffFilePath, "TIFF Layer");<br> if (!rasterLayer->isValid()) {<br> QMessageBox::warning(this, tr("Warning"), tr("Failed to load TIFF file."));<br> return;<br> } else {<br> qDebug() << "TIFF file loaded successfully.";<br> }<br><br> // Set up 2D map canvas<br> mapCanvas = new QgsMapCanvas(this);<br> mapCanvas->setExtent(rasterLayer->extent());<br> mapCanvas->setLayers(QList<QgsMapLayer *>() << rasterLayer);<br> setCentralWidget(mapCanvas);<br><br> // Set up 3D map settings<br> map3DSettings = new Qgs3DMapSettings;<br> map3DSettings->setLayers(QList<QgsMapLayer *>() << rasterLayer);<br> map3DSettings->setCrs(QgsCoordinateReferenceSystem("EPSG:4326"));<br> map3DSettings->setExtent(rasterLayer->extent());<br><br> // Set up 3D map canvas<br> map3DCanvas = new Qgs3DMapCanvas();<br> map3DCanvas->setMapSettings(map3DSettings);<br> map3DCanvas->resize(800, 600);<br> // map3DCanvas->setParent(this); // Ensure the canvas has a parent<br> map3DCanvas->show();<br> // Add the 3D canvas to a container widget<br>}</div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>
</blockquote></div>