Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ninjamint

Pages: [1]
1
Graphics / SFSL - Work in progress.
« on: January 29, 2010, 12:39:14 am »
I'm going to call this SFSL, Simple Fast Shader Language, an extension to GLSL, it will not use any SFML, although, I will write tutorials on how to link the two, and you may add it to the wiki if you please.

By the way, is there a reason you decided to use ARB extensions, opposed to OpenGL 2.0?

Can we talk at all via MSN/AIM/Yahoo?

2
Graphics / SFSL - Work in progress.
« on: January 29, 2010, 12:00:53 am »
Ah, thanks! It appears the sampler, is not based on the texture ID as I thought, you have to set this information using glActiveTexture(GL_TEXTURE{0...N});
then
glBindTexture(...);

so, i'll have to rethink my strategy a little, but it's not a big change/problem. =]

3
Graphics / GLSL Multiple Textures
« on: January 28, 2010, 11:57:58 pm »
maaaybeh

** nevermind tho, fixed it **

4
Graphics / GLSL Multiple Textures
« on: January 28, 2010, 11:26:52 pm »
any idea about multi-textures & GLSL laurent?

5
Graphics / SFSL - Work in progress.
« on: January 28, 2010, 08:05:11 pm »
will do, though the reason I said I wanted to embed it into SFML directly, is due to situations where I want to set a GLSL sampler directly, the sampler is a pointer ( i think ) to the OpenGL resource ID, in this case its a texture.. meaning you can force it to change the targeted unit, simply by setting it via glUniform1i(sampler_location, opengl_resource_id);

problem here is, sf::Image, doesn't allow me to get the resource id, you create using glGenTextures(GLuint &id, int size);

so if I wanted to make my c++ syntax simular to

myShader.Properties["texture_resource"].SetValue(mySFImage);

then I'd have to cry, cause i wouldn't be able to access the ID..

I've not mastered opengl, so I'm not sure if there are any functions simular to glGetMatrixf(..) which returns the world matrix, that'll allow me to get the ID of the current binded texture(glGetBindedTextureID()??)

though from what I've learned so far, I'm almost positive there isn't.. so I'd like for you to help me out here. =]

6
Graphics / SFSL - Work in progress.
« on: January 28, 2010, 01:56:45 am »
SFSL, otherwise known as Simple Fast Shading Language, will make writing, compiling, and implementing OpenGL Shading Language(GLSL), into your C or C++ program easier than ever! When completed I will post the source & binaries download locations, for everyone to use freely. Currently, I can only offer an example as to how one might use this in its most simplest form. Which you'll see below.
 
SFSL Example
Code: [Select]

vec4 Color;

void myVertexShader()
{
gl_Vertex = gl_ModelViewProjectionMatrix * gl_Vertex;
}

void myFragmentShader()
{
gl_FragColor = Color;
}

// requires at least 1 material
material ExampleMaterial
{
// optional material booleans
AlphaEnabled = true;

// required material functions
VertexShader = myVertexShader();
FragmentShader = myFragmentShader();
}


C++ Example
Code: [Select]

sfsl::Shader myShader;

void initialize()
{
// load our shader from file
if(!myShader.LoadFromFile("example_shader.sfsl"))
{
std::cerr << sfsl::IO::GetLastError() << std::endl;
return;
}
}

....

void render()
{
// this will automatically get the last called material ( or first material ), unless a name is specified
sfsl::Material myMaterial = myShader.GetMaterial();

// enable the shader
myShader.Enable();
myMaterial.Enable();

// set our color property to red
float myColor[4] = { 1, 0, 0, 1 };
myMaterial.SetProperty("Color", myColor);

// draw the triangle
glBegin(GL_TRIANGLE);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(1, 1, 0);
glEnd();

// and disable the last called material ( or specify which one to disable by its name )
myMaterial.Disable();

// disable the shader
myShader.Disable();
}
[/code]

7
Graphics / GLSL Multiple Textures
« on: January 27, 2010, 06:01:44 pm »
Code: [Select]
// set wrapping & texture units
glActiveTexture( GL_TEXTURE0 );
glClientActiveTexture( GL_TEXTURE0 );
glEnable( GL_TEXTURE_2D );
myWater.Bind();
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable( GL_TEXTURE_2D );

glActiveTexture( GL_TEXTURE1 );
glClientActiveTexture( GL_TEXTURE1 );
glEnable( GL_TEXTURE_2D );
myCubeMap.Bind();
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable( GL_TEXTURE_2D );


