6 Jan 2013

Materi KCB ( AI )

Assalamu 'alaikum wr.wb.
Hai Teman~
Ada pemberitahuan dari bu El bahwa :
Sifat ujian : Open (terbuka)
kisi-kisi : Sistem Pakar, NLP, JST dan Pola, Tugas Kelompok
maka dari itu dibawah ini ada sebagian materi kecerdasan buatan :
materi ai 1-14
dan tambahan dari bu El:
referensi ai

sebagai downloader yang baik silahkan tinggalkan coment
Photobucket

26 Des 2012

php web













delete.php

<?php
include "koneksi.php";
$id = $_GET['id'];
mysql_query("delete from user where id_user=$id");
header( 'Location: tampil.php' ) ;
?>

simpan.php
<?php
include "koneksi.php";
$username = $_POST['username'];
$password = $_POST['password'];
$password = md5($password);
$email = $_POST['email'];
mysql_query("insert into user (`username`,`password`,`email`) values('$username','$password','$email')");
header( 'Location: tampil.php' ) ;
?>

koneksi.php

<?php
$host = "localhost";
$username = "root";
$password = "";
$database = "terserah";

//koneksi ke mysql

mysql_connect($host,$username,$password) or die("koneksi gagal");

//select database

mysql_select_db($database);
?>

admin.php p7
<?php
session_start();
if(!$_SESSION['login_status']) echo '<script > alert("anda harus login terlebih dahulu"); location.href="login.php";</script>';
include 'tampil.php';
?>

login.php
<?php
session_start();
 if( $_SESSION['login_status'] ==true) echo '<script> alert("anda haru login terlebih dahulu"); location.href="admin.php";</script>';?>
<form method="post" action="proseslogin.php">
username : <input type="text" name="username"><br>
password : <input type="password" name="password"><br>
<input type="submit" value="Log in">
</form>

tampil.php
<form method="post" action="logout.php">
<?php
include "koneksi.php";

$hasil = mysql_query("select * from user");
echo "<table border='1'>
<tr>
<th>USERNAME</th>
<th>PASSWORD</th>
<th>EMAIL</th>
<th> </th>
</tr>";

while($row = mysql_fetch_array($hasil))
  {
  echo "<tr>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['password'] . "</td>";
  echo "<td>" . $row['email'] . "</td>";
  echo "<td> <a href='delete.php?id= ".$row['id_user']."'>Buang ke tempat sampah</a> </td>";
  echo "</tr>";
  }
echo "</table>";
?>
<input type="submit" value="Log out">
</form>

logout.php
<?php
session_start();
session_destroy();
header( 'Location: login.php' ) ;
?>

list_berita.php
<?php
include 'koneksi.php';
session_start();
if(!$_SESSION['login_status'])
echo '<script>alert("anda harus login terlebih dahulu"); location.href="login.php";</script>';

if(isset($_POST['judul']) && isset ($_POST['isi'])):
$date = date('Y-m-d');
$status = mysql_query("INSERT INTO berita (`judul`, `isi`, `tanggal`) VALUES ('$_POST[judul]', '$_POST[isi]', '".$date."')");
if($status): echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal"); location.href="list_berita.php"; </script>'; endif;
endif;
?>

<?php if (isset($_GET['action']) && $_GET['action'] == 'tambah') :?>
<form method="post" action="list_berita.php">
<label>judul</label><input type="text" name="judul"><br>
<label>konten</label><textarea name="isi"></textarea><br>
<input type="submit">
</form>
<?php else: ?>
<a href="?action=tambah"> Tambah berita </a>
<table>
<tr>
<td>NO</td>
<td>Judul</td>
<td>isi</td>
<td>aksi</td>
</tr>
<?php $i=1; ?>
<?php $result = mysql_query('SELECT * FROM berita'); ?>
<?php while($row = mysql_fetch_object($result)):?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $row->judul; ?></td>
<td><?php echo $row->isi; ?></td>
<td>
<a href="hapus_berita.php?id_berita=<?php echo $row->id_berita?>" onclick="return confirm ('ciyus ?? ')">hapus</a>
<a href="edit_berita.php?id_berita=<?php echo $row->id_berita?>">edit</a>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>

hapus_berita.php
<?php
include 'koneksi.php';
session_start();
if(isset($_GET['id_berita'])):
$status = mysql_query("DELETE FROM berita where id_berita = ".$_GET['id_berita']);
if($status):echo '<script> loaction.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';endif;
endif;
?>

