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


  • Content count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About synopfab

  • Rank
  1. Thanks for your proposal, but same result with i or f, a black screen. Here is big part of my class Shape.m, maybe it helps ? This code works and show a texture, but I don't find the way to repeat. [code] //Set the texture image -(void)setTextureImage:(UIImage *)image { NSError *error; texture = [GLKTextureLoader textureWithCGImage:image.CGImage options:nil error:&error]; if (error) { NSLog(@"Error loading texture from image: %@",error); } } // Set the texture coordinates - (GLKVector2 *)textureCoordinates { if (textureCoordinateData == nil) textureCoordinateData = [NSMutableData dataWithLength:sizeof(GLKVector2)*self.numVertices]; return [textureCoordinateData mutableBytes]; } // called on each shape -(void)renderInScene:(P3Scene *)scene { effect = [[GLKBaseEffect alloc] init]; if (useConstantColor) { effect.useConstantColor = YES; effect.constantColor = color; } //set the scene with the projectionMatrix we need effect.transform.projectionMatrix = scene.projectionMatrix; //translate, rotate and then scale modelviewMatrix = GLKMatrix4Multiply(GLKMatrix4MakeTranslation(position.x, position.y, 0), GLKMatrix4MakeRotation(rotation, 0, 0, 1)); modelviewMatrix = GLKMatrix4Multiply(modelviewMatrix, GLKMatrix4MakeScale(scale.x, scale.y, 1)); effect.transform.modelviewMatrix = modelviewMatrix; //set a texture if exists if (texture != nil) { effect.texture2d0.envMode = GLKTextureEnvModeReplace; effect.texture2d0.target = GLKTextureTarget2D; effect.texture2d0.name = texture.name; } [effect prepareToDraw]; [self render]; } //called in the renderInScene method -(void)render { //enable transparency for sprites glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //tells the shader that we are going to use vertex position data. glEnableVertexAttribArray(GLKVertexAttribPosition); glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, 0, self.vertices); //set the color of each vertices if (!useConstantColor) { glEnableVertexAttribArray(GLKVertexAttribColor); glVertexAttribPointer(GLKVertexAttribColor, 4, GL_FLOAT, GL_FALSE, 0, self.vertexColors); } if (texture != nil) { //ALL MY TESTS ARE HERE /*glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture.name); glTexCoordPointer(3, GL_FLOAT, 0, self.textureCoordinates); glDisable(GL_TEXTURE_2D);*/ //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); //glBindTexture( GL_TEXTURE_2D, texture.name ); //glEnable(GL_TEXTURE_2D); glEnableVertexAttribArray(GLKVertexAttribTexCoord0); glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, self.textureCoordinates); //glDisable(GL_TEXTURE_2D); } glDrawArrays(GL_TRIANGLE_FAN, 0, self.numVertices); //is cleanup code that tells the shader that we’re done using vertex position data. glDisableVertexAttribArray(GLKVertexAttribPosition); if (!useConstantColor) glDisableVertexAttribArray(GLKVertexAttribColor); if (texture != nil) glDisableVertexAttribArray(GLKVertexAttribTexCoord0); glDisable(GL_BLEND); } [/code] Is that code helping ? Thank you very much ! [quote name='Caste' timestamp='1320999312' post='4882876'] Ah I just spotted that you're using glTexParameterf which indicates that you will pass a float (hence the f at the end) to the function as a parameter. But the parameter GL_REPEAT is an enum (or an int) and thus you should use glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); [/quote]
  2. Ok, but I think that the error is that I've tried to add properties in openGL to texture loaded in GLKit. To my mind, the texture.name is OK, because I successfully display it to my view. The problem is that when I add the line [color=#AAB2B8][size=2]glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );[/size][/color] [color=#AAB2B8][size=2] [/size][/color] before , between, or after the lines [color=#AAB2B8][size=2][color=#E2E2E2]glEnableVertexAttribArray[/color][color=#B5973B]([/color][color=#660066]GLKVertexAttribTexCoord0[/color][color=#B5973B]);[/color][color=#E2E2E2] glVertexAttribPointer[/color][color=#B5973B]([/color][color=#660066]GLKVertexAttribTexCoord0[/color][color=#B5973B],[/color][color=#E2E2E2] [/color][color=#006666]2[/color][color=#B5973B],[/color][color=#E2E2E2] GL_FLOAT[/color][color=#B5973B],[/color][color=#E2E2E2] GL_FALSE[/color][color=#B5973B],[/color][color=#E2E2E2] [/color][color=#006666]0[/color][color=#B5973B],[/color][color=#E2E2E2] [/color][color=#3B77B5]self[/color][color=#B5973B].[/color][color=#E2E2E2]textureCoordinates[/color][color=#B5973B]);[/color][/size][/color] the view is empty and no texture is loaded. So everything is cool without the glTextParameterf but not repeated, and it is empty with the glTextParameterf. Thanks [quote name='lc_overlord' timestamp='1320924463' post='4882529'] The error your getting is from openGL itself 2011-11-09 20:10:28.614 ********[16309:207] GL ERROR: 0x0500 a quick look trough gl.h states that error 0x0500 is GL_INVALID_ENUM. It could be that texture.name is not a valid enum or the fact that your binding it after glTexParameterf. Alternatively it could be because of quirks in openGL ES, but i don't think so. [/quote]
  3. My code works without those lines, and don't work with those lines : [code] [color=#AAB2B8][font=monospace][size=2][color=#E2E2E2]glEnable[/color][color=#B5973B]([/color][color=#E2E2E2]GL_TEXTURE_2D[/color][color=#B5973B]);[/color][/size][/font][/color] [font=monospace][size=2][color="#e2e2e2"]glTexParameterf[/color][color=#B5973B]([/color][color=#E2E2E2] GL_TEXTURE_2D[/color][color=#B5973B],[/color][color=#E2E2E2] GL_TEXTURE_WRAP_S[/color][color=#B5973B],[/color][color=#E2E2E2] GL_REPEAT [/color][color=#B5973B]);[/color][/size][/font] [font=monospace][size=2][color=#E2E2E2]glBindTexture[/color][color=#B5973B]([/color][color=#E2E2E2] GL_TEXTURE_2D[/color][color=#B5973B],[/color][color=#E2E2E2] texture[/color][color=#B5973B].[/color][color=#E2E2E2]name [/color][color=#B5973B]);[/color][/size][/font] [/code] This is the reason why I think there is a sort of conflict, and maybe a glkit way to repeat a texture, without glTexParameterf ? [quote name='Caste' timestamp='1320908775' post='4882452'] Your problem is not the repeating of the texture, you already do the correct steps for that. Or does the code work if you leave out the glTexParameteri call? I bet it doesn't [/quote]
  4. Hi Caste, and thank you for your reply. [font="monospace"][size="2"][left] [/left][/size][/font][left]Thank you for your link to the docs.[/left][left][font="arial, sans-serif"][size="2"]The fact is that I don't find in the class GLKTextureLoader how to change WRAP_S and WRAP_T to GL_REPEAT.[/size][/font][/left][left][font="arial, sans-serif"][size="2"]It seems like there is a conflict if I use :[/size][/font][/left][left][font="arial, sans-serif"] [/font][/left][left] glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );[/left][left][font="arial, sans-serif"] [/font][/left][left][font="arial, sans-serif"][size="2"]Thanks again,[/size][/font][/left][left][font="arial, sans-serif"][size="2"]Fabrice[/size][/font][/left][left] [/left] [quote name='Caste' timestamp='1320876257' post='4882293'] Well as the error message you posted is already thrown in the 3rd line of code, your texture is not even loaded and will thus not be repeated as well. You should make sure that your texture is loaded correctly (or properly created by hand). So either the file is not found if you load the UIImage from disk, or while using CGContextCreateBitmap you missed something.. If you're sure that the image you pass to your setTextureImage function is valid, you probably should have a look at the [url="http://developer.apple.com/library/ios/#documentation/GLkit/Reference/GLKTextureLoader_ClassRef/Reference/Reference.html"]docs[/url]. Repeating the texture is easy as soon as it loads, setting WRAP_S and WRAP_T to GL_REPEAT as you already did for _S, and then assign texture coordinates that are bigger than 1, so e.g. a rectangle where the texture coordinates range from 0x0 to 2x2 will have the image 4 times on it. [/quote]
  5. Hi everybody, I am using GLKit in order to show textures on my project. The code is like this : [code]-(void)setTextureImage:(UIImage *)image { NSError *error; texture = [GLKTextureLoader textureWithCGImage:image.CGImage options:nil error:&error]; if (error) { NSLog(@"Error loading texture from image: %@",error); } }[/code] [code]effect.texture2d0.envMode = GLKTextureEnvModeReplace; effect.texture2d0.target = GLKTextureTarget2D; effect.texture2d0.name = texture.name;[/code] [code]glEnableVertexAttribArray(GLKVertexAttribTexCoord0); glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, self.textureCoordinates);[/code] Now I want to repeat this texture on a rectangle. Is there any way use GLKit for this behavior ? I've tried to use opengl function in addition to the glkit ones, but it raises errors : [code]glEnable(GL_TEXTURE_2D); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glBindTexture( GL_TEXTURE_2D, texture.name );[/code] [code]2011-11-09 20:10:28.614 ********[16309:207] GL ERROR: 0x0500 2011-11-09 20:10:30.840 ********[16309:207] Error loading texture from image: Error Domain=GLKTextureLoaderErrorDomain Code=8 "The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.)" UserInfo=0x68545c0 {GLKTextureLoaderGLErrorKey=1280, GLKTextureLoaderErrorKey=OpenGL error}[/code] Thank you for your help, Fabrice