@bayu_aji94

mari saling sharing di twitter

Bayu Aji

temukan saya di facebook

Serikat Mahasiswa Indonesia

Embrio Persatuan Serikat Mahasiswa Indonesia ( SMI ) adalah organisasi yang tidak lahir begitu saja, namun SMI mempunyai sejarah yang cukup panjang terutama dalam proses pembangunannya. Diawali sejak akhir tahun 2001.

Manchester City

Manchester City merupakan klub sepak bola asli kota manchester - Inggris

Senin, 26 Mei 2014

SA Prak 9


//memakai inputan

#include <cstdlib>
#include <iostream>

using namespace std;
void tampilkan(int data[], int n)
{
 int i;
 for (i=1;i<=n;i++)
 cout<<data[i]<<" ";
 cout<<"\n";
}
 
int partisi (int A[], int i, int j)
{
   int x,p,q,temp;
 
 
   p=i;
   q=j;
 
   while(1)
   {
   while(A[p]<A[i])
   p=p+1;
 
   while(A[q]>A[j])
   q=q-1;
 
   if (p<q)
   {
   //tukarkan data
   temp=A[p];
   A[p]=A[q];
   A[q]=temp;
   }
   else
   return q;
   }
   }
 
void quick_sort(int A[], int i, int j)
{
   int k;
   if(i<j)
   {
   k=partisi(A,i,j);
   quick_sort(A,i,k);
   quick_sort(A, k+1,j);
   }
}
int main(int argc, char *argv[])
{
    int i,j,n,A[100];
 
   cout<<"masukkan banyak data= ";cin>>n;
   for(i=1;i<=n;i++)
   {
    cout<<"data ke-"<<i<<" = ";cin>>A[i];
   }
 
 cout<<"Data sebelum diurut: "<<endl;
 for(j=1;j<=n;j++)
 {
  cout<<A[j]<<" ";
 }
 quick_sort(A,1,n);
 

 //hasil pengurutan
 cout<<endl;
 cout<<endl;
 cout<<"hasil pengurutan:\n";
 tampilkan(A,n);
    system("PAUSE");
    return EXIT_SUCCESS;
}

prak 10 grafkom

//main :


/* Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above notice and this permission notice shall be included in all copies
 * or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
/* File for "Textures" lesson of the OpenGL tutorial on
 * www.videotutorialsrock.com
 */



#include <iostream>
#include <stdlib.h>

#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <glut.h>
#endif

#include "imageloader.h"

using namespace std;

void handleKeypress(unsigned char key, int x, int y) {
switch (key) {
case 27: //Escape key
exit(0);
}
}

//Makes the image into a texture, and returns the id of the texture
GLuint loadTexture(Image* image) {
GLuint textureId;
glGenTextures(1, &textureId); //Make room for our texture
glBindTexture(GL_TEXTURE_2D, textureId); //Tell OpenGL which texture to edit
//Map the image to the texture
glTexImage2D(GL_TEXTURE_2D,                //Always GL_TEXTURE_2D
0,                            //0 for now
GL_RGB,                       //Format OpenGL uses for image
image->width, image->height,  //Width and height
0,                            //The border of the image
GL_RGB, //GL_RGB, because pixels are stored in RGB format
GL_UNSIGNED_BYTE, //GL_UNSIGNED_BYTE, because pixels are stored
                  //as unsigned numbers
image->pixels);               //The actual pixel data
return textureId; //Returns the id of the texture
}

GLuint _textureId; //The id of the texture

void initRendering() {
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);

Image* image = loadBMP("images.bmp");
_textureId = loadTexture(image);
delete image;
}

void handleResize(int w, int h) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);
}

void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

glTranslatef(0.0f, 1.0f, -6.0f);

GLfloat ambientLight[] = {0.2f, 0.2f, 0.2f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

GLfloat directedLight[] = {0.7f, 0.7f, 0.7f, 1.0f};
GLfloat directedLightPos[] = {-10.0f, 15.0f, 20.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, directedLight);
glLightfv(GL_LIGHT0, GL_POSITION, directedLightPos);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _textureId);

