• 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.

cHimura

Members
  • Content count

    30
  • Joined

  • Last visited

Community Reputation

133 Neutral

About cHimura

  • Rank
    Member
  1. Check this tutorial: http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html
  2. Hi,   It uses ID3DX11EffectTechnique
  3. Hi, I want to implement SSAO technique therefore I need to render with multipass. In the Frank D. Luna's book there is an example but he uses the deprecated d3dx library. I've searched on Internet but I didn't find anything. Has someone an example, tutorial, etc., about multipass with Direct3D 11?? Thanks, Regards
  4. Hi,   Thank you for your response.   Yes, I read the guide of migration but it says anything about the textures.   I found the error. I sent the nColor variable instead textureFormat i tne glTexImage2D function and now works well.   Regards
  5. Hi everybody, I'm migrating my engine to SDL2 + OpenGL. Originally, my engine worked with SDL 1.2 + OpenGL. Now, I have problems with the textures, the engine doesn't render the textures. Only see a black square. This is the code to load the image and convert to OpenGL texture: bool LoadTexture(GLuint* texture, string fileName, GLuint& width, GLuint& height) { SDL_Surface *surface = IMG_Load(fileName.c_str()); // this surface will tell us the details of the image GLint nColors; GLenum textureFormat; if(surface){ // Check that the image’s width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { cout << "Warning: image.bmp’s width is not a power of 2\n" << endl; } // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { cout << "Warning: image.bmp’s height is not a power of 2\n" << endl; } //get number of channels in the SDL surface nColors = surface->format->BytesPerPixel; //contains an alpha channel if(nColors == 4) { if(surface->format->Rmask==0x000000ff) textureFormat = GL_RGBA; else textureFormat = GL_BGRA; } else if(nColors == 3) //no alpha channel { if(surface->format->Rmask==0x000000ff) textureFormat = GL_RGB; else textureFormat = GL_BGR; } else { cout << "warning: the image is not truecolor…this will break " << endl; } // Have OpenGL generate a texture object handle for us glGenTextures(1, texture); // Bind the texture object glBindTexture(GL_TEXTURE_2D, *texture); // Set the texture’s stretching properties glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D( GL_TEXTURE_2D, 0, nColors, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surface->pixels); width = surface->w; height = surface->h; } else { cout << "LoadTexture:: Could not load " << fileName.c_str() << ": " << SDL_GetError() << endl; return false; //SDL_Quit(); } // Free the SDL_Surface only if it was successfully created if(surface) { SDL_FreeSurface(surface); } return true; } This is the Vertex Shader attribute vec4 a_position; attribute vec2 a_texCoord; varying vec2 v_texCoord; void main() { gl_Position = a_position; v_texCoord = a_texCoord; } This is the Fragment Shader precision mediump float; varying vec2 v_texCoord; uniform sampler2D s_texture; void main() { gl_FragColor = texture2D( s_texture, v_texCoord ); } And the function to render void SquareTextureDemo::Render(){ glClear(GL_COLOR_BUFFER_BIT); glClearColor(1.0f, 0.0f, 0.0f, 1.0f); glBindVertexArray(vao); glUseProgram(shaderProgram); glBindBuffer(GL_ARRAY_BUFFER, m_geometryBuffer); glVertexAttribPointer(att_position, 3, GL_FLOAT, GL_FALSE, sizeof(PositionTextured), (void*)0); glEnableVertexAttribArray(att_position); glVertexAttribPointer(att_texCoord, 2, GL_FLOAT, GL_FALSE, sizeof(PositionTextured), (void*)12); glEnableVertexAttribArray(att_texCoord); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tex); glUniform1i(uni_samplerTex, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndices); glDrawElements(GL_TRIANGLES, (6 * sizeof(GLubyte))/sizeof(GLubyte), GL_UNSIGNED_BYTE, (void*)0); glBindVertexArray(0); OPENGLRENDERER->SwapGLBuffers(); } I don't know what is wrong, with SDL 1.2 + OpenGL works well but now.   Someone can help me?? Regards
  6. Hi,   How can I create different structs with only one function according to one parameter??   I have the next example #define POSCOL 1 #define POSTEX 2 typedef struct PosCol { XMLFLOAT3 pos; XMLFLOAT4 col; }PosCol; typedef struct PosTex { XMLFLOAT3 pos; XMLFLOAT2 tex; }PosTex; void CreateShape(void** ppVerts, int type) { if(type == POSCOL) { *ppVerts = new PosCol[8]; (*ppVerts)[0] = //object type PosCol. ERROR! "expression must be a pointer to a complete object type" (*ppVerts)[1] = //object type PosCol. ERROR! "expression must be a pointer to a complete object type" } if(type == POSTEX) { *ppVerts = new PosTex[8]; (*ppVerts)[0] = //object type PosTex. ERROR! "expression must be a pointer to a complete object type" (*ppVerts)[1] = //object type PosTex. ERROR! "expression must be a pointer to a complete object type" } } That is the idea.   Someone can help me??   Thanks Cesar  
  7. Perfect!   Thanks for your replies. Regards.
  8. Hi,   I created the Orthogonal Projection with this matrix: 2.0f/(right-left)             0                            0                -((right+left)/(right-left))        0                2.0f/(top-bottom)             0                -((top+bottom)/(top-bottom))        0                     0                    -2.0f/(zf-zn)          -((zf+zn)/(zf-zn))        0                      0                            0                          1 I call the function on this way: OrthoProjection(&projection, 0, width, height, 0, -1.0f, 1.0f); And I want to invert the y-axis.   I'm looking for another solution because I don't want to multiply the projection matrix by scale matrix (1.0f, -1.0f, 1.0f)   How can I do it???   Thanks advance. Regards.  
  9. Hi everybody, What is the correct order to multiply matrices in 2D space?? When I multiply: m = projection * translate * scale; And finally in the vertex shader gl_Position = m * pos; Works perfectly. But when I multiply: m = projection * scale * translate; And in the vertex shader: gl_Position = m * pos; Nothing is draw in the screen. In this case scale is a matrix to invert the y axis and translate is a matrix to move a square on the screen. Thanks advance. Regards.
  10. Hi,   I want draw a cube with OpenGL ES 2.0 but I think that I have a problem with the depth buffer.   My cube looks that:   My setup buffers is   glGenFramebuffers(1, &defaultFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); glGenRenderbuffers(1, &colorRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer]; glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth); glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer); glViewport(0, 0, framebufferWidth, framebufferHeight); glGenRenderbuffers(1, &depthRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, framebufferWidth, framebufferHeight); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));   Can I help me??   Thanks!
  11. Hi,   I solved the problem! :)   I had the view matrix wrong! The components of the last vector was positive and the correct values are negative.   And the correct Perspective Matrix for the OpenGL is this: pOut->m[0][0] = xScale; pOut->m[0][1] = 0.0f; pOut->m[0][2] = 0.0f; pOut->m[0][3] = 0.0f; pOut->m[1][0] = 0.0f; pOut->m[1][1] = yScale; pOut->m[1][2] = 0.0f; pOut->m[1][3] = 0.0f; pOut->m[2][0] = 0.0f; pOut->m[2][1] = 0.0f; pOut->m[2][2] = (zf+zn)/(zn-zf); pOut->m[2][3] = -1.0f; pOut->m[3][0] = 0.0f; pOut->m[3][1] = 0.0f; pOut->m[3][2] = 2*zf*zn/(zn-zf); pOut->m[3][3] = 0.0f;   Thanks everyone!!
  12. Hi, Thanks for your answer everyone. I checked a lot matrices but anything works for me. In this page http://maniacdev.com/2009/05/opengl-gluperspective-function-in-iphone-opengl-es/ the perspective matrix is different to the other http://www.songho.ca/opengl/gl_matrix.html I don't understand why :( Anyway I'll check that with more detail. Thanks!!
  13. Thank you for your answer. I'll check that
  14. Hi,   I'm programming an app for iOS with OpenGL ES 2.0 but the application it isn't draw anything   I did my own math library for matrix and vector's operations and works good.   I compute the View Matrix like DirectX in Right Hand System MATRIX* ComputeViewMatrixRH(MATRIX *pOut, const VECTOR3 *pEye, const VECTOR3 *pLookAt, const VECTOR3 *pUp) { VECTOR3 zAxis = *pEye - *pLookAt; Vector3Normalize(&zAxis, &zAxis); VECTOR3 xAxis; Vector3Cross(&xAxis, pUp, &zAxis); Vector3Normalize(&xAxis, &xAxis); VECTOR3 yAxis; Vector3Cross(&yAxis, &zAxis, &xAxis); pOut->m[0][0] = xAxis.x; pOut->m[0][1] = yAxis.x; pOut->m[0][2] = zAxis.x; pOut->m[0][3] = 0.0f; pOut->m[1][0] = xAxis.y; pOut->m[1][1] = yAxis.y; pOut->m[1][2] = zAxis.y; pOut->m[1][3] = 0.0f; pOut->m[2][0] = xAxis.z; pOut->m[2][1] = yAxis.z; pOut->m[2][2] = zAxis.z; pOut->m[2][3] = 0.0f; pOut->m[3][0] = Vector3Dot(&xAxis, pEye); pOut->m[3][1] = Vector3Dot(&yAxis, pEye); pOut->m[3][2] = Vector3Dot(&zAxis, pEye); pOut->m[3][3] = 1.0f; return pOut; }   The perspective Matrix I compute like DirectX in Right Hand System MATRIX* ComputeProjectionMatrixRH(MATRIX* pOut, float fovY, float aspectRatio, float zn, float zf) { float yScale = 1/tan(fovY/2); float xScale = yScale / aspectRatio; pOut->m[0][0] = xScale; pOut->m[0][1] = 0.0f; pOut->m[0][2] = 0.0f; pOut->m[0][3] = 0.0f; pOut->m[1][0] = 0.0f; pOut->m[1][1] = yScale; pOut->m[1][2] = 0.0f; pOut->m[1][3] = 0.0f; pOut->m[2][0] = 0.0f; pOut->m[2][1] = 0.0f; pOut->m[2][2] = zf/(zn-zf); pOut->m[2][3] = -1.0f; pOut->m[3][0] = 0.0f; pOut->m[3][1] = 0.0f; pOut->m[3][2] = zn*zf/(zn-zf);pOut->m[3][3] = 0.0f; return pOut; }   Now I'm confused with that because some books and pages in Internet show the projection matrix different. I tested all matrix but anything works.   For example other perspective projection matrix for right hand system is this: 1/tan(alpha/2)*aspect, 0 , 0 , 0 0 , 1/tan(alpha/2), 0 , 0 0 , 0 ,(f+n)/(f-n) , 1 0 , 0 , 2*f*n/(n-f), 0   What's the correct matrix?? Why many matrices for perspective projection???   Thanks!
  15. Hi,   What's is the best practice for values return in a function in C/C++ for Game Engines??     In C/C++ I can return one value with the sentence return. Texture = LoadTexture(path);   or I can return the value on second via LoadTexure(path, &Texture);   In both examples the variable Texture is get by the function LoadTexture.   What's is the better??   Thanks