Giter Site home page Giter Site logo

vitagl's People

Contributors

bythos14 avatar electric1447 avatar fgsfdsfgs avatar frangarcj avatar georgewaraw avatar nikarh avatar rinnegatamante avatar rrhyacinth avatar scribam avatar shroomking avatar theofficialflow avatar usineur avatar v-atamanenko avatar zenoarrows avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vitagl's Issues

Scissor testing is broken

As the title states, scissor testing was broken since sceGxmSetRegionClip will adjust sizes to be multiple of 32.
To solve this, i swapped to perform scissor testing by taking advantage of the mask bit in the depth surface however scissor test seems to be still broken.

Compiling problem with last couple of changes

Unsure if this is because I'm compiling on windows, however issues arise with vitagl.c

When on line 941 using this code: SCE_GXM_DEPTH_STENCIL_FORMAT_DF32M_S8,

fails to compile - removing the M

IE: SCE_GXM_DEPTH_STENCIL_FORMAT_DF32_S8,

This lets is compile fine on windows, is this an error with windows or the code?

game build error

arm-vita-eabi/lib\libvitaGL.a(vgl.o) uses VFP register arguments, companion does not

game build error

arm-vita-eabi/lib\libvitaGL.a(vgl.o) uses VFP register arguments, companion does not

commits in b288b8d cause 'blocky' textures.

While compiling vitaquake with the latest update, the game has now git what I can only call 'blocky' textures while playing. Reverting back to 1359762 and installing, then compiling vitaquake makes the textures appear as normal again.

I have the latest vitasdk/headers etc.

Mipmaps for NPOT textures are broken

NPOT textures work fine by themselves, but all miplevels higher than 0 seem to contain garbage (other textures seem to bleed into them). Maybe mipmaps are not properly aligned or are generated without taking proper stride into account? Turning on NPOT textures in Xash gives me a large memory usage decrease, so I'm interested in making this work. Both glGenerateMipmap and manual mipmap generation give the same results, which is expected.

2018-03-17-045721

2018-03-17-045736

2018-03-17-050707

glLoadMatrixf ordering

glLoadMatrixf order seems to be incorrect or buggy at some extents:

Observed behaviours:

  • Using (*matrix)[i][j] = m[i*4+j]; results in vitaHexenII and vitaQuakeII to have no visual glitches however 3D renderer of vitaQuakeIII is completely faulty.
  • Using (*matrix)[i][j] = m[j*4+i]; results in vitaQuakeIII 3D renderer to work fine but vitaQuakeII doesn't render semi-transparent windows and water and vitaHexenII doesn't render semi-transparent water (or better, it seems it gets rendered wrong since it can be noticed a line of the same color of the water in vitaHexenII) and doesn't render player model.

vitaHexenII in the first scenario:
2019-01-13-121809

vitaHexenII in the second scenario (notice the line on the left side of the screen):
2019-01-12-233236

Having issues loading shaders

Hi! Great work!
Im trying to follow a simple case with OpenGL.
I´m trying to draw a triangle and paint it using shaders. However I´m doing something wrong and I don´t know what is the problem.
Here is the source code in C:

// Drawing a triangle on screen with vertex array

#include <stdlib.h>
#include <stdio.h>


#include <vitaGL.h>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>

// An array of 3 vectors which represents 3 vertices
static const float g_vertex_buffer_data[] = {
   -1.0f, -1.0f, 0.0f,
   1.0f, -1.0f, 0.0f,
   0.0f,  1.0f, 0.0f,
};

static const float colors[] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0};

char *file_contents(const char *path);


char *file_contents(const char *path) {
	FILE *f = fopen(path, "r");
	// Read file size
	fseek(f, 0, SEEK_END);
	long fsize = ftell(f);
	fseek(f, 0, SEEK_SET);  /* same as rewind(f); */

	char *string = (char *)malloc(fsize + 1);
	fread(string, 1, fsize, f);
	
	fclose(f);
	
	return string;
}


GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path){

	// Create the shaders
	GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
	GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
	
	GLint Result = GL_FALSE;
	int InfoLogLength;

	// Compile Vertex Shader
	printf("Compiling shader : %s\n", vertex_file_path);
	//GLchar *vertex_code;
	char *vertex_code = file_contents(vertex_file_path);
	//vertex_code = ;
	//strcpy(vertex_code, VertexShaderCode.c_str());
	const int32_t vertexSourceSize = strlen(vertex_code);
	glShaderSource(VertexShaderID, 1, &vertex_code , NULL);
	glCompileShader(VertexShaderID);
	// Check Vertex Shader
	glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
	
	if (!Result) {
		printf("Cant compile vertex code: %s\n", vertex_code);
	}	
	
	if ( InfoLogLength > 0 ){
		std::vector<char> VertexShaderErrorMessage(InfoLogLength+1);
		glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]);
		printf("%s\n", &VertexShaderErrorMessage[0]);
	}

	// Compile Fragment Shader
	printf("Compiling shader : %s\n", fragment_file_path);
	//GLchar *fragment_code;
	char *fragment_code = file_contents(fragment_file_path);
	printf("Codigo fragment: %s", fragment_code);
	
	const int32_t fragmentSourceSize = strlen(fragment_code);
	glShaderSource(FragmentShaderID, 1, &fragment_code , &fragmentSourceSize);
	glCompileShader(FragmentShaderID);

	// Check Fragment Shader
	glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
	
	if (!Result) {
		printf("Cant compile fragment code: %s\n", vertex_code);
	}	
	
	glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
	if ( InfoLogLength > 0 ){
		std::vector<char> FragmentShaderErrorMessage(InfoLogLength+1);
		glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]);
		printf("%s\n", &FragmentShaderErrorMessage[0]);
	}

	// Link the program
	printf("Linking program\n");
	GLuint ProgramID = glCreateProgram();
	printf("Program:%d\n", ProgramID);
	glAttachShader(ProgramID, FragmentShaderID);
	glAttachShader(ProgramID, VertexShaderID);
	
	glLinkProgram(ProgramID);

	// Check the program
	/*
	glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
	glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
	if ( InfoLogLength > 0 ){
		std::vector<char> ProgramErrorMessage(InfoLogLength+1);
		glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]);
		printf("%s\n", &ProgramErrorMessage[0]);
	}
	*/
	
	
	//glDetachShader(ProgramID, VertexShaderID);
	//glDetachShader(ProgramID, FragmentShaderID);
	
	glDeleteShader(VertexShaderID);
	glDeleteShader(FragmentShaderID);

	return ProgramID;
}

void check_for_shader_compiler() {
    if(!vglHasRuntimeShaderCompiler()) {
        SceMsgDialogParam param;
        sceMsgDialogParamInit(&param);

        SceMsgDialogUserMessageParam user_msg;
        memset(&user_msg, 0, sizeof(SceMsgDialogUserMessageParam));
        user_msg.msg =  "You do not have the runtime shader compiler installed. It must be installed to run this program.\n\n"
                        "Please check the README.md in the repository for a link to instructions on installing it.";
        user_msg.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_OK;

        param.userMsgParam = &user_msg;
        param.mode = SCE_MSG_DIALOG_MODE_USER_MSG;
        sceMsgDialogInit(&param);

        while (sceMsgDialogGetStatus() != SCE_COMMON_DIALOG_STATUS_FINISHED) {
            vglStartRendering();
            glClear(GL_COLOR_BUFFER_BIT);
            vglStopRenderingInit();
            vglUpdateCommonDialog();
            vglStopRenderingTerm();
        }
        sceKernelExitProcess(0);
    }
}

int main(){
	
	vglEnableRuntimeShaderCompiler(GL_TRUE);
    vglUseVram(GL_TRUE);
    vglWaitVblankStart(GL_TRUE);
	
	
	// Initializing graphics device
	vglInit(0x800000);
	check_for_shader_compiler();
	
	glEnable(GL_DEPTH_TEST);
	
	glClearColor (0.0f, 1.0f, 0.0f, 1.0f);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1, 1, -1, 1, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	GLuint programID = LoadShaders( "app0:vertex.shader", "app0:fragment.shader" );
	
	
	
	for (;;){
		
		
		vglStartRendering();
		glClear(GL_COLOR_BUFFER_BIT);
		
		
		//vglEnableVertexAttribArray(0);
		glEnableClientState(GL_VERTEX_ARRAY);
		glUseProgram(programID);
		//glEnableClientState(GL_COLOR_ARRAY);
		
		glVertexPointer(3, GL_FLOAT, 0, g_vertex_buffer_data);
		//glColorPointer(3, GL_FLOAT, 0, colors);
		
		//glDrawObjects(GL_TRIANGLES, 0, 3);
		
		glDrawArrays(GL_TRIANGLES, 0, 3);
		
		glDisableClientState(GL_COLOR_ARRAY);
		
		vglStopRendering();
		glLoadIdentity();
	}
	
	vglEnd();
	
}

