Jeff Molofee - NeHe's OpenGL Tutorials

Здесь есть возможность читать онлайн «Jeff Molofee - NeHe's OpenGL Tutorials» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

NeHe's OpenGL Tutorials: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «NeHe's OpenGL Tutorials»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

NeHe's OpenGL Tutorials — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «NeHe's OpenGL Tutorials», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

break; // Done

Our sixth object is created with gluPartialDisc. The object we create using this command will look exactly like the disc we created above, but with the command gluPartialDisk there are two new parameters. The fifth parameter (part1) is the start angle we want to start drawing the disc at. The sixth parameter is the sweep angle. The sweep angle is the distance we travel from the current angle. We'll increase the sweep angle, which causes the disc to be slowly drawn to the screen in a clockwise direction. Once our sweep hits 360 degrees we start to increase the start angle. the makes it appear as if the disc is being erased, then we start all over again!

case 5: // Drawing Object 6

part1+=p1; // Increase Start Angle

part2+=p2; // Increase Sweep Angle

if (part1>359) // 360 Degrees

{

p1=0; // Stop Increasing Start Angle

part1=0; // Set Start Angle To Zero

p2=1; // Start Increasing Sweep Angle

part2=0; // Start Sweep Angle At Zero

}

if (part2>359) // 360 Degrees

{

p1=1; // Start Increasing Start Angle

p2=0; // Stop Increasing Sweep Angle

}

gluPartialDisk(quadratic, 0.5f, 1.5f, 32, 32, part1, part2-part1); // A Disk Like The One Before

break; // Done

};

xrot+=xspeed; // Increase Rotation On X Axis

yrot+=yspeed; // Increase Rotation On Y Axis

return TRUE; // Keep Going

}

In the KillGLWindow() section of code, we need to delete the quadratic to free up system resources. We do this with the command gluDeleteQuadratic.

GLvoid KillGLWindow(GLvoid) // Properly Kill The Window

{

gluDeleteQuadric(quadratic); // Delete Quadratic – Free Resources

Now for the final part, they key input. Just add this where we check the rest of key input.

if (keys[' '] && !sp) // Is Spacebar Being Pressed?

{

sp=TRUE; // If So, Set sp To TRUE

object++; // Cycle Through The Objects

if (object>5) // Is object Greater Than 5?

object=0; // If So, Set To Zero

}

if (!keys[' ']) // Has The Spacebar Been Released?

{

sp=FALSE; // If So, Set sp To FALSE

}

Thats all! Now you can draw quadrics in OpenGL. Some really impressive things can be done with morphing and quadrics. The animated disc is an example of simple morphing.

Everyone if you have time go check out my website, TipTup.Com 2000.

GB Schmick (TipTup) Jeff Molofee (NeHe)

* DOWNLOAD Visual C++Code For This Lesson.

* DOWNLOAD Borland C++Code For This Lesson. (Conversion by Patrick Salmons)

* DOWNLOAD CygwinCode For This Lesson. (Conversion by Stephan Ferraro)

* DOWNLOAD DelphiCode For This Lesson. (Conversion by Marc Aarts)

* DOWNLOAD Game GLUTCode For This Lesson. (Conversion by Milikas Anastasios)

* DOWNLOAD Irix / GLUTCode For This Lesson. (Conversion by Rob Fletcher)

* DOWNLOAD JavaCode For This Lesson. (Conversion by Jeff Kirby)

* DOWNLOAD LinuxCode For This Lesson. (Conversion by Simon Werner)

* DOWNLOAD Linux/GLXCode For This Lesson. (Conversion by Mihael Vrbanec)

* DOWNLOAD Linux/SDLCode For This Lesson. (Conversion by Ti Leggett)

* DOWNLOAD Mac OSCode For This Lesson. (Conversion by Anthony Parker)

* DOWNLOAD Mac OS X/CocoaCode For This Lesson. (Conversion by Bryan Blackburn)

* DOWNLOAD Visual C++ / OpenILCode For This Lesson. (Conversion by Denton Woods)

* DOWNLOAD SDLCode For This Lesson. (Conversion by Ken Rockot)

* DOWNLOAD Visual BasicCode For This Lesson. (Conversion by The Gilb)

Lesson 19

Welcome to Tutorial 19. You've learned alot, and now you want to play. I will introduce one new command in this tutorial… The triangle strip. It's very easy to use, and can help speed up your programs when drawing alot of triangles.

In this tutorial I will teach you how to make a semi-complex Particle Engine. Once you understand how particle engines work, creating effects such as fire, smoke, water fountains and more will be a piece of cake!

I have to warn you however! Until today I had never written a particle engine. I had this idea that the 'famous' particle engine was a very complex piece of code. I've made attempts in the past, but usually gave up after I realized I couldn't control all the points without going crazy.

You might not believe me when I tell you this, but this tutorial was written 100% from scratch. I borrowed no ones ideas, and I had no technical information sitting in front of me. I started thinking about particles, and all of a sudden my head filled with ideas (brain turning on?). Instead of thinking about each particle as a pixel that had to go from point 'A' to point 'B', and do this or that, I decided it would be better to think of each particle as an individual object responding to the environment around it. I gave each particle life, random aging, color, speed, gravitational influence and more.

Soon I had a finished project. I looked up at the clock and realized aliens had come to get me once again. Another 4 hours gone! I remember stopping now and then to drink coffee and blink, but 4 hours… ?

So, although this program in my opinion looks great, and works exactly like I wanted it to, it may not be the proper way to make a particle engine. I don't care personally, as long as it works well, and I can use it in my projects! If you are the type of person that needs to know you're conforming, then spend hours browsing the net looking for information. Just be warned. The few code snippits you do find may appear cryptic :)

