Advertisement Jump to content
  • Advertisement

Decrius

Member
  • Content Count

    1152
  • Joined

  • Last visited

Community Reputation

100 Neutral

About Decrius

  • Rank
    Contributor
  1. Decrius

    1D or 2D fourier transformation

    Yes, indeed. That is always 1. I only want to calculate the magnitude, I should've mentioned. I think I do the sqrt too early. It should be outside the "k" loop. Luckily D has imaginary numbers build-in immutable int N = 8; creal[N] f = [0.0 + 0i, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0]; creal[N] F = 0.0 + 0i; for (int n = 0; n < N; n++) { for (int k = 0; k < N; k++) { real a = 2.0 * PI * cast(real) (k * n) / N; F[n] += f[k] * expi(-a); } } foreach (value; F) { writeln(value, " ", sqrt(value.re * value.re + value.im * value.im)); } Thanks.
  2. Consider the following D code (a real is like a double in C). f is the original discrete function, F the Fourier transformed immutable int N = 8; real[N] f = [0.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0]; real[N] F = 0.0; for (int n = 0; n < N; n++) { for (int k = 0; k < N; k++) { real a = 2.0 * PI * cast(real) (k * n) / N; real r_part = cos(a); real i_part = sin(a); F[n] += f[k] * sqrt(r_part * r_part + i_part * i_part); } } foreach (value; F) { writeln(value); } The Fourier transformed only ever has equal values on each discrete position. In the above example 8 times "3" is printed. Perhaps I'm missing a division by N, I'm not sure whether this is for the transformation or it's inverse. Futher I can't suspect any fault in the algorithm, it seems to be equivalent to the definition, unless I'm being stupid. Note this is FT, not FFT. Why do I not get sinusoids or sinc's for the transformed output? I want them... Thanks.
  3. Decrius

    FBO texture is empty / black

    The unsetting of the RBO is indeed not necessary, but neither a problem. The viewport settings were indeed redundant but neither causing the problem. It appeared to be the mipmapping, silly enough the tutorial mentions it: http://www.songho.ca/opengl/gl_fbo.html but I didn't add it. I uncommented the mipmapping setting line when generating the texture, so I thought it was without mipmapping. I don't need mipmapping, why does the FBO require it? Thanks.
  4. I've been trying but nothing seemed to work out, it's got to be an easy fix, but I don't see it. Draw code: void draw() { glBindTexture(GL_TEXTURE_2D, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, scene_fbo); glViewport (0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fov, cast(float) width / height, nearPlane, farPlane); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.0f, 1.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fov, cast(float) width / height, nearPlane, farPlane); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, scene_texture); glBegin(GL_QUADS); glTexCoord2d(0.0, 0.0); glVertex3d(-2.0, -2.0, -2.0); glTexCoord2d(texture_scale, 0.0); glVertex3d(2.0, -2.0, -2.0); glTexCoord2d(texture_scale, texture_scale); glVertex3d(2.0, 2.0, -2.0); glTexCoord2d(0.0, texture_scale); glVertex3d(-2.0, 2.0, -2.0); glEnd(); SDL_GL_SwapBuffers(); } Init code (both functions are called prior to draw): GLuint scene_texture, scene_rbo, scene_fbo; void init_opengl() { glViewport (0, 0, width, height); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepth(1.0); glShadeModel(GL_SMOOTH); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); } void init_fbo() { glGenTextures(1, &scene_texture); glBindTexture(GL_TEXTURE_2D, scene_texture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // automatic mipmap glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); glBindTexture(GL_TEXTURE_2D, 0); // create a renderbuffer object to store depth info glGenRenderbuffersEXT(1, &scene_rbo); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, scene_rbo); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); // create a framebuffer object glGenFramebuffersEXT(1, &scene_fbo); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, scene_fbo); // attach the texture to FBO color attachment point glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, scene_texture, 0); // attach the renderbuffer to depth attachment point glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, scene_rbo); // check FBO status GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { writeln("FBO error"); } // switch back to window-system-provided framebuffer glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } The FBO is complete, no error message. glGetError() returns 0. The FBO is black, but it should be green. If I remove the framebuffer bindings (and the code afterwards) it indeed shows green. But somehow the scene_texture remains empty. Drawing something else but scene_texture (other texture) works, so scene_texture is simply black. I hate dumping code like this, but I really don't see the problem... Thanks!
  5. Thank you for the reply. Yes, I was reviewing and would be pleased to drop Cairo. Not only for then I can drop a bunch of DLL's, but also a lot of complexity. I just need to be sure that QPainter can export PDF's, but it looks like it can a lot. Thanks for the eye opener
  6. Decrius

    Lua parser

    Why don't you just compile and check if any error has occurred?
  7. Decrius

    Several sdl_net questions

    I personally am favoured with ENet. It uses UDP with it's own reliability algorithm, so you get the speed of UDP with the reliability of TCP. A much better performance, according to the developer. But it also has a very simple and consistent API, which is the main reason I use it. http://enet.bespin.org/
  8. I'm writing my application using Qt, but would like to draw one widget (the working area) using Cairo. There is a lot of SVG's and text drawing to be done there, and Cairo has nice PNG and PDF export. I am not aware of the ability to draw a Cairo surface directly to a Qt widget (but is there a possibility?), thus I use OpenGL as an intermediate. However, this is giving me low quality results, and is slow too. I generally try to make the Cairo surface to be twice as large as the OpenGL surface, to keep the visible quality higher. That gives a sharper texture. However, since the Cairo surface is in the shape of an A4 paper and my screen is 1920 pixel wide, this gives a Cairo surface of about 3840 x 5435, and takes like 2 seconds to load (Qt draws it three times too when starting up). That is way too long. So I'm looking for ways to improve the performance and the visual quality. Each time any update is done, I would execute the following code: // are the following two lines really needed every loop? can't I keep using the same surface and cairo instance? surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); cr = cairo_create(surface); // cairo stuff here // keep copying texture to OpenGL unsigned char *pixels = static_cast<unsigned char *>(cairo_image_surface_get_data(surface)); unsigned int width = cairo_image_surface_get_width(surface); unsigned int height = cairo_image_surface_get_height(surface); unsigned int pow2_width = pow2(width); unsigned int pow2_height = pow2(height); if (pixels && width && height && (width != pow2_width || height != pow2_height)) { unsigned char *pow2_pixels = new unsigned char[pow2_width * pow2_height * 4]; memset(pow2_pixels, 0x00, pow2_width * pow2_height * 4); for (unsigned int y = 0; y < height; ++y) { memcpy(pow2_pixels + (y * pow2_width * 4), static_cast<const unsigned char *>(pixels) + (y * width * 4), width * 4); // premultiply alpha // for (unsigned int x = 0; x < width; ++x) // { // unsigned char *t_pixels = pow2_pixels + (y * pow2_width * 4) + (x * 4); // t_pixels[0] *= static_cast<float>(t_pixels[3] + 1) / 256.0f; // t_pixels[1] *= static_cast<float>(t_pixels[3] + 1) / 256.0f; // t_pixels[2] *= static_cast<float>(t_pixels[3] + 1) / 256.0f; // } } glBindTexture(GL_TEXTURE_2D, texture_id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pow2_pixels); delete[] pow2_pixels; } else { glBindTexture(GL_TEXTURE_2D, texture_id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels); } cairo_surface_destroy(surface); cairo_destroy(cr); It would be great if I can leave out the OpenGL part, and write Cairo directly to Qt, that would save time I bet. Thanks!
  9. Decrius

    48 Hours Later - Moving Forward

    Must get used to the new site, but it's good that you've stepped to professional software. Hopefully this will bring more stability and better features (I'm sure it will). I really like the new logo. Personally I'd fight for some minor points: - the same box on the right is sometimes displayed 3 times, I don't really like the boxes, would rather have a one column site, but I bet it's needed for navigation too...but slicing it down would make it less distracting - more compactness, I really prefer. More compact reply boxes, more compact +kudo buttons. Just less flashy "look here" items, so it resembles with the serious attitude on this forum - I don't see the point in blogs, or twitter like stati, but that's my opinion. Hasn't got much to do with the forum, except journals, they were / are great. [quote name='rubyonrails' timestamp='1294820427'] Wow...disappointing to read that some users are against the new site / layout. I for one, have only just returned to gamedev.net *BECAUSE* of it. I think it's a nice, fresh start and can't wait to see what comes next. Great job for the work involved, it sounded gruelling. [/quote] Huh? How so? It was the community that kept me to GameDev, not the layout so much. How could you leave a forum for you don't like the size of the font, to name a thing?
  10. Decrius

    Right

    The rating was indeed very good, even though I was at like 800 (from down 600). I just had a reply on your other "blog" post, but you deleted it in the meanwhile, getting all sorts of errors.<br><br>I very much dislike the new site. It looks trendy, modern and....very unprofessional, chaotic, immature. Facebook, Twitter...who uses those buttons any ways? The previous site was focussed on quality, seriousness, structure. This new layout focusses on show off, acquiring attention, huge-grand-ma-like-fonts...<br><br>The many high quality members will try and keep the forum as it is, while the owners fark it up, attracting the kids on the internet...if I wanted immature responses, I'd go to Facepunch, not GameDev.<br><br>This rant won't change a thing though.<br>
  11. Decrius

    Best Way to showcase your work?

    Blog with code sounds good for your purpose, or a small programmers portfolio (just Google, there are many). Just make sure it's not ugly as hell, most programmers sites are, and they scare off the more impressionables (the less programming folks). For bigger projects I prefer a wiki (often where only I can modify the pages) with additionally a forum, and perhaps a custom front page. Quote:Original post by OneThreeThreeSeven The absolute best way to showcase your work would be to hire me to make a portfolio site for you in php/javascript. You get custom graphics, 5 pages, interactivity, and I only charge $10 an hour. It's a STEAL! PM me now! Not only do you propagandize your religion (http://www.gamedev.net/community/forums/topic.asp?topic_id=590721&whichpage=1�) but also advertise your services. I don't like you.
  12. Decrius

    Static allocated smart pointer

    It's only static if you put the keyword "static" in front of it, which essentially makes it a global. What you want is composition, one object containing another object. If you want to be notified of deallocation, implement a destructor, it'll be called upon destruction.
  13. Decrius

    Too Old?

    Quote:Original post by OneThreeThreeSeven Jesus - carpenter to savior of the human race...after 30. You to can be like these people...and Jesus. Who is Jesus?
  14. I'm having no troubles with Windows 7 so far, runs well and no noticeable slow downs yet. BSOD's nor virusses have I encountered so far. I must admit with a few points though, Windows by default promotes disk chaos I find. It's not for nothing they had to implement better search capabilities (which I find still insufficient, if you ask me, the search functionality in directories is bugged...or incomplete...I always have to use Notepad++ to search). In this respect I really like Linux (like) systems where the home folder is yours to structure, easily migrated to a new installations. Windows' C drive is undeniably a mess... Also, for Windows XP I have countlessly encountered serious slow downs after approximately a half to one year. Regular used XP's get slower quicker then sparsely used, but it is significant. Windows 7 on the other does a good job so far. Most libraries or code bases are developed (around) the Unix way of folder naming and uses. it's become sort of a standard. And especially with GCC it might be easier to stick with their "original target/descendant platform". I barely ever use Linux / Mac / Amiga though.
  15. Quote:Original post by Zingam Hi, I'm trying to understand the samples by Google and AMD about how to get the function pointers to EGL and OpenGL ES. This is the part I don't get funcPtr_## or (*funcPtr_##funcName) from #define FNDEF(retType, funcName, args) IMPORTGL_API retType (*funcPtr_##funcName) args IMPORTGL_FNPTRINIT What does it do? What is "funcPtr_##" I could guess what it does but I'm not quite sure and I wasn't able to locate any information yet that explains it. Is there a book or tutorial that explains this stuff clearly? It concatenates 'funcName' to 'funcPtr_'. So an expansion of FNDEF(int, sort, (float, float)) would be (not sure about the parameter list...): IMPORTGL_API int (*funcPtr_sort) (float, float) IMPORTGL_FNPTRINIT
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!