//Bottom
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor3f(1.0f, 0.2f, 0.2f);
glBegin(GL_QUADS);

glNormal3f(0.0, 2.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);//koordinat bawah
glVertex3f(-2.5f, -2.5f, 2.5f);
glTexCoord2f(2.0f, 0.0f);//koordinat
glVertex3f(2.5f, -2.5f, 2.5f);
glTexCoord2f(2.0f, 2.0f);//koordinat
glVertex3f(2.5f, -2.5f, -2.5f);
glTexCoord2f(0.0f, 1.0f);//koordinat atas
glVertex3f(-2.5f, -2.5f, -2.5f);

glEnd();

//Back
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);

glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-2.5f, -2.5f, -2.5f);
glTexCoord2f(5.0f, 5.0f);
glVertex3f(0.0f, 2.5f, -2.5f);
glTexCoord2f(10.0f, 0.0f);
glVertex3f(2.5f, -2.5f, -2.5f);

glEnd();

//Left
glDisable(GL_TEXTURE_2D);
glColor3f(1.0f, 0.7f, 0.3f);
glBegin(GL_QUADS);

glNormal3f(1.0f, 0.0f, 0.0f);
glVertex3f(-2.5f, -2.5f, 2.5f);
glVertex3f(-2.5f, -2.5f, -2.5f);
glVertex3f(-2.5f, 2.5f, -2.5f);
glVertex3f(-2.5f, 2.5f, 2.5f);

glEnd();

glutSwapBuffers();
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);

glutCreateWindow("Textures - videotutorialsrock.com");
initRendering();

glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);

glutMainLoop();
return 0;
}








//imageloader :
/* Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above notice and this permission notice shall be included in all copies
 * or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
/* File for "Textures" lesson of the OpenGL tutorial on
 * www.videotutorialsrock.com
 */



#include <assert.h>
#include <fstream>

#include "imageloader.h"

using namespace std;

Image::Image(char* ps, int w, int h) : pixels(ps), width(w), height(h) {

}

Image::~Image() {
delete[] pixels;
}

namespace {
//Converts a four-character array to an integer, using little-endian form
int toInt(const char* bytes) {
return (int)(((unsigned char)bytes[3] << 24) |
((unsigned char)bytes[2] << 16) |
((unsigned char)bytes[1] << 8) |
(unsigned char)bytes[0]);
}

//Converts a two-character array to a short, using little-endian form
short toShort(const char* bytes) {
return (short)(((unsigned char)bytes[1] << 8) |
  (unsigned char)bytes[0]);
}

//Reads the next four bytes as an integer, using little-endian form
int readInt(ifstream &input) {
char buffer[4];
input.read(buffer, 4);
return toInt(buffer);
}

//Reads the next two bytes as a short, using little-endian form
short readShort(ifstream &input) {
char buffer[2];
input.read(buffer, 2);
return toShort(buffer);
}

//Just like auto_ptr, but for arrays
template<class T>
class auto_array {
private:
T* array;
mutable bool isReleased;
public:
explicit auto_array(T* array_ = NULL) :
array(array_), isReleased(false) {
}

auto_array(const auto_array<T> &aarray) {
array = aarray.array;
isReleased = aarray.isReleased;
aarray.isReleased = true;
}

~auto_array() {
if (!isReleased && array != NULL) {
delete[] array;
}
}

T* get() const {
return array;
}

T &operator*() const {
return *array;
}

void operator=(const auto_array<T> &aarray) {
if (!isReleased && array != NULL) {
delete[] array;
}
array = aarray.array;
isReleased = aarray.isReleased;
aarray.isReleased = true;
}

T* operator->() const {
return array;
}

T* release() {
isReleased = true;
return array;
}

void reset(T* array_ = NULL) {
if (!isReleased && array != NULL) {
delete[] array;
}
array = array_;
}

T* operator+(int i) {
return array + i;
}

T &operator[](int i) {
return array[i];
}
};
}