this can't be correct... although it should be, right? I have 2 samplers in my GLSL only, only the first one though, is binding to "myWater", which makes since, but the second will not bind correctly =|

8
Graphics / [FIXED] sf::Image Deallocation? (future advise still liked)
« on: December 19, 2009, 02:23:21 am »
I'm viewing 3D models, and when doing so, every-time I change the model, a memory leak appears cause the memory usage is increased dramatically, with every new model thats loaded(perhaps this is because the new model doesn't use the same texture as the previous, and some sort of caching prevents the old textures from being de-allocated). Though, if I disable the textures(or they fail to load) the memory barely changes(it still constantly increases... meaning I have another memory leak somewhere, but its such a small increase, that I am not worried about it). However the textures cause the memory usage to increase by 1,000+ kb/s; and that's a problem as I run out of virtual memory quick. So, my current method of de-allocating the sf::Image is like this..

Code: [Select]
for(unsigned int i = 0; i < f.tex_fns.size(); ++i)
delete &f.sfTextures[i];
f.sfTextures = 0;


where f.sfTextures is a sf::Image *;

any help would be greatly appreciated!

well, I stopped using sf::Image*, and switched to using a std::vector<sf::Image>, and that fixed the problem.. >.> but if you know what was wrong before, please let me know, for future situations, cause I don't like using std::vector all the time lol

9
Graphics / SFML annoying warning, in SFML "GL_STACK_UNDERFLOW"
« on: December 15, 2009, 04:15:14 pm »
alright, thanks, doesn't help me solve the warning, but I'll head your instructions and remember using MatrixMode during the appropriate protocols, this isn't to much of a problem, and so I'm hoping you or someone else will read this message, so I can avoid making a new topic..


I'm attempting to draw a model, and then store the rendered screen into a texture, so I can draw it as a sprite(this way I can render several models, aligned to a grid on some GUI interface);

I tried using RenderImage, but even though in visual c++ when I type sf:: and the little window w/ all the different objects shows up and clearly says 'sf::RenderImage' exist, im getting compiler errors saying sf::RenderImage is not defined... imagine that, how would I go about rendering to a texture, if not RenderImage?

10
Graphics / SFML annoying warning, in SFML "GL_STACK_UNDERFLOW"
« on: December 15, 2009, 03:13:38 pm »
The warning I'm getting is:
"An internal OpenGL call failed in image.cpp (481) : GL_STACK_UNDERFLOW, this com
mand would cause a stack underflow"

The code:
Code: [Select]

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <iostream>

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

#pragma comment(lib, "zdll.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "sfml-system-d.lib")
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-graphics-d.lib")

#include "grfio.h"
#include "rsm.h"

sf::RenderWindow App;
rsm::file rsm_file;

sf::Font myFont;
sf::String myString;

void initialize()
{
if(!myFont.LoadFromFile("H:\\WINDOWS\\Fonts\\arial.ttf"))
printf("Failed to load font..\n");

myString = sf::String("", myFont, 12);

float cN = 1.0f / 255;
glClearColor(100 * cN, 149 * cN, 237 * cN, 1.0);

App.PreserveOpenGLStates(true);

glEnable(GL_DEPTH_TEST);
        glDepthMask(GL_TRUE);
        glClearDepth(1.f);

glCullFace(GL_BACK);

/* get our grf files ready */
char *filenames[1];
filenames[0] = "sdata.grf";
//filenames[1] = "data.grf";

grfio_init(filenames, 1);

/* lets load our first 3d model */
char* fname = "data\\model\\manuk\\¿î¿µÃ».rsm";
rsm_file.filename = fname;
int fsize = 0;
char* fdata = (char*)grfio_reads(fname, &fsize);

if(!rsm::load(rsm_file, fdata, fsize))
printf("rsm: failed <load %s>\n", fname);
}

void shutdown()
{
rsm::dispose(rsm_file);
App.Close();
grfio_final();
}

void changeSize(int w, int h)
{
float ratio = (float)w / h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45, ratio, 1, 1000);
}

float angle = 0.0f;
void renderScene(void)
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

glPushMatrix();
gluLookAt(0.0, 20.0,200.0, 0.0,20.0 + 0.0,200.0+-1.0, 0.0f,1.0f,0.0f);
glRotatef((angle += App.GetFrameTime() * 100.0f), 0, 1, 0);
glScalef(1, -1, -1);
rsm::render_rsm(rsm_file);
glPopMatrix();

glPushMatrix();
myString.SetText(rsm_file.filename);
myString.SetPosition(10, 10);
App.Draw(myString);
glPopMatrix();

}

