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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать

/* LAST PASS: Do The Logos! */

doLogo();

return true; // Keep Going

}

Finally, a function to render the cube without bump mapping, so that you can see what difference this makes!

bool doMeshNoBumps(void) {

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

glLoadIdentity(); // Reset The View

glTranslatef(0.0f,0.0f,z);

glRotatef(xrot,1.0f,0.0f,0.0f);

glRotatef(yrot,0.0f,1.0f,0.0f);

if (useMultitexture) {

glActiveTextureARB(GL_TEXTURE1_ARB);

glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE0_ARB);

}

glDisable(GL_BLEND);

glBindTexture(GL_TEXTURE_2D,texture[filter]);

glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR);

glEnable(GL_LIGHTING);

doCube();

xrot+=xspeed;

yrot+=yspeed;

if (xrot>360.0f) xrot-=360.0f;

if (xrot<0.0f) xrot+=360.0f;

if (yrot>360.0f) yrot-=360.0f;

if (yrot<0.0f) yrot+=360.0f;

/* LAST PASS: Do The Logos! */

doLogo();

return true; // Keep Going

}

All the drawGLScene() function has to do is to determine which doMesh-function to call:

bool DrawGLScene(GLvoid) // Here's Where We Do All The Drawing {

if (bumps) {

if (useMultitexture && maxTexelUnits>1) return doMesh2TexelUnits();

else return doMesh1TexelUnits();

} else return doMeshNoBumps();

}

Kills the GLWindow, not modified (thus omitted):

GLvoid KillGLWindow(GLvoid) // Properly Kill The Window

>…<

Creates the GLWindow, not modified (thus omitted):

BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)

>…<

Windows main-loop, not modified (thus omitted):

LRESULT CALLBACK WndProc(HWND hWnd, // Handle For This Window

UINT uMsg, // Message For This Window

WPARAM wParam, // Additional Message Information

LPARAM lParam) // Additional Message Information

>…<

Windows main-function, added some keys:

• E: Toggle Emboss / Bumpmapped Mode

• M: Toggle Multitexturing

• B: Toggle Bumpmapping. This Is Mutually Exclusive With Emboss Mode

• F: Toggle Filters. You'll See Directly That GL_NEAREST Isn't For Bumpmapping

• CURSOR-KEYS: Rotate The Cube

int WINAPI WinMain(HINSTANCE hInstance, // Instance

HINSTANCE hPrevInstance, // Previous Instance

LPSTR lpCmdLine, // Command Line Parameters

int nCmdShow) // Window Show State {

>…<

if (keys['E']) {

keys['E']=false;

emboss=!emboss;

}

if (keys['M']) {

keys['M']=false;

useMultitexture=((!useMultitexture) && multitextureSupported);

}

if (keys['B']) {

keys['B']=false;

bumps=!bumps;

}

if (keys['F']) {

keys['F']=false;

filter++;

filter%=3;

}

if (keys[VK_PRIOR]) {

z-=0.02f;

}

if (keys[VK_NEXT]) {

z+=0.02f;

}

if (keys[VK_UP]) {

xspeed-=0.01f;

}

if (keys[VK_DOWN]) {

xspeed+=0.01f;

}

if (keys[VK_RIGHT]) {

yspeed+=0.01f;

}

if (keys[VK_LEFT]) {

yspeed-=0.01f;

}

}

}

}

// Shutdown

KillGLWindow(); // Kill The Window

return (msg.wParam); // Exit The Program

}

Now that you managed this tutorial some words about generating textures and bumpmapped objects before you start to program mighty games and wonder why bumpomapping isn't that fast or doesn't look that good:

• You shouldn't use textures of 256×256 as done in this lesson. This slows things down a lot. Only do so if demonstrating visual capabilities (like in tutorials).

• A bumpmapped cube is not usual. A rotated cube far less. The reason for this is the viewing angle: The steeper it gets, the more visual distortion due to filtering you get. Nearly all multipass algorithms are very affected by this. To avoid the need for high-resolution textures, reduce the minimum viewing angle to a sensible value or reduce the bandwidth of viewing angles and pre-filter you texture to perfectly fit that bandwidth.

• You should first have the colored-texture. The bumpmap can be often derived from it using an average paint-program and converting it to grey-scale.

• The bumpmap should be "sharper" and higher in contrast than the color-texture. This is usually done by applying a "sharpening filter" to the texture and might look strange at first, but believe me: you can sharpen it A LOT in order to get first class visual appearance.

• The bumpmap should be centered around 50%-grey (RGB=127,127,127), since this means "no bump at all", brighter values represent ing bumps and lower "scratches". This can be achieved using "histogram" functions in some paint-programs.

• The bumpmap can be one fourth in size of the color-texture without "killing" visual appearance, though you'll definitely see the difference. Now you should at least have a basic understanding of the issued covered in this tutorial. I hope you have enjoyed reading it.

If you have questions and / or suggestions regarding this lesson, you can just mail me, since I have not yet a web page.

This is my current project and will follow soon.

Thanks must go to:

• Michael I. Gold for his Bump Mapping Documentation

• Diego Tártara for his example code

• NVidia for putting great examples on the WWW

• And last but not least to NeHe who helped me learn a lot about OpenGL.

Jens Schneider Jeff Molofee (NeHe)

* DOWNLOAD Visual C++Code For This Lesson.

* DOWNLOAD Borland C++ Builder 5.0Code For This Lesson. (Conversion by Michael Friedl)

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

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

* DOWNLOAD LinuxCode For This Lesson. (Conversion by Luca Rizzuti)

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

* DOWNLOAD Mac OSCode For This Lesson. (Conversion by Morgan Aldridge)

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

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

Lesson 23

Sphere Environment Mapping is a quick way to add a reflection to a metallic or reflective object in your scene. Although it is not as accurate as real life or as a Cube Environment Map, it is a whole lot faster! We'll be using the code from lesson eighteen (Quadrics) for the base of this tutorial. Also we're not using any of the same texture maps, we're going to use one sphere map, and one background image.

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

Интервал:

Закладка:

Сделать

Похожие книги на «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