Jump to content
  • Advertisement

fear4ever

Member
  • Content Count

    31
  • Joined

  • Last visited

Everything posted by fear4ever

  1. fear4ever

    My first C++ game

    I think you should start with c# or java and use the built in graphics API as they are pretty straight forward and require little effort to learn. You'll use eclipse/visual studio to write the code and intellisense will remember function names for you so you wont have to bother with 1- Graphics APIs/Frameworks 2- Function details/graphics pipelines 3- Windowing/keyboard-mouse input routines. You can easily focus on actual game development/algorithms/geometry calculations. By the time you create a game like snake that actually works you'll have learned a great deal about essentials of game programming. Then you can move to more professional stuff like OpenGL/DirectX
  2. Hello, As far as I can see glPolygonStipple isnt applied when glDrawPixels is called. Is there a way to make this work?
  3. Hi I am trying to create a c++ dll which draws some stuff to a c# form (hWd passed as a parameter to the dll). It works fine up to that point. I put a timer to the c# application and it calls the dll's draw method on each tick. What I am trying to add now is an overlay on top of what is drawn by the c++ part. That overlay can be drawn by the c# application itself or maybe by some other dll. Is that possible? And if so how do i go about it? Something like void tick() { openGL_Part.draw(); draw_Some_Stuff_On_Top_Of_That(); }
  4. Quote:Original post by fear4ever That overlay can be drawn by the c# application itself or maybe by some other dll. It doesn't really matter whether it gdi+ or anything else that does the drawing. What i am trying to find is the method of double buffered drawing onto a c# form (flicker free). As i understand OpenGL and gdi+ use different buffers for drawing so something like is not possible? in each timer tick clear_area() oglDLL.draw() //dont swap buffers yet some_other_dll.draw() //dont swap buffers yet gdi+.draw() //dont swap buffers yet swap_buffers() Any explanation or pointers to that kind of drawing tecnique would be appriciated.
  5. fear4ever

    c++ bitmap to bmp

    Hello. I am having a problem creating and saving an image as bmp in a MFC application. Project is created by VS6 from mfc appication wizard(exe) with standard options. This is the source of the onDraw method. This creates a bitmap and draws to screen. Also creates a bmp file of application size but its just black. What am i doing wrong? // CDenemeView drawing void CDenemeView::OnDraw(CDC* pDC) { CDenemeDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here // bitmap dimensions RECT windowRect; GetWindowRect(&windowRect); int bitmap_dx = windowRect.right - windowRect.left; int bitmap_dy = windowRect.bottom - windowRect.top; CPaintDC odc(this); CBitmap bmp; CDC dc; dc.CreateCompatibleDC(&odc); bmp.CreateCompatibleBitmap( &odc, bitmap_dx, bitmap_dy ); dc.SelectObject(&bmp); //fill the area for ( int x = 0; x < bitmap_dy; x ++ ) { for ( int y = 0; y < bitmap_dx; y ++ ) { dc.SetPixel(x,y, RGB(x%256,y%256,(x*y)%256)); } } // create file ofstream file("example.bmp", ios::binary); if(!file) return; // save bitmap file headers BITMAPFILEHEADER fileHeader; BITMAPINFOHEADER infoHeader; fileHeader.bfType = 0x4d42; fileHeader.bfSize = 0; fileHeader.bfReserved1 = 0; fileHeader.bfReserved2 = 0; fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); infoHeader.biSize = sizeof(infoHeader); infoHeader.biWidth = bitmap_dx; infoHeader.biHeight = bitmap_dy; infoHeader.biPlanes = 1; infoHeader.biBitCount = 24; infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = 0; infoHeader.biXPelsPerMeter = 0; infoHeader.biYPelsPerMeter = 0; infoHeader.biClrUsed = 0; infoHeader.biClrImportant = 0; file.write((char*)&fileHeader, sizeof(fileHeader)); file.write((char*)&infoHeader, sizeof(infoHeader)); // dibsection information BITMAPINFO info; info.bmiHeader = infoHeader; //for checking if dc has correct drawing pDC->BitBlt( 0,0,bitmap_dx, bitmap_dy, &dc,0,0,SRCCOPY); BYTE *memory; SelectObject(dc, bmp); HBITMAP bitmap = CreateDIBSection(dc, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0); // save dibsection data int bytes = (((24*bitmap_dx + 31) & (~31))/8)*bitmap_dy; file.write((char*)memory, bytes); DeleteObject(bmp); DeleteDC(dc); DeleteDC(odc); file.close(); }
  6. fear4ever

    c++ bitmap to bmp

    I have played a bit around with the code. First off the HBITMAP i created was not getting the info from CBitmap bmp; so i decided to get pixel directly from it. and changed 24 color depth to 32 which is my desktop resolution. At last i got some output but half the picture is still in black. What could be the reason? // CDenemeView drawing void CDenemeView::OnDraw(CDC* pDC) { CDenemeDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here // bitmap dimensions RECT windowRect; GetWindowRect(&windowRect); int bitmap_dx = windowRect.right - windowRect.left; int bitmap_dy = windowRect.bottom - windowRect.top; CPaintDC odc(this); CBitmap bmp; CDC dc; dc.CreateCompatibleDC(&odc); bmp.CreateCompatibleBitmap( &odc, bitmap_dx, bitmap_dy ); dc.SelectObject(&bmp); //fill the area for ( int x = 0; x < bitmap_dy; x ++ ) { for ( int y = 0; y < bitmap_dx; y ++ ) { dc.SetPixel(x,y, RGB(x%256,y%256,(x+y)%256)); } } // create file ofstream file("example.bmp", ios::binary); if(!file) return; // save bitmap file headers BITMAPFILEHEADER fileHeader; BITMAPINFOHEADER infoHeader; fileHeader.bfType = 0x4d42; fileHeader.bfSize = 0; fileHeader.bfReserved1 = 0; fileHeader.bfReserved2 = 0; fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); infoHeader.biSize = sizeof(infoHeader); infoHeader.biWidth = bitmap_dx; infoHeader.biHeight = bitmap_dy; infoHeader.biPlanes = 1; infoHeader.biBitCount = 32; infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = 0; infoHeader.biXPelsPerMeter = 0; infoHeader.biYPelsPerMeter = 0; infoHeader.biClrUsed = 0; infoHeader.biClrImportant = 0; file.write((char*)&fileHeader, sizeof(fileHeader)); file.write((char*)&infoHeader, sizeof(infoHeader)); // save dibsection data int bytes = (((32*bitmap_dx + 31) & (~31))/8)*bitmap_dy; char *memory2= (char*)malloc(sizeof(char)*bytes); bmp.GetBitmapBits(bytes,memory2); file.write((char*)memory2, bytes); DeleteObject(bmp); DeleteDC(dc); DeleteDC(odc); file.close(); }
  7. Hi, I am trying to create a simple windows opengl application. For GUI i decided to use visual basic. I know people can code opengl in vb using a tlb file which i cannot remember the exact name for but that's not i am after. I am looking for a way to implement only GUI in VB and all application code in visual c++. That means i'll have a dll that initiliazes opengl using the window handle of vb, vb will pass GUI events to that/or another dll responsible for application impelemtatioin. Is that possible? I tried to create a simple win32 dll with VS/c++ and reference it in a VB app but that doesnt seem to work. Do i have to create an mfc activeX control instead of a regular dll? (That i tried and managed to link the ocx file to vb but is creating a control best way to do this?) I am also open for suggestions about the platform to implement the GUI (MFC is a bit too complicated and glut/glui do not have a good application feel). Thanks in advance.
  8. fear4ever

    Visual Basic And OpenGL

    Yes you are right. Basically i wanted to develop a GUI based opengl application. Nehe's window system works just fine but controlling everything with keyboard is not possible when you want to create an actual application. SDL is not any different as far as i can see. Anyway i did manage to integrate opengl/vb/c++. After a bit of a work i'll hopefully have a simple framework where vb controls user input and c++ handles application logic and opengl. Thanks for the replies.
  9. fear4ever

    Visual Basic And OpenGL

    Thanks edgar. I did manage to make it work by creating a simple atl com object and linking to vb. This brings some problems with it of course i.e i have to prevent vb from drawing over opengl stuff by running it in a closed loop. Still it works and will save me some time while designing a GUI. Hopefully i'll have a generic framework for future use. I also looked into SDL a bit. It seems quite nice but is there a form editor type tool for creating GUI's based on it?
  10. fear4ever

    Vector rotation

    This is not a homework. I am trying to build a pipe around a curve, the normals at curve points need to match so i can create circles around it and connect them with triangle strips. BeanDog, your methods seems like it will work. I am not very good with linear algebra, so i'll try to implement this and let you know. Thanks for replies
  11. fear4ever

    Vector rotation

    Hi, I have 2 vectors. a=[x1,y1,y1] b=[x2,y2,z2] Now somehow the vector a is rotated to a'=[x1',y1',z1'] a' is given without the rotation matrix that produced it. What i need is to rotate the vector b the same way vector a has been rotated to obtain b'=[x2',y2',z2']. Any (if possible easy) way to do this? Thanks
  12. fear4ever

    3D Pipe

    Thanks a lot. I just cannot see such typos especially it is me who made them :( This works fine now.
  13. fear4ever

    3D Pipe

    Any ideas on implemneting a smooth 3d Pipe when 3D points that the pipe will follow are present (say generated from a bezier curve)? I thought about drawing cylinders at each point in direction of next point with height equal to the distance between these two points, but that's a lot of calculation. Anyne got a better idea? edit: I guess there is no simple solution for this. Also my solution leaves empty areas at curving intersection points...Still hoping someone got some ideas..
  14. fear4ever

    Spotlight not working

    This page shows how to set up lights. Specifiying spotlight properties. Hope it helps
  15. fear4ever

    3D Pipe

    I have written a simple program to implement this. Here is a link to MSVS 6 workspace (10kb) Source I am using a bezier curve. You can play with resetControl() function to specify diffrent control points and get diffrent curves. The pipe is generated with some weird looking parts especially at curving regions. I could not figure out if this is due to the 3D structure of it or not. (I think something is definetely wrong though). If you have time to download and have a look at it please check the "circlesFromCurve" function and let me know if there is any problem there. For those who dont have time to download the source, this is the function. double PI = acos(-1); const float DEG2RAD=PI/180; typedef struct { double x; double y; double z; }Point3D; typedef struct { Point3D* points; int n; }Circle; /*This func generates a circle for each point on curve *cn is numner of curve points that i will generate circles for *res is resolution of circles(number of points per circle) */ Circle* circlesFromCurve(Point3D* curvePoints,int cn, int res, double radius) { Circle* circles=(Circle*)malloc(sizeof(Circle)*cn); Point3D pRandom; pRandom.x=1; pRandom.y=1; pRandom.z=1; for(int i=0;i<cn-1;i++) { Point3D pDirection; Point3D axis1,axis2; pDirection.x=curvePoints[i+1].x-curvePoints.x; pDirection.y=curvePoints[i+1].y-curvePoints.y; pDirection.z=curvePoints[i+1].z-curvePoints.z; axis1.x=pDirection.y*pRandom.z - pDirection.z*pRandom.y; axis1.y=pDirection.z*pRandom.x - pDirection.x*pRandom.z; axis1.z=pDirection.x-pRandom.y - pDirection.y*pRandom.x; axis2.x=axis1.y*pDirection.z - axis1.z*pDirection.y; axis2.y=axis1.z*pDirection.x - axis1.x*pDirection.z; axis2.z=axis1.x-pDirection.y - axis1.y*pDirection.x; double l=axis1.x*axis1.x+axis1.y*axis1.y+axis1.z*axis1.z; axis1.x=axis1.x/sqrt(l); axis1.y=axis1.y/sqrt(l); axis1.z=axis1.z/sqrt(l); l=axis2.x*axis1.x+axis2.y*axis2.y+axis2.z*axis2.z; axis2.x=axis2.x/sqrt(l); axis2.y=axis2.y/sqrt(l); axis2.z=axis2.z/sqrt(l); circles.n=res; circles.points=(Point3D*)malloc(sizeof(Point3D)*res); double step=360/res; for(int j=0;j<res;j++) { double degree=j*step*DEG2RAD; double vcos=sin(degree)*radius; double vsin=cos(degree)*radius; circles.points[j].x=curvePoints.x+axis1.x*vcos+axis2.x*vsin; circles.points[j].y=curvePoints.y+axis1.y*vcos+axis2.y*vsin; circles.points[j].z=curvePoints.z+axis1.z*vcos+axis2.z*vsin; } pRandom.x=pDirection.x; pRandom.y=pDirection.y; pRandom.z=pDirection.z; } return circles; }
  16. fear4ever

    3D Pipe

    TGA your approach seems correct. Only a minor flow as far as i can see is even if i take the same random vector each time, because the direction vector changes my first point will be on a diffrent part of circles each time. Am i correct? Now my algebra is a bit weak so i'll request your help here. This is my example P1(1,1,1) P2(3,5,4) PDirection=P2-P1= (2,4,3) PRandom= (1,1,1) axis1= PDirection X PRandom = (4*1-3*1)i+(3*1-2*1)j+(2*1-4*1)k = (1,1,-2) axis2= axis1 X PDirection = (1,1,-2) X (5,3,4) = (1*4-(-2)*3)i+((-2)*5-1*4)j+(1*3-1*5)k = (10, -14, -2) so axis1= (1,1,-2) axis1= (10, -14, -2) Assuming what i have done is correct, how can i find circle points using these two axis? (at radius r )
  17. fear4ever

    3D Pipe

    Thanks for the replies. jyk, i had a glance at parallel transport frame method. Its a bit overkill for my application since the tube generation part is just a small part of it (i'm not very good at linear algebra am i:) ). AlgorithmX2, if I understand you correctly you are proposing i find equadistance points around all original curve points. That will give me circle points around curve points. Then I can triangulate the points of circles to get a pipe. The circles will be on planes that are perpendicular to the tangent of the curve at that point. That is what I had in mind. If that's not what you are suggesting please correct me. Now assuming that is the method, can you please elaborate on how to find the circle points based on the direction vector of a curve point. (The points of the red circle P1 and P2 given) [Edited by - fear4ever on March 8, 2007 2:25:12 AM]
  18. fear4ever

    Vbo? Fbo? List?

    Hi, I am working on a 3d terrain visulization program that i wish to optimize. I use heightmaps for height data and pre-generate color information to later use as texture. Currently i am using 1-quadtrees for view frustum culling 2-LOD method to simplify the mesh 3-Triangle fans to render each quadtree node. In the picture the fans I draw are numbered in the order they are processed. Now i am using immediate mode and that's a lot of overhead. Possible fan confiurations are : (numbered lines in red are optional i simetimes have to draw 1 or more of them ) That makes 4!=24 possible fans. My height data is stored in a 2-d array and i am loading 1 precomputed texture to match the heightmap and using it for coloring. The list of vertices i am using change dynamically with user input (flying over terrain) but every vertex has a precomputable texture coordinate. Also note that at max resolution i am using 9x1025x1025 vertices (gpu memory limitations?) all of which of course are not displayed due to LOD and culling. Hope i explained the system enough. Now the question is can i use display lists,vbo's ,fbo's etc to obtain a better speed?
  19. fear4ever

    Vbo? Fbo? List?

    Thnx for the reply. Quote:Original post by Krohm Sure, but you should tell us if this performance gain is really necessary. Tell us about the context. This pdf is where i base my program. Have a look at it if u have some free time. I think it will help you visualize the process a little better. The triangle fan usage is a result of the quadtree based visibility culling sheme. I have managed to make a tri-strip version of it (heighly inefficient,many double-triple vertex usage) so i would use only use 1 glBegin End command but it only lead to a worse performance. Now the need for dynamic lod change.. As u go up in the sky you see more of the terrain. So if i dont change the lod i will end up drawing say.. a terrain as large as France with 9*1024*1024 vertices.I dont like the sound of that:) But i will now try to implement a version where there is no culling no lod only vbos. I'll let u know the results if i manage to do it (1 "tile" is 1024*1024 ,i use 9 tiles where the user is always in the center tile for caching purpose)
  20. fear4ever

    How To Questions

    You may have a look at bilboarding if u want a 2d texture to always look at the camera. But you better cover the basics first bilboarding tutorial
  21. fear4ever

    Vbo? Fbo? List?

    LorenzoGatti: 1- Corrected picture. Sorry i was just concerned about giving an idea of the order of triangles drawn. 2-I am drawing the fans recursively in counter clockwise direction. 3-Assume, i have a whole image of a city (a .jpg for example). Now my mesh is the city with 1024*1024 vertices and i lay my image on the grid. Hence only 1 picture. krohm: By fan i mean a triangle fan as seen in picture 2. I wondered maybe if i made 24 triangle fan dl's and used them .. but i have to change the texture for each fan. The terrain changes because of LOD(level of detail) .User flies closer to terrain and sees more detail, fans are further subdivided. So the data does not change but the i sometimes use some of the vertices and sometimes i dont. For example if user goes high up in the sky i wont use the picture 1s vertices but a simpler picture 2 will be sufficent. Now the thing is i read about VBO's and if i update the vertex data every frame it wont do much good as far as i see. Would be be somehow possible to chose which vertices to draw and which not to draw so i wont have to draw all 1024*1024 vertices all the time ,rendering view frustum culling and lod useless.
  22. fear4ever

    VBO performance

    Hi all, I am experimenting with VBO's to see if it can help me speed up my app. I use a triangle fan with 8 triangles and draw it for 1000 times each frame. I get the same fps whether i use VBO or just use glVertex3f. So my question is, is it the way i use the VBO that causes no improvement in fps or are VBO's not suitable for ~10 vertices of data? GLfloat data[] = {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f }; int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View glTranslatef(0.0f,1.0f,z); glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f); if( GetTickCount() - g_dwLastFPS >= 1000 ) // When A Second Has Passed... { g_dwLastFPS = GetTickCount(); // Update Our Time Variable g_nFPS = g_nFrames; // Save The FPS g_nFrames = 0; // sprintf(title,"triangles= %d fps=%d throughput:%.2g MT/s vbo=%d",triangles,g_nFPS,(float)g_nFPS*triangles/1000000,vbo); sprintf(title,"fps=%d",g_nFPS); SetWindowText( hWnd, title ); } g_nFrames++; triangles=0; if(vbo) { for(int i=0;i<1000;i++) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer); glVertexPointer(3, GL_FLOAT, 0, 0); glDrawArrays(GL_TRIANGLE_FAN, 0, 10); } } else { for(int i=0;i<1000;i++) { glBegin(GL_TRIANGLE_FAN); for(int i=0;i<3*10;i+=3) glVertex3f(data,data[i+1],data[i+2]); glEnd(); } } triangles+=8; xrot+=xspeed; yrot+=yspeed; return TRUE; // Keep Going }
  23. fear4ever

    VBO performance

    Quote:Original post by Taharez Quote:Original post by fear4ever I am already drawing 8k triangles/frame Yes, but only 8 at a time, so the overhead of VBO and glVertex-calls is probably pretty similar. If you hade 8k tris in a single VBO and rendered that with one call vs glVertex in a loop, that'd most likely give you a bigger difference Yes that is what i have been asking about. My application has a large datum but it is drawn with numerous small triangle fans. Also these fans are dynamic (losing some vertices or regaining them in runtime). So in that case should i stick to immediate mode? Is there still a way to improve performance here? For anyone interested, i am drawing a large terrain with dynamic lod.
  24. fear4ever

    VBO performance

    I am already drawing 8k triangles/frame
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!