edit_berita.php

<?php
include 'koneksi.php';
session_start();
if(!$_SESSION['login_status'])
echo '<script>alert("anda harus login dahulu");location.href="login.php";</script>';

if(isset($_POST['id_berita']) && isset($_POST['judul']) && isset($_POST['isi'])):
$status = mysql_query("UPDATE berita SET `judul` = '$_POST[judul]', `isi` = '$_POST[isi]' WHERE id_berita=$_POST[id_berita]  ");
if($status): echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal"); location.href="list_berita.php"; </script>'; endif;
endif;
if(isset($_GET['id_berita'])):
$result = mysql_query("SELECT * FROM berita where id_berita=".$_GET['id_berita']);
$berita = mysql_fetch_object($result);
?>
<form method="post" action="edit_berita.php">
<input type="hidden" name="id_berita" value="<?php echo $berita->id_berita;?>">
<label>judul</label><input type="text" name="judul" value="<?php echo $berita->judul;?>"><br>
<label>konten</label><textarea name="isi"><?php echo $berita->isi;?></textarea><br>
<input type="submit" value="simpan">
</form>
<?php endif; ?>

index.php
<a href="?act=tambah">tambah berita</a>
<?php
include 'koneksi.php';
if(isset($_GET['act'])=='tambah'):?>
<form action="?atc=insert" method="post">
Judul : <input type="text" name="judul"/><br>
Isi : <textarea name="isi"></textarea><br>
<input type="submit" name="sumbit" value="tambah berita"/>
</form>
<?php
endif;
if($_GET['atc']=='insert'):
$tanggal = date('y-m-d');
mysql_query("INSERT INTO beritaa(`judul`,`isi`,`tanggal`) 
VALUES ('$_POST[judul]','$_POST[isi]','$tanggal');");
endif;
?>
<table border="1">
<tr>
<td>no</td>
<td>judul</td>
<td>isi</td>
<td>tanggal</td>
<td>aksi</td>
</tr>
<?php
$result = mysql_query("SELECT * FROM beritaa");
$no = 1;
while($r = mysql_fetch_object($result)):?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $r->judul;?></td>
<td><?php echo $r->isi;?></td>
<td><?php echo $r->tanggal;?></td>
<td><a href="?act=edit&id_berita=<?php echo $r->id_berita?>">edit</a> | <a href="?act=delet">delet</a></td>
</tr>
<?php
endwhile;
?>
</table>
<?php
if($_GET['act']=='edit'):
$id_berita=$_GET['id_berita'];
$result = mysql_query("SELECT * FROM beritaa where id_berita='$id_berita'");
$no = 1;
$r = mysql_fetch_object($result);
?>
<form action="?atc=postedit" method="post">
Judul : <input type="text" name="judul" value="<?php echo $r->judul?>"/><br>
Isi : <textarea name="isi" ><?php echo $r->isi?></textarea><br>
<input type="submit" name="sumbit" value="tambah berita"/>
</form>
<?php
endif;
?>

dashboard.php
<a href="?act=tambah">tambah berita</a>
<?php
include 'koneksi.php';
if(isset($_GET['act'])=='tambah'):?>
<form action="?atc=insert" method="post">
Judul : <input type="text" name="judul"/><br>
Isi : <textarea name="isi"></textarea><br>
<input type="submit" name="sumbit" value="tambah berita"/>
</form>
<?php
endif;
if($_GET['atc']=='insert'):
$tanggal = date('y-m-d');
mysql_query("INSERT INTO beritaa(`judul`,`isi`,`tanggal`) 
VALUES ('$_POST[judul]','$_POST[isi]','$tanggal');");
endif;
?>
<table border="1">
<tr>
<td>no</td>
<td>judul</td>
<td>isi</td>
<td>tanggal</td>
<td>aksi</td>
</tr>
<?php
$result = mysql_query("SELECT * FROM beritaa");
$no = 1;
while($r = mysql_fetch_object($result)):?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $r->judul;?></td>
<td><?php echo $r->isi;?></td>
<td><?php echo $r->tanggal;?></td>
<td><a href="?act=edit&id_berita=<?php echo $r->id_berita?>">edit</a> | <a href="?act=delet&id_berita=<?php echo $r->id_berita?>">delet</a></td>
</tr>
<?php
endwhile;
?>
</table>
<?php
if($_GET['act']=='edit'):
$id_berita=$_GET['id_berita'];
$result = mysql_query("SELECT * FROM beritaa where id_berita='$id_berita'");
$no = 1;
$r = mysql_fetch_object($result);
?>
<form action="?atc=postedit&id_berita=<?php echo $r->id_berita?>" method="post">
Judul : <input type="text" name="judul" value="<?php echo $r->judul?>"/><br>
Isi : <textarea name="isi" ><?php echo $r->isi?></textarea><br>
<input type="submit" name="sumbit" value="tambah berita"/>
</form>
<?php
endif;
if($_GET['act']=='postedit'):
if(isset($_POST['id_berita']) && isset($_POST['judul']) && isset($_POST['isi'])):
$status = mysql_query("UPDATE berita SET `judul` = '$_POST[judul]', `isi` = '$_POST[isi]' WHERE id_berita=$_POST[id_berita]  ");
if($status): echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal"); location.href="list_berita.php"; </script>'; endif;
endif;
endif;
if($_GET['act']=='delet'):
$id_berita=$_GET['id_berita'];
$hasil = mysql_query("DELETE FROM beritaa WHERE id_berita = '$id_berita'");
echo "<script>alert('Berhasil Menghapus Data!');</script>";
echo "<script>location.href='admin.php'</script>";
?>
<?php
endif;
?>

proseslogin.php
<?php
include 'koneksi.php';
session_start();
if(isset($_POST['username']) && isset($_POST['password'])):
$query_count = mysql_query("select count(*) as jumlah from user where username='$_POST[username]' AND password=MD5('$_POST[password]')");
$result_count = mysql_fetch_object($query_count);
if($result_count->jumlah > 0):
$query = mysql_query("select * from user where username='$_POST[username]' AND password=MD5('$_POST[password]')");
$result = mysql_fetch_object($query);
$_SESSION['id_user'] = $result->id_user;
$_SESSION['login_status'] = true;
echo '<script> alert("sukses tos sik"); location.href="admin.php";</script>';
else:
'<script> alert("Username dan password yang anda masukkan salah"); location.href="login.php";</script>';
endif;
else:
'<script> alert("Username dan password harus diisi"); location.href="login.php";</script>';
endif;
?>admin.php p9

<?php
session_start();
if(!$_SESSION['login_status']) echo '<script>alert("anda harus login terlebih dahulu"); location.href="login.php";</script>';

include 'dashboard.php';

?>


home.php
<?php
include "koneksi.php";

$berita = mysql_query("SELECT * FROM berita");
while ($row = mysql_fetch_object($berita)):
echo "<h1>".$row->judul."</h1>";
echo "<small>".$row->tanggal."<small>";
echo "<p>".$row->isi."</p><br>";
echo "<hr>";

$komentar = mysql_query("SELECT * FROM komentar where id_berita = ".$row->id_berita);

while($komen = mysql_fetch_object($komentar)):
echo $komen->nama." : ";
echo "<i>".$komen->komentar."</i><br><br>";
endwhile;

echo "<hr>";
?>
<form method="post" action="post_komentar.php">
<input type="hidden" name="id_berita" value="<?php echo $row->id_berita ?>"></input>
nama : <input type="text" name="nama"></input><br>
email : <input type="email" name="email"></input><br>
url : <input type="text" name="url"></input><br>
komentar : <textarea name="komentar"></textarea><br>
<input type="submit" value="kirim">
</form>

<?php
endwhile;
?>


post_komentar.php

<?php
include "koneksi.php";

if(isset($_POST['komentar']) && isset($_POST['email']) && isset($_POST['nama'])):
$send = mysql_query("INSERT INTO komentar (`nama`, `email`, `url`, `komentar`, `id_berita`) 
VALUES ('$_POST[nama]', '$_POST[email]', '$_POST[url]', '$_POST[komentar]','$_POST[id_berita]')");
if($send):
echo '<script>location.href="home.php";</script>';
else : echo '<script>alert("gagal");location.href="home.php";</script>';
endif;
endif;

?>

Photobucket

16 Apr 2012

Materi sertifikasi 3 - Dakwah

Bagi yang belum punya materi Sertifikasi 3 tentang dakwah bisa mendownload lewat link di bawah ini.
materi yang ada disini adalah materi dari awal perkuliahan sampai dengan UAS.

Klik "4Shared"
Password : r_maulana

Photobucket

14 Apr 2012

Grafkom prak 4 postes Membuat 3 garis dengan DDA dan Bresenham

/* Praktikum 04
* Membuat objek garis dengan DDA dan Bresenham
*/

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

void display(void)
{
//set display-window background color to white
glClearColor(1.0,1.0,1.0,0.0);
//set projection parameters
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 300.0, 0.0, 300.0);
}
void setPixel(GLint xCoordinate, GLint yCoordinate)
{
glBegin(GL_POINTS);
glVertex2i(xCoordinate, yCoordinate);
glEnd();
glFlush();
}
//Procedure Bresenham line-drawing untuk |m| < 1.0
void lineBres(GLint x0, GLint y0, GLint xEnd, GLint yEnd)
{
GLint dx = (float)fabs((float) xEnd - x0);
GLint dy = (float)fabs((float) yEnd - y0);
GLint p = 2 * dy - dx;
GLint twoDy = 2 * dy;
GLint twoDyMinusDx = 2 * (dy - dx);
GLint x,y;
//determine which endpoint to use as start position
if (x0 > xEnd) {
x = xEnd;
y = yEnd;
xEnd = x;
} else {
  x = x0;
  y = y0;
  }
  setPixel(x,y);
  while (x  x++;
  if (p<0)
  p += twoDy;
  else {
  y++;
  p += twoDyMinusDx;
  }
  setPixel(x,y);
  }
  }
void drawMyLine1(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glPointSize(1.0);
GLint x0 = 100;
GLint y0 = 100;
GLint xEnd = 250;
GLint yEnd = 200;
lineBres(x0,y0,xEnd, yEnd);

glPointSize(4.0);
glColor3f(0.0,0.0,1.0);
GLint x1 = 100;
GLint y1 = 100;
GLint x4 = 150;
GLint y4 = 100;
lineBres(x1,y1,x4, y4);

glPointSize(2.0);
glColor3f(0.0,1.0,0.0);
GLint x2 = 150;
GLint y2 = 100;
GLint x3 = 250;
GLint y3 = 200;
lineBres(x2,y2,x3, y3);

}
int main(int argc, char** argv)
{
//initialize GLUT
glutInit(&argc, argv);
//initialize display mode
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
//set display-window width & height
glutInitWindowSize(400,400);
//set display-window upper-left position
glutInitWindowPosition(0,0);
//create display-window with a title
glutCreateWindow("Digital Differential Analiyzer Algorithm");
//initialize OpenGL
display();
//call graphics to be diplayes on the window

glutDisplayFunc(drawMyLine1);
//display everything and wait
glutMainLoop();
return 0;
}




Photobucket

Grafkom prak 4 Membuat garis dengan DDA dan Bresenham

/* Praktikum 04
* Membuat objek garis dengan DDA dan Bresenham
*/

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

void display(void)
{
//set display-window background color to white
glClearColor(1.0,1.0,1.0,0.0);
//set projection parameters
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 300.0, 0.0, 300.0);
}
void setPixel(GLint xCoordinate, GLint yCoordinate)
{
glBegin(GL_POINTS);
glVertex2i(xCoordinate, yCoordinate);
glEnd();
glFlush();
}
//Procedure Bresenham line-drawing untuk |m| < 1.0
void lineBres(GLint x0, GLint y0, GLint xEnd, GLint yEnd)
{
GLint dx = (float)fabs((float) xEnd - x0);
GLint dy = (float)fabs((float) yEnd - y0);
GLint p = 2 * dy - dx;
GLint twoDy = 2 * dy;
GLint twoDyMinusDx = 2 * (dy - dx);
GLint x,y;
//determine which endpoint to use as start position
if (x0 > xEnd){
x = xEnd;
y = yEnd;
xEnd = x;
} else {
  x = x0;
  y = y0;
  }
  setPixel(x,y);
  while (x   x++;
  if (p<0)
  p += twoDy;
  else {
  y++;
  p += twoDyMinusDx;
  }
  setPixel(x,y);
  }
  }
void drawMyLine1(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glPointSize(4.0);
GLint x0 = 10;
GLint y0 = 10;
GLint xEnd = 50;
GLint yEnd = 50;
lineBres(x0,y0,xEnd, yEnd);
}
void drawMyLine(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glPointSize(4.0);
GLint x0 = 50;
GLint y0 = 50;
GLint xEnd = 10;
GLint yEnd = 0;
lineBres(x0,y0,xEnd, yEnd);
}
int main(int argc, char** argv)
{
//initialize GLUT
glutInit(&argc, argv);
//initialize display mode
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
//set display-window width & height
glutInitWindowSize(400,400);
//set display-window upper-left position
glutInitWindowPosition(0,0);
//create display-window with a title
glutCreateWindow("Digital Differential Analiyzer Algorithm");
//initialize OpenGL
display();
//call graphics to be diplayes on the window
glutDisplayFunc(drawMyLine);
glutDisplayFunc(drawMyLine1);
//display everything and wait
glutMainLoop();
return 0;
}



sumber : Nuri Priyanto

Photobucket

7 Apr 2012

Postes 3 Grafkom dengan inisial nama "R" dan "M"

/* Praktikum 03
* Membuat objek primitif : poligon
*/
#include < windows.h >
#include < stdio.h >
#include < stdlib.h >
#include < string.h >
#include < stdarg.h >
#include < glut.h >

void display(void)
{
GLubyte fly[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60,
0x04, 0x60, 0x06, 0x20, 0x04, 0x30, 0x0C, 0x20,
0x04, 0x18, 0x18, 0x20, 0x04, 0x0C, 0x30, 0x20,
0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xC0, 0x22,
0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22,
0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22,
0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22,
0x66, 0x01, 0x80, 0x66, 0x33, 0x01, 0x80, 0xCC,
0x19, 0x81, 0x81, 0x98, 0x0C, 0xC1, 0x83, 0x30,
0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0,
0x03, 0x31, 0x8c, 0xc0, 0x03, 0x33, 0xcc, 0xc0,
0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30,
0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08,
0x10, 0x63, 0xC6, 0x08, 0x10, 0x30, 0x0c, 0x08,
0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08};
GLubyte halftone[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0,
0xff, 0x00, 0xff, 0xc0, 0xff, 0x00, 0xff, 0xc0,
0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xc0,
0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0,
0xff, 0xc0, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0,
0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xc0,
0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00};

GLubyte m[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0x0c, 0x00, 0xc0, 0xff, 0x0c, 0x00, 0xc0,
0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xc0,
0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xc0};

glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
//glRectf (25.0, 25.0, 125.0, 125.0);
glEnable (GL_POLYGON_STIPPLE);
//glPolygonStipple (fly);
//glRectf (125.0, 25.0, 225.0, 125.0);
glPolygonStipple (halftone);
glRectf (25.0, 25.0, 125.0, 125.0);
//glColor3f (1.0, 0.0, 1.0);
glPolygonStipple (m);
glRectf (225.0, 25.0, 320.0, 120.0);
glDisable (GL_POLYGON_STIPPLE);
glFlush ();
}
void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (350, 150);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop();
return 0;
}