Image* loadBMP(const char* filename) {
ifstream input;
input.open(filename, ifstream::binary);
assert(!input.fail() || !"Could not find file");
char buffer[2];
input.read(buffer, 2);
assert(buffer[0] == 'B' && buffer[1] == 'M' || !"Not a bitmap file");
input.ignore(8);
int dataOffset = readInt(input);

//Read the header
int headerSize = readInt(input);
int width;
int height;
switch(headerSize) {
case 40:
//V3
width = readInt(input);
height = readInt(input);
input.ignore(2);
assert(readShort(input) == 24 || !"Image is not 24 bits per pixel");
assert(readShort(input) == 0 || !"Image is compressed");
break;
case 12:
//OS/2 V1
width = readShort(input);
height = readShort(input);
input.ignore(2);
assert(readShort(input) == 24 || !"Image is not 24 bits per pixel");
break;
case 64:
//OS/2 V2
assert(!"Can't load OS/2 V2 bitmaps");
break;
case 108:
//Windows V4
assert(!"Can't load Windows V4 bitmaps");
break;
case 124:
//Windows V5
assert(!"Can't load Windows V5 bitmaps");
break;
default:
assert(!"Unknown bitmap format");
}

//Read the data
int bytesPerRow = ((width * 3 + 3) / 4) * 4 - (width * 3 % 4);
int size = bytesPerRow * height;
auto_array<char> pixels(new char[size]);
input.seekg(dataOffset, ios_base::beg);
input.read(pixels.get(), size);

//Get the data into the right format
auto_array<char> pixels2(new char[width * height * 3]);
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
for(int c = 0; c < 3; c++) {
pixels2[3 * (width * y + x) + c] =
pixels[bytesPerRow * y + 3 * x + (2 - c)];
}
}
}

input.close();
return new Image(pixels2.release(), width, height);
}








//images loader.h:
/* Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above notice and this permission notice shall be included in all copies
 * or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
/* File for "Textures" lesson of the OpenGL tutorial on
 * www.videotutorialsrock.com
 */



#ifndef IMAGE_LOADER_H_INCLUDED
#define IMAGE_LOADER_H_INCLUDED

//Represents an image
class Image {
public:
Image(char* ps, int w, int h);
~Image();

/* An array of the form (R1, G1, B1, R2, G2, B2, ...) indicating the
* color of each pixel in image.  Color components range from 0 to 255.
* The array starts the bottom-left pixel, then moves right to the end
* of the row, then moves up to the next column, and so on.  This is the
* format in which OpenGL likes images.
*/
char* pixels;
int width;
int height;
};

//Reads a bitmap image from file.
Image* loadBMP(const char* filename);










#endif


link file : http://www.4shared.com/folder/E7JT8w0A/grafkom_prak_10.html

prak 9 grafkom

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <glut.h>
//#include <glu.h>



void initRendering() {
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_NORMALIZE);
glShadeModel(GL_SMOOTH);
}

void handleResize(int w, int h) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (double)w / (double)h, 1.0, 200.0);
}

float _angle = 60.0f;
void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -8.0f);

GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);

GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f};
GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 1.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
//radius
GLfloat lightColor1[] = {0.5f, 0.2f, 0.2f, 1.0f};

GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f};
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);

glRotatef(_angle, 0.0f, 1.0f, 0.0f);
glColor3f(1.0f, 1.0f, 0.0f);
glBegin(GL_QUADS);

//Front
//glNormal3f(0.0f, 0.0f, 1.0f);
glNormal3f(-1.0f, 0.0f, 1.0f);
glVertex3f(-1.5f, -1.0f, 1.5f);
glNormal3f(1.0f, 0.0f, 1.0f);
glVertex3f(1.5f, -1.0f, 1.5f);
glNormal3f(1.0f, 0.0f, 1.0f);
glVertex3f(1.5f, 1.0f, 1.5f); //muka
glNormal3f(-1.0f, 0.0f, 1.0f);
glVertex3f(-1.5f, 1.0f, 1.5f);
glEnd();

