• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

RippeR37

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

102 Neutral

About RippeR37

  • Rank
    Newbie
  1. But then i guess u mean that every mesh has its own VBO, right?     I plan for it to be outdoor top-down shooter. Something similiar to Left 4 Dead, but top-down, now for PC and maybe in the future for Android(/iOS). Test pic (a lot to do yet): http://i.stack.imgur.com/XC0ga.png S(it had some debugging on so actually rendering time is not even half now) I thought about making group of objects but it doesnt help me too much, if i put - in example - all trees in one VBO...     I guess i'll have to update my shadow-map generation so that i'm not creating new texture every frame (for each light) but use same texture and just update it... Luckily its only couple lines... In the end i still dont know how should i keep it. Group it by position in bigger VBOs and use only 2-4 VBOs per frame looks best, right? But the question is - should i keep it in VRAM or RAM and just send it if i need it? 2nd option would allow me to create very big maps since it holds very little data in vram (and ram is usally much bigger), but seems slower... Btw. as i asked before - how slow is binding VAOs, binding VBOs, binding Texture, drawing 100 triangles, drawing 100k triangles, drawing 500k triangles, turning of depth test, something else that could be important here too, etc. ? I'd like to know what should i avoid and how hard should i optimize things to use as few as possible. 
  2. Hey, im working on engine for future game and i stumbled on a problem. I'm not sure how to efficiently manage (mostly store and send to GPU) data of my level geometry. Game will be with Top-Down camera (3D), so visibile area will be reduced, also most of objects will be pretty low-poly since nobody needs extra sharp(/smooth) models if u barely can see some details on it. ;) Problem is that i'm not sure how to store it, (update if needed* - though geometry is static, just what is visible) and send to GPU. I've come up with some ideas: 1. Most basic - load everything right in one VBO (as models are very low-poly it won't have too much data as you might think?). I think that though vertex shadders will work on every vertex, fragment shaders will work only on visible fragments and "discard" others automatic, right? + simple to write + dont have to bind multiple VAOs/VBOs/textures every frame + don't have to send new data every frame to GPU (using CPU time) and compute it! - lot of data is on VBO (though size won't change during game) and will go through Vertex Shader (i think not by F.S. - right?) - it seem's not so optimized? - everything must be in one texture atlas which limits possibilities 2. Load every distinct object at startup of level, and then every frame create new VBO with new mesh, that would be made from objects that are currently visible at scene (modified with transformation matrix so that it all works ok). + it sounds as its an optimization ;p (but after some thought i'm not so sure) + i manage what i send to draw, so i could do some work (like LOD, though not in that kind of game, becouse all models are usally at same distance from camera...) so it's not actually "pro" per se... + i bind one VAO/VBO after creating that whole scene's mesh and dont change it for frame. + only visible vertexes (objects, somevertex might be little out of course) are sent to GPU - loooooot of work on CPU, which may result in: GPU waits for CPU data ..... CPU waits for rendering by GPU ... and again GPU waits... - looks much more complicated to build efficiently (at least as much as can) - everything visible must be in one texture atlas... 3. Split level on smaller areas like 2D-tiles, each tile contains every object's data that is (at least partial) in this tile. Just not too small tiles, so that per visible scene there would be 3x3 or 4x4 tiles max. (or even 2x2?). + sound pretty fast (only needed data, not many VAO/VBO binds per frame, VAO/VBO would be already set-up at loading-time so no computing time needed per frame, only draw call). + somehow more flexible with textures, becouse i need current texture only for small tile which can be only couple meshes. - seems hard to code it efficient, some problems (look below) - some meshe's that would be on more than one tile would have to be doubled or splitted (not easy job i guess to do it right and fast! doubled seems better somehow) - lot of pre-processing so as long as #1 pre-processing or even longer. 4. Render each object separate. If it's visible multiple times, render it using some kind of mechanism to do it efficiently like instancing (or something else? suggestons? i dont know instancing yet, but i heard of it). + normally it may be common way to render scenes (when meshes have many triangles its ok, becouse switching vbo doesnt cost so much then) + easiest to implement + easy to manage scene + easy to create a scene (just add description of mesh - pos/rotate/scale and which object it is just to add it). + i could create VAOs/VBOs earlier so no computing time needed on CPU side every frame + only visible models would be rendered - lot of switches between every objects (maybe not that much, but when meshes are low-poly, i guess switching would take long time compared to rendering) - it doesn't seems too optimized. As i said, mostly i'd like to balance between complexity and performance, since i'm not working on some top-level, AAA project, just smaller project that may be very playable, may not ;) PS. Could someone write in some order or with "weights" how much OpenGL actions cost (about)? Like: single draw call, bind VBO, bind VAO, bind texture, etc... so i'd knew what to watch for :)
  3. Hey, I bought new book so i could learn OpenGL more (i've currently read some small book about it for really begginers) called OpenGL Superbible 5th edition, i downloaded source for chapters from net and i tried to build them with no succes. I have found some usefull advices [url="http://stackoverflow.com/questions/5608520/opengl-superbible-5th-edition-set-up-problems"]here[/url] but after doing all that it is there, it's still not working for me... I've downloaded all the libraries and add them to linker in order: freeglut-2.6.0, GLTools, libglew32.a (i've reimped it), libwinmm, libgdi32, libopengl32 All of them are in format *.a First i had errors like: [code]error: 'GLAPI' does not name a type|[/code] but i add (as told) [code]#define GLAPI extern[/code] So it's gone, but now i have: [code](GLBatch.o):GLBatch.cpp|| undefined reference to `__glewDeleteBuffers'|[/code] And many more (50 to be exact). What to do now? I've spent hours searching for something about that but couldnt anything that could help... Code (from Chapter1 named "Block") looks now like: [code]// Block.cpp // OpenGL SuperBible, Chapter 1 // Demonstrates an assortment of basic 3D concepts // Program by Richard S. Wright Jr. #include <GL/glew.h> #include <GLTools.h> // OpenGL toolkit #include <GLMatrixStack.h> #include <GLFrame.h> #include <GLFrustum.h> #include <GLBatch.h> #include <GLGeometryTransform.h> #define FREEGLUT_STATIC #define GLAPI extern #include <math.h> #ifdef __APPLE__ #include <glut/glut.h> #else #define FREEGLUT_STATIC #include <GL/glut.h> #endif ///////////////////////////////////////////////////////////////////////////////// // An assortment of needed classes GLShaderManager shaderManager; GLMatrixStack modelViewMatrix; GLMatrixStack projectionMatrix; GLFrame cameraFrame; GLFrustum viewFrustum; GLBatch cubeBatch; GLBatch floorBatch; GLBatch topBlock; GLBatch frontBlock; GLBatch leftBlock; GLGeometryTransform transformPipeline; M3DMatrix44f shadowMatrix; // Keep track of effects step int nStep = 0; // Lighting data GLfloat lightAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat lightDiffuse[] = { 0.7f, 0.7f, 0.7f, 1.0f }; GLfloat lightSpecular[] = { 0.9f, 0.9f, 0.9f }; GLfloat vLightPos[] = { -8.0f, 20.0f, 100.0f, 1.0f }; GLuint textures[4]; /////////////////////////////////////////////////////////////////////////////// // Make a cube out of a batch of triangles. Texture coordinates and normals // are also provided. void MakeCube(GLBatch& cubeBatch) { cubeBatch.Begin(GL_TRIANGLES, 36, 1); ///////////////////////////////////////////// // Top of cube cubeBatch.Normal3f(0.0f, 1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f); //////////////////////////////////////////// // Bottom of cube cubeBatch.Normal3f(0.0f, -1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(0.0f, -1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(0.0f, -1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f); cubeBatch.Normal3f(0.0f, -1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f); cubeBatch.Normal3f(0.0f, -1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(0.0f, -1.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f); /////////////////////////////////////////// // Left side of cube cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(-1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f); // Right side of cube cubeBatch.Normal3f(1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f); cubeBatch.Normal3f(1.0f, 0.0f, 0.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f); // Front and Back // Front cubeBatch.Normal3f(0.0f, 0.0f, 1.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 0.0f, 1.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 0.0f, 1.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 0.0f, 1.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 0.0f, 1.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, 1.0f); cubeBatch.Normal3f(0.0f, 0.0f, 1.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, 1.0f); // Back cubeBatch.Normal3f(0.0f, 0.0f, -1.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 0.0f, -1.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 0.0f); cubeBatch.Vertex3f(-1.0f, -1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 0.0f, -1.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 0.0f, -1.0f); cubeBatch.MultiTexCoord2f(0, 0.0f, 1.0f); cubeBatch.Vertex3f(-1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 0.0f, -1.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 1.0f); cubeBatch.Vertex3f(1.0f, 1.0f, -1.0f); cubeBatch.Normal3f(0.0f, 0.0f, -1.0f); cubeBatch.MultiTexCoord2f(0, 1.0f, 0.0f); cubeBatch.Vertex3f(1.0f, -1.0f, -1.0f); cubeBatch.End(); } ///////////////////////////////////////////////////////////////////////////// // Make the floor, just the verts and texture coordinates, no normals void MakeFloor(GLBatch& floorBatch) { GLfloat x = 5.0f; GLfloat y = -1.0f; floorBatch.Begin(GL_TRIANGLE_FAN, 4, 1); floorBatch.MultiTexCoord2f(0, 0.0f, 0.0f); floorBatch.Vertex3f(-x, y, x); floorBatch.MultiTexCoord2f(0, 1.0f, 0.0f); floorBatch.Vertex3f(x, y, x); floorBatch.MultiTexCoord2f(0, 1.0f, 1.0f); floorBatch.Vertex3f(x, y, -x); floorBatch.MultiTexCoord2f(0, 0.0f, 1.0f); floorBatch.Vertex3f(-x, y, -x); floorBatch.End(); } /////////////////////////////////////////////////////////////////////////////// // This function does any needed initialization on the rendering context. // This is the first opportunity to do any OpenGL related tasks. void SetupRC() { GLbyte *pBytes; GLint nWidth, nHeight, nComponents; GLenum format; shaderManager.InitializeStockShaders(); // Black background glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); glEnable(GL_DEPTH_TEST); glLineWidth(2.5f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix); cameraFrame.MoveForward(-15.0f); cameraFrame.MoveUp(6.0f); cameraFrame.RotateLocalX(float(m3dDegToRad(20.0f))); MakeCube(cubeBatch); MakeFloor(floorBatch); // Make top topBlock.Begin(GL_TRIANGLE_FAN, 4, 1); topBlock.Normal3f(0.0f, 1.0f, 0.0f); topBlock.MultiTexCoord2f(0, 0.0f, 0.0f); topBlock.Vertex3f(-1.0f, 1.0f, 1.0f); topBlock.Normal3f(0.0f, 1.0f, 0.0f); topBlock.MultiTexCoord2f(0, 1.0f, 0.0f); topBlock.Vertex3f(1.0f, 1.0f, 1.0f); topBlock.Normal3f(0.0f, 1.0f, 0.0f); topBlock.MultiTexCoord2f(0, 1.0f, 1.0f); topBlock.Vertex3f(1.0f, 1.0f, -1.0f); topBlock.Normal3f(0.0f, 1.0f, 0.0f); topBlock.MultiTexCoord2f(0, 0.0f, 1.0f); topBlock.Vertex3f(-1.0f, 1.0f, -1.0f); topBlock.End(); // Make Front frontBlock.Begin(GL_TRIANGLE_FAN, 4, 1); frontBlock.Normal3f(0.0f, 0.0f, 1.0f); frontBlock.MultiTexCoord2f(0, 0.0f, 0.0f); frontBlock.Vertex3f(-1.0f, -1.0f, 1.0f); frontBlock.Normal3f(0.0f, 0.0f, 1.0f); frontBlock.MultiTexCoord2f(0, 1.0f, 0.0f); frontBlock.Vertex3f(1.0f, -1.0f, 1.0f); frontBlock.Normal3f(0.0f, 0.0f, 1.0f); frontBlock.MultiTexCoord2f(0, 1.0f, 1.0f); frontBlock.Vertex3f(1.0f, 1.0f, 1.0f); frontBlock.Normal3f(0.0f, 0.0f, 1.0f); frontBlock.MultiTexCoord2f(0, 0.0f, 1.0f); frontBlock.Vertex3f(-1.0f, 1.0f, 1.0f); frontBlock.End(); // Make left leftBlock.Begin(GL_TRIANGLE_FAN, 4, 1); leftBlock.Normal3f(-1.0f, 0.0f, 0.0f); leftBlock.MultiTexCoord2f(0, 0.0f, 0.0f); leftBlock.Vertex3f(-1.0f, -1.0f, -1.0f); leftBlock.Normal3f(-1.0f, 0.0f, 0.0f); leftBlock.MultiTexCoord2f(0, 1.0f, 0.0f); leftBlock.Vertex3f(-1.0f, -1.0f, 1.0f); leftBlock.Normal3f(-1.0f, 0.0f, 0.0f); leftBlock.MultiTexCoord2f(0, 1.0f, 1.0f); leftBlock.Vertex3f(-1.0f, 1.0f, 1.0f); leftBlock.Normal3f(-1.0f, 0.0f, 0.0f); leftBlock.MultiTexCoord2f(0, 0.0f, 1.0f); leftBlock.Vertex3f(-1.0f, 1.0f, -1.0f); leftBlock.End(); // Create shadow projection matrix GLfloat floorPlane[] = { 0.0f, 1.0f, 0.0f, 1.0f}; m3dMakePlanarShadowMatrix(shadowMatrix, floorPlane, vLightPos); // Load up four textures glGenTextures(4, textures); // Wood floor pBytes = gltReadTGABits("floor.tga", &nWidth, &nHeight, &nComponents, &format); glBindTexture(GL_TEXTURE_2D, textures[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0, format, GL_UNSIGNED_BYTE, pBytes); free(pBytes); // One of the block faces pBytes = gltReadTGABits("Block4.tga", &nWidth, &nHeight, &nComponents, &format); glBindTexture(GL_TEXTURE_2D, textures[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0, format, GL_UNSIGNED_BYTE, pBytes); free(pBytes); // Another block face pBytes = gltReadTGABits("block5.tga", &nWidth, &nHeight, &nComponents, &format); glBindTexture(GL_TEXTURE_2D, textures[2]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0, format, GL_UNSIGNED_BYTE, pBytes); free(pBytes); // Yet another block face pBytes = gltReadTGABits("block6.tga", &nWidth, &nHeight, &nComponents, &format); glBindTexture(GL_TEXTURE_2D, textures[3]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D,0,nComponents,nWidth, nHeight, 0, format, GL_UNSIGNED_BYTE, pBytes); free(pBytes); } /////////////////////////////////////////////////////////////////////////////// // Render the block void RenderBlock(void) { GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f}; GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f }; switch(nStep) { // Wire frame case 0: glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDisable(GL_CULL_FACE); // Draw the cube cubeBatch.Draw(); break; // Wire frame, but not the back side... we also want the block to be in the stencil buffer case 1: shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed); // Draw solid block in stencil buffer // Back face culling prevents the back sides from showing through // The stencil pattern is used to mask when we draw the floor under it // to keep it from showing through. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_NEVER, 0, 0); glStencilOp(GL_INCR, GL_INCR, GL_INCR); cubeBatch.Draw(); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glDisable(GL_STENCIL_TEST); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Draw the front side cube cubeBatch.Draw(); break; // Solid case 2: shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed); // Draw the cube cubeBatch.Draw(); break; // Lit case 3: shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), projectionMatrix.GetMatrix(), vLightPos, vRed); // Draw the cube cubeBatch.Draw(); break; // Textured & Lit case 4: case 5: default: glBindTexture(GL_TEXTURE_2D, textures[2]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), projectionMatrix.GetMatrix(), vLightPos, vWhite, 0); glBindTexture(GL_TEXTURE_2D, textures[1]); topBlock.Draw(); glBindTexture(GL_TEXTURE_2D, textures[2]); frontBlock.Draw(); glBindTexture(GL_TEXTURE_2D, textures[3]); leftBlock.Draw(); break; } // Put everything back glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); glDisable(GL_STENCIL_TEST); } /////////////////////////////////////////////////////////////////////////////// // Render the floor void RenderFloor(void) { GLfloat vBrown [] = { 0.55f, 0.292f, 0.09f, 1.0f}; GLfloat vFloor[] = { 1.0f, 1.0f, 1.0f, 0.6f }; switch(nStep) { // Wire frame case 0: glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDisable(GL_CULL_FACE); break; // Wire frame, but not the back side.. and only where stencil == 0 case 1: glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_EQUAL, 0, 0xff); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); break; // Solid case 2: case 3: shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown); break; // Textured case 4: case 5: default: glBindTexture(GL_TEXTURE_2D, textures[0]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloor, 0); break; } // Draw the floor floorBatch.Draw(); // Put everything back glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); glDisable(GL_STENCIL_TEST); } /////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); // Reflection step... draw cube upside down, the floor // blended on top of it if(nStep == 5) { glDisable(GL_CULL_FACE); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); modelViewMatrix.Translate(0.0f, 2.0f, 0.0f); modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f); RenderBlock(); modelViewMatrix.PopMatrix(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderFloor(); glDisable(GL_BLEND); } modelViewMatrix.PushMatrix(); // Draw normally modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f); RenderBlock(); modelViewMatrix.PopMatrix(); // If not the reflection pass, draw floor last if(nStep != 5) RenderFloor(); modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); } /////////////////////////////////////////////////////////////////////////////// // A normal ASCII key has been pressed. // In this case, advance the scene when the space bar is pressed void KeyPressFunc(unsigned char key, int x, int y) { if(key == 32) { nStep++; if(nStep > 5) nStep = 0; } // Refresh the Window glutPostRedisplay(); } /////////////////////////////////////////////////////////////////////////////// // Window has changed size, or has just been created. In either case, we need // to use the window dimensions to set the viewport and the projection matrix. void ChangeSize(int w, int h) { glViewport(0, 0, w, h); viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 500.0f); projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix()); modelViewMatrix.LoadIdentity(); } /////////////////////////////////////////////////////////////////////////////// // Main entry point for GLUT based programs int main(int argc, char* argv[]) { gltSetWorkingDirectory(argv[0]); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize(800, 600); glutCreateWindow("3D Effects Demo"); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); return 1; } glutReshapeFunc(ChangeSize); glutKeyboardFunc(KeyPressFunc); glutDisplayFunc(RenderScene); SetupRC(); glutMainLoop(); glDeleteTextures(4,textures); return 0; } [/code] Thanks in advance, hope u could help me. //Edit: also, i have GLEW from net (downloaded .lib version and converted it to *.a), and not from own build from GLTools as told, becouse when i tried to build it from glew.c i've got many errors like this: [code]glew.c:10652:16: warning: 'const GLubyte* glewGetErrorString(GLenum)' redeclared without dllimport attribute: previous dllimport ignored glew.c: In function 'const GLubyte* glewGetString(GLenum)': glew.c:10666:16: warning: 'const GLubyte* glewGetString(GLenum)' redeclared with out dllimport attribute: previous dllimport ignored glew.c: At global scope: glew.c:10682:11: warning: 'glewExperimental' redeclared without dllimport attrib ute after being referenced with dll linkage glew.c: In function 'GLenum glewInit()': glew.c:10692:8: warning: 'GLenum glewInit()' redeclared without dllimport attrib ute: previous dllimport ignored glew.c: In function 'GLboolean glewIsSupported(const char*)': glew.c:10709:11: warning: 'GLboolean glewIsSupported(const char*)' redeclared wi thout dllimport attribute: previous dllimport ignored glew.c: In function 'GLboolean wglewIsSupported(const char*)': glew.c:13558:11: warning: 'GLboolean wglewIsSupported(const char*)' redeclared w ithout dllimport attribute: previous dllimport ignored[/code] I've just downloaded it from official glew site and paste (converted) and link to it.