-1
I have done some search, in manuals and such on google however I would like to know how to adapt my code below to plot a chart (line for example) along with a file image .png. I do not know where I am missing below:
#include </usr/include/SDL/SDL.h> //compilar com gcc -o exSDLopengl exSDLopengl.c -lSDL -lGL -lSDL_image
#include </usr/include/GL/gl.h>
#include </usr/include/SDL/SDL_image.h>
#include <stdio.h>
#include <stdlib.h>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;
int tex;
void init(){
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,800,600,1.0,-1.0,1.0);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
}
void draw2() {
//init();
glDisable(GL_TEXTURE_2D); // isto é necessário quando se deseja desenhar SEM texturas
glColor3f(1,1,0);
glLineWidth(3);
glBegin(GL_LINES);
glVertex2i(0,0);
glVertex2i(100,100);
glEnd();
glColor3f(1,1,1);
}
void mostra_imagem() {
SDL_Surface* screen1;
SDL_Surface* imagemPNG;
SDL_Rect dest;
screen1=SDL_SetVideoMode(800,600,16,SDL_SWSURFACE | SDL_OPENGL);
imagemPNG = IMG_Load("mar.png");
dest.x=10;
dest.y=10;
SDL_FillRect(screen1, NULL, 0x3); // Pinta de preto todo o screen
SDL_BlitSurface(imagemPNG, NULL, screen1, &dest); // mostra imagem do mar
SDL_UpdateRect(screen1,0,0,0,0); // Atualiza o screen com a imagem blitada
SDL_Delay(1000);
}
int main(int argc,char** argv){
SDL_Init(SDL_INIT_VIDEO);
//SDL_Surface* screen=SDL_SetVideoMode(800,600,32,SDL_SWSURFACE|SDL_OPENGL);
int running=1;
Uint32 start;
SDL_Event event;
//init();
mostra_imagem();
draw2();
SDL_Quit();
return 0;
}
Grateful Augustus. Next step and' use lists to navigate in memory to animate images and drawings made from primitvas. Hug
– Ronaldo de Oliveira