glBegin(GL_QUADS);

glNormal3f(1.0f, 0.0f, 0.0f);
glVertex3f(1.5f, -1.0f, 1.5f);
glVertex3f(1.5f, -1.0f, -1.5f);
glVertex3f(1.5f, 1.0f, -1.5f);
glVertex3f(1.5f, 1.0f, 1.5f);


glEnd();

glutSwapBuffers();
}

void update(int value) {
_angle += 1.5f;
if (_angle > 360) {
_angle -= 360;
}

glutPostRedisplay();
glutTimerFunc(25, update, 0);
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);
glutCreateWindow("Lighting - videotutorialsrock.com");
initRendering();
glutDisplayFunc(drawScene);
glutReshapeFunc(handleResize);
glutTimerFunc(25, update, 0);

glutMainLoop();
return 0;
}

Selasa, 20 Mei 2014

baju


Senin, 19 Mei 2014

Prak 8


#include <cstdlib>
#include <iostream>

using namespace std;
void MinMaks2(int A[], int i, int j, int &min, int &maks)
{
     int min1, min2, maks1, maks2, k;
   
     if (i=j)
     {
             min = A[i];
             maks = A[i];
             }
     else
     {
         if (i = j-1)
         {
               if (A[i] < A[j])
               {
                        maks = A[j];
                        min = A[i];
                        }
               else
               {
                   maks = A[i];
                   min = A[j];
                   }
                   }
         else
         {
             k = ((i+j)/2);
             MinMaks2(A, i, k, min1, maks1);
             MinMaks2(A, i+1, j, min2, maks2);
             }
             if (min1 < min2)
             {
                 min = min1;
                 }
               
             else
             {
                 min = min2;
                 }
                 }
             if (maks1 < maks2)
             {
                 maks = maks2;
                       }
             else
             {
                 maks = maks1;
                 }
                 }
                 

