• Advertisement

Clueless

Member
  • Content count

    415
  • Joined

  • Last visited

Community Reputation

185 Neutral

About Clueless

  • Rank
    Member
  1. Regular Java vs Tomcat Project

    Don't think I'll figure it out. For some reason the root path was set from the project root directory to somewhere in the eclipse directory. No idea why. Maybe it usually doesn't happen and I just messed up somewhere. I can't find anything suspicious in the project settings. The other problem was just that I didn't put the library into the lib directory in the WEB_INF folder. Guess it has to be put there.
  2. Regular Java vs Tomcat Project

    Funny ... like so often. I think I researched about 2 hours before I posted ... and I think I just fixed it :-) Just not sure how to set the root folder yet ...
  3. Hi everybody, I tried getting code that works as a regular Java project to work as a Tomcat project with servlets. Now a lot of things change when you do that, right? First thing I had to struggle with was the root path. Why does it change at all? Can I change it back somehow? For example this used to work: ... new File("./properties.xml") ... And I had to change it to: ... new File("\\D:/EclipseWS/Italienisch/properties.xml") ... The next problem that I have not fixed yet is that dynamically loading classes doesn't work any more. There is no error when I import it in the java file directly ... but when I use the exact code in Class.forName(...) a ClassNotFoundException is thrown. It did work in the regular Java project. And I did not forget to add the external library (obviously). Any ideas? Maybe some ideas where I can start researching? Didn't really find anything in google.
  4. Hi everybody ... I wrote a test in school and couldn't get a program to work properly there. Now I tried the same at home with a different setup and it does work. Does anybody know of any known bugs that fit here? At school we use Tomcat 5.x ... I have Tomcat 6 at home. It could also be a Firefox cookie bug ... maybe!? Somehow the value of the cookie is weird at school. There are "-charcters inserted and I don't know why. When I append something to a cookie value it totally messes things up at school: ss_res.addCookie(new Cookie(name,cookies[i].getValue()+"Fach: "+fach+", Note: "+note+"<br />")); It leaves me with "" as the only content of value (to be sure this comes across right - the debugger says: value="""" ...) Any ideas? Complete Source: public void doGet(HttpServletRequest ss_req, HttpServletResponse ss_res) { ss_res.setContentType("text/html"); String funktion = ""; if (null!=ss_req.getParameter("anzeigen")) { funktion = "anzeigen"; } else { funktion = "hinzu"; } String name = ss_req.getParameter("name"); String fach = ss_req.getParameter("fach"); String note = ss_req.getParameter("note"); PrintWriter out; try { out = ss_res.getWriter(); } catch (IOException ioex) { out = null; } Cookie[] cookies; try { cookies = ss_req.getCookies(); } catch (Exception ex) { cookies = null; } if (null!=out) { out.println("<html><head><title>Hello</title><link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/ItalienischTrainer/default.css\" /></head><body>"); if (funktion.equals("anzeigen")) { if (null!=cookies) { out.println("<h1>Noten&uuml;bersicht</h1><br />"); for (int i=0; i<cookies.length; i++) { if (cookies[i].getValue().startsWith("Fach")) out.println("<br /><strong>Sch&uuml;ler: </strong>"+cookies[i].getName()+"<br /><br />"+cookies[i].getValue()); } } out.println("<br /><br />"); } else if (funktion.equals("hinzu")) { if (null!=name && null!=fach && null!=note) { out.println("<strong>Note erfasst: </strong> Sch&uuml;ler"+name+", Fach: "+fach+", Note: "+note); boolean isGefunden = false; if (null!=cookies) { for (int i=0; i<cookies.length; i++) { if (cookies[i].getName().equals(name)) { isGefunden = true; ss_res.addCookie(new Cookie(name,cookies[i].getValue()+"Fach: "+fach+", Note: "+note+"<br />")); } } } if (!isGefunden) { ss_res.addCookie(new Cookie(name,"Fach: "+fach+", Note: "+note+"<br />")); } } try { //Trainer tr = new Trainer(); out.println("<form action=\"http://localhost:8080/ItalienischTrainer/zeigehome\" method=\"POST\">"); out.println("Sch&uuml;ler: <input type=\"textfield\" name=\"name\" /><br />"); out.println("Fach: <input type=\"textfield\" name=\"fach\" /><br />"); out.println("Note: <input type=\"textfield\" name=\"note\" /><br />"); out.println(" <input type=\"submit\" name=\"hinzu\" value=\"Hinzuf&uuml;gen\" />"); out.println(" <input type=\"submit\" name=\"anzeigen\" value=\"Noten anzeigen\" />"); out.println("</form>"); out.println("</body></html>"); } catch (Exception ex) { out.println(ex.getMessage()); } } } }
  5. Hi, I asked this a while ago in the forum for beginners ... but the problem could not be solved then. Has anybody here written code that renders the ascii-letters of a font to a texture? The problem that I'm running into is that the vertical positioning doesn't work properly. I want the letters in the top left corner, but moved down depending on the bitmap_top value. With the code below they are moved too far down and I have to change a value manually. I need a way to do the vertical positioning inside the quad automatically. Can anybody help? void EditorFont::initialize() { g_error = FT_Init_FreeType(&g_library); if (g_error) { Instances::get_pGlobal()->get_pCore()->quit(); } else { g_error = FT_New_Face(g_library,"./content/Gargoyles.ttf",0,&g_face); if (g_error) { Instances::get_pGlobal()->get_pCore()->quit(); } else { m_pFont = new Font(); m_pGlyph = new Glyph(); Uint8* pixels = 0; Uint16 width; Uint16 height; Uint16 glyphpixels = 0; g_error = FT_Set_Char_Size(g_face,32*64,0,0,0); if (g_error) { Instances::get_pGlobal()->get_pCore()->quit(); } else { for (Uint16 j=0; j<256; j++) { g_error = FT_Load_Char(g_face,(Uint8)j,FT_LOAD_RENDER); if (g_error) { Instances::get_pGlobal()->get_pCore()->quit(); } else { width = 32; height = 32; // setting alpha to 0 everywhere for (Uint32 i=0; i<width*height; i++) { m_pFont->set_pixel(255,255,255,0, i%width, i/width, (Uint8)j); } // setting the gray-values of the bitmap as alpha values for (Uint32 i=0; i<g_face->glyph->bitmap.rows* g_face->glyph->bitmap.width; i++) { m_pFont->set_pixel(255,255,255, g_face->glyph->bitmap.buffer[i], ((i%g_face->glyph->bitmap.width)+1), ((i/g_face->glyph->bitmap.width)) /* !!! Here is the value that has to be adjusted manually for different fonts !!! : */ + 26 - g_face->glyph->bitmap_top, (Uint8)j); } } glyphpixels = 0; } m_pFont->export_font("./content/gargoyles.tga"); } } } }
  6. FreeType2 question

    Yes ... what you wrote is pretty much what I am doing. But it produces the evil result I posted. For some fonts the calculated offset for a 'G' should be between 0 and 3 but it is 17. For the ',' it is 29 ... which means the difference between 'G' and ',' is ok. For a different font the offset for a 'G' is 6. So subtracting for example 15 from the offset is not an option. Any ideas what I can do? Somebody must have done something like that successfully before ...
  7. FreeType2 question

    Thanks for the reply! Guess I need to elaborate a little ... this is not the text rendering code. Here I convert a ttf font into a bitmap font. I try to create a texture with all the ASCII characters in it. So the pen position initialy is always the top-left corner of a 32x32 field. Then I try to move the pen down depending on the bitmap_top value and copy the glyph bitmap there. This only works if I adjust a certain offset value. FontFace->size->metrics.y_ppem looked like a candidate ... but using that doesn't seem to help: The left image shows what I want, the right image shows what happens.
  8. FreeType2 question

    Hi, I just noticed that there is a difference between fonts that I don't quite understand. I try to store characters inside 32x32 areas of a texture. Inside those areas I move the characters down depending on the glyph->bitmap_top value. Pseudo Code: AreaRow = GlyphRow + (x-GlyphBitmapTop) (Result of trial and error) However I have no idea how to find a decent value for x automatically. For some fonts 24 is perfect ... for others it is 28 and so on. Can anybody explain what phenomenon this is? Or is there another way to do the vertical positioning?
  9. Writing compressed tga files

    Hi, finally I have set up FreeType2 and I create a nice Texture with all the characters I need ... just saving the result as a tga file does not quite work. The tga header is written properly. Right now (for font-images) the color bits are all 255 ... just the alpha values differ. Debugging the image content is what I have troubles with. There is no decent way of using logfiles that I can think of. Maybe somebody has written a tga writer and can spot an error here. I guess it has something to do with the iterators. No program I tested can open the file ... just my own loader (there is little error checking going on) It displays colorful results ... so for some reason not even the colorbits are always 255. The filesize is not insane ... between 120 and 150kb, depending on small changes I made. So I think I'm not too far off. Any help is greatly appreciated! set_filename(filename); const Uint8 compHeader[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; const Uint8 width1 = 0; /* won't need different values */ const Uint8 width2 = (m_width/256)>255?255:(m_width/256); const Uint8 height1 = 0; /* won't need different values */ const Uint8 height2 = (m_height/256)>256?255:(m_height/256); const Uint8 bpp = 32; start_writing(); /* write header */ write_uint8(compHeader,12); write_uint8(&width1,1); write_uint8(&width2,1); write_uint8(&height1,1); write_uint8(&height2,1); write_uint8(&bpp,1); /* write content */ Uint8 prevColor[4]; Uint8 nextColor[4]; Uint8 pixelsCount; for (Uint32 i=0; i<m_width*m_height;) { /* color of first pixel in chunk */ prevColor[0] = m_pPixels[(i*4)]; prevColor[1] = m_pPixels[(i*4)+1]; prevColor[2] = m_pPixels[(i*4)+2]; prevColor[3] = m_pPixels[(i*4)+3]; /* color of next pixel, only if there is a next pixel */ if (i<(m_width*m_height)-1) { i++; nextColor[0] = m_pPixels[(i*4)]; nextColor[1] = m_pPixels[(i*4)+1]; nextColor[2] = m_pPixels[(i*4)+2]; nextColor[3] = m_pPixels[(i*4)+3]; } pixelsCount = 1; /* pixelCount in chunk, only first one counted */ /* check chunk type by comparing first two pixels */ if (0==memcmp(nextColor,prevColor,4) && i<m_width*m_height) { /* chunk of pixels with the same color */ /* compare nextColor with prevColor until - a different color is found - the max chunk size is reached - the last pixel was read increment number of pixels in chunk increment pixel array index read new next color value */ while (0==memcmp(nextColor,prevColor,4) && pixelsCount < 128 && i<m_width*m_height) { pixelsCount++; i++; nextColor[0] = m_pPixels[(i*4)]; nextColor[1] = m_pPixels[(i*4)+1]; nextColor[2] = m_pPixels[(i*4)+2]; nextColor[3] = m_pPixels[(i*4)+3]; } /* if two distinct pixels were found take back one iteration */ if (0!=memcmp(nextColor,prevColor,4)) { pixelsCount--; i--; } const Uint8 header = pixelsCount+127; /* max value: 255 */ /* write header and color of chunk */ write_uint8(&header,1); write_uint8(prevColor,4); } else if (0!=memcmp(nextColor,prevColor,4) && i<m_width*m_height) { /* chunk of pixels with different colors */ /* compare nextColor with prevColor until - two equal pixels are found - the max chunk size is reached - the last pixel was read increment number of pixels in chunk increment pixel array index read new prev and next color values */ while (0!=memcmp(nextColor,prevColor,4) && pixelsCount < 128 && i<m_width*m_height) { pixelsCount++; i++; prevColor[0] = nextColor[0]; prevColor[1] = nextColor[1]; prevColor[2] = nextColor[2]; prevColor[3] = nextColor[3]; nextColor[0] = m_pPixels[(i*4)]; nextColor[1] = m_pPixels[(i*4)+1]; nextColor[2] = m_pPixels[(i*4)+2]; nextColor[3] = m_pPixels[(i*4)+3]; } /* if two equal pixels were found take back one iteration */ if (i<m_width*m_height && pixelsCount<128) { pixelsCount--; i--; } else { } const Uint8 header = pixelsCount-1; /* max Value 127 */ write_uint8(&header,1); write_uint8(&m_pPixels[(i-pixelsCount)*4],pixelsCount*4); } else { /* only one more pixel */ const Uint8 header = 0; /* 0 represents a one pixel chunk */ write_uint8(&header,1); write_uint8(&m_pPixels[i*4],4); } } finish_writing();
  10. glOrtho ... how to project?

    Crap! What confused me was that I thought by translating into the screen in an identity matrix: ( glTranslatef(0.0f, 0.0f, -4.0f); ) I'd end up at position 0.0f, 0.0f, -4.0f in the world matrix. So I set the far clipping to -5.0f instead of setting the near clipping plane to 5.0f. It did work when I was on the save side with both planes. Sorry 'bout that. No idea why I thought so. Probably because I am currently forcing myself to program and I can't concentrate enough. Thanks again!
  11. glOrtho ... how to project?

    Hi again, thanks for your replies. They helped! For the GUI I did not want the size to change ... but it did. I found out that I did not enter the projection mode properly in that case. The other problem still occured, though. The objects did not appear on the screen. I noticed that when I play with the far and near clipping plane values in the glOrtho function call the objects sometimes appear and sometimes they don't. Sometimes it does not really quite make sense to me. Guess unfortunately I'll have to stick with one setting that works without really understanding why it does.
  12. glOrtho ... how to project?

    Hi everybody, I thought glOrtho is used to project stuff!? This is the first time I tried to implement gui rendering functionality ... and it doesn't work. How is glOrtho used properly? Can I stay in modelview mode? If I switch to projection mode nothing is drawn, if I stay in modelview mode the objects are not projected ... meaning if I use glTranslatef the objects get smaller/bigger. I know there was a tutorial at gametutorials.com ... but they are not free any more afaik. Is there a NeHe tutorial that covers projections? Or can somebody please post a brief code example that shows how to enter projection mode properly?
  13. Free Resource Thread (updated 5/27/06)

    Correct me if I'm wrong, but ... to me it seems that this TrueVision is about as free as the Unreal Engine (Version 2): there's a binary version available for personal and educational use only. You are not allowed to redistribute the software so for the competitions it is pretty useless. I'd remove it from the list.
  14. OO C++ Question

    In the source file you can include the whole headers. Using forward declarations instead of that is only required in the header files sometimes. Btw. you might want to define a Logfile class. If all modules use the same then give the Debug class a pointer to one Logfile object as a static member. You can then use: Logfile* pLog = Debugger::get_pLog(); and access the same file from any source file. With that approach it will also be easier to give the modules their own Logfiles later if you should need that in the future.
  15. File output

    I don't really get your setup. Why is there name as well as filename if you just assign one to the other? Are those global variables or member variables? They probably should not be global. Maybe you created the file manually in project 1? Guess you want to delete the previous logfile if there is one? Try: fout.open(filename.c_str(), ios::trunc); If that doesn't help maybe post both the header and source files.
  • Advertisement