VPN termux about China.net

SDL with OpenGL

 #include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <SDL/SDL.h>

SDL_Surface* surface;
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#define SCREEN_BPP 16
GLuint texture[1];
void wyswietlanie(void)
{
  
    glClear(GL_COLOR_BUFFER_BIT);
  
  
  
  
    glBegin(GL_POLYGON);
      
        glTexCoord2f(1.0f,1.0f);

        glVertex2f(-0.9,-0.9);

        glTexCoord2f(1.0f, 0.0f);

        glVertex2f(-0.9, 0.9);

        glTexCoord2i(0.0f,0.0f);

        glVertex2f( 0.9,0.9);

        glTexCoord2i(0.0f, 1.0f);

        glVertex2f( 0.9,-0.9);

      
    glEnd();
   
    glFlush();
}

void skalowanie(int s, int w)
{
  
  
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();



}
namespace SDL
{

void tekstura(void)
{
    SDL_Surface* textureImage;
    textureImage = SDL_LoadBMP("aaa.bmp");
        glGenTextures(1 , &texture[0]);

        //Typical texture generation using data from the bitmap.
        glBindTexture(GL_TEXTURE_2D , texture[0]);

        //Generate the texture.
        glTexImage2D(GL_TEXTURE_2D , 0 , 3, textureImage->w ,
            textureImage->h , 0 , GL_RGB , GL_UNSIGNED_BYTE ,
            textureImage->pixels);

        //Linear filtering.
        glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_NEAREST);

    // włączenie teksturowania
    glDisable(GL_TEXTURE_1D);
    glEnable(GL_TEXTURE_2D);
}
};
int main(int argc,char **argv)                   //kopjuj wklej p.

{

    glutInit(&argc,argv);

   
    glutInitDisplayMode(GLUT_RGBA);
   
    glutInitWindowSize(600,800);
   
    glutInitWindowPosition(50,50);
   
    glutCreateWindow("Nakładanie tekstur");

  
    glClearColor(0,0,0,0);
   
    SDL::tekstura();

   
    glutDisplayFunc(wyswietlanie);
    glutReshapeFunc(skalowanie);

  
    glutMainLoop();
}

No comments:

Post a Comment