int main(int argc, char *argv[])
{
    int A[] = {3,6,1,10,8,19,2,4};
    int i = 0;
    int j = 7;
    int min, maks;
    MinMaks2(A, i, j, min, maks);
    cout<<"min = "<<min<<endl;
    cout<<"maks = "<<maks<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Senin, 12 Mei 2014

Prak 7

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <glut.h>
//#include <glu.h>
#include <iostream>


float _angle = 45.0f;
 void init(void)
{
   glClearColor (0.0, 0.0, 0.0, 0.0);
   glShadeModel (GL_FLAT);
}
void display(void)
{

 
   glClear (GL_COLOR_BUFFER_BIT);
   glColor3f (0.0, 0.0, 1.0);
   glLoadIdentity ();
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   //glTranslatef(0.0,0.0,0.0);
   glFlush ();
   //glClear (GL_COLOR_BUFFER_BIT);
   //glColor3f (0.0, 1.0, 1.0);
   glLoadIdentity ();
   glTranslatef(0.0,0.2,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

   glLoadIdentity ();
   glTranslatef(0.0,0.4,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

   glLoadIdentity ();
   glTranslatef(0.0,0.6,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

   glLoadIdentity ();
   glTranslatef(0.0,0.8,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

 
   glColor3f (1.0, 0.0, 0.0);
   glRotatef(_angle, 0.0f, 3.0f, 1.0f);
   glLoadIdentity ();
   glTranslatef(0.0,1.0,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();


   glLoadIdentity ();
   glTranslatef(0.2,1.0,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

   glLoadIdentity ();
   glTranslatef(-0.2,1.0,0.0);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

   glLoadIdentity ();
   glTranslatef(0.0,1.0,-0.2);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();

   glLoadIdentity ();
   glTranslatef(0.0,1.0,0.2);
   gluLookAt (0.5, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);//posisi kamera 3 parameter depan
   glutWireCube(0.2);//ukuran
   glFlush ();
}
void reshape (int w, int h)
{
   glViewport (0, 0, (GLsizei) w, (GLsizei) h);
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glFrustum (-1.0, 1.0, -1.0, 1.0, 2.0, 20.0);
   glMatrixMode (GL_MODELVIEW);
}
int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (500, 500);
   //glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   init ();
   glutDisplayFunc(display);
   glutReshapeFunc(reshape);
   glutMainLoop();
   return 0;
}

Senin, 05 Mei 2014

SA 6


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int graf[7][7];
   
    //
    for(int i=0; i<7; i++){
    for(int j=0; j<7; j++){
            graf[i][j]=0;
            }
            }
    //set nilai bobot
    graf[0][1]=7;
    graf[0][4]=15;
    graf[0][6]=12;
    graf[1][2]=8;
    graf[2][3]=3;
    graf[2][4]=25;
    graf[3][5]=10;
    graf[6][4]=5;
    graf[6][5]=35;
    //dts...
   
    int pohon[7];
    //proses pengurutan data
    for(int i=0; i<7; i++)
    {
        for(int j=0; j<7; j++)
        {
            if(graf[i][j] > graf[i][j+1])
            {   int tmp = graf[i][j];
                graf[i][j] = graf[i][j+1];
                graf[i][j+1] = tmp;
            }    
        }
       
    }
   
    for(int i=0; i<7; i++){
    for(int j=0; j<7; j++){
            cout<<graf[i][j+1];
            cout<<", ";
            }
            }
     
    //masukkan nilai bobot terendah ke aray pohon
    //cetak isi aray dari pohon
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

prak 6

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <glut.h>
//#include <glu.h>
#include <iostream>

float _angle = 45.0f;
//draws the 3D scene
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //menghapus layar
glMatrixMode(GL_MODELVIEW); //switch to setting the camera perspective
glLoadIdentity();//reset the camera
//glTranslatef(0.5f, 0.0f, 0.0f);//translasi
//glScalef(2.0f, 2.0f, 3.0f);//skala
//glRotatef(_angle, 0.0f, 0.0f, 1.0f);
glPushMatrix();//save the transformations performed thus far
glRotatef(_angle, 0.0f, 0.0f, 1.0f);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex3f(-0.1f, -0.1f, 0.0f);
glVertex3f(-0.1f, 0.1f, 0.0f);
glVertex3f(0.1f, 0.1f, 0.0f);
glVertex3f(0.1f, -0.1f, 0.0f);
glEnd();

glTranslatef(0.5f, 0.0f, .0f);//translasi
glRotatef(_angle, 0.0f, 0.0f, 1.0f);
glColor3f(0.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex3f(-0.1f, -0.1f, 0.0f);
glVertex3f(-0.1f, 0.1f, 0.0f);
glVertex3f(0.1f, 0.1f, 0.0f);
glVertex3f(0.1f, -0.1f, 0.0f);
glEnd();

glTranslatef(0.5f, 0.0f, .0f);//translasi
glRotatef(_angle, 0.0f, 0.0f, -1.0f);
glColor3f(1.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(-0.1f, -0.1f, 0.0f);
glVertex3f(-0.1f, 0.1f, 0.0f);
glVertex3f(0.1f, 0.1f, 0.0f);
glVertex3f(0.1f, -0.1f, 0.0f);
glEnd();
glPopMatrix();//undo the move to the center of the trapezoid
glutSwapBuffers();//send the 3D scene to the screen
glFlush();
}



void update(int value){
_angle += 9.0f;
if(_angle > 360){
_angle -= 360;
}
glutPostRedisplay();//tell glut that the display changed
//Tell glut to call update
glutTimerFunc(80, update, 0);
}
int main(int argc, char** argv)
{
glutInitWindowSize(400,400);
printf("Contoh Sederhana Kotak ");
glutCreateWindow("Praktikum");
glutDisplayFunc(mydisplay);
glutTimerFunc(25, update,0);
glutMainLoop();
return 0;
}
"bayuaji-master.blogspot.com". Diberdayakan oleh Blogger.