Jeff Molofee - NeHe's OpenGL Tutorials
Здесь есть возможность читать онлайн «Jeff Molofee - NeHe's OpenGL Tutorials» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:NeHe's OpenGL Tutorials
- Автор:
- Жанр:
- Год:неизвестен
- ISBN:нет данных
- Рейтинг книги:3 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 60
- 1
- 2
- 3
- 4
- 5
NeHe's OpenGL Tutorials: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «NeHe's OpenGL Tutorials»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
NeHe's OpenGL Tutorials — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «NeHe's OpenGL Tutorials», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
if (star[loop].dist<0.0f) // Is The Star In The Middle Yet
{
star[loop].dist+=5.0f; // Move The Star 5 Units From The Center
star[loop].r=rand()%256; // Give It A New Red Value
star[loop].g=rand()%256; // Give It A New Green Value
star[loop].b=rand()%256; // Give It A New Blue Value
}
}
return TRUE; // Everything Went OK
}
Now we're going to add code to check if any keys are being pressed. Go down to WinMain(). Look for the line SwapBuffers(hDC). We'll add our key checking code right under that line. lines of code.
The lines below check to see if the T key has been pressed. If it has been pressed and it's not being held down the following will happen. If twinkle is FALSE, it will become TRUE. If it was TRUE, it will become FALSE. Once T is pressed tp will become TRUE. This prevents the code from running over and over again if you hold down the T key.
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
if (keys['T'] && !tp) // Is T Being Pressed And Is tp FALSE
{
tp=TRUE; // If So, Make tp TRUE
twinkle=!twinkle; // Make twinkle Equal The Opposite Of What It Is
}
The code below checks to see if you've let go of the T key. If you have, it makes tp=FALSE. Pressing the T key will do nothing unless tp is FALSE, so this section of code is very important.
if (!keys['T']) // Has The T Key Been Released
{
tp=FALSE; // If So, make tp FALSE
}
The rest of the code checks to see if the up arrow, down arrow, page up or page down keys are being pressed.
if (keys[VK_UP]) // Is Up Arrow Being Pressed
{
tilt-=0.5f; // Tilt The Screen Up
}
if (keys[VK_DOWN]) // Is Down Arrow Being Pressed
{
tilt+=0.5f; // Tilt The Screen Down
}
if (keys[VK_PRIOR]) // Is Page Up Being Pressed
{
zoom-=0.2f; // Zoom Out
}
if (keys[VK_NEXT]) // Is Page Down Being Pressed
{
zoom+=0.2f; // Zoom In
}
Like all the previous tutorials, make sure the title at the top of the window is correct.
if (keys[VK_F1]) // Is F1 Being Pressed?
{
keys[VK_F1]=FALSE; // If So Make Key FALSE
KillGLWindow(); // Kill Our Current Window
fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
// Recreate Our OpenGL Window
if (!CreateGLWindow("NeHe's Textures, Lighting & Keyboard Tutorial", 640, 480, 16, fullscreen)) {
return 0; // Quit If Window Was Not Created
}
}
}
}
In this tutorial I have tried to explain in as much detail how to load in a gray scale bitmap image, remove the black space around the image (using blending), add color to the image, and move the image around the screen in 3D. I've also shown you how to create beautiful colors and animation by overlapping a second copy of the bitmap on top of the original bitmap. Once you have a good understanding of everything I've taught you up till now, you should have no problems making 3D demos ofyour own. All the basics have been covered!
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 IrixCode For This Lesson. (Conversion by Lakmal Gunasekara)
* DOWNLOAD JavaCode For This Lesson. (Conversion by Jeff Kirby)
* DOWNLOAD Jedi-SDLCode For This Lesson. (Conversion by Dominique Louis)
* DOWNLOAD LinuxCode For This Lesson. (Conversion by Richard Campbell)
* 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 MASMCode For This Lesson. (Conversion by Nico (Scalp))
* DOWNLOAD Visual C++ / OpenILCode For This Lesson. (Conversion by Denton Woods)
* DOWNLOAD Power BasicCode For This Lesson. (Conversion by Angus Law)
* DOWNLOAD SolarisCode For This Lesson. (Conversion by Lakmal Gunasekara)
* DOWNLOAD Visual BasicCode For This Lesson. (Conversion by Peter De Tagyos)
* DOWNLOAD Visual FortranCode For This Lesson. (Conversion by Jean-Philippe Perois)
Lesson 10
This tutorial was created by Lionel Brits (ßetelgeuse). This lesson only explains the sections of code that have been added. By adding just the lines below, the program will not run. If you're interested to know where each of the lines of code below go, download the source code, and follow through it, as you read the tutorial.
Welcome to the infamous Tutorial 10. By now you have a spinning cube or a couple of stars, and you have the basic feel for 3D programming. But wait! Don't run off and start to code Quake IV just yet. Spinning cubes just aren't going to make cool deathmatch opponents :-) These days you need a large, complicated and dynamic 3D world with 6 degrees of freedom and fancy effects like mirrors, portals, warping and of course, high framerates. This tutorial explains the basic "structure" of a 3D world, and also how to move around in it.
While it is perfectly alright to code a 3D environment as a long series of numbers, it becomes increasingly hard as the complexity of the environment goes up. For this reason, we must catagorize our data into a more workable fashion. At the top of our list is the sector. Each 3D world is basically a collection of sectors. A sector can be a room, a cube, or any enclosed volume.
typedef struct tagSECTOR // Build Our Sector Structure
{
int numtriangles; // Number Of Triangles In Sector
TRIANGLE* triangle; // Pointer To Array Of Triangles
} SECTOR; // Call It SECTOR
A sector holds a series of polygons, so the next catagory will be the triangle (we will stick to triangles for now, as they are alot easier to code.)
typedef struct tagTRIANGLE // Build Our Triangle Structure
{
VERTEX vertex[3]; // Array Of Three Vertices
} TRIANGLE; // Call It TRIANGLE
The triangle is basically a polygon made up of vertices (plural of vertex), which brings us to our last catagory. The vertex holds the real data that OpenGL is interested in. We define each point on the triangle with it's position in 3D space (x, y, z) as well as it's texture coordinates (u, v).
typedef struct tagVERTEX // Build Our Vertex Structure
{
float x, y, z; // 3D Coordinates
float u, v; // Texture Coordinates
} VERTEX; // Call It VERTEX
Storing our world data inside our program makes our program quite static and boring. Loading worlds from disk, however, gives us much more flexibility as we can test different worlds without having to recompile our program. Another advantage is that the user can interchange worlds and modify them without having to know the in's and out's of our program. The type of data file we are going to be using will be text. This makes for easy editing, and less code. We will leave binary files for a later date.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «NeHe's OpenGL Tutorials»
Представляем Вашему вниманию похожие книги на «NeHe's OpenGL Tutorials» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «NeHe's OpenGL Tutorials» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.