This tutorial uses the base code from lesson 1. There is alot of new code however, so I'll rewrite any section of code that contains changes (makes it easier to understand).

Using the code from lesson 1, we'll add 5 new lines of code at the top of our program. The first line (stdio.h) allows us to read data from files. It's the same line we've added to previous tutorials the use texture mapping. The second line defines how many particles were going to create and display on the screen. Define just tells our program that MAX_PARTICLES will equal whatever value we specify. In this case 1000. The third line will be used to toggle 'rainbow mode' off and on. We'll set it to on by default. sp and rp are variables we'll use to prevent the spacebar or return key from rapidly repeating when held down.

#include // Header File For Windows

#include // Header File For Standard Input/Output ( ADD )

#include // Header File For The OpenGL32 Library

#include // Header File For The GLu32 Library

#include // Header File For The GLaux Library

#define MAX_PARTICLES 1000 // Number Of Particles To Create ( NEW )

HDC hDC=NULL; // Private GDI Device Context

HGLRC hRC=NULL; // Permanent Rendering Context

HWND hWnd=NULL; // Holds Our Window Handle

HINSTANCE hInstance; // Holds The Instance Of The Application

bool keys[256]; // Array Used For The Keyboard Routine

bool active=TRUE; // Window Active Flag Set To TRUE By Default

bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default

bool rainbow=true; // Rainbow Mode? ( ADD )

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «NeHe's OpenGL Tutorials»

Представляем Вашему вниманию похожие книги на «NeHe's OpenGL Tutorials» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Jeff Jacobson - Sleep Tight
Jeff Jacobson
Jeff Salyards - Veil of the Deserters
Jeff Salyards
Jeff LaSala - The Darkwood Mask
Jeff LaSala
Jeff Lindsay - Dexter's Final Cut
Jeff Lindsay
libcat.ru: книга без обложки
Неизвестный Автор
libcat.ru: книга без обложки
Неизвестный Автор
libcat.ru: книга без обложки
Неизвестный Автор
libcat.ru: книга без обложки
Неизвестный Автор
Отзывы о книге «NeHe's OpenGL Tutorials»

Обсуждение, отзывы о книге «NeHe's OpenGL Tutorials» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x