... And here is the shaders:
fragment.shader

float4 main(uniform float4 uClearColor) : COLOR
{
	return float4(0.0, 0.0, 1.0, 1.0);
}

vertex shader

void main(float3 aPosition,
	float4 aColor,
	uniform float4x4 wvp,
	float4 out vPosition : POSITION,
	float4 out vColor : COLOR)
{
	vPosition = float4(aPosition, 1.f);
}

This only gives a white triangle.
With Vita3K I can see they are compiling, but I don´t what is the problem!.

Thanks a lot!

Debug Text / Font loading and rendering text.

Just an enhancement that can be added later.

This was really handy in LPP and would save a lot of time for debugging issues.

vita2D has this but it might cause problems so it'd be better to implement it in vitaGL.

Clip Planes bug

Clip Planes are still bugged (probably an issue with depth.).

Ps1 emulator

Hello Rinnegatamante,

i’m sorry to use an issue to talk to you but Twitter doesnt allow for long messages.

Thank you for this awesome port and for everything you ve done in the past.

I’m just wondring if you mind porting pcsx rermed or duckstation to psvita.

i know that ps1 emulation is already a reality thanks to adrenaline but its too limited, and with vitagl you can achive better result.

the reason why we need a proper ps1 emulator are simple:

  • native vita resolution (maybe 720p for pstv?)
  • improved hz and fps
  • Texture replacing
  • fix for geometry problems due to ps1 hardware limitations
  • a lot of improvements over Sony official emulator

Duckstation already support aarch32 arm v7 but i dont know if its compatible with vitagl.

Pcsx rearmed has already been ported to vita by retroarch team, but with native resolution it works too bad (seems that they dont use vitagl).

Thank you anyway

have a good day

Can't compile samples

Hello,

I'm unable to compile samples. Get this error on first sample: error: 'GL_VITA2D_TEXTURE' undeclared here.

No problem for compiling vitaGL.
Tried to reinstall vitasdk but no changes.

I'm missing something but don't know what.

