• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=robmaister12;36309561]GLTools is only really used for the first few chapters as a way to introduce OpenGL concepts before introducing the API itself (which can seem pretty daunting if you're an absolute beginner). I have the book and I absolutely love it for the last 2/3 of the book which very cleanly explains how to do some of the things that I have a hard time finding solutions to on the internet.[/QUOTE] i mean i can give it another try, but i have to jump through hoops to get it to compile on VC 10
[QUOTE=MickeyCantor;36310721]i mean i can give it another try, but i have to jump through hoops to get it to compile on VC 10[/QUOTE] If it's difficult to get it to work on VS2010, then learn the basics from one of the many great online tutorials for beginners. The stuff you find later in the book is very useful IMO, and having a physical copy of the OpenGL man pages is also very handy.
(Now with the correct thread!) So I've begun working on an android app that does all calculations related to first year chemistry. I've got most of the methods handling formulae down and complete, but I've run into a wall with building the UI. [url=http://www.manhack-arcade.net/Content_Pack/phone/Screenshot_2012-06-12-22-47-32.png]Here is what it currently looks like[/url], but I haven't really touched it since I'm unsure how to proceed. I'm very unsatisfied with my layout since I'm not sure how my layout should be shown. It looks a lot better on a 10" tablet (and landscape in general) where I have actually made headway due to the extra screen real estate allowing me more room to put stuff per group of elements, but the phone side of the GUI is stopping me dead.
Do I need a mac to develop an iPhone app, or can it be done on windows (without jailbreaking my phone)? [editline]13th June 2012[/editline] [QUOTE=MickeyCantor;36307268]Actually i have tried to use that, some of the code took reworking to compile on VS2010, they don't have the updated lib's for 2010, and they also restrict you to using their lib "GLTools" and im not a fan of that[/QUOTE] I initially used this book, and as you say it is quite outdated, and it also uses an inferior library for context/window-handling. I had to switch to a better one, but I did learn quite a lot from the book itself. I only read the first few chapters, though...
[QUOTE=Mordi;36311265]Do I need a mac to develop an iPhone app, or can it be done on windows (without jailbreaking my phone)?[/QUOTE] I can't speak from experience, but I think there are several platforms for developing apps on Windows (e.g. Adobe AIR). It is only possible to submit an app to the app store on a Mac though.
[QUOTE=Naelstrom;36302554]Do this instead: [cpp] //position. private float x = 50; private float y = 100; private float width = 50; private float height = 50; private float rot; function draw(GL10 gl) { gl.glPushMatrix(); gl.glTranslatef(x, y, 0); // Translated to 0. gl.glRotatef(rot, 0, 0, 1); rot+=1; // Drawing goes here... gl.glPopMatrix(); }[/cpp] Make sure your drawing calls are drawing at the origin though.[/QUOTE] It works now, thank you! However it rotated around it's left corner so i had to do this: [cpp] function draw(GL10 gl) { gl.glPushMatrix(); gl.glTranslatef(x+(width/2), y+(height/2), 0); // Translate to center. gl.glRotatef(rot, 0, 0, 1); gl.glTranslatef(x, y, 0); // Translate back. rot+=1; // Drawing goes here... gl.glPopMatrix(); } [/cpp] But now it likes to disappear again...
I'm using (abusing?) render-targets. Most of this is actually drawn first onto a rendertarget, and then all the rendertargets are drawn into another rendertarget. Does anyone know how I would fix the transparent black pixels? [IMG]http://i.snag.gy/oMXhy.jpg[/IMG] I am using GL_RGBA, like so: [cpp] glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, texRT[i], 0); [/cpp] And then I basically just draw the texture that I get from the framebuffer as a regular old quad. I did some google-searching, and it seems to be a known problem. But I could not find anyone who had solved it properly. Any ideas? Am I doing something horribly wrong?
I don't understand what the problem is. If it's that text in the bottom-left, are you sure it's not just a problem with font rasterization? Not a GL problem? [i]How[/i] are you actually drawing it? What blend mode?
[QUOTE=Mordi;36316160]I'm using (abusing?) render-targets. Most of this is actually drawn first onto a rendertarget, and then all the rendertargets are drawn into another rendertarget. Does anyone know how I would fix the transparent black pixels? [IMG]http://i.snag.gy/oMXhy.jpg[/IMG] I am using GL_RGBA, like so: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, texRT[i], 0); And then I basically just draw the texture that I get from the framebuffer as a regular old quad. I did some google-searching, and it seems to be a known problem. But I could not find anyone who had solved it properly. Any ideas? Am I doing something horribly wrong?[/QUOTE] Are you by any chance drawing the text with GDI? In any case, it's probably a AA issue.
So, I got extremely bored and decided to write a fairly simple interpreted programming language, to be put into Garry's Mod. Which is to say I am making a programming computer for Garry's Mod. This is done entirely through Lua. Right now, I am currently working on conditional statements. I have first-degree conditional statements working, but nested conditionals are throwing me off. The way I currently do conditionals is I store each conditional into its own table, where the actual "condition" is stored separately from the table of "lines." The lines within the conditional are not executed in realtime, but are stored in the conditional's table, and are executed if the conditions are met. Calculations as to whether conditions are met are run when the command "RUN" is sent to the "computer." However, this method only works for first-tier nested conditionals. I am setting up my own language for interpretation, and am trying to keep it fairly simple. Here is how you create a simple conditional that will increase one variable if its lower than another: [code]NUM a 1 NUM b 2 STARTIF a < b NUM a a { += 5 } ENDIF RUN[/code] I won't go into the details of why the variable declaration works that way, but just trust me that this works. This particular statement will increase "a" by 5, if "a" is less than "b". However, because of the way I handle first-tier conditional statements, I can do this: [code] NUM a 1 NUM b 2 NUM c 3 STARTIF a < b STARTIF b < c NUM a a { += 55 } NUM b b { += 5 } ENDIF ENDIF RUN[/code] And it will store the entire chunk from "STARTIF b<c" to the first "ENDIF" (inclusively) in the conditional table entry for "STARTIF a<b". However, if the "a<b" conditional is met, and it runs all those lines, the nested conditional sits and is never tested, because it isn't ran. If I include a "RUN" in there then it goes into an infinite loop, which is no good. I'll probably have to end up completely redoing how do I conditional statements, but I was wondering if anyone had any suggestions of more efficient ways to do it? Note that I've never done anything like this, and I am doing this more for personal entertainment and for learning. I'm sure I'm doing this in very backwards and asinine ways, but :v:.
use a proper parser
Here's an interesting question in my opinion: I've been following tutorials and reading books about programming for some time. I have no problem understanding most parts, however recently I came to a shocking discovery. I haven't made anything. Not a thing. What the hell? I don't even know where to start. I understand most of the programming stuff, but I have trouble applying it. Why? If I decided on the spot to make a C++ & SFML platformer, I'd have no idea where to start. A main loop sure. But then what? And how? ...help?
[QUOTE=Asgard;36323669]Here's an interesting question in my opinion: I've been following tutorials and reading books about programming for some time. I have no problem understanding most parts, however recently I came to a shocking discovery. I haven't made anything. Not a thing. What the hell? I don't even know where to start. I understand most of the programming stuff, but I have trouble applying it. Why? If I decided on the spot to make a C++ & SFML platformer, I'd have no idea where to start. A main loop sure. But then what? And how? ...help?[/QUOTE] Well, as a beginner project you could try to make some bouncing balls on a two dimensional horizontal surface. You would then hopefully learn how to create shapes, how to change their position, how to use classes and create classes(if you want to make a ball class). You'd also use conditional statements to check where it will hit and so on.
i'm really close to finishing my deferred renderer, i have all of the necessary info (pos/uv/normal/diffuse) stored to textures in an FBO, and i'm able to read the textures in my fragment buffer. i've checked the values against my forward shader to make sure all the light and position data is correct, and it seems that everything is in check. the NdotL, the light attenuation, etc are all valid when i check them, but i get hung up on one thing: my abilities to access and view this data is sporadic at best, for what reason i don't know. i think i read somewhere that if a variable isn't guaranteed to end up affecting the final color output of your fragment shader, the compiler will discard it and the data in it will be invalid at runtime. it seems like rubbish but it seems to sorta fall in line with the issues i'm having. for instance: if i strip out all the code in main() and just make it so i ONLY calculate things that will go into the final value of the attenuation, i get the correct output seen below: [img]http://i.imgur.com/yCbdC.png[/img] code: [cpp] void main() { vec4 f_pos = texture2D(fbo_pos, texCoords); float dist = length(lightPos - f_pos.xyz); float att = (1.0 / (constAtt + linAtt * dist + quadAtt * dist * dist) * lightPower); color = vec4(att, att, att, 1.0); } [/cpp] so all is well when there are no extra vars. however, if i simply enable the diffuse value, everything goes to bits: [img]http://i.imgur.com/YHtwq.png[/img] code: [cpp] void main() { vec4 f_pos = texture2D(fbo_pos, texCoords); vec4 f_diffuse = texture2D(fbo_diffuse, texCoords); float dist = length(lightPos - f_pos.xyz); float att = (1.0 / (constAtt + linAtt * dist + quadAtt * dist * dist) * lightPower); color = vec4(att, att, att, 1.0); } [/cpp] so it seems that for whatever reason, unless every value declared in my fragment shader somehow makes its way to the final color output, other vars become null and everything ceases to work! [B]fragment shader[/B] - vertex shader doesn't do anything relevant, don't worry about it [cpp] #version 330 // _MS = Model Space // _WS = World Space // _CS = Camera Space // vertex data out vec4 color; in vec2 texCoords; // texture samplers uniform sampler2D fbo_pos; uniform sampler2D fbo_diffuse; uniform sampler2D fbo_normal; uniform sampler2D fbo_texcoord; // light data uniform vec3 globalAmbient; uniform vec3 camPos; uniform vec3 lightPos; uniform vec3 lightDiffuse; uniform vec3 lightAmbient; uniform vec3 lightSpecular; uniform float lightPower; uniform float constAtt, linAtt, quadAtt; void main() { vec4 f_pos = texture2D(fbo_pos, texCoords); vec4 f_diffuse = texture2D(fbo_diffuse, texCoords); vec4 f_normal = texture2D(fbo_normal, texCoords); //vec4 f_texcoord = texture2D(fbo_texcoord, texCoords); color = f_diffuse * vec4(globalAmbient, 1.0); //vec4 specular = vec4(0.0, 0.0, 0.0, 0.0); vec3 lightDir = normalize(lightPos - f_pos.xyz); float NdotL = max(dot(f_normal.xyz, lightDir), 0.0); float dist = length(lightPos - f_pos.xyz); float att = (1.0 / (constAtt + linAtt * dist + quadAtt * dist * dist) * lightPower); // Calculate half-vector //vec3 L = normalize(lightPos - f_pos.xyz); //vec3 V = normalize(camPos - f_pos.xyz); //vec3 halfVector = normalize(L + V); if (att > 0.004) { color += att * (vec4(lightDiffuse, 1.0) * NdotL + vec4(lightAmbient, 1.0)); //float NdotHV = max(dot(f_normal, normalize(vec4(halfVector, 1.0))), 0.0); //color += att * vec4(lightSpecular, 1.0) * pow(NdotHV, 32.0); } //color += vec4(NdotL, NdotL, NdotL, 1.0); } [/cpp] [editline]14th June 2012[/editline] opengl / GLSL (#version 330) by the way [B]edit:[/B] fixed: you have to disable mipmapping on the FBO textures or else GLSL will fuck with your samplers: [url]http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control[/url] leaving post unsnipped if anyone else has the same issue
[QUOTE=rute;36312689]It works now, thank you! However it rotated around it's left corner so i had to do this: [cpp] function draw(GL10 gl) { gl.glPushMatrix(); gl.glTranslatef(x+(width/2), y+(height/2), 0); // Translate to center. gl.glRotatef(rot, 0, 0, 1); gl.glTranslatef(x, y, 0); // Translate back. rot+=1; // Drawing goes here... gl.glPopMatrix(); } [/cpp] But now it likes to disappear again...[/QUOTE] Remove the [code]gl.glTranslatef(x, y, 0); // Translate back.[/code] To change the origin of an object, you need to change it's vertices directly to be centered around 0,0,0. You can probably manage to change it with matrix magic, but I've never needed to do that.
[QUOTE=ROBO_DONUT;36316966]I don't understand what the problem is. If it's that text in the bottom-left, are you sure it's not just a problem with font rasterization? Not a GL problem? [/quote] Yep, I'm sure. I've been drawing fonts and sprites as they should for months now. Some days ago, I decided to implement rendertargets, and that's when the issue popped up. In the upper left corner you can see text that isn't rendered onto a rendertarget, and it looks normal. [quote] [i]How[/i] are you actually drawing it? What blend mode?[/QUOTE] I'm using this blend mode: [cpp]glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);[/cpp] I put my RenderTarget class up on Pastebin. Here you can see how I set it up, and how I draw it. [url]http://pastebin.com/zd9xQW4X[/url] This is basically how I handle it: [cpp] RT.Begin(); // draw stuff RT.End(); RT.Draw(); [/cpp] [QUOTE]Are you by any chance drawing the text with GDI? In any case, it's probably a AA issue.[/QUOTE] Hmm, I'm not using GDI (unless there is some automatic process for this via GLFW or GLEW). The text is first converted into a spritefont using FreeType, and then drawn as a texture. In the top left, it is drawn directly, without any rendertarget usage. As you can see, it draws fine on it's own. The problem lies somewhere in the process of drawing it onto a rendertarget, and drawing the rendertarget itself.
ok i have a pretty stupid issue, i feel like this is polymorphism 101 but i don't know how to solve it: see the following code: [cpp] class Parent { public: Parent(); ~Parent(); virtual void MyFunc(); } Parent::Parent() { MyFunc(); } void Parent::MyFunc() { std::cout << "Parent!" << std::endl; } // -------------------- class Child : public Parent { public: Child(); ~Child(); virtual void MyFunc(); } Child::Child() : Parent() {} void Child::MyFunc() { std::cout << "Child!" << std::endl; } [/cpp] the output of the program ends up as "Parent!", whereas i would expect/hope it to be "Child!" i want a parent class to call the overloaded version of a virtual function, however, the parent class only calls it's own version of the function. what's the dealio?
Child isn't derived from Parent.
[QUOTE=dajoh;36336016]Child isn't derived from Parent.[/QUOTE] haha sorry that was just me mucking up the example, in the actual code Child is derived from Parent lmao
Turns out that's just not how it works, expected it to work that way also at first glance. You need to call MyFunc() in Child to use the overloaded function.
shoot, well if thats the only way to do it i guess it's not much effort to copy and paste the original constructor and get things going thanks anyway
[QUOTE=Kopimi;36336089]shoot, well if thats the only way to do it i guess it's not much effort to copy and paste the original constructor and get things going thanks anyway[/QUOTE] That code looks like it should work. When you mark a function virtual, for each class that implements it, it should call the bottom-most-implementation's version of it, and then it's up to that implementation to see if it wants to call it's parents one. I dunno why it's not working for you though. [b]Edit:[/b] Are you actually creating an instance of the child?
Only works that way outside of the class, not inside.
[QUOTE=Lord Ned;36336125]That code looks like it should work. When you mark a function virtual, for each class that implements it, it should call the bottom-most-implementation's version of it, and then it's up to that implementation to see if it wants to call it's parents one. I dunno why it's not working for you though. [b]Edit:[/b] Are you actually creating an instance of the child?[/QUOTE] yeah i'm creating an instance of the child, sorry i just didn't include any of that in the example, wanted to keep it simple + i think dajoh is right, other virtual functions get called properly but only when they are referenced from someone other than the parent. it seems that a class will always call it's own virtual function, but everyone else will get the bottom-most override
[QUOTE=Kopimi;36336201]+ i think dajoh is right, other virtual functions get called properly but only when they are referenced from someone other than the parent. it seems that a class will always call it's own virtual function, but everyone else will get the bottom-most override[/QUOTE] [url=http://codepad.org/41mhiW2X]Nope.[/url] It only happens inside a constructor or destructor because you shouldn't call virtual methods inside them. [url]http://www.parashift.com/c%2B%2B-faq-lite/strange-inheritance.html#faq-23.5[/url]
[QUOTE=Mordi;36326322]I'm using this blend mode: [cpp]glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);[/cpp][/QUOTE] If you're drawing to a fully transparent buffer, then this is wrong. You want glBlendFunc(GL_ONE, GL_ZERO). Or just disable blending altogether.
Oh yeah ROBO_DONUT, long ago you helped me out with my multi-pass lighting technique. You told me I could be using stencil buffers, but I couldn't figure stencils out. Just so you know I've figured it out and it works pretty flawlessly now. It was hell to get working though, my video card didn't support just plain stencil buffers + color buffers attached to a FBO. It REQUIRED a depth buffer as well. [vid]http://bit.ly/KrcFGt[/vid] Feels good knowing it's as optimized as can be. I still need to code in more multi-platform capabilities though, my ATI friend kopini gets GL_INVALID_OPERATION's generated all over the place. At least it works ok. :u Thanks ROBO_DONUT.
No problem. :D And, AFAIK, very few (if any) video cards support stencil buffers without a depth buffer, so it's just not your specific hardware. Stencil-only formats were dropped entirely in GL3.
hey donut, since you're not on steam: i've implemented deferred shading in my engine, but i'm wondering how to get ambient lighting working properly. essentially i want a global ambient, like a baseline "minimum light level", which the other lights will add on top of. however, i can't see any way of doing this. if i multiply my diffuse by the global ambient in my lighting pass fragment shader, then when all of the passes are blended together, the ambient factor is added on top of itself and i end up with the ambient factor being multiplied by the number of lights being processed. i'm thinking of rendering my ambient light to a texture during the geometry pass, then in the lighting pass, rendering on top of that existing texture (thus making it so the ambient factor is only calculated once) and then finally rendering this texture to a quad, making the full scene, but im unsure on what would be the correct approach. should i add an ambient texture to my GBuffer, or create a separate texture to store the final lit scene before being rendered to a quad? wadda ya think?
I'm trying to make a chat thing in python and I have a problem... the script [url]https://gist.github.com/edbfc622eb7ab52a82ca[/url] When I open up client.py it works fine, but when I open up a 2nd one, it freezes saying [code]New connection from ('127.0.0.1', 52486), adding. Now have 2 connections Thread waiting to accept..[/code]
Sorry, you need to Log In to post a reply to this thread.