Skip to content

Commit 6985845

Browse files
MarioGabIFPMarioGabIFP
MarioGabIFP
authored and
MarioGabIFP
committed
Proyecto base; Añadida API LWJGL
0 parents  commit 6985845

File tree

97 files changed

+4336
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4336
-0
lines changed

.metadata/.lock

Whitespace-only changes.

.metadata/.log

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
!SESSION 2022-03-11 13:37:11.775 -----------------------------------------------
2+
eclipse.buildId=4.21.0.I20210906-0500
3+
java.version=16.0.1
4+
java.vendor=Oracle Corporation
5+
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=es_ES
6+
Framework arguments: -product org.eclipse.epp.package.java.product
7+
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
8+
9+
!ENTRY org.eclipse.jface 2 0 2022-03-11 13:37:32.215
10+
!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.
11+
!SUBENTRY 1 org.eclipse.jface 2 0 2022-03-11 13:37:32.215
12+
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
13+
Binding(CTRL+SHIFT+T,
14+
ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
15+
Open a type in a Java editor,
16+
Category(org.eclipse.ui.category.navigate,Navigate,null,true),
17+
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@38b54694,
18+
,,true),null),
19+
org.eclipse.ui.defaultAcceleratorConfiguration,
20+
org.eclipse.ui.contexts.window,,,system)
21+
Binding(CTRL+SHIFT+T,
22+
ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
23+
,
24+
Category(org.eclipse.lsp4e.category,Language Servers,null,true),
25+
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@7619fbe7,
26+
,,true),null),
27+
org.eclipse.ui.defaultAcceleratorConfiguration,
28+
org.eclipse.ui.contexts.window,,,system)
29+
30+
!ENTRY org.eclipse.egit.ui 2 0 2022-03-11 13:37:35.201
31+
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
32+
user global configuration and to define the default location to store repositories: 'C:\Users\mario'. If this is
33+
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
34+
EGit might behave differently since they see different configuration options.
35+
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
36+
!SESSION 2022-03-11 13:38:06.445 -----------------------------------------------
37+
eclipse.buildId=4.21.0.I20210906-0500
38+
java.version=16.0.1
39+
java.vendor=Oracle Corporation
40+
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=es_ES
41+
Framework arguments: -product org.eclipse.epp.package.java.product
42+
Command-line arguments: -data file:/C:/Users/mario/Documents/GitHub/MarioGabIFP/Super_Paco_Bros/ -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
43+
44+
!ENTRY org.eclipse.jface 2 0 2022-03-11 13:38:09.163
45+
!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.
46+
!SUBENTRY 1 org.eclipse.jface 2 0 2022-03-11 13:38:09.163
47+
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
48+
Binding(CTRL+SHIFT+T,
49+
ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
50+
Open a type in a Java editor,
51+
Category(org.eclipse.ui.category.navigate,Navigate,null,true),
52+
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@549d14fe,
53+
,,true),null),
54+
org.eclipse.ui.defaultAcceleratorConfiguration,
55+
org.eclipse.ui.contexts.window,,,system)
56+
Binding(CTRL+SHIFT+T,
57+
ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
58+
,
59+
Category(org.eclipse.lsp4e.category,Language Servers,null,true),
60+
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@77d54a41,
61+
,,true),null),
62+
org.eclipse.ui.defaultAcceleratorConfiguration,
63+
org.eclipse.ui.contexts.window,,,system)
64+
65+
!ENTRY org.eclipse.egit.ui 2 0 2022-03-11 13:38:11.161
66+
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
67+
user global configuration and to define the default location to store repositories: 'C:\Users\mario'. If this is
68+
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
69+
EGit might behave differently since they see different configuration options.
70+
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
71+
72+
!ENTRY org.eclipse.ui.ide 4 4 2022-03-11 14:44:39.374
73+
!MESSAGE Not properly disposed SWT resource
74+
!STACK 0
75+
java.lang.Error: SWT Resource was not properly disposed
76+
at org.eclipse.swt.graphics.Resource.initNonDisposeTracking(Resource.java:172)
77+
at org.eclipse.swt.graphics.Resource.<init>(Resource.java:120)
78+
at org.eclipse.swt.graphics.Image.<init>(Image.java:683)
79+
at org.eclipse.jface.resource.URLImageDescriptor.createImage(URLImageDescriptor.java:274)
80+
at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:287)
81+
at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:265)
82+
at org.eclipse.pde.internal.ui.util.SharedLabelProvider.createImage(SharedLabelProvider.java:114)
83+
at org.eclipse.pde.internal.ui.util.SharedLabelProvider.get(SharedLabelProvider.java:90)
84+
at org.eclipse.pde.internal.ui.util.SharedLabelProvider.get(SharedLabelProvider.java:79)
85+
at org.eclipse.pde.internal.ui.correction.java.SearchRepositoriesForIUProposal.getImage(SearchRepositoriesForIUProposal.java:75)
86+
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.createCompletionProposalLink(AbstractAnnotationHover.java:492)
87+
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.createCompletionProposalsList(AbstractAnnotationHover.java:396)
88+
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.createCompletionProposalsControl(AbstractAnnotationHover.java:377)
89+
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:306)
90+
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:190)
91+
at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1151)
92+
at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1120)
93+
at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:884)
94+
at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:237)
95+
at org.eclipse.jface.text.TextViewerHoverManager.lambda$3(TextViewerHoverManager.java:227)
96+
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
97+
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
98+
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4029)
99+
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3629)
100+
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
101+
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
102+
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1041)
103+
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
104+
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
105+
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
106+
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
107+
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
108+
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
109+
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
110+
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
111+
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
112+
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
113+
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
114+
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
115+
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
116+
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
117+
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
118+
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
119+
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
120+
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
121+
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package controller;
2+
import org.lwjgl.*;
3+
import org.lwjgl.glfw.*;
4+
import org.lwjgl.opengl.*;
5+
import org.lwjgl.system.*;
6+
7+
import java.nio.*;
8+
9+
import static org.lwjgl.glfw.Callbacks.*;
10+
import static org.lwjgl.glfw.GLFW.*;
11+
import static org.lwjgl.opengl.GL11.*;
12+
import static org.lwjgl.system.MemoryStack.*;
13+
import static org.lwjgl.system.MemoryUtil.*;
14+
15+
public class HelloWorld {
16+
17+
// The window handle
18+
private long window;
19+
20+
public void run() {
21+
System.out.println("Hello LWJGL " + Version.getVersion() + "!");
22+
23+
init();
24+
loop();
25+
26+
// Free the window callbacks and destroy the window
27+
glfwFreeCallbacks(window);
28+
glfwDestroyWindow(window);
29+
30+
// Terminate GLFW and free the error callback
31+
glfwTerminate();
32+
glfwSetErrorCallback(null).free();
33+
}
34+
35+
private void init() {
36+
// Setup an error callback. The default implementation
37+
// will print the error message in System.err.
38+
GLFWErrorCallback.createPrint(System.err).set();
39+
40+
// Initialize GLFW. Most GLFW functions will not work before doing this.
41+
if ( !glfwInit() )
42+
throw new IllegalStateException("Unable to initialize GLFW");
43+
44+
// Configure GLFW
45+
glfwDefaultWindowHints(); // optional, the current window hints are already the default
46+
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
47+
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
48+
49+
// Create the window
50+
window = glfwCreateWindow(300, 300, "Hello World!", NULL, NULL);
51+
if ( window == NULL )
52+
throw new RuntimeException("Failed to create the GLFW window");
53+
54+
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
55+
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
56+
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
57+
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
58+
});
59+
60+
// Get the thread stack and push a new frame
61+
try ( MemoryStack stack = stackPush() ) {
62+
IntBuffer pWidth = stack.mallocInt(1); // int*
63+
IntBuffer pHeight = stack.mallocInt(1); // int*
64+
65+
// Get the window size passed to glfwCreateWindow
66+
glfwGetWindowSize(window, pWidth, pHeight);
67+
68+
// Get the resolution of the primary monitor
69+
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
70+
71+
// Center the window
72+
glfwSetWindowPos(
73+
window,
74+
(vidmode.width() - pWidth.get(0)) / 2,
75+
(vidmode.height() - pHeight.get(0)) / 2
76+
);
77+
} // the stack frame is popped automatically
78+
79+
// Make the OpenGL context current
80+
glfwMakeContextCurrent(window);
81+
// Enable v-sync
82+
glfwSwapInterval(1);
83+
84+
// Make the window visible
85+
glfwShowWindow(window);
86+
}
87+
88+
private void loop() {
89+
// This line is critical for LWJGL's interoperation with GLFW's
90+
// OpenGL context, or any context that is managed externally.
91+
// LWJGL detects the context that is current in the current thread,
92+
// creates the GLCapabilities instance and makes the OpenGL
93+
// bindings available for use.
94+
GL.createCapabilities();
95+
96+
// Set the clear color
97+
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
98+
99+
// Run the rendering loop until the user has attempted to close
100+
// the window or has pressed the ESCAPE key.
101+
while ( !glfwWindowShouldClose(window) ) {
102+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
103+
104+
glfwSwapBuffers(window); // swap the color buffers
105+
106+
// Poll for window events. The key callback above will only be
107+
// invoked during this call.
108+
glfwPollEvents();
109+
}
110+
}
111+
112+
public static void main(String[] args) {
113+
new HelloWorld().run();
114+
}
115+
116+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package controller;
2+
3+
import org.lwjgl.*;
4+
import org.lwjgl.glfw.*;
5+
import org.lwjgl.opengl.*;
6+
import org.lwjgl.system.*;
7+
import java.nio.*;
8+
import static org.lwjgl.glfw.Callbacks.*;
9+
import static org.lwjgl.glfw.GLFW.*;
10+
import static org.lwjgl.opengl.GL11.*;
11+
import static org.lwjgl.system.MemoryStack.*;
12+
import static org.lwjgl.system.MemoryUtil.*;
13+
14+
public class PacoMotor {
15+
16+
// The window handle
17+
private long window;
18+
19+
public void run() {
20+
System.out.println("Hello LWJGL " + Version.getVersion() + "!");
21+
22+
init();
23+
loop();
24+
25+
// Free the window callbacks and destroy the window
26+
glfwFreeCallbacks(window);
27+
glfwDestroyWindow(window);
28+
29+
// Terminate GLFW and free the error callback
30+
glfwTerminate();
31+
glfwSetErrorCallback(null).free();
32+
}
33+
34+
private void init() {
35+
// Setup an error callback. The default implementation
36+
// will print the error message in System.err.
37+
GLFWErrorCallback.createPrint(System.err).set();
38+
39+
// Initialize GLFW. Most GLFW functions will not work before doing this.
40+
if ( !glfwInit() )
41+
throw new IllegalStateException("Unable to initialize GLFW");
42+
43+
// Configure GLFW
44+
glfwDefaultWindowHints(); // optional, the current window hints are already the default
45+
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
46+
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
47+
48+
// Create the window
49+
window = glfwCreateWindow(1000, 300, "Hello World!", NULL, NULL);
50+
if ( window == NULL )
51+
throw new RuntimeException("Failed to create the GLFW window");
52+
53+
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
54+
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
55+
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
56+
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
57+
});
58+
59+
// Get the thread stack and push a new frame
60+
try ( MemoryStack stack = stackPush() ) {
61+
IntBuffer pWidth = stack.mallocInt(1); // int*
62+
IntBuffer pHeight = stack.mallocInt(1); // int*
63+
64+
// Get the window size passed to glfwCreateWindow
65+
glfwGetWindowSize(window, pWidth, pHeight);
66+
67+
// Get the resolution of the primary monitor
68+
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
69+
70+
// Center the window
71+
glfwSetWindowPos(
72+
window,
73+
(vidmode.width() - pWidth.get(0)) / 2,
74+
(vidmode.height() - pHeight.get(0)) / 2
75+
);
76+
} // the stack frame is popped automatically
77+
78+
// Make the OpenGL context current
79+
glfwMakeContextCurrent(window);
80+
// Enable v-sync
81+
glfwSwapInterval(1);
82+
83+
// Make the window visible
84+
glfwShowWindow(window);
85+
}
86+
87+
private void loop() {
88+
// This line is critical for LWJGL's interoperation with GLFW's
89+
// OpenGL context, or any context that is managed externally.
90+
// LWJGL detects the context that is current in the current thread,
91+
// creates the GLCapabilities instance and makes the OpenGL
92+
// bindings available for use.
93+
GL.createCapabilities();
94+
95+
// Set the clear color
96+
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
97+
98+
// Run the rendering loop until the user has attempted to close
99+
// the window or has pressed the ESCAPE key.
100+
while ( !glfwWindowShouldClose(window) ) {
101+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
102+
103+
glfwSwapBuffers(window); // swap the color buffers
104+
105+
// Poll for window events. The key callback above will only be
106+
// invoked during this call.
107+
glfwPollEvents();
108+
}
109+
}
110+
111+
public static void main(String[] args) {
112+
new PacoMotor().run();
113+
}
114+
115+
}

0 commit comments

Comments
 (0)