Undefined reference to `vglHasRuntimeShaderCompiler'

First off, thank you for the hard work. I'm compiling a program and keep encountering an error with this being the result when compiling SM64-vita. It seems to originate in something added to the newest build in terms of shader compilation. If the issue is with my setup please let me know. I have confirmed the vitasdk is up-to-date and works with the samples being used. If i have to copy a file off of my vita let me know.

Here is a quick error output for reference.

/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.1.0/../../../../arm-vita-eabi/bin/ld: build/us_vita/src/pc/gfx/gfx_vitagl.o: in function check_for_shader_compiler': gfx_vitagl.c:(.text+0x1194): undefined reference to vglHasRuntimeShaderCompiler'
collect2: error: ld returned 1 exit status
make: *** [Makefile:860: build/us_vita/sm64.us.f3dex2e] Error 1

Porting to Wii U/3DS

How complex do you think porting it to the Wii U and/or 3DS homebew SDKs would be ?
Because both kind of lack real opengl support apart from opengl 1.1 which makes porting game engines etc to the platforms fairly difficult

Runtime shader compiler support

Hello @Rinnegatamante, first of all thank you for the nice work you've done with vitaGL!

I've managed to get SceShaccCg working in VitaQuakeII. (Thanks to @frangarcj, I used his vitahelloshader as a starting point).
You can view my changes here.

What are the current blocks from integrating runtime shader compiler support in vitaGL and have glCompileShader? I'm guessing it's how users can obtain the needed module. Maybe we can have an installer app that can extract the module from official fw pub file? The PSM compatibility packs seem to have it too.

Also while working on this, I did notice that SceShaccCg is a stripped down version of psp2cgc. It doesn't support Cg extensions like defining column_major for storage. We can use transpose function in the shader as an alternative though.

Can let me know what's needed. I'd like to help!

Porting of PSP glib2d

Hi,

Nice job! Do you think is possible to implement the GL_CLAMP flag in vitaGL? I am trying to port glib2d (https://github.com/KapLex/gLib2D_PC) and i believe without that we want be able to draw part of the texture as a sprite.

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, rctx.use_tex_linear ? GL_REPEAT : GL_CLAMP);

Regards
Nicholas

CppCheck Fixes

Hi,

I ran vitaGL through Cppcheck and there seems to be quick a few issues, that seem to be actual issues but would need to your guidance as they might be intended.

Here's an example subset:
image

CppCheck issues

Ran cppcheck.net against the latest vitagl master and there's a number of issues that look real.

Example but there are a few, might be worth installing the app in case it helps.

Thanks

image

image
vitagl.txt

OpenGL Additions

Hi @Rinnegatamante , very cool work you've been doing in regards to the Vita scene as a whole. =)

Just getting into Vita development, as I'm on a quest to port my engine EDGE to Vita. EDGE is an enhanced, GPL-licensed, OpenGL only port of id Tech 1; think of it as an in-between of GZDoom and Eternity.

So - you having developed a wrapper for OpenGL - I decided to take my hand and begin a slow port to the Vita, which is one of my favorite platforms.

However I do have some requests for some older and newer implementations of GL into vitaGL:

The below functions are older OpenGL. In the case of GL_POLYGON, I suppose I can swap that code to just use GL_TRIANGLE_FAN, but just throwing it out there:

GL_LINE_SMOOTH
GL_POLYGON

The next two are OpenGL2. I know you have the float variations implemented:

glVertex2i
glVertex3i

The below functions are used for swapping buffers in regards to Post-Processing shaders (newer GL functions), primarily used for Camera Exposure, Blooming the scene, and lens distortion. These are used here and here.

glUniform1i
glUniform4iv
glUniform4f

GL_DRAW_FRAMEBUFFER
GL_READ_FRAMEBUFFER
glBindFramebuffer
glBlitFramebuffer

Thank you for your hard work again! I look forward to your response and/or any help I can get.

Unable to link vitaGL on macOS

I am unable to compile samples on macOS with newest VitaSDK. I can compile the library without any problems but I get this linking error when I'm building vitaGL samples:

/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/7.3.0/../../../../arm-vita-eabi/lib/libvitaGL.a: error adding symbols: Malformed archive collect2: error: ld returned 1 exit status make: *** [vitaGL-Sample002.elf] Error 1

I tried both master and code_refactor branches. I can link other libs without any issues.

macOS 10.13.4
VitaSDK master-osx-v774 (same problem with older releases)

glScissor is still broken

Seems glScissor is still faulty and sometimes doesn't properly clip the screen. An easy way to test this is to try imgui-vita demo app.

cant compile samples [2]

Hello Rinnegatamente, I've installed vitagl on my vitasdk on linux emulated thanks to msys64 but can not compile samples

I successfully compiled every samples in vitasdk/samples so the problem is from here I think

Camille@LAPTOP-02QKF6SS MSYS ~/vdpm/vitaGL/samples/sample2 $ make arm-vita-eabi-gcc -g -Wl,-q -O2 -c -o main.o main.c arm-vita-eabi-gcc -g -Wl,-q -O2 main.o -lvitaGL -lc -lSceCommonDialog_stub -lm -lSceGxm_stub -lSceDisplay_stub -o vitaGL-Sample002.elf c:/msys64/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/8.2.0/../../../../arm-vita-eabi/bin/ld.exe: C:\msys64\tmp\ccKU3FNkdebugobjtem: file not recognized: file truncated collect2.exe: error: ld returned 1 exit status lto-wrapper.exe: fatal error: C:\msys64\usr\local\vitasdk\bin\arm-vita-eabi-gcc.exe returned 1 exit status compilation terminated. c:/msys64/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/8.2.0/../../../../arm-vita-eabi/bin/ld.exe: error: lto-wrapper failed collect2.exe: error: ld returned 1 exit status make: *** [Makefile:38: vitaGL-Sample002.elf] Error 1

Possible Source engine port?

Hello there! I dont know how contact directly you, so i wrote here. Feel free to delete this if is not relevant.
Recently a user called nillerusr release here on github a working port of source engine to android, making half life 2 and portal working on all android smartphone.
Apparently it can use gles 2.0 or gles 1.0
It will be awesome if someone will port it to ps vita making half life 2 playable in this console and I think that if it's possible, you certainly can do it
Here the source of source engine port.
Have a good day and because we are italian, WLF :)

Sorry is not an issue. version of opengl?

Hi, thanks for your good work. I want to develope something 3d in vita, but unity is imposible without sony license and i will try your vitagl lib. In which version of opengl is based?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.