Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SDL/SDL.h"
- #include "SDL/SDL_opengl.h"
- int main(int argc, char **argv)
- {
- if ( SDL_Init(SDL_INIT_VIDEO) != 0 )
- {
- printf("Unable to initialize SDL: %s\n", SDL_GetError());
- return 1;
- }
- SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
- SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL);
- if (screen == NULL)
- {
- printf("SDL_SetVideoMode() returned NULL: %s\n", SDL_GetError());
- return 1;
- }
- glViewport( 0, 0, screen->w, screen->h );
- glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); //taustaväri
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-0.5f * screen->w / screen->h, 0.5f * screen->w / screen->h, 0.5f, -0.5f, 1.0f, 500000.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glColor3i(0, 255, 0);
- glBegin(GL_TRIANGLES);
- glVertex3f(1.0f, 1.0f, 5.0f);
- glVertex3f(0.5f, 1.5f, 5.0f);
- glVertex3f(1.5f, 1.5f, 5.0f);
- glEnd();
- SDL_Delay(5000);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement