SlideShare ist ein Scribd-Unternehmen logo
1 von 32
3D Development with Qt
                
Agenda

    3D Concepts
    OpenGL
    Qt + OpenGL


                   
     
     
We need an API




           
 
    Graphics rendering API
               
Current industry standard for 3D graphics 
             ( Hi DirectX! ) 




                      
MultiPlatform

       MultiLanguage

    Hardware Independent

       Open Standard
               
More than 250 functions to produce 
        three­dimensional scenes


    glColor, glVertex, glTranslate, glRotate ...



                          
Geometric Primitives




              
     
Camera
Physical locations
Projection properties




                            
Lighting

glEnable ( GL_LIGHTING )
Lighting simulates how objects reflect light
Material composition
Light’s color and position
Two sided

GLfloat mred[4]= {1,0,0,1};
glMaterialfv(GL_FRONT, GL_AMBIENT, mred);




                                           
Primitives are specified:
glBegin(primitiveType);
    …
    …
glEnd();
Example:

glBegin(GL_TRIANGLES);    
    glVertex3f( 0.0, 1.0, 0.0 );
    glVertex3f( ­1.0, ­1.0, 0.0 );
    glVertex3f( 1.0, ­1.0, 0.0 );
glEnd();
                               
Color




        
The human eye has 3 types of light receptor 
                  cells 




glColor3f ( GLfloat red, GLfloat green, GLfloat blue );
                           
glBegin(GL_TRIANGLES);
    // red
    glColor3f( 1.0, 0.0, 0.0 );
    glVertex3f( 0.0, 1.0, 0.0 );

    // green
    glColor3f( 0.0, 1.0, 0.0 );
    glVertex3f( ­1.0, ­1.0, 0.0 );

    // blue
    glColor3f( 0.0, 0.0, 1.0 );
    glVertex3f( 1.0, ­1.0, 0.0 );
glEnd();  

                                      
Shading

Smooth:
glShadeModel ( GL_SMOOTH  );    


Flat:
glShadeModel ( GL_FLAT  );  




                         
// Smooth shading
glShadeModel(GL_SMOOTH); 
glBegin(GL_TRIANGLE_STRIP);
        glColor3( 0.0, 0.5, 0.0 );
        glVertex3( ­1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 0.0, 0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.5, 0.0, ­5.0 );

        glColor3( 0.0, 0.0, 1.0 );
        glVertex3( 2.0, ­1.5, ­5.0 );        
    
glEnd();
// Flat shading
glShadeModel(GL_FLAT); 
glBegin(GL_TRIANGLE_STRIP);
        glColor3( 0.0, 0.5, 0.0 );
        glVertex3( ­1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 0.0, 0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.5, 0.0, ­5.0 );

        glColor3( 0.0, 0.0, 1.0 );
        glVertex3( 2.0, ­1.5, ­5.0 );        
    
glEnd();
 
 
    glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR );
                                    
     
+

    Qt OpenGL module
              
#include <QGLWidget>
class GLWidget : public QGLWidget
{
    Q_OBJECT

public:
    GLWidget( QWidget *parent=0 );
    ~GLWidget();
    ...

protected:
    void initializeGL();
    void resizeGL( int width, int height );
    void paintGL();

private:
    ...
                                      

};
    void initializeGL();
    void resizeGL( int width, int height );
    void paintGL();


                        
void GLWidget::initializeGL()
    {

        // Smooth shading
        glShadeModel( GL_SMOOTH ); 

        // Background color
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );  ­>    qglClearColor( Qt::black );

        // Depth buffer setup
        glClearDepth( 1.0f );

        // Enable depth testing
        glEnable( GL_DEPTH_TEST );

        // Set type of depth test
        glDepthFunc( GL_LEQUAL );
                                            
    }
void GLWidget::resizeGL( int width, int height ) 
    {
       
        if ( height == 0 )
            height = 1;

        // Reset current viewport
        GlViewport( 0, 0, width, height ); 

        // Select projection matrix
        GlMatrixMode( GL_PROJECTION ); 
        
        // Reset projection matrix
        glLoadIdentity(); 

        // Select modelview matrix
        GlMatrixMode( GL_MODELVIEW ); 

 
        // Reset modelview matrix          
        glLoadIdentity(); 
void GLWidget::paintGL()
    {
        glClear ( GL_COLOR_BUFFER_BIT );

        // Reset the drawing perspective
        glLoadIdentity(); 

        // triangle
        glBegin (GL_TRIANGLES);
            GlColor3f ( 1.0,  0.0,  0.0 );
            glVertex3f ( 5.0,  5.0, 0.0 );

            glColor3f ( 0.0,  1.0, 0.0 );
            glVertex3f ( 25.0, 5.0, 0.0 );

            glColor3f ( 0.0,  0.0, 1.0 );
            GlVertex3f ( 5.0,  25.0, 0.0 );
        glEnd();                               
    }
void GLWidget::drawtriangle()
{
    glBegin ( GL_TRIANGLES );
        glColor3f ( 1.0,  0.0,  0.0 );
        glVertex3f ( 5.0,  5.0, 0.0 );
   
        glColor3f ( 0.0,  1.0, 0.0 );
        glVertex3f ( 25.0, 5.0, 0.0 );
   
        glColor3f ( 0.0,  0.0, 1.0 );
        glVertex3f ( 5.0,  25.0, 0.0 );
    glEnd();
}
void GLWidget::paintGL()
{
    glClear ( GL_COLOR_BUFFER_BIT );

    // Reset the drawing perspective
    glLoadIdentity(); 
                                           

    drawTriangle();
Demo Animation




           
Demo Rotation




            
Thanks

    Ronny Yabar Aizcorbe

    ronnycontacto@gmail.com
      ronnyml.wordpress.com

                

Weitere ähnliche Inhalte

Ähnlich wie Development with OpenGL and Qt

Ähnlich wie Development with OpenGL and Qt (20)

Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
 
Grafika komputer 2
Grafika komputer 2Grafika komputer 2
Grafika komputer 2
 
Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
 
OpenGL L03-Utilities
OpenGL L03-UtilitiesOpenGL L03-Utilities
OpenGL L03-Utilities
 
Open gl tips
Open gl tipsOpen gl tips
Open gl tips
 
Ujug07presentation
Ujug07presentationUjug07presentation
Ujug07presentation
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flag
 
Robot by gulnaz
Robot by gulnazRobot by gulnaz
Robot by gulnaz
 
Robot by gulnaz
Robot by gulnazRobot by gulnaz
Robot by gulnaz
 
The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185
 
01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt
 
Bai 1
Bai 1Bai 1
Bai 1
 
Practicing 2d drawing primitives
Practicing 2d drawing primitivesPracticing 2d drawing primitives
Practicing 2d drawing primitives
 
CGLabLec6.pptx
CGLabLec6.pptxCGLabLec6.pptx
CGLabLec6.pptx
 
2D Drawing
2D Drawing2D Drawing
2D Drawing
 
opengl.ppt
opengl.pptopengl.ppt
opengl.ppt
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
 

Kürzlich hochgeladen

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Development with OpenGL and Qt