OpenGL GL_LINE_STRIP ile dikdörtgen prizma çizmek


GL_LINE_STRIP ile dikdörtgen çizimine örnek bir kodu aşağıda bulabilirsiniz;
Ekran görüntüsü;

Kod;

#include "stdlib.h"
#include "glut.h"
#include "time.h"
#include "math.h"
#include "stdio.h"

GLvoid drawScene(GLvoid);

void main(int argc, char** argv)
{
	int width,height;

	glutInit(&argc,argv);

	width=glutGet(GLUT_SCREEN_WIDTH);
	height=glutGet(GLUT_SCREEN_HEIGHT);

	glutInitWindowPosition(height*0.25,height*0.25);
	glutInitWindowSize(width*.5,height*.5);
	glutInitDisplayMode( GLUT_RGB );
	glutCreateWindow("");

	glMatrixMode(GL_PROJECTION);
	gluPerspective(45,(double)width/height,1,17);
	glMatrixMode(GL_MODELVIEW);

	glTranslatef(0,0,-5);

	glLineWidth(2.0);

	glutDisplayFunc( drawScene );
	glutMainLoop();
}

GLvoid wireBox(GLfloat width,GLfloat height, GLfloat depth)
{
	float x,y,z;

	x=width/2;
	y=height/2;
	z=depth/2;

	glColor3f(0,0,1);

	glBegin(GL_LINE_STRIP);
	  glVertex3f(-x,y,-z);
	  glVertex3f(x,y,-z);
	  glVertex3f(x,-y,-z);
	  glVertex3f(-x,-y,-z);
	  glVertex3f(-x,y,-z);
	  glVertex3f(-x,y,z);
	  glVertex3f(x,y,z);
	  glVertex3f(x,y,-z);
	  glVertex3f(x,y,z);
	  glVertex3f(x,-y,z);
	  glVertex3f(x,-y,-z);
	  glVertex3f(x,-y,z);
	  glVertex3f(-x,-y,z);
	  glVertex3f(-x,-y,-z);
	  glVertex3f(-x,-y,z);
	  glVertex3f(-x,y,z);
	glEnd();

}

GLvoid drawScene()
{
	glClearColor(1,1,1,1);
	glClear(GL_COLOR_BUFFER_BIT);

	wireBox(2.0,1.0,1.0);
	glFlush();
}

Rastgele Yazılar

OpenGL GL_LINE_STRIP ile dikdörtgen prizma çizmek ile Benzer Yazılar:

16 November 2010 Saat : 9:29
  OpenGL

OpenGL GL_LINE_STRIP ile dikdörtgen prizma çizmek Yazısı için Yorum Yapabilirsiniz

 Son Yazılar FriendFeed
reklam
seo kitabı
reklam
reklam

Translate

EnglishFrenchGermanItalianPortugueseRussianSpanishTurkish