int main(int argc, char **argv)
{
sf::WindowSettings Settings;
Settings.DepthBits         = 24;
Settings.StencilBits       = 8;
Settings.AntialiasingLevel = 2;
App.Create(sf::VideoMode(640, 480, 32), "RO Engineer", sf::Style::Close, Settings);
changeSize(App.GetWidth(), App.GetHeight());

initialize();
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
shutdown();

if (Event.Type == sf::Event::Resized)
changeSize(Event.Size.Width, Event.Size.Height);
}

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
App.SetActive();
renderScene();
App.Display();
}

return 0;
}


The important bits:
(That cause the warning)

[ COMMENT 1 ]
if the fallowing code is placed here, then the warning is shown EVERY frame

"    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();"

however, if I place the above code where you see [ COMMENT 2 ]
the warning only shows its ugly head once... interesting phenomenon

Code: [Select]

float angle = 0.0f;
void renderScene(void)
{
        // [ COMMENT 1 ]
glPushMatrix();
        // [ COMMENT 2 ]
gluLookAt(0.0, 20.0,200.0, 0.0,20.0 + 0.0,200.0+-1.0, 0.0f,1.0f,0.0f);
glRotatef((angle += App.GetFrameTime() * 100.0f), 0, 1, 0);
glScalef(1, -1, -1);
rsm::render_rsm(rsm_file);
glPopMatrix();

glPushMatrix();
myString.SetText(rsm_file.filename);
myString.SetPosition(10, 10);
App.Draw(myString);
glPopMatrix();
}


Of course, it's only appearing(along w/ other conflictions between SFML and my code) when I added the sf::String class; which is defined here
Code: [Select]

// outside everything
sf::String myString;

// in the initialization function
myString = sf::String("", myFont, 12);


I hope someone know why this warning occures, and might have some insight on how I may prevent it..

[ SIDE QUESTION ]
Also, if I don't use "glMatrixMode(GL_MODELVIEW);" before rendering my 3d stuff, for some reason it conflict with App.Draw() routine, and not render properly.. so I'm forced to add the glMatrixMode(); does anyone know a way around this, or the proper steps I should be taking to use my code around SFML?

11
Graphics / Access Violation, and Sprite Clipping?
« on: April 27, 2009, 11:45:52 am »
I guess you did, but I didn't really like them.. >_> I'll look through the source and maybe write my own string class to handle this. e_e

Thanks!

Edit: I guess I cannot look through the source as it's not open to public, or I cannot find it.

12
Graphics / Access Violation, and Sprite Clipping?
« on: April 27, 2009, 11:41:31 am »
I would like to 'clip' my 'sf::String' so that it only renders part of the string texture;

Rather then displaying the entire string, only displaying the first 100pixels, opposed to simply erasing characters that exceed or lay on the 100th pixel..
I need this for proper 'scrolling' when  create my text-box;

Though you say that isn't the case, so how else might I do this?

Note: A friend told me 'SubRect' was to render only a region of some image, which in that scenerio it made since.. (he's been using SFML via the .Net wrapper)

13
Graphics / Access Violation, and Sprite Clipping?
« on: April 27, 2009, 11:21:25 am »
SubRect method exist within the sf::Sprite class, though not within the sf::String class, any reason for this? Can this please be implemented..?

14
Graphics / Access Violation, and Sprite Clipping?
« on: April 25, 2009, 01:07:23 am »
@"Is it happening at global exit, or really on window.Close()? Have you tried your debugger?" :

If I close the application using the consoles 'close' icon there are no issues, if I close it using the SFML Window Close event via sf::RenderWindow.Close() then I get the error.

@"The roadmap has the answer Wink" : what? lol I'll search for 'roadmap' >_>

15
Graphics / Access Violation, and Sprite Clipping?
« on: April 24, 2009, 11:11:00 pm »
I am getting an access violation when the window closes, I'm only calling it once; I do have multiple sprites/images which I've read on here might cause the error. The thread I read about this didn't have a clear solution, has this issue been resolved?

The other question is about object clipping. Only rendering a specific region(rectangle) within the sprite. Is this going to be included in any future updates? Is there some per-built way I can clip/mask the objects? At the moment I need this for my Text-Box;

I want any part of the string to be clipped once exceeding the components Size bounds; Though I do not wanna do this simply by removing characters out of the bounds, I would like to add pixel-scrolling; So I'd like to see parts of a character clipped out, rather then individual characters.

P.S : Has the Joy-Stick issue has been resolved?

Pages: [1]
anything