Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "app.h"
- #include <gl/glut.h>
- int glutWindowID;
- bool MyInit(int,char* []);
- void MyExit(void);
- void MyRender(void);
- int main(int arg, char* args[]){
- bool isInitialized = MyInit(arg,args);
- if (!isInitialized) {
- return false;
- }
- return 0;
- }
- bool MyInit(int arg,char* args[]){
- glutInit(&arg,args);
- glutInitWindowPosition(-1,-1);
- glutInitWindowSize(600,600);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);
- glutWindowID = glutCreateWindow("Hello");
- glutSetWindow(glutWindowID);
- //callback methods
- glutDisplayFunc(MyRender);
- return true;
- }
- void MyExit(void){
- glutDestroyWindow(glutWindowID);
- }
- void MyRender(void){
- //HWND Wnd;
- glutSetWindow(glutWindowID);
- //HDC hDC = GetDC(Wnd);
- glClearColor(0.0,0.0,0.9,0.0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glDrawBuffer(GL_BACK);
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
- //lighting
- float Mambient[]={0.2,0.2,0.2,1.0};
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT,Mambient);
- float LightAmbient[] = {0.1,0.1,0.1,1.0};
- float LightDiffuse[] = {0.5,0.5,0.5,1.0};
- float LightPosition[] = {5.0,5.0,5.0,0.0};
- glLightfv(GL_LIGHT0,GL_AMBIENT,LightAmbient);
- glLightfv(GL_LIGHT0,GL_DIFFUSE,LightDiffuse);
- glLightfv(GL_LIGHT0,GL_POSITION,LightPosition);
- glEnable(GL_LIGHT0);
- /*RECT rect;
- GetClientRect(Wnd, &rect);
- float width = rect.right - rect.left;
- float height = rect.bottom - rect.top;
- float aspect = (height == 0)?width:width/height;
- glViewport(0,0,width,height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(45,aspect,1,100);*/
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(2.0,3.0,4.0,0.0,0.0,0.0,0.0,1.0,0.0);
- float GreenS[] = {1.0,0.0,0.0,1.0};
- glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,GreenS);
- glutSolidTeapot(1.0);
- glutSwapBuffers();
- }
Advertisement
Add Comment
Please, Sign In to add comment