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

crim

Members
  • Content count

    13
  • Joined

  • Last visited

Community Reputation

122 Neutral

About crim

  • Rank
    Member
  1. int sdl_interface::load_text ( string output_text ) { TTF_Font* font; if(TTF_Init()) cout << "error load font: " << TTF_GetError() << endl; atexit(TTF_Quit); if(!(font = TTF_OpenFont("data\\fonts\\comic.ttf", 20))) cout << "Error loading font: " << TTF_GetError() << endl; SDL_Surface *initial; SDL_Surface *intermediary; SDL_Rect rect; int w; int h; GLuint texture; SDL_Color color; color.r = 255; color.g = 255; color.b = 255; initial = TTF_RenderText_Blended(font, "TESTING THE TEXT", color); if(initial == NULL) cout << "Error crating text" << TTF_GetError() << endl; intermediary = SDL_CreateRGBSurface(SDL_SWSURFACE, 256, 32, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); if(intermediary == NULL) cout << "Error: Creating surface" << endl; if(SDL_BlitSurface(initial, 0, intermediary, 0) == -1) cout << "Error: Bliting surface" << endl; SDL_UpdateRect( intermediary, 0, 0, 0, 0 ); intermediary = SDL_DisplayFormat(intermediary); SDL_SaveBMP(initial, "blah0.bmp"); SDL_SaveBMP(intermediary, "blah1.bmp"); SDL_FreeSurface( initial ); glEnable(GL_TEXTURE_2D); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, intermediary->pixels ); texture_data tex_temp; tex_temp.filepath = "text"; tex_temp.texture = texture; tex_temp.texture_id = next_texture_store; texture_store.push_back(tex_temp); next_texture_store++; cout << "Added text texture (#" << (next_texture_store - 1) << ")" << endl; /* Clean up */ SDL_FreeSurface(initial); SDL_FreeSurface(intermediary); glDeleteTextures(1, &texture); } sorry about the lack of comments, just messed around with the code to much, anyway, blah0.bmp and blah1.bmp are both perfect images, the texture should print out to the screen on a ortho plane in another class, but doesn't. I tested the plane with other textures stored in memory and they worked but only this algorithum refuses to show anything. What does appear on the plane is the values set for glColor(); If anyone could help with this, i would be grateful. i have looked at other sources on the net but none of them can explain the problem with the code.
  2. O M G it worked, i was reading that twenty minutes before posting that and i didnt try it. Thanks so much. BTW: That line may cause a memory leak "Remember to use a different variable for the returned surface, otherwise you have a memory leak, since the original surface isn't freed." Source: http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fDisplayFormat
  3. int sdl_interface::load_text ( string output_text ) { TTF_Font* font; if(TTF_Init()) cout << "error load font: " << TTF_GetError() << endl; atexit(TTF_Quit); if(!(font = TTF_OpenFont("data\\fonts\\comic.ttf", 20))) cout << "Error loading font: " << TTF_GetError() << endl; SDL_Surface *initial; SDL_Surface *intermediary; SDL_Surface *intermediary2; SDL_Rect rect; SDL_Rect location; int w; int h; GLuint texture; /* Use SDL_TTF to render our text */ location.x = 0; location.y = 0; SDL_Color color; color.r = 128; color.g = 255; color.b = 255; initial = TTF_RenderText_Blended(font, "TESTING THE TEXT", color); if(initial == NULL) cout << "Error crating text" << TTF_GetError() << endl; intermediary2 = SDL_CreateRGBSurface(SDL_SWSURFACE, 256, 32, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); intermediary = SDL_DisplayFormatAlpha(initial); if(intermediary == NULL) cout << "Error: Creating surface" << endl; if(intermediary2 == NULL) cout << "Error: Creating surface2" << endl; if(SDL_BlitSurface(initial, 0, intermediary, 0) == -1) cout << "Error: Bliting surface" << endl; if(SDL_BlitSurface(initial, 0, intermediary2, 0) == -1) cout << "Error: Bliting surface" << endl; SDL_UpdateRect( intermediary2, 0, 0, 0, 0 ); SDL_UpdateRect( intermediary, 0, 0, 0, 0 ); SDL_SaveBMP(initial, "blah0.bmp"); SDL_SaveBMP(intermediary, "blah1.bmp"); SDL_SaveBMP(intermediary2, "blah2.bmp"); Outputs: blah0.bmp and blah1.bmp are perfect, they print 'TESTING THE TEXT' On the other hand blah2.bmp prints a black screen From the above code i came to the conclusion it was something to do with the format of the intermediary2 at creatergbsurface(). If anyone can help, being working on this for yonks.
  4. Tried it, no effect btw with that second question, red and green dont show up at all Edit: also tried intermediary = SDL_CreateRGBSurface(0, 256, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); [Edited by - crim on July 20, 2005 7:40:57 PM]
  5. initial = TTF_RenderText_Blended(font, "TESTING THE TEXT", color); if(initial == NULL) cout << "Error crating text" << TTF_GetError() << endl; intermediary = SDL_CreateRGBSurface(0, 256, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); if(intermediary == NULL) cout << "Error: Creating surface" << endl; if(SDL_BlitSurface(initial, 0, intermediary, 0) == -1) cout << "Error: Bliting surface" << endl; SDL_SaveBMP(initial, "blah0.bmp"); SDL_SaveBMP(intermediary, "blah1.bmp"); blah0.bmp is a perfect picture of the text while blah1.bmp is a black image but it has the right width and height, I think its something to do with the CreateRGBSurface command. Also while im typing, i have a second problem, with my textures, all the white shades have been changed to blue shades. So pure white has been changed to pure blue.
  6. Yeah, i looked at that posted and wrote a comment at the bottom already, im trying the sdl_ttf again to see if i can remember the problem.
  7. ::Sorry for bring topic back up If GL_BGRA is unidentified put this line in #include <GL/glext.h>
  8. There was a reason why but now i cant remember it. Let me think on it. I just noticed i put lersson instead of lesson >_>
  9. Im not really into bitmaps fonts, id rather use the OS method, to get it cross compadible im planning on doing it for windows and linux systems using #ifdef, etc. Double the amount of work but there is more control in the display of the fonts in the long run. Further stuff i did to see if i can find the answer is, get a DC for the current interface using. int sdl_interface::load_text ( string output_text ) { HFONT loading_font; base = glGenLists(96); loading_font = CreateFont( -24, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH, "Courier New"); if(loading_font == NULL) cout &lt;&lt; "CreateFont failed" &lt;&lt; endl; cout &lt;&lt; "Win ERROR: " &lt;&lt; GetLastError() &lt;&lt; endl; SDL_SysWMinfo wmi; HWND current_hwnd; SDL_VERSION( &wmi.version ); SDL_GetWMInfo( &wmi ); current_hwnd = wmi.window; hDC = GetDC(current_hwnd); cout &lt;&lt; "Win ERROR: " &lt;&lt; GetLastError() &lt;&lt; endl; if(hDC == NULL) cout &lt;&lt; "GetDC failed" &lt;&lt; endl; oldfont = (HFONT)SelectObject(hDC, loading_font); // Selects The Font We Want if(oldfont == NULL) cout &lt;&lt; "oldfont failed" &lt;&lt; endl; if(oldfont == HGDI_ERROR) cout &lt;&lt; "oldfont HGDI_ERROR" &lt;&lt; endl; wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32 SelectObject(hDC, oldfont); // Selects The Font We Want DeleteObject(loading_font); } No errors came up on the above code. Copy paste stuff between the lesson13 devc++ example and mine. glTranslatef(0.0f,0.0f,-1.0f); // Move One Unit Into The Screen // Pulsing Colors Based On Text Position glColor3f(.5f,1.0f,.0f); // Position The Text On The Screen glRasterPos2f(-.5f, .0f); glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits ( NEW ) glListBase(base - 32); // Sets The Base Character to 32 ( NEW ) char text[256]; sprintf(text, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glPopAttrib(); cout &lt;&lt; "ERROR:" &lt;&lt; glGetError() &lt;&lt; endl; cout &lt;&lt; "ERROR:" &lt;&lt; SDL_GetError() &lt;&lt; endl; When i put that into the example it worked perfectly and printed aaaaaaaaaaa... on the screen. Maybe its related to the display requirment, should it be on otha or prespective? Which is... int sdl_interface::interface_paste_flip() { glClearColor( bg_colour.red, bg_colour.green, bg_colour.blue, 0 ); //background colour can be customize glClearDepth(1.0f); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //destroy the world... i mean the buffer glLoadIdentity(); /* TODO (#1#): make ortho objects dynamic */ glMatrixMode (GL_PROJECTION ); /* glPushMatrix(); glLoadIdentity(); glOrtho(-1.5, 1.5, -1.5*(GLfloat) display_data.width/(GLfloat) display_data.height, 1.5*(GLfloat) display_data.width/(GLfloat) display_data.height, -10, 10); glPopMatrix(); */ glLoadIdentity(); gluPerspective(45.0, (GLfloat) display_data.width/(GLfloat) display_data.height, 0.0, 60.0); // glRotatef(270.0, 1.0, 0.0, 0.0); glRotatef(cam_info.cam_rotation.x, 1.0, 0.0, 0.0); glRotatef(cam_info.cam_rotation.y, 0.0, 1.0, 0.0); glRotatef(cam_info.cam_rotation.z, 0.0, 0.0, 1.0); glRotatef(turn, 1.0, 0.0, 1.0); // turn = turn + 1.0; // cout &lt;&lt; "t " &lt;&lt; cam_info.cam_translation.x &lt;&lt; ":" &lt;&lt; cam_info.cam_translation.y &lt;&lt; ":" &lt;&lt; cam_info.cam_translation.z &lt;&lt; endl; glTranslatef(cam_info.cam_translation.x, cam_info.cam_translation.y, cam_info.cam_translation.z); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef(0.0f,0.0f,-1.0f); // Move One Unit Into The Screen // Pulsing Colors Based On Text Position glColor3f(.5f,1.0f,.0f); // Position The Text On The Screen glRasterPos2f(-.5f, .0f); glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits ( NEW ) glListBase(base - 32); // Sets The Base Character to 32 ( NEW ) char text[256]; sprintf(text, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glPopAttrib(); cout &lt;&lt; "ERROR:" &lt;&lt; glGetError() &lt;&lt; endl; cout &lt;&lt; "ERROR:" &lt;&lt; SDL_GetError() &lt;&lt; endl; glLoadIdentity(); ...... +400 lines The init of sdl looks like this int sdl_interface::interface_init( Uint32 flags ) { int status = SDL_Init( flags ); //let sdl rip if(status &lt; 0) { cout &lt;&lt; "Cannot init SDL, Error: (#" &lt;&lt; status &lt;&lt; ") " &lt;&lt; SDL_GetError() &lt;&lt; endl; cout &lt;&lt; "Forced to exit" &lt;&lt; endl; exit(1); } atexit(SDL_Quit); //force sdl to exit, as required by the standards for opengl, god save the ram //just sets the opengl settings through sdl SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); glClearColor( 0, 0, 0, 0 ); //setting the backgroud to black, black is good return 0; } with flags varible looking like 'SDL_OPENGL' source is messy, shoot me :P [Edited by - crim on June 23, 2005 1:06:28 PM]
  10. Its labeled SDL/Linux because the interface is created with SDL hence is crossplatform but the way the font is implemented it is linux specific. I think llvllatrix uses a bitmap and cuts the font from an image, which isnt how i intended to do it, i still have to wake up to read the source properly. [Edited by - crim on June 21, 2005 3:16:51 PM]
  11. Ah sweet, thanks for that. Im to tired to look over it now, *bashes exams*, ill look at it in a few hours. btw it was missing openal32.dll Thanks
  12. My source uses OpenGL + SDL on windows, down the bottom of the lesson i couldn't find any sources for this combination and i am confused about an aspect of lesson 13 (printing text onto the screen). The example source I used is the DevC++ one. After many tries, i was not able to print text to the screen. I checked SDL and OpenGL for errors but none appeared. The source compiled correctly. The Z axis is set to -1. If someone knows the common problems assosiated with this, could you post them. One section i noted was this. hDC was used but SDL was never attached to it previously. oldfont = (HFONT)SelectObject(hDC, font); wglUseFontBitmaps(hDC, 32, 96, base); SelectObject(hDC, oldfont); DeleteObject(font); Futhermore SDL uses the command SDL_GL_SwapBuffers( ); but in the example this is used. SwapBuffers(hDC); hDC is not used at all with SDL. How do i overcome this problem?