Photobucket

Grafkom Praktikum 3

Hasil runningnya...











 Dan ini codingnya...


/* Praktikum 03
* Membuat objek primitif : poligon
*/
#include < windows.h >
#include < stdio.h >
#include < stdlib.h >
#include < string.h >
#include < stdarg.h >
#include < glut.h >

void display(void)
{
GLubyte fly[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60,
0x04, 0x60, 0x06, 0x20, 0x04, 0x30, 0x0C, 0x20,
0x04, 0x18, 0x18, 0x20, 0x04, 0x0C, 0x30, 0x20,
0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xC0, 0x22,
0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22,
0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22,
0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22,
0x66, 0x01, 0x80, 0x66, 0x33, 0x01, 0x80, 0xCC,
0x19, 0x81, 0x81, 0x98, 0x0C, 0xC1, 0x83, 0x30,
0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0,
0x03, 0x31, 0x8c, 0xc0, 0x03, 0x33, 0xcc, 0xc0,
0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30,
0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08,
0x10, 0x63, 0xC6, 0x08, 0x10, 0x30, 0x0c, 0x08,
0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08};
GLubyte halftone[] = {
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55};

glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glRectf (25.0, 25.0, 125.0, 125.0);
glEnable (GL_POLYGON_STIPPLE);
glPolygonStipple (fly);
glRectf (125.0, 25.0, 225.0, 125.0);
glPolygonStipple (halftone);
glRectf (225.0, 25.0, 325.0, 125.0);
glColor3f (1.0, 1.0, 0.0);
glDisable (GL_POLYGON_STIPPLE);
glFlush ();
}
void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (350, 150);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop();
return 0;
}



Photobucket