• What do you need help with? Version 1
    5,001 replies, posted
What I'm trying to do is display a ID and name along with grade from a external file.
[QUOTE=Darwin226;21762166]How can I rotate the camera around a point in OpenGL while centering on that same point. I currently have this and it's failing miserably. *code* Update is called every frame. I also call CenterOn every time the object I want to center on and rotate around is moved. [editline]12:46AM[/editline] Position is the top left corner of the "camera"[/QUOTE] Why don't you just use gluLookAt?
Can I use that in 2D? What Z coordinate should I use for the eye?
Does anyone know how to draw transparent lines in OpenGL? It looks like it's simply ignoring the alpha value. [cpp] Gl.glBegin(Gl.GL_LINES); Gl.glColor4f(color.R, color.G, color.B, 0); Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); Gl.glVertex2f(from.X, from.Y); Gl.glVertex2f(to.X, to.Y); Gl.glDisable(Gl.GL_BLEND); Gl.glEnd();[/cpp] RGB channels work but alpha doesn't.
You also need Gl.glEnable(Gl.GL_ALPHA_TEST);.
No difference. Btw, how did you know about that GL_ALPHA_TEST? I googled quite a lot but didn't find anything like that.
I misread glBlendFunc as glAlphaFunc. You need GL_ALPHA_TEST only for glAlphaFunc :P Did you choose the RGBA-mode when creating the OpenGL context? I code with OpenGL.
Probably not. This is what I have: [code] Glfw.glfwInit(); if (Glfw.glfwOpenWindow(800, 600, 8, 8, 8, 8, 0, 0, Glfw.GLFW_WINDOW) == Gl.GL_FALSE) { Glfw.glfwTerminate(); return; } Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Gl.glOrtho(0, 800, 600, 0, 0, 1); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glDisable(Gl.GL_DEPTH_TEST); Glfw.glfwSwapInterval(0);[/code]
glfw probably takes care of that when you set some alpha bits. Dunno how you draw alpha, but I can't remember if it's range [0..1] or [0..255]. Are you sure that you've chosen the correct value?
Well, setting it to 0 should make it completely invisible regardless. But, it's not, it's 100% visible.
[url=http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08]This tutorial[/url], which is using C but also Immediate Mode, disables GL_DEPTH_TEST for drawing alpha and also uses glBlendFunc(GL_SRC_ALPHA,GL_ONE);.
You can't call most OpenGL functions between glBegin and glEnd. [quote=OpenGL]GL_INVALID_OPERATION is generated if glEnable or glDisable [i](and glBlendFunc)[/i] is executed between the execution of glBegin and the corresponding execution of glEnd.[/quote] This should work: [cpp] Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); Gl.glBegin(Gl.GL_LINES); Gl.glColor4f(color.R, color.G, color.B, 0); Gl.glVertex2f(from.X, from.Y); Gl.glVertex2f(to.X, to.Y); Gl.glEnd(); Gl.glDisable(Gl.GL_BLEND); [/cpp]
I'm making a simple networking program with C# only when I made it as a console application the server could just do this : [code] while (!done) { //Do stuff } [/code] Now I want to use a button to start and stop it, but where can I put the code ? is there some kind of thinking method on a form ? code for button on off system : [code] private void StartClick(object sender, EventArgs e) { if (hosting) { hosting = false; Start.Text = "Start"; } else { hosting = true; Start.Text = "Stop"; } } [/code]
I don't know why you'd want that in a very simple networking program, but you will probably want to create a thread and have that loop there.
Yeah, was just about to post that, found a little example that used a thread for networking. Because I want to start and stop the server with a button xD
That worked, thanks guys, you both rock.
:3 [QUOTE=quincy18;21775635]Yeah, was just about to post that, found a little example that used a thread for networking. Because I want to start and stop the server with a button xD[/QUOTE] For my networking needs there's usually asynchronous functions, working with events. But I dunno what data you're sending there, you'll know why you need a loop :)
[cpp]// Gradebook.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <fstream> #include <cstdlib> #include <string> #include <iomanip> using namespace std; int main() { fstream ClientFile("grades.tst", ios::in | ios::out | ios::binary ); fstream DBFile( "IDatabase.tst", ios::in | ios::out | ios::binary ); //Error checking! Checks to see if the file exists, if it doesn't, creates a new one. Initially uses ofstream than uses fstream so I don't waste space by adding a ifstream. if( !ClientFile ) { cerr << "Failure to find grades.tst, creating file."; ofstream outClientFile( "grades.tst", ios::out | ios::binary ); fstream ClientFile( "grades.tst", ios::in | ios::out | ios::binary ); } if( !DBFile ) { cerr << "Failure to find IDatabase.tst, creating file."; ofstream outDBFile( "IDatabase.tst", ios::out | ios::binary ); fstream DBFile( "IDatabase.tst", ios::in | ios::out | ios::binary ); } if( !DBFile ) { cerr << "FILE STILL DOESN'T EXIST"; } if( !ClientFile ) { cerr << "FILE STILL DOESN'T EXIST"; } void displaymessage(); int INPUT; int id; char firstname; char lastname; double grade; int A; string stuffName; cout << "Welcome to the Gradebook system designed by Kyle Devine, menu sortings are below." << endl << "1 - Grades" << endl << "2 - Instructions" << endl << "3 - Quit" << endl << "Just enter the number of the menu you want to enter" << endl; cin >> INPUT; if(INPUT = 1 || 2 || 3){ void displaymessage();} if(INPUT = 1) // Enter to the grade list, which than displays ID, name, than their grade in percent. Shows a wierd ass thing though { cout << "Welcome to the grade list, please wait while the ID file is loaded" << endl; //Creating a table for the list which is pulled from the file. cout << left << setw( 10 ) << "Account" << setw( 13 ) << "First Name" << setw( 13 ) << "First Name" << setw( 13 ) << "Balance" << endl << fixed; //Pull the data from the ID database and than list it DBFile >> id >> firstname >> lastname >> grade; //Displays the actual stuff, cin and getline allow you to add things to the DB list. Last one writes what you enter to the file cout << id << setw( 10 ) << lastname << setw( 13 ) << firstname << setw( 13 ) << grade << endl; cin >> stuffName; getline( cin, stuffName ); DBFile << stuffName; } }[/cpp] I optimized the code a bit, it actually outputs something but for some reason its a number and than the letters y and k. The thing I need help with is the fact that it outputs a very large number and two letters, y and k.
@ZeekyHBomb Is there a way to use 2D graphics but in 3D space? So the current screen would be like a plane that you could rotate in 3D. Something like, let's say, that game where you tilt the board with a ball on it and you have to get the ball to drop in a hole. I would draw 2D graphics on the board and only the board it self would be a 3D object. What would be the best way to do that?
Either a rendertarget as texture for your 3D object or decals on your 3D object, depending on the exact effect you wanna have.
I think render target will be good. I'll Google it, thanks.
It's a bit of a joke that there are still no OpenGL 3 or 4 documentation pages. "Under Construction..." That said for most stuff the 2.1 documentation suffices, and if you're half way serious reading the standards documents is a really good idea anyway. (Note they are really quite readable and informative, much more so than I expected before I started reading)
[URL="http://www.opengl.org/sdk/docs/man/"]What this?[/URL] Do you mean reading it from beginning to end? I only use reference pages about specific stuff I want to know. Do you think reading the whole thing is a good idea?
I'm trying to use SFML with VC++ 2010 and I'm failing miserably. I tried compiling the first tutorial, and I get these: [code] 1>------ Build started: Project: sfmltest2, Configuration: Debug Win32 ------ 1> sfmltest2.cpp 1>sfmltest2.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Window::~Window(void)" (??1Window@sf@@UAE@XZ) referenced in function _main 1>sfmltest2.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ) referenced in function _main 1>sfmltest2.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function _main 1>sfmltest2.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main 1>c:\users\owner\documents\visual studio 2010\Projects\sfmltest2\Debug\sfmltest2.exe : fatal error LNK1120: 4 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/code] Any ideas what I'm doing wrong?
Uh, well crap. If I'd seen this thread, I wouldn't have made this one: [url]http://www.facepunch.com/showthread.php?t=935531[/url] My bad.
[QUOTE=Darwin226;21814047][URL="http://www.opengl.org/sdk/docs/man/"]What this?[/URL] Do you mean reading it from beginning to end? I only use reference pages about specific stuff I want to know. Do you think reading the whole thing is a good idea?[/QUOTE] No, like I said that's really out of date. For OpenGL 2.1 only. When I said standards documents I meant the OpenGL specifications: [url]http://www.opengl.org/documentation/specs/[/url]
I'm making a Minecraft ripoff, and I've got a Block class array. Its size is 128 × 128 × 32. How would I get a certain block by having a certain X, Y and Z? I know how to do it in 2d... [cpp] BlockArray[x + width * y] [/cpp] But how would I turn this into 3D?
BlockArray[x + width * y + z * width * height] If my calculations are correct :D
[QUOTE=Darwin226;21833755]BlockArray[x + width * y + z * width * height] If my calculations are correct :D[/QUOTE] Thanks, that worked!
It's layers. If your field was only 1 block high you could use x + width * y since z would always be 0, now if you wanted to find the block on the 3rd layer you need to account those 2 layers of blocks above, each containing width * height blocks.
Sorry, you need to Log In to post a reply to this thread.