er

Berbagai Tutorial dan Info Menarik

Belajar, Berjuang, dan Bertaqwa

Saturday, 31 January 2015

Rumah 3D OpenGL

#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<GL/glut.h>

void renderScene(void){
 glPointSize(2);
 glClear(GL_COLOR_BUFFER_BIT);

 // rgb(108, 51, 18)
 glColor3f (108.0/255.0, 51.0/255., 18.0/255.);
 glBegin(GL_TRIANGLES);
 glVertex2f (-0.9, 0.0);
 glVertex2f (-0.5, 0.5);
 glVertex2f (-0.25, 0.0);
 glEnd();

 // rgb(200, 195, 145)
 glColor3f (200.0/255.0, 195.0/255., 145.0/255.);
 glBegin(GL_POLYGON);
 glVertex2f (-0.9, -0.4);
 glVertex2f (-0.9, 0.0);
 glVertex2f (-0.25, 0.0);
 glVertex2f (-0.25, -0.4);
 glEnd();

 // rgb(220, 215, 160)
 glColor3f (220.0/255.0, 215.0/255., 160.0/255.);
 glBegin(GL_POLYGON);
 glVertex2f (-0.25, 0.0);
 glVertex2f (-0.25, -0.4);
 glVertex2f (0.8, -0.1);
 glVertex2f (0.8, 0.25);
 glEnd();
// ATAP
 //rgb(134, 64, 22)
 glColor3f (134.0/255.0, 64.0/255., 22.0/255.);
 glBegin(GL_POLYGON);
 glVertex2f (-0.5, 0.5);
 glVertex2f (-0.25, 0.0);
 glVertex2f (0.8, 0.25);
 glVertex2f (0.35, 0.65);
 glEnd();

 // rgb(142, 85, 44)
 glColor3f (142.0/255.0, 85.0/255., 44.0/255.);
 glBegin(GL_POLYGON);
 glVertex2f (0.07, 0.0);
 glVertex2f (0.25, 0.05);
 glVertex2f (0.25, -0.25);
 glVertex2f (0.07, -0.3);
 glEnd();

 glFlush();
}
void kunci(unsigned char key, int x, int y) {
 switch (key)
 {
 case 27 :
     case 'q':
 exit(0);
 break;
 }
 glutPostRedisplay();
}
int main(int argc, char *argv[])
{
 glutInit(&argc, argv);
 glutInitWindowSize(640,480);
 glutInitWindowPosition(100,100);
 glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
 glutCreateWindow("Primitive Object");
 glutDisplayFunc(renderScene);
 glutKeyboardFunc(kunci);
 glutMainLoop();
 return 0;
}

Screenshot :

Primitve Object 3D OpenGL

#include <Windows.h>
#include <iostream>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
#include <math.h>
void renderScene(void){

 glClear(GL_COLOR_BUFFER_BIT);

 // Draw a white torus of outer radius 3, inner radius 0.5 with 15 stacks
 // and 30 slices.
 glColor3f(1.0, 1.0, 1.0);
 //glutWireTorus(0.5, 3, 15, 30);
 glutWireCube(1.3);

 // Draw a red x-axis, a green y-axis, and a blue z-axis. Each of the
 // axes are ten units long.
 glBegin(GL_LINES);
 glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(10, 0, 0);
 glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 10, 0);
 glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 10);
 glEnd();

 glFlush();
}
void kunci(unsigned char key, int x, int y) {
 switch (key)
 {
 case 27 :
 case 'q':
 exit(0);
 break;
 }
 glutPostRedisplay();
}
void init() {

 // Set the current clear color to black and the current drawing color to
 // white.
 glClearColor(0.0, 0.0, 0.0, 1.0);
 glColor3f(1.0, 1.0, 1.0);

 // Set the camera lens to have a 60 degree (vertical) field of view, an
 // aspect ratio of 4/3, and have everything closer than 1 unit to the
 // camera and greater than 40 units distant clipped away.
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 gluPerspective(60.0, 4.0/3.0, 1, 40);

 // Position camera at (4, 6, 5) looking at (0, 0, 0) with the vector
 // <0, 1, 0> pointing upward.
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 gluLookAt(4, 6, 5, 0, 0, 0, 0, 1, 0);
}

int main(int argc, char *argv[])
{
 glutInit(&argc, argv);
 glutInitWindowSize(800,600);
 glutInitWindowPosition(100,100);
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
 glutCreateWindow("Primitive Object");
 glutDisplayFunc(renderScene);
 glutKeyboardFunc(kunci);
 init();
 glutMainLoop();
 return 0;
}

Screenshot :


Saturday, 13 December 2014

Gambar Kos 3D dengan Opengl



Source Code :

#include <stdlib.h> // standard definitions
#include <math.h> // math definitions
#include <stdio.h> // standard I/O
#include <iostream>

// include files are in a slightly different location for MacOS
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

..............................
Download source code lengkap Di Sini


Hasil :





Keterangan :
Untuk masalah gambar, gunakan gambar dengan format BMP. Letakkan gambar di folder yang sama dengan letak penyimpanan file codeblock tersebut.

Perhatikan juga hal ini :

Untuk melihat dari berbagai sudut kamar, ganti gluLookAt, berikut script-nya :
gluLookAt(1.0, 0.8,  3.3,    1.0, 0.8,  1.0,    0, 1, 0);

gluLookAt(0.7, 5.2,  1.2,    0.7, 0.0,  1.2,    0, 0, 1);

gluLookAt(0.0, 0.95,  3.0,    1.5, 0.95,  1.0,    0, 1, 0);

gluLookAt(0.0, 0.95,  2.8,    1.0, 0.95,  1.0,    0, 1, 0);

Pilih salah satu saja.
Sekian. 
Regards.

Friday, 5 December 2014

Mantan Kepala Dinas Pariwisata Kabupaten Tegal Ditahan


Menurut Kepala Kejaksaan Negeri Slawi , Hj, Unaisi Hetty Nining,SH,MH mengatakan, mantan kepala Dinas Pariwisata dan kebudayaan Kabupaten Tegal, Dra. Indah Winarni ditahan dan dititipkan di Lapas kota Tegal. Sebelumnya, tersangka sudah menjalani serangkian pemeriksaan sehingga berkas tersangka dinyatakan P 21. “ Penahanan dilakukan setelah Satreskrim Polres Tegal melimpahkan berkas hasil penyidikan kasus dugaan korupsi proyek Road Race Cacaban yang sudah dinyatakan lengkap (P21). Tersangka dalam kapasitasnya sebagai pengguna anggaran,”
Baca Selengkapnya

Lumix Camera

Lumix Camera: Panasonic Lumix DMC-GF6. Comes with a 180-degree-tiltable LCD and enables unlimited artistic expression with a variety of creative filters, with new feature new self shot, perfect camera for you who like selfie. The Lumix DMC-GF6 compact mirror less digital camera delivers amazing image.



Find this cool stuff here: http://zocko.it/LHDh1

Coolpix S3500 Camera

Coolpix S3500 Camera: Nikon Coolpix S3500 Camera in orange.



Find this cool stuff here: http://zocko.it/LHDiF